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" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 29 | #include <wlan_hdd_includes.h> |
| 30 | #include <cds_api.h> |
| 31 | #include <cds_sched.h> |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 32 | #include <linux/cpu.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 33 | #include <linux/etherdevice.h> |
| 34 | #include <linux/firmware.h> |
| 35 | #include <wlan_hdd_tx_rx.h> |
| 36 | #include <wni_api.h> |
| 37 | #include <wlan_hdd_cfg.h> |
| 38 | #include <wlan_ptt_sock_svc.h> |
| 39 | #include <dbglog_host.h> |
| 40 | #include <wlan_logging_sock_svc.h> |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 41 | #include <wlan_roam_debug.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 42 | #include <wlan_hdd_wowl.h> |
| 43 | #include <wlan_hdd_misc.h> |
| 44 | #include <wlan_hdd_wext.h> |
| 45 | #include "wlan_hdd_trace.h" |
| 46 | #include "wlan_hdd_ioctl.h" |
| 47 | #include "wlan_hdd_ftm.h" |
| 48 | #include "wlan_hdd_power.h" |
| 49 | #include "wlan_hdd_stats.h" |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 50 | #include "wlan_hdd_scan.h" |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 51 | #include "wlan_policy_mgr_ucfg.h" |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 52 | #include <wlan_osif_request_manager.h> |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 53 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 54 | #include "qdf_debug_domain.h" |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 55 | #endif |
Dustin Brown | d424194 | 2018-02-26 12:51:37 -0800 | [diff] [blame] | 56 | #include "qdf_str.h" |
| 57 | #include "qdf_trace.h" |
| 58 | #include "qdf_types.h" |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 59 | #include <cdp_txrx_peer_ops.h> |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 60 | #include <cdp_txrx_misc.h> |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 61 | #include <cdp_txrx_stats.h> |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 62 | #include "cdp_txrx_flow_ctrl_legacy.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 63 | |
| 64 | #include <net/addrconf.h> |
| 65 | #include <linux/wireless.h> |
| 66 | #include <net/cfg80211.h> |
| 67 | #include <linux/inetdevice.h> |
| 68 | #include <net/addrconf.h> |
| 69 | #include "wlan_hdd_cfg80211.h" |
| 70 | #include "wlan_hdd_ext_scan.h" |
| 71 | #include "wlan_hdd_p2p.h" |
| 72 | #include <linux/rtnetlink.h> |
| 73 | #include "sap_api.h" |
| 74 | #include <linux/semaphore.h> |
| 75 | #include <linux/ctype.h> |
| 76 | #include <linux/compat.h> |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 77 | #include <linux/reboot.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 78 | #ifdef MSM_PLATFORM |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 79 | #include <soc/qcom/subsystem_restart.h> |
| 80 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 81 | #include <wlan_hdd_hostapd.h> |
| 82 | #include <wlan_hdd_softap_tx_rx.h> |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 83 | #include <wlan_hdd_green_ap.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 84 | #include "cfg_api.h" |
| 85 | #include "qwlan_version.h" |
| 86 | #include "wma_types.h" |
| 87 | #include "wlan_hdd_tdls.h" |
| 88 | #ifdef FEATURE_WLAN_CH_AVOID |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 89 | #include "cds_regdomain.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 90 | #endif /* FEATURE_WLAN_CH_AVOID */ |
Dustin Brown | ce46d1d | 2017-08-15 13:34:24 -0700 | [diff] [blame] | 91 | #include "cdp_txrx_flow_ctrl_v2.h" |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 92 | #include "pld_common.h" |
Tushnim Bhattacharyya | 15596cf | 2016-02-12 11:57:02 -0800 | [diff] [blame] | 93 | #include "wlan_hdd_ocb.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 94 | #include "wlan_hdd_nan.h" |
| 95 | #include "wlan_hdd_debugfs.h" |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 96 | #include "wlan_hdd_debugfs_csr.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 97 | #include "wlan_hdd_driver_ops.h" |
| 98 | #include "epping_main.h" |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 99 | #include "wlan_hdd_data_stall_detection.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 100 | |
| 101 | #include <wlan_hdd_ipa.h> |
| 102 | #include "hif.h" |
| 103 | #include "wma.h" |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 104 | #include "wlan_policy_mgr_api.h" |
Manikandan Mohan | dcc21ba | 2016-03-15 14:31:56 -0700 | [diff] [blame] | 105 | #include "wlan_hdd_tsf.h" |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 106 | #include "bmi.h" |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 107 | #include <wlan_hdd_regulatory.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 108 | #include "wlan_hdd_lpass.h" |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 109 | #include "nan_api.h" |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 110 | #include <wlan_hdd_napi.h> |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 111 | #include "wlan_hdd_disa.h" |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 112 | #include <dispatcher_init_deinit.h> |
Rajeev Kumar | 699debf | 2017-01-06 14:17:00 -0800 | [diff] [blame] | 113 | #include "wlan_hdd_object_manager.h" |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 114 | #include "cds_utils.h" |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 115 | #include <cdp_txrx_handle.h> |
Sandeep Puligilla | fdd201e | 2017-02-02 18:43:46 -0800 | [diff] [blame] | 116 | #include <qca_vendor.h> |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 117 | #include "wlan_pmo_ucfg_api.h" |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 118 | #include "sir_api.h" |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 119 | #include "os_if_wifi_pos.h" |
| 120 | #include "wifi_pos_api.h" |
| 121 | #include "wlan_hdd_oemdata.h" |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 122 | #include "wlan_hdd_he.h" |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 123 | #include "os_if_nan.h" |
| 124 | #include "nan_public_structs.h" |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 125 | #include "wlan_reg_ucfg_api.h" |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 126 | #include "wlan_dfs_ucfg_api.h" |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 127 | #include "wlan_hdd_rx_monitor.h" |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 128 | #include "sme_power_save_api.h" |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 129 | #include "enet.h" |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 130 | #include <cdp_txrx_cmn_struct.h> |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 131 | #include <dp_txrx.h> |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 132 | #include "wlan_hdd_sysfs.h" |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 133 | #include "wlan_disa_ucfg_api.h" |
Wu Gao | 52084c1 | 2018-05-17 20:47:11 +0800 | [diff] [blame] | 134 | #include "wlan_disa_obj_mgmt_api.h" |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 135 | #include "wlan_action_oui_ucfg_api.h" |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 136 | #include "wlan_ipa_ucfg_api.h" |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 137 | #include <target_if.h> |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 138 | #include "wlan_hdd_nud_tracking.h" |
Nachiket Kukade | d0dd62e | 2018-05-21 18:39:22 +0530 | [diff] [blame] | 139 | #include "wlan_hdd_apf.h" |
Varun Reddy Yeturu | e93d246 | 2018-05-22 13:54:52 -0700 | [diff] [blame] | 140 | #include "wlan_hdd_twt.h" |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 141 | #include "qc_sap_ioctl.h" |
Sandeep Puligilla | c5609d5 | 2018-05-17 19:23:41 -0700 | [diff] [blame] | 142 | #include "wlan_mlme_main.h" |
Wu Gao | e568979 | 2018-07-05 19:20:13 +0800 | [diff] [blame] | 143 | #include "wlan_p2p_cfg_api.h" |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 144 | #include "wlan_tdls_cfg_api.h" |
Qiwei Cai | e689a26 | 2018-07-26 15:50:22 +0800 | [diff] [blame] | 145 | #include <wlan_hdd_rssi_monitor.h> |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 146 | #include "wlan_mlme_ucfg_api.h" |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 147 | #include "cfg_mlme_acs.h" |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 148 | #include "wlan_mlme_public_struct.h" |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 149 | #include "wlan_fwol_ucfg_api.h" |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 150 | #include "wlan_policy_mgr_ucfg.h" |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 151 | #ifdef CNSS_GENL |
| 152 | #include <net/cnss_nl.h> |
| 153 | #endif |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 154 | #include "wlan_reg_ucfg_api.h" |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 155 | #include "wlan_ocb_ucfg_api.h" |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 156 | #include <wlan_hdd_spectralscan.h> |
gaurank kathpalia | 4a205fc | 2018-09-15 00:59:15 +0530 | [diff] [blame] | 157 | #include "wlan_green_ap_ucfg_api.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 158 | #ifdef MODULE |
| 159 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 160 | #else |
| 161 | #define WLAN_MODULE_NAME "wlan" |
| 162 | #endif |
| 163 | |
| 164 | #ifdef TIMER_MANAGER |
| 165 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 166 | #else |
| 167 | #define TIMER_MANAGER_STR "" |
| 168 | #endif |
| 169 | |
| 170 | #ifdef MEMORY_DEBUG |
| 171 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 172 | #else |
| 173 | #define MEMORY_DEBUG_STR "" |
| 174 | #endif |
| 175 | |
Dustin Brown | c1034df | 2018-02-07 14:51:32 -0800 | [diff] [blame] | 176 | #ifdef PANIC_ON_BUG |
| 177 | #define PANIC_ON_BUG_STR " +PANIC_ON_BUG" |
| 178 | #else |
| 179 | #define PANIC_ON_BUG_STR "" |
| 180 | #endif |
| 181 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 182 | bool g_is_system_reboot_triggered; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 183 | int wlan_start_ret_val; |
| 184 | static DECLARE_COMPLETION(wlan_start_comp); |
| 185 | static unsigned int dev_num = 1; |
| 186 | static struct cdev wlan_hdd_state_cdev; |
| 187 | static struct class *class; |
| 188 | static dev_t device; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 189 | #ifndef MODULE |
| 190 | static struct gwlan_loader *wlan_loader; |
| 191 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 192 | struct kobj_attribute *attr, |
| 193 | const char *buf, size_t count); |
| 194 | struct gwlan_loader { |
| 195 | bool loaded_state; |
| 196 | struct kobject *boot_wlan_obj; |
| 197 | struct attribute_group *attr_group; |
| 198 | }; |
| 199 | |
| 200 | static struct kobj_attribute wlan_boot_attribute = |
| 201 | __ATTR(boot_wlan, 0220, NULL, wlan_boot_cb); |
| 202 | |
| 203 | static struct attribute *attrs[] = { |
| 204 | &wlan_boot_attribute.attr, |
| 205 | NULL, |
| 206 | }; |
| 207 | |
| 208 | #define MODULE_INITIALIZED 1 |
Qun Zhang | 4a83a46 | 2018-09-11 16:28:51 +0800 | [diff] [blame] | 209 | |
| 210 | #ifdef MULTI_IF_NAME |
| 211 | #define WLAN_LOADER_NAME "boot_" MULTI_IF_NAME |
| 212 | #else |
| 213 | #define WLAN_LOADER_NAME "boot_wlan" |
| 214 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 215 | #endif |
| 216 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 217 | #define HDD_OPS_INACTIVITY_TIMEOUT (120000) |
| 218 | #define MAX_OPS_NAME_STRING_SIZE 20 |
Rajeev Kumar | 6d0b2ea | 2017-12-26 17:55:33 -0800 | [diff] [blame] | 219 | #define RATE_LIMIT_ERROR_LOG (256) |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 220 | |
| 221 | static qdf_timer_t hdd_drv_ops_inactivity_timer; |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 222 | static struct task_struct *hdd_drv_ops_task; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 223 | static char drv_ops_string[MAX_OPS_NAME_STRING_SIZE]; |
| 224 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 225 | /* the Android framework expects this param even though we don't use it */ |
| 226 | #define BUF_LEN 20 |
| 227 | static char fwpath_buffer[BUF_LEN]; |
| 228 | static struct kparam_string fwpath = { |
| 229 | .string = fwpath_buffer, |
| 230 | .maxlen = BUF_LEN, |
| 231 | }; |
| 232 | |
| 233 | static char *country_code; |
| 234 | static int enable_11d = -1; |
| 235 | static int enable_dfs_chan_scan = -1; |
| 236 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 237 | /* |
| 238 | * spinlock for synchronizing asynchronous request/response |
| 239 | * (full description of use in wlan_hdd_main.h) |
| 240 | */ |
| 241 | DEFINE_SPINLOCK(hdd_context_lock); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 242 | DEFINE_MUTEX(hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 243 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 244 | #define WLAN_NLINK_CESIUM 30 |
| 245 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 246 | static qdf_wake_lock_t wlan_wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 247 | |
| 248 | #define WOW_MAX_FILTER_LISTS 1 |
| 249 | #define WOW_MAX_FILTERS_PER_LIST 4 |
| 250 | #define WOW_MIN_PATTERN_SIZE 6 |
| 251 | #define WOW_MAX_PATTERN_SIZE 64 |
| 252 | |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 253 | /* max peer can be tdls peers + self peer + bss peer */ |
| 254 | #define HDD_MAX_VDEV_PEER_COUNT (HDD_MAX_NUM_TDLS_STA + 2) |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 255 | #define IS_IDLE_STOP (!cds_is_driver_unloading() && \ |
| 256 | !cds_is_driver_recovering() && !cds_is_driver_loading()) |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 257 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 258 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 259 | static const struct wiphy_wowlan_support wowlan_support_reg_init = { |
| 260 | .flags = WIPHY_WOWLAN_ANY | |
| 261 | WIPHY_WOWLAN_MAGIC_PKT | |
| 262 | WIPHY_WOWLAN_DISCONNECT | |
| 263 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 264 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 265 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 266 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 267 | WIPHY_WOWLAN_RFKILL_RELEASE, |
| 268 | .n_patterns = WOW_MAX_FILTER_LISTS * WOW_MAX_FILTERS_PER_LIST, |
| 269 | .pattern_min_len = WOW_MIN_PATTERN_SIZE, |
| 270 | .pattern_max_len = WOW_MAX_PATTERN_SIZE, |
| 271 | }; |
| 272 | #endif |
| 273 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 274 | static const struct category_info cinfo[MAX_SUPPORTED_CATEGORY] = { |
| 275 | [QDF_MODULE_ID_TLSHIM] = {QDF_TRACE_LEVEL_ALL}, |
| 276 | [QDF_MODULE_ID_WMI] = {QDF_TRACE_LEVEL_ALL}, |
| 277 | [QDF_MODULE_ID_HTT] = {QDF_TRACE_LEVEL_ALL}, |
| 278 | [QDF_MODULE_ID_HDD] = {QDF_TRACE_LEVEL_ALL}, |
| 279 | [QDF_MODULE_ID_SME] = {QDF_TRACE_LEVEL_ALL}, |
| 280 | [QDF_MODULE_ID_PE] = {QDF_TRACE_LEVEL_ALL}, |
| 281 | [QDF_MODULE_ID_WMA] = {QDF_TRACE_LEVEL_ALL}, |
| 282 | [QDF_MODULE_ID_SYS] = {QDF_TRACE_LEVEL_ALL}, |
| 283 | [QDF_MODULE_ID_QDF] = {QDF_TRACE_LEVEL_ALL}, |
| 284 | [QDF_MODULE_ID_SAP] = {QDF_TRACE_LEVEL_ALL}, |
| 285 | [QDF_MODULE_ID_HDD_SOFTAP] = {QDF_TRACE_LEVEL_ALL}, |
| 286 | [QDF_MODULE_ID_HDD_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 287 | [QDF_MODULE_ID_HDD_SAP_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 288 | [QDF_MODULE_ID_HIF] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 289 | [QDF_MODULE_ID_HTC] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 290 | [QDF_MODULE_ID_TXRX] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 291 | [QDF_MODULE_ID_QDF_DEVICE] = {QDF_TRACE_LEVEL_ALL}, |
| 292 | [QDF_MODULE_ID_CFG] = {QDF_TRACE_LEVEL_ALL}, |
| 293 | [QDF_MODULE_ID_BMI] = {QDF_TRACE_LEVEL_ALL}, |
| 294 | [QDF_MODULE_ID_EPPING] = {QDF_TRACE_LEVEL_ALL}, |
| 295 | [QDF_MODULE_ID_QVIT] = {QDF_TRACE_LEVEL_ALL}, |
| 296 | [QDF_MODULE_ID_DP] = {QDF_TRACE_LEVEL_ALL}, |
| 297 | [QDF_MODULE_ID_SOC] = {QDF_TRACE_LEVEL_ALL}, |
| 298 | [QDF_MODULE_ID_OS_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 299 | [QDF_MODULE_ID_TARGET_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 300 | [QDF_MODULE_ID_SCHEDULER] = {QDF_TRACE_LEVEL_ALL}, |
| 301 | [QDF_MODULE_ID_MGMT_TXRX] = {QDF_TRACE_LEVEL_ALL}, |
| 302 | [QDF_MODULE_ID_PMO] = {QDF_TRACE_LEVEL_ALL}, |
| 303 | [QDF_MODULE_ID_SCAN] = {QDF_TRACE_LEVEL_ALL}, |
| 304 | [QDF_MODULE_ID_POLICY_MGR] = {QDF_TRACE_LEVEL_ALL}, |
| 305 | [QDF_MODULE_ID_P2P] = {QDF_TRACE_LEVEL_ALL}, |
| 306 | [QDF_MODULE_ID_TDLS] = {QDF_TRACE_LEVEL_ALL}, |
| 307 | [QDF_MODULE_ID_REGULATORY] = {QDF_TRACE_LEVEL_ALL}, |
| 308 | [QDF_MODULE_ID_SERIALIZATION] = {QDF_TRACE_LEVEL_ALL}, |
Arif Hussain | fde76e7 | 2017-09-05 16:58:23 -0700 | [diff] [blame] | 309 | [QDF_MODULE_ID_DFS] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar | ca8ef9d | 2017-10-06 10:43:21 -0700 | [diff] [blame] | 310 | [QDF_MODULE_ID_OBJ_MGR] = {QDF_TRACE_LEVEL_ALL}, |
Deepak Dhamdhere | f918d42 | 2017-07-06 12:56:29 -0700 | [diff] [blame] | 311 | [QDF_MODULE_ID_ROAM_DEBUG] = {QDF_TRACE_LEVEL_ALL}, |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 312 | [QDF_MODULE_ID_GREEN_AP] = {QDF_TRACE_LEVEL_ALL}, |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 313 | [QDF_MODULE_ID_OCB] = {QDF_TRACE_LEVEL_ALL}, |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 314 | [QDF_MODULE_ID_IPA] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 315 | [QDF_MODULE_ID_ACTION_OUI] = {QDF_TRACE_LEVEL_ALL}, |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 316 | [QDF_MODULE_ID_CONFIG] = {QDF_TRACE_LEVEL_ALL}, |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 317 | [QDF_MODULE_ID_MLME] = {QDF_TRACE_LEVEL_ALL}, |
Ashish Kumar Dhanotiya | 8d039c8 | 2018-07-11 20:41:14 +0530 | [diff] [blame] | 318 | [QDF_MODULE_ID_TARGET] = {QDF_TRACE_LEVEL_ALL}, |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 319 | [QDF_MODULE_ID_FWOL] = {QDF_TRACE_LEVEL_ALL}, |
Abhishek Singh | 0b0105f | 2018-09-25 10:44:16 +0530 | [diff] [blame] | 320 | [QDF_MODULE_ID_SM_ENGINE] = {QDF_TRACE_LEVEL_ALL}, |
| 321 | [QDF_MODULE_ID_CMN_MLME] = {QDF_TRACE_LEVEL_ALL}, |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 322 | }; |
| 323 | |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 324 | struct notifier_block hdd_netdev_notifier; |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 325 | struct notifier_block system_reboot_notifier; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 326 | |
| 327 | struct sock *cesium_nl_srv_sock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 328 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 329 | static void wlan_hdd_auto_shutdown_cb(void); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 330 | #endif |
| 331 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 332 | void hdd_start_complete(int ret) |
| 333 | { |
| 334 | wlan_start_ret_val = ret; |
| 335 | |
| 336 | complete(&wlan_start_comp); |
| 337 | } |
| 338 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 339 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 340 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 341 | * @hdd_ctx: pointer to struct hdd_context |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 342 | * |
| 343 | * Return: none |
| 344 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 345 | static void hdd_set_rps_cpu_mask(struct hdd_context *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 346 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 347 | struct hdd_adapter *adapter; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 348 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 349 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 350 | hdd_send_rps_ind(adapter); |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 351 | } |
| 352 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 353 | #ifdef QCA_HL_NETDEV_FLOW_CONTROL |
| 354 | void wlan_hdd_mod_fc_timer(struct hdd_adapter *adapter, |
| 355 | enum netif_action_type action) |
| 356 | { |
| 357 | if (!adapter->tx_flow_timer_initialized) |
| 358 | return; |
| 359 | |
| 360 | if (action == WLAN_WAKE_NON_PRIORITY_QUEUE) { |
| 361 | qdf_mc_timer_stop(&adapter->tx_flow_control_timer); |
| 362 | } else if (action == WLAN_STOP_NON_PRIORITY_QUEUE) { |
| 363 | QDF_STATUS status = |
| 364 | qdf_mc_timer_start(&adapter->tx_flow_control_timer, |
| 365 | WLAN_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME); |
| 366 | |
| 367 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 368 | hdd_err("Failed to start tx_flow_control_timer"); |
| 369 | else |
| 370 | adapter-> |
| 371 | hdd_stats.tx_rx_stats.txflow_timer_cnt++; |
| 372 | |
| 373 | adapter->hdd_stats.tx_rx_stats.txflow_pause_cnt++; |
| 374 | adapter->hdd_stats.tx_rx_stats.is_txflow_paused = true; |
| 375 | } |
| 376 | } |
| 377 | #endif /* QCA_HL_NETDEV_FLOW_CONTROL */ |
| 378 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 379 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 380 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 381 | * @vdev_id: vdev_id |
| 382 | * @action: action type |
| 383 | * @reason: reason type |
| 384 | * |
| 385 | * Return: none |
| 386 | */ |
| 387 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 388 | enum netif_action_type action, enum netif_reason_type reason) |
| 389 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 390 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 391 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 392 | |
| 393 | if (!hdd_ctx) { |
| 394 | hdd_err("hdd ctx is NULL"); |
| 395 | return; |
| 396 | } |
| 397 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 398 | wlan_hdd_mod_fc_timer(adapter, action); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 399 | wlan_hdd_netif_queue_control(adapter, action, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 400 | } |
| 401 | |
| 402 | /* |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 403 | * Store WLAN driver version and timestamp info in global variables such that |
| 404 | * crash debugger can extract them from driver debug symbol and crashdump for |
| 405 | * post processing |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 406 | */ |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 407 | #ifdef BUILD_TAG |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 408 | 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] | 409 | #else |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 410 | 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] | 411 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 412 | |
| 413 | /** |
| 414 | * hdd_device_mode_to_string() - return string conversion of device mode |
| 415 | * @device_mode: device mode |
| 416 | * |
| 417 | * This utility function helps log string conversion of device mode. |
| 418 | * |
| 419 | * Return: string conversion of device mode, if match found; |
| 420 | * "Unknown" otherwise. |
| 421 | */ |
| 422 | const char *hdd_device_mode_to_string(uint8_t device_mode) |
| 423 | { |
| 424 | switch (device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 425 | CASE_RETURN_STRING(QDF_STA_MODE); |
| 426 | CASE_RETURN_STRING(QDF_SAP_MODE); |
| 427 | CASE_RETURN_STRING(QDF_P2P_CLIENT_MODE); |
| 428 | CASE_RETURN_STRING(QDF_P2P_GO_MODE); |
| 429 | CASE_RETURN_STRING(QDF_FTM_MODE); |
| 430 | CASE_RETURN_STRING(QDF_IBSS_MODE); |
| 431 | CASE_RETURN_STRING(QDF_P2P_DEVICE_MODE); |
| 432 | CASE_RETURN_STRING(QDF_OCB_MODE); |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 433 | CASE_RETURN_STRING(QDF_NDI_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 434 | default: |
| 435 | return "Unknown"; |
| 436 | } |
| 437 | } |
| 438 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 439 | /** |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 440 | * hdd_get_valid_chan() - return current chan list from regulatory. |
| 441 | * @hdd_ctx: HDD context |
| 442 | * @chan_list: buf hold returned chan list |
| 443 | * @chan_num: input buf size and output returned chan num |
| 444 | * |
| 445 | * This function helps get current available chan list from regulatory |
| 446 | * module. It excludes the "disabled" and "invalid" channels. |
| 447 | * |
| 448 | * Return: 0 for success. |
| 449 | */ |
| 450 | static int hdd_get_valid_chan(struct hdd_context *hdd_ctx, |
| 451 | uint8_t *chan_list, |
| 452 | uint32_t *chan_num) |
| 453 | { |
| 454 | int i = 0, j = 0; |
| 455 | struct regulatory_channel *cur_chan_list; |
| 456 | struct wlan_objmgr_pdev *pdev; |
| 457 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 458 | if (!hdd_ctx || !hdd_ctx->pdev || !chan_list || !chan_num) |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 459 | return -EINVAL; |
| 460 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 461 | pdev = hdd_ctx->pdev; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 462 | cur_chan_list = qdf_mem_malloc(NUM_CHANNELS * |
| 463 | sizeof(struct regulatory_channel)); |
| 464 | if (!cur_chan_list) |
| 465 | return -ENOMEM; |
| 466 | |
| 467 | if (wlan_reg_get_current_chan_list(pdev, cur_chan_list) != |
| 468 | QDF_STATUS_SUCCESS) { |
| 469 | qdf_mem_free(cur_chan_list); |
| 470 | return -EINVAL; |
| 471 | } |
| 472 | |
| 473 | for (i = 0; i < NUM_CHANNELS; i++) { |
| 474 | uint32_t ch = cur_chan_list[i].chan_num; |
| 475 | enum channel_state state = wlan_reg_get_channel_state(pdev, |
| 476 | ch); |
| 477 | |
| 478 | if (state != CHANNEL_STATE_DISABLE && |
| 479 | state != CHANNEL_STATE_INVALID && |
| 480 | j < *chan_num) { |
| 481 | chan_list[j] = (uint8_t)ch; |
| 482 | j++; |
| 483 | } |
| 484 | } |
| 485 | *chan_num = j; |
| 486 | qdf_mem_free(cur_chan_list); |
| 487 | return 0; |
| 488 | } |
| 489 | |
| 490 | /** |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 491 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 492 | * @adapter: HDD adapter |
| 493 | * @chan_number: Channel number |
| 494 | * @chan_bw: Bandwidth |
| 495 | * |
| 496 | * Checks if the given bandwidth is valid for the given channel number. |
| 497 | * |
| 498 | * Return: 0 for success, non-zero for failure |
| 499 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 500 | int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 501 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 502 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 503 | { |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 504 | uint8_t chan[NUM_CHANNELS]; |
| 505 | uint32_t len = NUM_CHANNELS, i; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 506 | bool found = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 507 | mac_handle_t mac_handle; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 508 | int ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 509 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 510 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 511 | if (!mac_handle) { |
| 512 | hdd_err("Invalid MAC handle"); |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 513 | return -EINVAL; |
| 514 | } |
| 515 | |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 516 | ret = hdd_get_valid_chan(adapter->hdd_ctx, chan, |
| 517 | &len); |
| 518 | if (ret) { |
| 519 | hdd_err("error %d in getting valid channel list", ret); |
| 520 | return ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 521 | } |
| 522 | |
| 523 | for (i = 0; i < len; i++) { |
| 524 | if (chan[i] == chan_number) { |
| 525 | found = true; |
| 526 | break; |
| 527 | } |
| 528 | } |
| 529 | |
| 530 | if (found == false) { |
| 531 | hdd_err("Channel not in driver's valid channel list"); |
| 532 | return -EOPNOTSUPP; |
| 533 | } |
| 534 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 535 | if ((!WLAN_REG_IS_24GHZ_CH(chan_number)) && |
| 536 | (!WLAN_REG_IS_5GHZ_CH(chan_number))) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 537 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 538 | return -EINVAL; |
| 539 | } |
| 540 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 541 | if (WLAN_REG_IS_24GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 542 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 543 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 544 | return -EINVAL; |
| 545 | } |
| 546 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 547 | (chan_bw != CH_WIDTH_MAX)) { |
| 548 | hdd_err("Only BW20 possible on channel 14"); |
| 549 | return -EINVAL; |
| 550 | } |
| 551 | } |
| 552 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 553 | if (WLAN_REG_IS_5GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 554 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 555 | (chan_bw != CH_WIDTH_MAX)) { |
| 556 | hdd_err("Only BW20 possible on channel 165"); |
| 557 | return -EINVAL; |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | return 0; |
| 562 | } |
| 563 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 564 | /** |
| 565 | * hdd_wait_for_recovery_completion() - Wait for cds recovery completion |
| 566 | * |
| 567 | * Block the unloading of the driver (or) interface up until the |
| 568 | * cds recovery is completed |
| 569 | * |
| 570 | * Return: true for recovery completion else false |
| 571 | */ |
| 572 | static bool hdd_wait_for_recovery_completion(void) |
| 573 | { |
| 574 | int retry = 0; |
| 575 | |
| 576 | /* Wait for recovery to complete */ |
| 577 | while (cds_is_driver_recovering()) { |
| 578 | if (retry == HDD_MOD_EXIT_SSR_MAX_RETRIES/2) |
| 579 | hdd_err("Recovery in progress; wait here!!!"); |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 580 | |
| 581 | if (g_is_system_reboot_triggered) { |
| 582 | hdd_info("System Reboot happening ignore unload!!"); |
| 583 | return false; |
| 584 | } |
| 585 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 586 | msleep(1000); |
| 587 | if (retry++ == HDD_MOD_EXIT_SSR_MAX_RETRIES) { |
| 588 | hdd_err("SSR never completed, error"); |
| 589 | /* |
| 590 | * Trigger the bug_on in the internal builds, in the |
| 591 | * customer builds self-recovery will be enabled |
| 592 | * in those cases just return error. |
| 593 | */ |
| 594 | if (cds_is_self_recovery_enabled()) |
| 595 | return false; |
| 596 | QDF_BUG(0); |
| 597 | } |
| 598 | } |
| 599 | |
| 600 | hdd_info("Recovery completed successfully!"); |
| 601 | return true; |
| 602 | } |
| 603 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 604 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 605 | static int __hdd_netdev_notifier_call(struct notifier_block *nb, |
| 606 | unsigned long state, void *data) |
| 607 | { |
| 608 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 609 | struct netdev_notifier_info *dev_notif_info = data; |
| 610 | struct net_device *dev = dev_notif_info->dev; |
| 611 | #else |
| 612 | struct net_device *dev = data; |
| 613 | #endif |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 614 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 615 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 616 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 617 | hdd_enter_dev(dev); |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 618 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 619 | if (!dev->ieee80211_ptr) { |
Dustin Brown | aeb5564 | 2018-07-30 17:20:32 -0700 | [diff] [blame] | 620 | hdd_debug("ieee80211_ptr is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 621 | return NOTIFY_DONE; |
| 622 | } |
| 623 | |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 624 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 625 | if (!hdd_ctx) { |
| 626 | hdd_err("HDD Context is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 627 | return NOTIFY_DONE; |
| 628 | } |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 629 | |
| 630 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 631 | hdd_debug("%s: Driver module is closed", __func__); |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 632 | return NOTIFY_DONE; |
| 633 | } |
| 634 | |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 635 | /* Make sure that this callback corresponds to our device. */ |
| 636 | adapter = hdd_get_adapter_by_iface_name(hdd_ctx, dev->name); |
| 637 | if (!adapter) { |
Dustin Brown | aeb5564 | 2018-07-30 17:20:32 -0700 | [diff] [blame] | 638 | hdd_debug("failed to look up adapter for '%s'", dev->name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 639 | return NOTIFY_DONE; |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 640 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 641 | |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 642 | if (adapter != WLAN_HDD_GET_PRIV_PTR(dev)) { |
| 643 | hdd_err("HDD adapter mismatch!"); |
| 644 | return NOTIFY_DONE; |
| 645 | } |
| 646 | |
Dustin Brown | aeb5564 | 2018-07-30 17:20:32 -0700 | [diff] [blame] | 647 | if (cds_is_driver_recovering()) { |
| 648 | hdd_debug("Driver is recovering"); |
| 649 | return NOTIFY_DONE; |
| 650 | } |
| 651 | |
| 652 | if (cds_is_driver_in_bad_state()) { |
| 653 | hdd_debug("Driver is in failed recovery state"); |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 654 | return NOTIFY_DONE; |
| 655 | } |
| 656 | |
| 657 | hdd_debug("%s New Net Device State = %lu", dev->name, state); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 658 | |
| 659 | switch (state) { |
| 660 | case NETDEV_REGISTER: |
| 661 | break; |
| 662 | |
| 663 | case NETDEV_UNREGISTER: |
| 664 | break; |
| 665 | |
| 666 | case NETDEV_UP: |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 667 | sme_ch_avoid_update_req(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 668 | break; |
| 669 | |
| 670 | case NETDEV_DOWN: |
| 671 | break; |
| 672 | |
| 673 | case NETDEV_CHANGE: |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 674 | if (adapter->is_link_up_service_needed) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 675 | complete(&adapter->linkup_event_var); |
| 676 | break; |
| 677 | |
| 678 | case NETDEV_GOING_DOWN: |
Dustin Brown | 89fa06e | 2018-09-07 10:47:27 -0700 | [diff] [blame] | 679 | if (ucfg_scan_get_vdev_status(adapter->vdev) != |
Sandeep Puligilla | 5f86d99 | 2017-10-29 14:58:53 -0700 | [diff] [blame] | 680 | SCAN_NOT_IN_PROGRESS) { |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 681 | wlan_abort_scan(hdd_ctx->pdev, INVAL_PDEV_ID, |
| 682 | adapter->session_id, INVALID_SCAN_ID, |
| 683 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 684 | } |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 685 | cds_flush_work(&adapter->scan_block_work); |
| 686 | /* Need to clean up blocked scan request */ |
| 687 | wlan_hdd_cfg80211_scan_block_cb(&adapter->scan_block_work); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 688 | hdd_debug("Scan is not Pending from user"); |
Arunk Khandavalli | f0c0d76 | 2017-12-07 10:18:50 +0530 | [diff] [blame] | 689 | /* |
| 690 | * After NETDEV_GOING_DOWN, kernel calls hdd_stop.Irrespective |
| 691 | * of return status of hdd_stop call, kernel resets the IFF_UP |
| 692 | * flag after which driver does not send the cfg80211_scan_done. |
| 693 | * Ensure to cleanup the scan queue in NETDEV_GOING_DOWN |
| 694 | */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 695 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->pdev, dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 696 | break; |
| 697 | |
| 698 | default: |
| 699 | break; |
| 700 | } |
| 701 | |
| 702 | return NOTIFY_DONE; |
| 703 | } |
| 704 | |
| 705 | /** |
| 706 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 707 | * @nb: pointer to notifier block |
| 708 | * @state: state |
| 709 | * @ndev: ndev pointer |
| 710 | * |
| 711 | * Return: 0 on success, error number otherwise. |
| 712 | */ |
| 713 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 714 | unsigned long state, |
| 715 | void *ndev) |
| 716 | { |
| 717 | int ret; |
| 718 | |
| 719 | cds_ssr_protect(__func__); |
| 720 | ret = __hdd_netdev_notifier_call(nb, state, ndev); |
| 721 | cds_ssr_unprotect(__func__); |
| 722 | |
| 723 | return ret; |
| 724 | } |
| 725 | |
| 726 | struct notifier_block hdd_netdev_notifier = { |
| 727 | .notifier_call = hdd_netdev_notifier_call, |
| 728 | }; |
| 729 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 730 | static int system_reboot_notifier_call(struct notifier_block *nb, |
| 731 | unsigned long msg_type, void *_unused) |
| 732 | { |
| 733 | switch (msg_type) { |
| 734 | case SYS_DOWN: |
| 735 | case SYS_HALT: |
| 736 | case SYS_POWER_OFF: |
| 737 | g_is_system_reboot_triggered = true; |
| 738 | hdd_info("reboot, reason: %ld", msg_type); |
| 739 | break; |
| 740 | default: |
| 741 | break; |
| 742 | } |
| 743 | |
| 744 | return NOTIFY_OK; |
| 745 | } |
| 746 | |
| 747 | struct notifier_block system_reboot_notifier = { |
| 748 | .notifier_call = system_reboot_notifier_call, |
| 749 | }; |
| 750 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 751 | /* variable to hold the insmod parameters */ |
| 752 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 753 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 754 | static int con_mode_ftm; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 755 | int con_mode_monitor; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 756 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 757 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 758 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 759 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 760 | /** |
| 761 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 762 | * @ch_width: NL channel width |
| 763 | * |
| 764 | * Converts the NL channel width to the driver's internal representation |
| 765 | * |
| 766 | * Return: Converted channel width. In case of non matching NL channel width, |
| 767 | * CH_WIDTH_MAX will be returned. |
| 768 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 769 | 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] | 770 | { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 771 | uint8_t fw_ch_bw; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 772 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 773 | fw_ch_bw = wma_get_vht_ch_width(); |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 774 | switch (ch_width) { |
| 775 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 776 | case NL80211_CHAN_WIDTH_20: |
| 777 | return CH_WIDTH_20MHZ; |
| 778 | case NL80211_CHAN_WIDTH_40: |
| 779 | return CH_WIDTH_40MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 780 | case NL80211_CHAN_WIDTH_80: |
| 781 | return CH_WIDTH_80MHZ; |
| 782 | case NL80211_CHAN_WIDTH_80P80: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 783 | if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ) |
| 784 | return CH_WIDTH_80P80MHZ; |
| 785 | else if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 786 | return CH_WIDTH_160MHZ; |
| 787 | else |
| 788 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 789 | case NL80211_CHAN_WIDTH_160: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 790 | if (fw_ch_bw >= WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 791 | return CH_WIDTH_160MHZ; |
| 792 | else |
| 793 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 794 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 795 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 796 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 797 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 798 | default: |
| 799 | hdd_err("Invalid channel width %d, setting to default", |
| 800 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 801 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 802 | } |
| 803 | } |
| 804 | |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 805 | QDF_STATUS hdd_nl_to_qdf_iface_type(enum nl80211_iftype nl_type, |
| 806 | enum QDF_OPMODE *out_qdf_type) |
| 807 | { |
| 808 | switch (nl_type) { |
| 809 | case NL80211_IFTYPE_ADHOC: |
| 810 | *out_qdf_type = QDF_IBSS_MODE; |
| 811 | break; |
| 812 | case NL80211_IFTYPE_AP: |
| 813 | *out_qdf_type = QDF_SAP_MODE; |
| 814 | break; |
| 815 | case NL80211_IFTYPE_MONITOR: |
| 816 | *out_qdf_type = QDF_MONITOR_MODE; |
| 817 | break; |
| 818 | case NL80211_IFTYPE_OCB: |
| 819 | *out_qdf_type = QDF_OCB_MODE; |
| 820 | break; |
| 821 | case NL80211_IFTYPE_P2P_CLIENT: |
| 822 | *out_qdf_type = QDF_P2P_CLIENT_MODE; |
| 823 | break; |
| 824 | case NL80211_IFTYPE_P2P_DEVICE: |
| 825 | *out_qdf_type = QDF_P2P_DEVICE_MODE; |
| 826 | break; |
| 827 | case NL80211_IFTYPE_P2P_GO: |
| 828 | *out_qdf_type = QDF_P2P_GO_MODE; |
| 829 | break; |
| 830 | case NL80211_IFTYPE_STATION: |
| 831 | *out_qdf_type = QDF_STA_MODE; |
| 832 | break; |
| 833 | case NL80211_IFTYPE_WDS: |
| 834 | *out_qdf_type = QDF_WDS_MODE; |
| 835 | break; |
| 836 | default: |
| 837 | hdd_err("Invalid nl80211 interface type %d", nl_type); |
| 838 | return QDF_STATUS_E_INVAL; |
| 839 | } |
| 840 | |
| 841 | return QDF_STATUS_SUCCESS; |
| 842 | } |
| 843 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 844 | uint8_t wlan_hdd_find_opclass(mac_handle_t mac_handle, uint8_t channel, |
| 845 | uint8_t bw_offset) |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 846 | { |
| 847 | uint8_t opclass = 0; |
| 848 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 849 | sme_get_opclass(mac_handle, channel, bw_offset, &opclass); |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 850 | return opclass; |
| 851 | } |
| 852 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 853 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 854 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 855 | * @module_id: Module whose trace level is being configured |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 856 | * @bitmask: Bitmask of log levels to be enabled |
| 857 | * |
| 858 | * Called immediately after the cfg.ini is read in order to configure |
| 859 | * the desired trace levels. |
| 860 | * |
| 861 | * Return: None |
| 862 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 863 | 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] | 864 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 865 | QDF_TRACE_LEVEL level; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 866 | int qdf_print_idx = -1; |
| 867 | int status = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 868 | /* |
| 869 | * if the bitmask is the default value, then a bitmask was not |
| 870 | * specified in cfg.ini, so leave the logging level alone (it |
| 871 | * will remain at the "compiled in" default value) |
| 872 | */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 873 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 874 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 875 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 876 | qdf_print_idx = qdf_get_pidx(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 877 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 878 | /* a mask was specified. start by disabling all logging */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 879 | status = qdf_print_set_category_verbose(qdf_print_idx, module_id, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 880 | QDF_TRACE_LEVEL_NONE, 0); |
| 881 | |
| 882 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 883 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 884 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Ashish Kumar Dhanotiya | 83f286b | 2017-09-15 19:52:58 +0530 | [diff] [blame] | 885 | level = QDF_TRACE_LEVEL_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 886 | while (0 != bitmask) { |
| 887 | if (bitmask & 1) { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 888 | status = qdf_print_set_category_verbose(qdf_print_idx, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 889 | module_id, level, 1); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 890 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 891 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 892 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 893 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 894 | level++; |
| 895 | bitmask >>= 1; |
| 896 | } |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 897 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 898 | } |
| 899 | |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 900 | 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] | 901 | { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 902 | if (!hdd_ctx) { |
| 903 | hdd_err("HDD context is null (via %s)", func); |
| 904 | return -ENODEV; |
| 905 | } |
| 906 | |
| 907 | if (!hdd_ctx->config) { |
| 908 | hdd_err("HDD config is null (via %s)", func); |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 909 | return -ENODEV; |
| 910 | } |
| 911 | |
| 912 | if (cds_is_driver_recovering()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 913 | hdd_debug("Recovery in progress (via %s); state:0x%x", |
| 914 | func, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 915 | return -EAGAIN; |
| 916 | } |
| 917 | |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 918 | if (cds_is_load_or_unload_in_progress()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 919 | hdd_debug("Load/unload in progress (via %s); state:0x%x", |
| 920 | func, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 921 | return -EAGAIN; |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 922 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 923 | |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 924 | if (hdd_ctx->start_modules_in_progress) { |
| 925 | hdd_debug("Start modules in progress (via %s)", func); |
| 926 | return -EAGAIN; |
| 927 | } |
| 928 | |
| 929 | if (hdd_ctx->stop_modules_in_progress) { |
| 930 | hdd_debug("Stop modules in progress (via %s)", func); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 931 | return -EAGAIN; |
| 932 | } |
| 933 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 934 | if (cds_is_driver_in_bad_state()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 935 | hdd_debug("Driver in bad state (via %s); state:0x%x", |
| 936 | func, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 937 | return -EAGAIN; |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 938 | } |
| 939 | |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 940 | if (cds_is_fw_down()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 941 | hdd_debug("FW is down (via %s); state:0x%x", |
| 942 | func, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 943 | return -EAGAIN; |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 944 | } |
| 945 | |
Liangwei Dong | 858feb1 | 2018-05-21 01:52:46 -0400 | [diff] [blame] | 946 | if (qdf_atomic_read(&hdd_ctx->con_mode_flag)) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 947 | hdd_debug("Driver mode change in progress (via %s)", func); |
Liangwei Dong | 858feb1 | 2018-05-21 01:52:46 -0400 | [diff] [blame] | 948 | return -EAGAIN; |
| 949 | } |
| 950 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 951 | return 0; |
| 952 | } |
| 953 | |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 954 | int __hdd_validate_adapter(struct hdd_adapter *adapter, const char *func) |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 955 | { |
| 956 | if (!adapter) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 957 | hdd_err("adapter is null (via %s)", func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 958 | return -EINVAL; |
| 959 | } |
| 960 | |
| 961 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 962 | hdd_err("bad adapter magic (via %s)", func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 963 | return -EINVAL; |
| 964 | } |
| 965 | |
| 966 | if (!adapter->dev) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 967 | hdd_err("adapter net_device is null (via %s)", func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 968 | return -EINVAL; |
| 969 | } |
| 970 | |
| 971 | if (!(adapter->dev->flags & IFF_UP)) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 972 | hdd_debug_rl("adapter '%s' is not up (via %s)", |
| 973 | adapter->dev->name, func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 974 | return -EAGAIN; |
| 975 | } |
| 976 | |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 977 | return __wlan_hdd_validate_session_id(adapter->session_id, func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 978 | } |
| 979 | |
Dustin Brown | 6350061 | 2018-08-07 11:36:09 -0700 | [diff] [blame] | 980 | int __wlan_hdd_validate_session_id(uint8_t session_id, const char *func) |
| 981 | { |
| 982 | if (session_id == CSR_SESSION_ID_INVALID) { |
| 983 | hdd_debug_rl("adapter is not up (via %s)", func); |
| 984 | return -EINVAL; |
| 985 | } |
| 986 | |
| 987 | if (session_id >= CSR_ROAM_SESSION_MAX) { |
| 988 | hdd_err("bad session Id:%u (via %s)", session_id, func); |
| 989 | return -EINVAL; |
| 990 | } |
| 991 | |
| 992 | return 0; |
| 993 | } |
| 994 | |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 995 | QDF_STATUS __wlan_hdd_validate_mac_address(struct qdf_mac_addr *mac_addr, |
| 996 | const char *func) |
| 997 | { |
| 998 | if (!mac_addr) { |
| 999 | hdd_err("Received NULL mac address (via %s)", func); |
| 1000 | return QDF_STATUS_E_INVAL; |
| 1001 | } |
| 1002 | |
| 1003 | if (qdf_is_macaddr_zero(mac_addr)) { |
| 1004 | hdd_err("MAC is all zero (via %s)", func); |
| 1005 | return QDF_STATUS_E_INVAL; |
| 1006 | } |
| 1007 | |
| 1008 | if (qdf_is_macaddr_broadcast(mac_addr)) { |
| 1009 | hdd_err("MAC is Broadcast (via %s)", func); |
| 1010 | return QDF_STATUS_E_INVAL; |
| 1011 | } |
| 1012 | |
| 1013 | if (QDF_NET_IS_MAC_MULTICAST(mac_addr->bytes)) { |
| 1014 | hdd_err("MAC is Multicast (via %s)", func); |
| 1015 | return QDF_STATUS_E_INVAL; |
| 1016 | } |
| 1017 | |
| 1018 | return QDF_STATUS_SUCCESS; |
| 1019 | } |
| 1020 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1021 | /** |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1022 | * wlan_hdd_validate_modules_state() - Check modules status |
| 1023 | * @hdd_ctx: HDD context pointer |
| 1024 | * |
| 1025 | * Check's the driver module's state and returns true if the |
| 1026 | * modules are enabled returns false if modules are closed. |
| 1027 | * |
| 1028 | * Return: True if modules are enabled or false. |
| 1029 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1030 | bool wlan_hdd_validate_modules_state(struct hdd_context *hdd_ctx) |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1031 | { |
| 1032 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 1033 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 1034 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 1035 | hdd_info("Modules not enabled, Present status: %d", |
| 1036 | hdd_ctx->driver_status); |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1037 | return false; |
| 1038 | } |
| 1039 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 1040 | return true; |
| 1041 | } |
| 1042 | |
| 1043 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1044 | * 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] | 1045 | * @struct hdd_adapter Hdd adapter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1046 | * |
| 1047 | * This function sets the IBSS power save config parameters to WMA |
| 1048 | * which will send it to firmware if FW supports IBSS power save |
| 1049 | * before vdev start. |
| 1050 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1051 | * 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] | 1052 | * on failure. |
| 1053 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 1054 | QDF_STATUS hdd_set_ibss_power_save_params(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1055 | { |
| 1056 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1057 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1058 | |
| 1059 | if (hdd_ctx == NULL) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1060 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1061 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1062 | } |
| 1063 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1064 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1065 | WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE, |
| 1066 | hdd_ctx->config->ibssATIMWinSize, |
| 1067 | VDEV_CMD); |
| 1068 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1069 | hdd_err("atim window set failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1070 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1071 | } |
| 1072 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1073 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1074 | WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED, |
| 1075 | hdd_ctx->config->isIbssPowerSaveAllowed, |
| 1076 | VDEV_CMD); |
| 1077 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1078 | hdd_err("power save allow failed %d", |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1079 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1080 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1081 | } |
| 1082 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1083 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1084 | WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED, |
| 1085 | hdd_ctx->config-> |
| 1086 | isIbssPowerCollapseAllowed, VDEV_CMD); |
| 1087 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1088 | hdd_err("power collapse allow failed %d", |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1089 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1090 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1091 | } |
| 1092 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1093 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1094 | WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX, |
| 1095 | hdd_ctx->config->isIbssAwakeOnTxRx, |
| 1096 | VDEV_CMD); |
| 1097 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1098 | hdd_err("set awake on tx/rx failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1099 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1100 | } |
| 1101 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1102 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1103 | WMA_VDEV_IBSS_SET_INACTIVITY_TIME, |
| 1104 | hdd_ctx->config->ibssInactivityCount, |
| 1105 | VDEV_CMD); |
| 1106 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1107 | hdd_err("set inactivity time failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1108 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1109 | } |
| 1110 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1111 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1112 | WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME, |
| 1113 | hdd_ctx->config->ibssTxSpEndInactivityTime, |
| 1114 | VDEV_CMD); |
| 1115 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1116 | hdd_err("set txsp end failed %d", |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1117 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1118 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1119 | } |
| 1120 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1121 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1122 | WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS, |
| 1123 | hdd_ctx->config->ibssPsWarmupTime, |
| 1124 | VDEV_CMD); |
| 1125 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1126 | hdd_err("set ps warmup failed %d", |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1127 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1128 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1129 | } |
| 1130 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1131 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1132 | WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW, |
| 1133 | hdd_ctx->config->ibssPs1RxChainInAtimEnable, |
| 1134 | VDEV_CMD); |
| 1135 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1136 | hdd_err("set 1rx chain atim failed %d", |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1137 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1138 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1139 | } |
| 1140 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1141 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1142 | } |
| 1143 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1144 | #ifdef FEATURE_RUNTIME_PM |
| 1145 | /** |
| 1146 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 1147 | * @hdd_ctx: HDD context |
| 1148 | * |
| 1149 | * Return: None |
| 1150 | */ |
| 1151 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) |
| 1152 | { |
| 1153 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1154 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1155 | qdf_runtime_lock_init(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1156 | qdf_runtime_lock_init(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1157 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1158 | wlan_scan_runtime_pm_init(hdd_ctx->pdev); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1159 | } |
| 1160 | |
| 1161 | /** |
| 1162 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 1163 | * @hdd_ctx: HDD Context |
| 1164 | * |
| 1165 | * Return: None |
| 1166 | */ |
| 1167 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) |
| 1168 | { |
| 1169 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1170 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1171 | qdf_runtime_lock_deinit(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1172 | qdf_runtime_lock_deinit(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1173 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1174 | wlan_scan_runtime_pm_deinit(hdd_ctx->pdev); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1175 | } |
| 1176 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1177 | #else /* FEATURE_RUNTIME_PM */ |
| 1178 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) {} |
| 1179 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) {} |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1180 | #endif /* FEATURE_RUNTIME_PM */ |
| 1181 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1182 | #define INTF_MACADDR_MASK 0x7 |
| 1183 | |
| 1184 | /** |
| 1185 | * hdd_update_macaddr() - update mac address |
| 1186 | * @config: hdd configuration |
| 1187 | * @hw_macaddr: mac address |
| 1188 | * |
| 1189 | * Mac address for multiple virtual interface is found as following |
| 1190 | * i) The mac address of the first interface is just the actual hw mac address. |
| 1191 | * ii) MSM 3 or 4 bits of byte5 of the actual mac address are used to |
| 1192 | * define the mac address for the remaining interfaces and locally |
| 1193 | * admistered bit is set. INTF_MACADDR_MASK is based on the number of |
| 1194 | * supported virtual interfaces, right now this is 0x07 (meaning 8 |
| 1195 | * interface). |
| 1196 | * Byte[3] of second interface will be hw_macaddr[3](bit5..7) + 1, |
| 1197 | * for third interface it will be hw_macaddr[3](bit5..7) + 2, etc. |
| 1198 | * |
| 1199 | * Return: None |
| 1200 | */ |
| 1201 | void hdd_update_macaddr(struct hdd_config *config, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1202 | struct qdf_mac_addr hw_macaddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1203 | { |
| 1204 | int8_t i; |
| 1205 | uint8_t macaddr_b3, tmp_br3; |
| 1206 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1207 | qdf_mem_copy(config->intfMacAddr[0].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1208 | QDF_MAC_ADDR_SIZE); |
| 1209 | for (i = 1; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1210 | qdf_mem_copy(config->intfMacAddr[i].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1211 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1212 | macaddr_b3 = config->intfMacAddr[i].bytes[3]; |
| 1213 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 1214 | INTF_MACADDR_MASK; |
| 1215 | macaddr_b3 += tmp_br3; |
| 1216 | |
| 1217 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 1218 | * mac address range before collision |
| 1219 | */ |
| 1220 | macaddr_b3 ^= (1 << 7); |
| 1221 | |
| 1222 | /* Set locally administered bit */ |
| 1223 | config->intfMacAddr[i].bytes[0] |= 0x02; |
| 1224 | config->intfMacAddr[i].bytes[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1225 | hdd_debug("config->intfMacAddr[%d]: " |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1226 | MAC_ADDRESS_STR, i, |
| 1227 | MAC_ADDR_ARRAY(config->intfMacAddr[i].bytes)); |
| 1228 | } |
| 1229 | } |
| 1230 | |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1231 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
| 1232 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1233 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1234 | struct tdls_start_params tdls_cfg; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1235 | struct hdd_config *cfg = hdd_ctx->config; |
| 1236 | QDF_STATUS status; |
| 1237 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1238 | cfg_tdls_set_vdev_nss_2g(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1239 | CFG_TDLS_NSS(cfg->vdev_type_nss_2g)); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1240 | cfg_tdls_set_vdev_nss_5g(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1241 | CFG_TDLS_NSS(cfg->vdev_type_nss_5g)); |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1242 | tdls_cfg.tdls_send_mgmt_req = eWNI_SME_TDLS_SEND_MGMT_REQ; |
| 1243 | tdls_cfg.tdls_add_sta_req = eWNI_SME_TDLS_ADD_STA_REQ; |
| 1244 | tdls_cfg.tdls_del_sta_req = eWNI_SME_TDLS_DEL_STA_REQ; |
| 1245 | tdls_cfg.tdls_update_peer_state = WMA_UPDATE_TDLS_PEER_STATE; |
| 1246 | tdls_cfg.tdls_del_all_peers = eWNI_SME_DEL_ALL_TDLS_PEERS; |
| 1247 | tdls_cfg.tdls_update_dp_vdev_flags = CDP_UPDATE_TDLS_FLAGS; |
| 1248 | tdls_cfg.tdls_event_cb = wlan_cfg80211_tdls_event_callback; |
| 1249 | tdls_cfg.tdls_evt_cb_data = psoc; |
Jeff Johnson | 1d40f5b | 2018-03-02 08:35:53 -0800 | [diff] [blame] | 1250 | tdls_cfg.tdls_peer_context = hdd_ctx; |
| 1251 | tdls_cfg.tdls_reg_peer = hdd_tdls_register_peer; |
| 1252 | tdls_cfg.tdls_dereg_peer = hdd_tdls_deregister_peer; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1253 | tdls_cfg.tdls_wmm_cb = hdd_wmm_is_acm_allowed; |
| 1254 | tdls_cfg.tdls_wmm_cb_data = psoc; |
| 1255 | tdls_cfg.tdls_rx_cb = wlan_cfg80211_tdls_rx_callback; |
| 1256 | tdls_cfg.tdls_rx_cb_data = psoc; |
| 1257 | tdls_cfg.tdls_dp_vdev_update = hdd_update_dp_vdev_flags; |
| 1258 | |
| 1259 | status = ucfg_tdls_update_config(psoc, &tdls_cfg); |
| 1260 | if (status != QDF_STATUS_SUCCESS) { |
| 1261 | hdd_err("failed pmo psoc configuration"); |
| 1262 | return -EINVAL; |
| 1263 | } |
| 1264 | |
| 1265 | hdd_ctx->tdls_umac_comp_active = true; |
| 1266 | /* enable napier specific tdls data path */ |
| 1267 | hdd_ctx->tdls_nap_active = true; |
| 1268 | |
| 1269 | return 0; |
| 1270 | } |
| 1271 | |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 1272 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1273 | static void hdd_update_roam_offload(struct hdd_context *hdd_ctx, |
| 1274 | struct wma_tgt_services *cfg) |
| 1275 | { |
| 1276 | bool roam_offload_enable; |
| 1277 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1278 | ucfg_mlme_get_roaming_offload(hdd_ctx->psoc, &roam_offload_enable); |
| 1279 | ucfg_mlme_set_roaming_offload(hdd_ctx->psoc, |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 1280 | roam_offload_enable & |
| 1281 | cfg->en_roam_offload); |
| 1282 | } |
| 1283 | #else |
| 1284 | static inline void hdd_update_roam_offload(struct hdd_context *hdd_ctx, |
| 1285 | struct wma_tgt_services *cfg) |
| 1286 | { |
| 1287 | } |
| 1288 | #endif |
| 1289 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1290 | static void hdd_update_tgt_services(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1291 | struct wma_tgt_services *cfg) |
| 1292 | { |
| 1293 | struct hdd_config *config = hdd_ctx->config; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 1294 | bool arp_offload_enable; |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1295 | #ifdef FEATURE_WLAN_TDLS |
| 1296 | bool tdls_support; |
| 1297 | bool tdls_off_channel; |
| 1298 | bool tdls_buffer_sta; |
| 1299 | uint32_t tdls_uapsd_mask; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 1300 | bool value; |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1301 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1302 | /* Set up UAPSD */ |
| 1303 | config->apUapsdEnabled &= cfg->uapsd; |
| 1304 | |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 1305 | /* 11AX mode support */ |
| 1306 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 1307 | config->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) && !cfg->en_11ax) |
| 1308 | config->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 1309 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1310 | /* 11AC mode support */ |
| 1311 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 1312 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 1313 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1314 | |
| 1315 | /* ARP offload: override user setting if invalid */ |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 1316 | arp_offload_enable = |
| 1317 | ucfg_pmo_is_arp_offload_enabled(hdd_ctx->psoc); |
| 1318 | ucfg_pmo_set_arp_offload_enabled(hdd_ctx->psoc, |
| 1319 | arp_offload_enable & cfg->arp_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1320 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 1321 | /* PNO offload */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1322 | hdd_debug("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1323 | if (cfg->pno_offload) |
| 1324 | config->PnoOffload = true; |
| 1325 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1326 | #ifdef FEATURE_WLAN_TDLS |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1327 | cfg_tdls_get_support_enable(hdd_ctx->psoc, &tdls_support); |
| 1328 | cfg_tdls_set_support_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1329 | tdls_support & cfg->en_tdls); |
| 1330 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1331 | cfg_tdls_get_off_channel_enable(hdd_ctx->psoc, &tdls_off_channel); |
| 1332 | cfg_tdls_set_off_channel_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1333 | tdls_off_channel && |
| 1334 | cfg->en_tdls_offchan); |
| 1335 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1336 | cfg_tdls_get_buffer_sta_enable(hdd_ctx->psoc, &tdls_buffer_sta); |
| 1337 | cfg_tdls_set_buffer_sta_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1338 | tdls_buffer_sta && |
| 1339 | cfg->en_tdls_uapsd_buf_sta); |
| 1340 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1341 | cfg_tdls_get_uapsd_mask(hdd_ctx->psoc, &tdls_uapsd_mask); |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1342 | if (tdls_uapsd_mask && cfg->en_tdls_uapsd_sleep_sta) |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1343 | cfg_tdls_set_sleep_sta_enable(hdd_ctx->psoc, true); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1344 | else |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1345 | cfg_tdls_set_sleep_sta_enable(hdd_ctx->psoc, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1346 | #endif |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 1347 | hdd_update_roam_offload(hdd_ctx, cfg); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 1348 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 1349 | if (ucfg_mlme_get_sap_get_peer_info(hdd_ctx->psoc, &value) == |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 1350 | QDF_STATUS_SUCCESS) |
| 1351 | value &= cfg->get_peer_info_enabled; |
| 1352 | |
Varun Reddy Yeturu | 62c3265 | 2017-10-26 15:32:35 -0700 | [diff] [blame] | 1353 | config->MAWCEnabled &= cfg->is_fw_mawc_capable; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1354 | hdd_update_tdls_config(hdd_ctx); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1355 | sme_update_tgt_services(hdd_ctx->mac_handle, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1356 | } |
| 1357 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1358 | /** |
| 1359 | * hdd_update_vdev_nss() - sets the vdev nss |
| 1360 | * @hdd_ctx: HDD context |
| 1361 | * |
| 1362 | * Sets the Nss per vdev type based on INI |
| 1363 | * |
| 1364 | * Return: None |
| 1365 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1366 | static void hdd_update_vdev_nss(struct hdd_context *hdd_ctx) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1367 | { |
| 1368 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1369 | uint8_t max_supp_nss = 1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1370 | mac_handle_t mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1371 | QDF_STATUS status; |
| 1372 | bool bval; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1373 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1374 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 1375 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1376 | hdd_err("unable to get vht_enable2x2"); |
| 1377 | |
| 1378 | if (bval && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1379 | max_supp_nss = 2; |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 1380 | hdd_debug("max nss %d vdev_type_nss_2g %x vdev_type_nss_5g %x", |
| 1381 | max_supp_nss, cfg_ini->vdev_type_nss_2g, |
| 1382 | cfg_ini->vdev_type_nss_5g); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1383 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1384 | mac_handle = hdd_ctx->mac_handle; |
| 1385 | sme_update_vdev_type_nss(mac_handle, max_supp_nss, |
| 1386 | cfg_ini->vdev_type_nss_2g, BAND_2G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1387 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1388 | sme_update_vdev_type_nss(mac_handle, max_supp_nss, |
| 1389 | cfg_ini->vdev_type_nss_5g, BAND_5G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1390 | } |
| 1391 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1392 | /** |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1393 | * hdd_update_wiphy_vhtcap() - Updates wiphy vhtcap fields |
| 1394 | * @hdd_ctx: HDD context |
| 1395 | * |
| 1396 | * Updates wiphy vhtcap fields |
| 1397 | * |
| 1398 | * Return: None |
| 1399 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1400 | static void hdd_update_wiphy_vhtcap(struct hdd_context *hdd_ctx) |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1401 | { |
| 1402 | struct ieee80211_supported_band *band_5g = |
| 1403 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1404 | QDF_STATUS status; |
| 1405 | uint8_t value = 0, value1 = 0; |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1406 | |
| 1407 | if (!band_5g) { |
| 1408 | hdd_debug("5GHz band disabled, skipping capability population"); |
| 1409 | return; |
| 1410 | } |
| 1411 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1412 | status = ucfg_mlme_cfg_get_vht_tx_bfee_ant_supp(hdd_ctx->psoc, |
| 1413 | &value); |
| 1414 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1415 | hdd_err("unable to get tx_bfee_ant_supp"); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1416 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1417 | band_5g->vht_cap.cap |= (value << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT); |
| 1418 | |
| 1419 | value1 = NUM_OF_SOUNDING_DIMENSIONS; |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1420 | band_5g->vht_cap.cap |= |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1421 | (value1 << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1422 | |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 1423 | hdd_debug("Updated wiphy vhtcap:0x%x, CSNAntSupp:%d, NumSoundDim:%d", |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1424 | band_5g->vht_cap.cap, value, value1); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1425 | } |
| 1426 | |
| 1427 | /** |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1428 | * hdd_update_hw_dbs_capable() - sets the dbs capability of the device |
| 1429 | * @hdd_ctx: HDD context |
| 1430 | * |
| 1431 | * Sets the DBS capability as per INI and firmware capability |
| 1432 | * |
| 1433 | * Return: None |
| 1434 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1435 | static void hdd_update_hw_dbs_capable(struct hdd_context *hdd_ctx) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1436 | { |
| 1437 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1438 | uint8_t hw_dbs_capable = 0; |
| 1439 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1440 | if (policy_mgr_is_hw_dbs_capable(hdd_ctx->psoc) && |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 1441 | ((cfg_ini->dual_mac_feature_disable == |
| 1442 | ENABLE_DBS_CXN_AND_SCAN) || |
| 1443 | (cfg_ini->dual_mac_feature_disable == |
Tushnim Bhattacharyya | aececb2 | 2018-08-06 14:27:46 -0700 | [diff] [blame] | 1444 | ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF) || |
| 1445 | (cfg_ini->dual_mac_feature_disable == |
| 1446 | ENABLE_DBS_CXN_AND_DISABLE_SIMULTANEOUS_SCAN))) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1447 | hw_dbs_capable = 1; |
| 1448 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1449 | sme_update_hw_dbs_capable(hdd_ctx->mac_handle, hw_dbs_capable); |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1450 | } |
| 1451 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1452 | static void hdd_update_tgt_ht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1453 | struct wma_tgt_ht_cap *cfg) |
| 1454 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1455 | QDF_STATUS status; |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 1456 | qdf_size_t value_len; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1457 | uint32_t value; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1458 | struct mlme_ht_capabilities_info ht_cap_info; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1459 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1460 | mac_handle_t mac_handle = hdd_ctx->mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1461 | bool b_enable1x1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1462 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1463 | /* get the MPDU density */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1464 | status = sme_cfg_get_int(mac_handle, WNI_CFG_MPDU_DENSITY, &value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1465 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1466 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1467 | hdd_err("could not get MPDU DENSITY"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1468 | value = 0; |
| 1469 | } |
| 1470 | |
| 1471 | /* |
| 1472 | * MPDU density: |
| 1473 | * override user's setting if value is larger |
| 1474 | * than the one supported by target |
| 1475 | */ |
| 1476 | if (value > cfg->mpdu_density) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1477 | status = sme_cfg_set_int(mac_handle, WNI_CFG_MPDU_DENSITY, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1478 | cfg->mpdu_density); |
| 1479 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1480 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1481 | hdd_err("could not set MPDU DENSITY to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1482 | } |
| 1483 | |
| 1484 | /* get the HT capability info */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1485 | 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] | 1486 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1487 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1488 | return; |
| 1489 | } |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1490 | |
| 1491 | /* check and update RX STBC */ |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1492 | if (ht_cap_info.rx_stbc && !cfg->ht_rx_stbc) |
| 1493 | ht_cap_info.rx_stbc = cfg->ht_rx_stbc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1494 | |
| 1495 | /* Set the LDPC capability */ |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1496 | ht_cap_info.adv_coding_cap = cfg->ht_rx_ldpc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1497 | |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1498 | if (ht_cap_info.short_gi_20_mhz && !cfg->ht_sgi_20) |
| 1499 | ht_cap_info.short_gi_20_mhz = cfg->ht_sgi_20; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1500 | |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1501 | if (ht_cap_info.short_gi_40_mhz && !cfg->ht_sgi_40) |
| 1502 | ht_cap_info.short_gi_40_mhz = cfg->ht_sgi_40; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1503 | |
| 1504 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 1505 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 1506 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1507 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &b_enable1x1); |
| 1508 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1509 | hdd_err("unable to get vht_enable2x2"); |
| 1510 | |
| 1511 | b_enable1x1 = b_enable1x1 && (cfg->num_rf_chains == 2); |
| 1512 | |
| 1513 | status = ucfg_mlme_set_vht_enable2x2(hdd_ctx->psoc, b_enable1x1); |
| 1514 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1515 | hdd_err("unable to set vht_enable2x2"); |
| 1516 | |
| 1517 | if (b_enable1x1 == false) { |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1518 | ht_cap_info.tx_stbc = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1519 | |
| 1520 | /* 1x1 */ |
| 1521 | /* Update Rx Highest Long GI data Rate */ |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1522 | status = ucfg_mlme_cfg_set_vht_rx_supp_data_rate( |
| 1523 | hdd_ctx->psoc, |
| 1524 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1); |
| 1525 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1526 | hdd_err("Failed to set rx_supp_data_rate"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1527 | /* Update Tx Highest Long GI data Rate */ |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1528 | status = ucfg_mlme_cfg_set_vht_tx_supp_data_rate( |
| 1529 | hdd_ctx->psoc, |
| 1530 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1); |
| 1531 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1532 | hdd_err("Failed to set tx_supp_data_rate"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1533 | } |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1534 | if (!(cfg->ht_tx_stbc && b_enable1x1)) |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1535 | ht_cap_info.tx_stbc = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1536 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1537 | 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] | 1538 | if (status != QDF_STATUS_SUCCESS) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1539 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1540 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 1541 | value_len = SIZE_OF_SUPPORTED_MCS_SET; |
| 1542 | if (ucfg_mlme_get_supported_mcs_set( |
| 1543 | hdd_ctx->psoc, mcs_set, |
| 1544 | &value_len) == QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1545 | hdd_debug("Read MCS rate set"); |
gaurank kathpalia | 18b4936 | 2018-04-15 23:12:03 +0530 | [diff] [blame] | 1546 | if (cfg->num_rf_chains > SIZE_OF_SUPPORTED_MCS_SET) |
| 1547 | cfg->num_rf_chains = SIZE_OF_SUPPORTED_MCS_SET; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1548 | |
| 1549 | if (b_enable1x1) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1550 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 1551 | mcs_set[value] = |
| 1552 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 1553 | |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 1554 | status = ucfg_mlme_set_supported_mcs_set( |
| 1555 | hdd_ctx->psoc, |
| 1556 | mcs_set, |
| 1557 | (qdf_size_t)SIZE_OF_SUPPORTED_MCS_SET); |
| 1558 | if (QDF_IS_STATUS_ERROR(status)) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1559 | hdd_err("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1560 | } |
| 1561 | } |
| 1562 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 1563 | } |
| 1564 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1565 | static void hdd_update_tgt_vht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1566 | struct wma_tgt_vht_cap *cfg) |
| 1567 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1568 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1569 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 1570 | struct ieee80211_supported_band *band_5g = |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 1571 | wiphy->bands[HDD_NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1572 | uint32_t ch_width = eHT_CHANNEL_WIDTH_80MHZ; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1573 | struct wma_caps_per_phy caps_per_phy; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1574 | uint8_t val = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1575 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1576 | if (!band_5g) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1577 | hdd_debug("5GHz band disabled, skipping capability population"); |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1578 | return; |
| 1579 | } |
| 1580 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1581 | status = ucfg_mlme_update_vht_cap(hdd_ctx->psoc, cfg); |
| 1582 | if (QDF_IS_STATUS_ERROR(status)) |
| 1583 | hdd_err("could not update vht capabilities"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1584 | |
| 1585 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1586 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1587 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1588 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1589 | else |
| 1590 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1591 | |
| 1592 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1593 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) { |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1594 | status = |
| 1595 | ucfg_mlme_cfg_set_vht_chan_width(hdd_ctx->psoc, |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1596 | VHT_CAP_160_AND_80P80_SUPP); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1597 | if (QDF_IS_STATUS_ERROR(status)) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1598 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1599 | band_5g->vht_cap.cap |= |
| 1600 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1601 | ch_width = eHT_CHANNEL_WIDTH_80P80MHZ; |
| 1602 | } else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) { |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1603 | status = |
| 1604 | ucfg_mlme_cfg_set_vht_chan_width(hdd_ctx->psoc, |
| 1605 | VHT_CAP_160_SUPP); |
| 1606 | if (QDF_IS_STATUS_ERROR(status)) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1607 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1608 | band_5g->vht_cap.cap |= |
| 1609 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1610 | ch_width = eHT_CHANNEL_WIDTH_160MHZ; |
| 1611 | } |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1612 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1613 | status = |
| 1614 | ucfg_mlme_cfg_get_vht_chan_width(hdd_ctx->psoc, &val); |
| 1615 | if (QDF_IS_STATUS_ERROR(status)) |
| 1616 | hdd_err("could not get channel_width"); |
| 1617 | |
| 1618 | val = QDF_MIN(val, ch_width); |
| 1619 | status = |
| 1620 | ucfg_mlme_cfg_set_vht_chan_width(hdd_ctx->psoc, val); |
| 1621 | if (QDF_IS_STATUS_ERROR(status)) |
| 1622 | hdd_err("could not set the channel width"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1623 | |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1624 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1625 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1626 | hdd_debug("VHT RxLDPC capability is set"); |
| 1627 | } else { |
| 1628 | /* |
| 1629 | * Get the RX LDPC capability for the NON DBS |
| 1630 | * hardware mode for 5G band |
| 1631 | */ |
| 1632 | status = wma_get_caps_for_phyidx_hwmode(&caps_per_phy, |
| 1633 | HW_MODE_DBS_NONE, CDS_BAND_5GHZ); |
| 1634 | if ((QDF_IS_STATUS_SUCCESS(status)) && |
| 1635 | (caps_per_phy.vht_5g & WMI_VHT_CAP_RX_LDPC)) { |
| 1636 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1637 | hdd_debug("VHT RX LDPC capability is set"); |
| 1638 | } |
| 1639 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1640 | |
| 1641 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1642 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1643 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1644 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1645 | |
| 1646 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1647 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1648 | |
| 1649 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1650 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1651 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1652 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1653 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1654 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1655 | |
| 1656 | band_5g->vht_cap.cap |= |
| 1657 | (cfg->vht_max_ampdu_len_exp << |
| 1658 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1659 | |
| 1660 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1661 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1662 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1663 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1664 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1665 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1666 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1667 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1668 | |
| 1669 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1670 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1671 | |
| 1672 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1673 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1674 | /** |
| 1675 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1676 | * @hdd_ctx: Pointer to the HDD context |
| 1677 | * |
| 1678 | * Auto-generate mac address using device serial number. |
| 1679 | * Keep the first 3 bytes of OUI as before and replace |
| 1680 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1681 | * |
| 1682 | * Return: 0 for success |
| 1683 | * Non zero failure code for errors |
| 1684 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1685 | static int hdd_generate_macaddr_auto(struct hdd_context *hdd_ctx) |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1686 | { |
| 1687 | unsigned int serialno = 0; |
| 1688 | struct qdf_mac_addr mac_addr = { |
| 1689 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1690 | }; |
| 1691 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1692 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1693 | if (serialno == 0) |
| 1694 | return -EINVAL; |
| 1695 | |
| 1696 | serialno &= 0x00ffffff; |
| 1697 | |
| 1698 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1699 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1700 | mac_addr.bytes[5] = serialno & 0xff; |
| 1701 | |
| 1702 | hdd_update_macaddr(hdd_ctx->config, mac_addr); |
| 1703 | return 0; |
| 1704 | } |
| 1705 | |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1706 | /** |
| 1707 | * hdd_update_ra_rate_limit() - Update RA rate limit from target |
| 1708 | * configuration to cfg_ini in HDD |
| 1709 | * @hdd_ctx: Pointer to hdd_ctx |
| 1710 | * @cfg: target configuration |
| 1711 | * |
| 1712 | * Return: None |
| 1713 | */ |
| 1714 | #ifdef FEATURE_WLAN_RA_FILTERING |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1715 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1716 | struct wma_tgt_cfg *cfg) |
| 1717 | { |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 1718 | ucfg_fwol_set_is_rate_limit_enabled(hdd_ctx->psoc, |
| 1719 | cfg->is_ra_rate_limit_enabled); |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1720 | } |
| 1721 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1722 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1723 | struct wma_tgt_cfg *cfg) |
| 1724 | { |
| 1725 | } |
| 1726 | #endif |
| 1727 | |
Jeff Johnson | f917638 | 2018-07-17 19:15:58 -0700 | [diff] [blame] | 1728 | static void hdd_sar_target_config(struct hdd_context *hdd_ctx, |
| 1729 | struct wma_tgt_cfg *cfg) |
| 1730 | { |
| 1731 | hdd_ctx->sar_version = cfg->sar_version; |
| 1732 | } |
| 1733 | |
Jeff Johnson | 8abc593 | 2018-06-02 22:51:37 -0700 | [diff] [blame] | 1734 | 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] | 1735 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1736 | int ret; |
Jeff Johnson | ea70b94 | 2018-07-02 09:42:31 -0700 | [diff] [blame] | 1737 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1738 | uint8_t temp_band_cap, band_capability; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1739 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1740 | uint8_t antenna_mode; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1741 | uint8_t sub_20_chan_width; |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1742 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1743 | mac_handle_t mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1744 | bool bval = false; |
| 1745 | uint8_t value = 0; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1746 | |
gaurank kathpalia | 843f7c3 | 2018-07-02 18:04:14 +0530 | [diff] [blame] | 1747 | if (!hdd_ctx) { |
| 1748 | hdd_err("HDD context is NULL"); |
| 1749 | return; |
| 1750 | } |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1751 | ret = hdd_objmgr_create_and_store_pdev(hdd_ctx); |
| 1752 | if (ret) { |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1753 | QDF_DEBUG_PANIC("Failed to create pdev; errno:%d", ret); |
| 1754 | return; |
| 1755 | } |
| 1756 | |
| 1757 | hdd_debug("New pdev has been created with pdev_id = %u", |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1758 | hdd_ctx->pdev->pdev_objmgr.wlan_pdev_id); |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1759 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1760 | status = dispatcher_pdev_open(hdd_ctx->pdev); |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1761 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1762 | QDF_DEBUG_PANIC("dispatcher pdev open failed; status:%d", |
| 1763 | status); |
| 1764 | return; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1765 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1766 | |
Sandeep Puligilla | b7beb47 | 2018-08-13 22:54:20 -0700 | [diff] [blame] | 1767 | status = hdd_component_pdev_open(hdd_ctx->pdev); |
| 1768 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1769 | QDF_DEBUG_PANIC("hdd component pdev open failed; status:%d", |
| 1770 | status); |
| 1771 | return; |
| 1772 | } |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1773 | cdp_pdev_set_ctrl_pdev(cds_get_context(QDF_MODULE_ID_SOC), |
| 1774 | cds_get_context(QDF_MODULE_ID_TXRX), |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1775 | (struct cdp_ctrl_objmgr_pdev *)hdd_ctx->pdev); |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1776 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1777 | wlan_pdev_set_dp_handle(hdd_ctx->pdev, |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1778 | cds_get_context(QDF_MODULE_ID_TXRX)); |
| 1779 | |
Will Huang | 0724417 | 2018-05-14 14:23:30 +0800 | [diff] [blame] | 1780 | hdd_objmgr_update_tgt_max_vdev_psoc(hdd_ctx, cfg->max_intf_count); |
| 1781 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1782 | ucfg_ipa_set_dp_handle(hdd_ctx->psoc, |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1783 | cds_get_context(QDF_MODULE_ID_SOC)); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1784 | ucfg_ipa_set_txrx_handle(hdd_ctx->psoc, |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1785 | cds_get_context(QDF_MODULE_ID_TXRX)); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1786 | ucfg_ipa_reg_sap_xmit_cb(hdd_ctx->pdev, |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 1787 | hdd_softap_hard_start_xmit); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1788 | ucfg_ipa_reg_send_to_nw_cb(hdd_ctx->pdev, |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 1789 | hdd_ipa_send_skb_to_network); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1790 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1791 | status = ucfg_mlme_get_sub_20_chan_width(hdd_ctx->psoc, |
| 1792 | &sub_20_chan_width); |
| 1793 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1794 | hdd_err("Failed to get sub_20_chan_width config"); |
| 1795 | return; |
| 1796 | } |
| 1797 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1798 | if (cds_cfg) { |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1799 | if (sub_20_chan_width != |
| 1800 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1801 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1802 | cds_cfg->sub_20_channel_width = |
| 1803 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1804 | } else { |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1805 | cds_cfg->sub_20_channel_width = sub_20_chan_width; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1806 | } |
| 1807 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1808 | |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1809 | status = ucfg_mlme_get_band_capability(hdd_ctx->psoc, &band_capability); |
| 1810 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1811 | hdd_err("Failed to get MLME band capability"); |
| 1812 | return; |
| 1813 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1814 | |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1815 | /* first store the INI band capability */ |
| 1816 | temp_band_cap = band_capability; |
| 1817 | |
| 1818 | band_capability = cfg->band_cap; |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 1819 | hdd_ctx->is_fils_roaming_supported = |
| 1820 | cfg->services.is_fils_roaming_supported; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1821 | |
Vignesh Viswanathan | 694e28e | 2018-01-18 20:53:57 +0530 | [diff] [blame] | 1822 | hdd_ctx->config->is_11k_offload_supported = |
| 1823 | cfg->services.is_11k_offload_supported; |
| 1824 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 1825 | /* |
| 1826 | * now overwrite the target band capability with INI |
| 1827 | * setting if INI setting is a subset |
| 1828 | */ |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1829 | if ((band_capability == BAND_ALL) && |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1830 | (temp_band_cap != BAND_ALL)) |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1831 | band_capability = temp_band_cap; |
| 1832 | else if ((band_capability != BAND_ALL) && |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1833 | (temp_band_cap != BAND_ALL) && |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1834 | (band_capability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1835 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1836 | } |
| 1837 | |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1838 | status = ucfg_mlme_set_band_capability(hdd_ctx->psoc, band_capability); |
| 1839 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1840 | hdd_err("Failed to set MLME Band Capability"); |
| 1841 | return; |
| 1842 | } |
| 1843 | |
| 1844 | hdd_ctx->curr_band = band_capability; |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 1845 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1846 | if (!cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1847 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 1848 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 1849 | } |
| 1850 | |
| 1851 | /* This can be extended to other configurations like ht, vht cap... */ |
| 1852 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 1853 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1854 | hdd_update_macaddr(hdd_ctx->config, cfg->hw_macaddr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1855 | hdd_ctx->update_mac_addr_to_fw = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1856 | } else { |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1857 | static struct qdf_mac_addr default_mac_addr = { |
| 1858 | {0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF} |
| 1859 | }; |
| 1860 | if (qdf_is_macaddr_equal(&hdd_ctx->config->intfMacAddr[0], |
| 1861 | &default_mac_addr)) { |
| 1862 | if (hdd_generate_macaddr_auto(hdd_ctx) != 0) |
| 1863 | hdd_err("Fail to auto-generate MAC, using MAC from ini file " |
| 1864 | MAC_ADDRESS_STR, |
| 1865 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1866 | intfMacAddr[0].bytes)); |
| 1867 | } else { |
| 1868 | hdd_err("Invalid MAC passed from target, using MAC from ini file " |
| 1869 | MAC_ADDRESS_STR, |
| 1870 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1871 | intfMacAddr[0].bytes)); |
| 1872 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1873 | hdd_ctx->update_mac_addr_to_fw = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1874 | } |
| 1875 | |
| 1876 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 1877 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1878 | |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 1879 | hdd_ctx->hw_bd_id = cfg->hw_bd_id; |
| 1880 | qdf_mem_copy(&hdd_ctx->hw_bd_info, &cfg->hw_bd_info, |
| 1881 | sizeof(cfg->hw_bd_info)); |
| 1882 | |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 1883 | if (cfg->max_intf_count > CSR_ROAM_SESSION_MAX) { |
| 1884 | hdd_err("fw max vdevs (%u) > host max vdevs (%u); using %u", |
| 1885 | cfg->max_intf_count, CSR_ROAM_SESSION_MAX, |
| 1886 | CSR_ROAM_SESSION_MAX); |
| 1887 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 1888 | } else { |
| 1889 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 1890 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1891 | |
Jeff Johnson | f917638 | 2018-07-17 19:15:58 -0700 | [diff] [blame] | 1892 | hdd_sar_target_config(hdd_ctx, cfg); |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 1893 | hdd_lpass_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1894 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1895 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 1896 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 1897 | |
| 1898 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 1899 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1900 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame] | 1901 | if (cfg->services.en_11ax) { |
| 1902 | hdd_info("11AX: 11ax is enabled - update HDD config"); |
| 1903 | hdd_update_tgt_he_cap(hdd_ctx, cfg); |
| 1904 | } |
Varun Reddy Yeturu | e93d246 | 2018-05-22 13:54:52 -0700 | [diff] [blame] | 1905 | hdd_update_tgt_twt_cap(hdd_ctx, cfg); |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1906 | |
| 1907 | hdd_update_vdev_nss(hdd_ctx); |
| 1908 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1909 | hdd_update_hw_dbs_capable(hdd_ctx); |
| 1910 | |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1911 | hdd_ctx->config->fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 1912 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1913 | hdd_debug("fine_time_meas_cap: 0x%x", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1914 | hdd_ctx->config->fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1915 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1916 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 1917 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1918 | hdd_err("unable to get vht_enable2x2"); |
| 1919 | |
| 1920 | antenna_mode = (bval == 0x01) ? |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1921 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 1922 | hdd_update_smps_antenna_mode(hdd_ctx, antenna_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1923 | hdd_debug("Init current antenna mode: %d", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1924 | hdd_ctx->current_antenna_mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1925 | |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 1926 | hdd_ctx->rcpi_enabled = cfg->rcpi_enabled; |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1927 | hdd_update_ra_rate_limit(hdd_ctx, cfg); |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1928 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1929 | status = ucfg_mlme_cfg_get_vht_tx_bfee_ant_supp(hdd_ctx->psoc, |
| 1930 | &value); |
| 1931 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1932 | status = false; |
| 1933 | hdd_err("set tx_bfee_ant_supp failed"); |
| 1934 | } |
| 1935 | |
| 1936 | if ((value > |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1937 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF) && |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1938 | !cfg->tx_bfee_8ss_enabled) { |
| 1939 | status = |
| 1940 | ucfg_mlme_cfg_set_vht_tx_bfee_ant_supp(hdd_ctx->psoc, |
| 1941 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF); |
| 1942 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1943 | status = false; |
| 1944 | hdd_err("set tx_bfee_ant_supp failed"); |
| 1945 | } |
| 1946 | } |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 1947 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1948 | mac_handle = hdd_ctx->mac_handle; |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 1949 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1950 | hdd_debug("txBFCsnValue %d", value); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1951 | |
| 1952 | /* |
| 1953 | * Update txBFCsnValue and NumSoundingDim values to vhtcap in wiphy |
| 1954 | */ |
| 1955 | hdd_update_wiphy_vhtcap(hdd_ctx); |
Manjeet Singh | 70d3d93 | 2016-12-20 20:41:10 +0530 | [diff] [blame] | 1956 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 1957 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 1958 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1959 | /* |
| 1960 | * This needs to be done after HDD pdev is created and stored since |
| 1961 | * it will access the HDD pdev object lock. |
| 1962 | */ |
| 1963 | hdd_runtime_suspend_context_init(hdd_ctx); |
| 1964 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 1965 | /* Configure NAN datapath features */ |
| 1966 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Arif Hussain | 759a023 | 2017-03-20 13:17:18 -0700 | [diff] [blame] | 1967 | hdd_ctx->dfs_cac_offload = cfg->dfs_cac_offload; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 1968 | hdd_ctx->lte_coex_ant_share = cfg->services.lte_coex_ant_share; |
Liangwei Dong | 0da1426 | 2018-07-03 03:30:23 -0400 | [diff] [blame] | 1969 | hdd_ctx->obss_scan_offload = cfg->services.obss_scan_offload; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1970 | status = sme_cfg_set_int(mac_handle, WNI_CFG_OBSS_DETECTION_OFFLOAD, |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1971 | cfg->obss_detection_offloaded); |
| 1972 | if (QDF_IS_STATUS_ERROR(status)) |
| 1973 | hdd_err("Couldn't pass WNI_CFG_OBSS_DETECTION_OFFLOAD to CFG"); |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 1974 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1975 | status = sme_cfg_set_int(mac_handle, |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 1976 | WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD, |
| 1977 | cfg->obss_color_collision_offloaded); |
| 1978 | if (QDF_IS_STATUS_ERROR(status)) |
| 1979 | hdd_err("Failed to set WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1980 | } |
| 1981 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1982 | bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1983 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 1984 | struct hdd_adapter *adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 1985 | struct hdd_ap_ctx *ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1986 | |
Jiachao Wu | f610d91 | 2018-01-23 17:47:32 +0800 | [diff] [blame] | 1987 | if (!hdd_ctx) { |
| 1988 | hdd_info("Couldn't get hdd_ctx"); |
| 1989 | return true; |
| 1990 | } |
| 1991 | |
| 1992 | if (hdd_ctx->config->disableDFSChSwitch) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 1993 | hdd_info("skip tx block hdd_ctx=%pK, disableDFSChSwitch=%d", |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1994 | hdd_ctx, hdd_ctx->config->disableDFSChSwitch); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1995 | return true; |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1996 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1997 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 1998 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1999 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 2000 | |
| 2001 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 2002 | QDF_P2P_GO_MODE == adapter->device_mode) && |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 2003 | (wlan_reg_is_passive_or_disable_ch(hdd_ctx->pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 2004 | ap_ctx->operating_channel))) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2005 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->dfs_cac_block_tx = |
| 2006 | true; |
| 2007 | hdd_info("tx blocked for session: %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2008 | adapter->session_id); |
bings | 6fb9bf6 | 2018-07-05 14:01:53 +0800 | [diff] [blame] | 2009 | if (adapter->txrx_vdev) |
| 2010 | cdp_fc_vdev_flush( |
| 2011 | cds_get_context(QDF_MODULE_ID_SOC), |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 2012 | adapter->txrx_vdev); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2013 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2014 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2015 | |
| 2016 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2017 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2018 | |
| 2019 | /** |
| 2020 | * hdd_is_valid_mac_address() - validate MAC address |
| 2021 | * @pMacAddr: Pointer to the input MAC address |
| 2022 | * |
| 2023 | * This function validates whether the given MAC address is valid or not |
| 2024 | * Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 2025 | * where X is the hexa decimal digit character and separated by ':' |
| 2026 | * This algorithm works even if MAC address is not separated by ':' |
| 2027 | * |
| 2028 | * This code checks given input string mac contains exactly 12 hexadecimal |
| 2029 | * digits and a separator colon : appears in the input string only after |
| 2030 | * an even number of hex digits. |
| 2031 | * |
| 2032 | * Return: 1 for valid and 0 for invalid |
| 2033 | */ |
| 2034 | bool hdd_is_valid_mac_address(const uint8_t *pMacAddr) |
| 2035 | { |
| 2036 | int xdigit = 0; |
| 2037 | int separator = 0; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2038 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2039 | while (*pMacAddr) { |
| 2040 | if (isxdigit(*pMacAddr)) { |
| 2041 | xdigit++; |
| 2042 | } else if (':' == *pMacAddr) { |
| 2043 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 2044 | break; |
| 2045 | |
| 2046 | ++separator; |
| 2047 | } else { |
| 2048 | /* Invalid MAC found */ |
| 2049 | return 0; |
| 2050 | } |
| 2051 | ++pMacAddr; |
| 2052 | } |
| 2053 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 2054 | } |
| 2055 | |
| 2056 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2057 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 2058 | * @dev: Handle to struct net_device to be updated. |
| 2059 | * |
| 2060 | * Return: None |
| 2061 | */ |
| 2062 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 2063 | { |
| 2064 | dev->header_ops = NULL; |
| 2065 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 2066 | dev->hard_header_len = ETH_HLEN; |
| 2067 | dev->mtu = ETH_DATA_LEN; |
| 2068 | dev->addr_len = ETH_ALEN; |
| 2069 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 2070 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 2071 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 2072 | |
| 2073 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 2074 | } |
| 2075 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 2076 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2077 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2078 | * __hdd__mon_open() - HDD Open function |
| 2079 | * @dev: Pointer to net_device structure |
| 2080 | * |
| 2081 | * This is called in response to ifconfig up |
| 2082 | * |
| 2083 | * Return: 0 for success; non-zero for failure |
| 2084 | */ |
| 2085 | static int __hdd_mon_open(struct net_device *dev) |
| 2086 | { |
| 2087 | int ret; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2088 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2089 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2090 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2091 | hdd_enter_dev(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2092 | |
| 2093 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2094 | if (ret) |
| 2095 | return ret; |
| 2096 | |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2097 | hdd_mon_mode_ether_setup(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2098 | |
| 2099 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2100 | ret = hdd_wlan_start_modules(hdd_ctx, false); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2101 | if (ret) { |
| 2102 | hdd_err("Failed to start WLAN modules return"); |
| 2103 | return ret; |
| 2104 | } |
| 2105 | hdd_err("hdd_wlan_start_modules() successful !"); |
| 2106 | |
| 2107 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2108 | ret = hdd_start_adapter(adapter); |
| 2109 | if (ret) { |
| 2110 | hdd_err("Failed to start adapter :%d", |
| 2111 | adapter->device_mode); |
| 2112 | return ret; |
| 2113 | } |
| 2114 | hdd_err("hdd_start_adapters() successful !"); |
| 2115 | } |
| 2116 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2117 | } |
| 2118 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2119 | ret = hdd_set_mon_rx_cb(dev); |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 2120 | |
| 2121 | if (!ret) |
| 2122 | ret = hdd_enable_monitor_mode(dev); |
| 2123 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2124 | return ret; |
| 2125 | } |
| 2126 | |
| 2127 | /** |
| 2128 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 2129 | * @dev: Pointer to net_device structure |
| 2130 | * |
| 2131 | * This is called in response to ifconfig up |
| 2132 | * |
| 2133 | * Return: 0 for success; non-zero for failure |
| 2134 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2135 | static int hdd_mon_open(struct net_device *dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2136 | { |
| 2137 | int ret; |
| 2138 | |
| 2139 | cds_ssr_protect(__func__); |
| 2140 | ret = __hdd_mon_open(dev); |
| 2141 | cds_ssr_unprotect(__func__); |
| 2142 | |
| 2143 | return ret; |
| 2144 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 2145 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2146 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2147 | static QDF_STATUS |
| 2148 | wlan_hdd_update_dbs_scan_and_fw_mode_config(void) |
| 2149 | { |
| 2150 | struct policy_mgr_dual_mac_config cfg = {0}; |
| 2151 | QDF_STATUS status; |
Krunal Soni | 13b50f8 | 2018-09-27 12:37:03 -0700 | [diff] [blame] | 2152 | uint32_t channel_select_logic_conc = 0; |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2153 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 2154 | |
| 2155 | if (!hdd_ctx) { |
| 2156 | hdd_err("HDD context is NULL"); |
| 2157 | return QDF_STATUS_E_FAILURE; |
| 2158 | } |
| 2159 | |
| 2160 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2161 | if (!policy_mgr_is_hw_dbs_capable(hdd_ctx->psoc)) |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2162 | return QDF_STATUS_SUCCESS; |
| 2163 | |
| 2164 | cfg.scan_config = 0; |
| 2165 | cfg.fw_mode_config = 0; |
| 2166 | cfg.set_dual_mac_cb = policy_mgr_soc_set_dual_mac_cfg_cb; |
Krunal Soni | 13b50f8 | 2018-09-27 12:37:03 -0700 | [diff] [blame] | 2167 | ucfg_policy_mgr_get_chnl_select_plcy(hdd_ctx->psoc, |
| 2168 | &channel_select_logic_conc); |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2169 | |
| 2170 | if (hdd_ctx->config->dual_mac_feature_disable != |
| 2171 | DISABLE_DBS_CXN_AND_SCAN) { |
| 2172 | status = policy_mgr_get_updated_scan_and_fw_mode_config( |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2173 | hdd_ctx->psoc, &cfg.scan_config, |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2174 | &cfg.fw_mode_config, |
| 2175 | hdd_ctx->config->dual_mac_feature_disable, |
| 2176 | channel_select_logic_conc); |
| 2177 | |
| 2178 | if (status != QDF_STATUS_SUCCESS) { |
| 2179 | hdd_err("wma_get_updated_scan_and_fw_mode_config failed %d", |
| 2180 | status); |
| 2181 | return status; |
| 2182 | } |
| 2183 | } |
| 2184 | |
| 2185 | hdd_debug("send scan_cfg: 0x%x fw_mode_cfg: 0x%x to fw", |
| 2186 | cfg.scan_config, cfg.fw_mode_config); |
| 2187 | |
| 2188 | status = sme_soc_set_dual_mac_config(cfg); |
| 2189 | if (status != QDF_STATUS_SUCCESS) { |
| 2190 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 2191 | return status; |
| 2192 | } |
| 2193 | |
| 2194 | return QDF_STATUS_SUCCESS; |
| 2195 | } |
| 2196 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2197 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2198 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 2199 | * @adapter: pointer to HDD adapter |
| 2200 | * |
| 2201 | * This function is called to start the device specific adapter for |
| 2202 | * the mode passed in the adapter's device_mode. |
| 2203 | * |
| 2204 | * Return: 0 for success; non-zero for failure |
| 2205 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2206 | int hdd_start_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2207 | { |
| 2208 | |
| 2209 | int ret; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 2210 | enum QDF_OPMODE device_mode = adapter->device_mode; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2211 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2212 | hdd_enter_dev(adapter->dev); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2213 | hdd_debug("Start_adapter for mode : %d", adapter->device_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2214 | |
| 2215 | switch (device_mode) { |
| 2216 | case QDF_P2P_CLIENT_MODE: |
| 2217 | case QDF_P2P_DEVICE_MODE: |
| 2218 | case QDF_OCB_MODE: |
| 2219 | case QDF_STA_MODE: |
| 2220 | case QDF_MONITOR_MODE: |
| 2221 | ret = hdd_start_station_adapter(adapter); |
| 2222 | if (ret) |
| 2223 | goto err_start_adapter; |
Alok Kumar | 81e1d73 | 2018-09-04 11:10:36 +0530 | [diff] [blame] | 2224 | |
| 2225 | hdd_nud_ignore_tracking(adapter, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2226 | break; |
| 2227 | case QDF_P2P_GO_MODE: |
| 2228 | case QDF_SAP_MODE: |
| 2229 | ret = hdd_start_ap_adapter(adapter); |
| 2230 | if (ret) |
| 2231 | goto err_start_adapter; |
| 2232 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 2233 | case QDF_IBSS_MODE: |
| 2234 | /* |
| 2235 | * For IBSS interface is initialized as part of |
| 2236 | * hdd_init_station_mode() |
| 2237 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2238 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2239 | case QDF_FTM_MODE: |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2240 | /* vdevs are dynamically managed by firmware in FTM */ |
| 2241 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2242 | default: |
| 2243 | hdd_err("Invalid session type %d", device_mode); |
| 2244 | QDF_ASSERT(0); |
| 2245 | goto err_start_adapter; |
| 2246 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2247 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2248 | if (hdd_set_fw_params(adapter)) |
| 2249 | hdd_err("Failed to set the FW params for the adapter!"); |
| 2250 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2251 | if (adapter->session_id != HDD_SESSION_ID_INVALID) { |
| 2252 | ret = wlan_hdd_cfg80211_register_frames(adapter); |
| 2253 | if (ret < 0) { |
| 2254 | hdd_err("Failed to register frames - ret %d", ret); |
| 2255 | goto err_start_adapter; |
| 2256 | } |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2257 | } |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2258 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2259 | wlan_hdd_update_dbs_scan_and_fw_mode_config(); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2260 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2261 | exit_with_success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2262 | hdd_exit(); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2263 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2264 | return 0; |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2265 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2266 | err_start_adapter: |
| 2267 | return -EINVAL; |
| 2268 | } |
| 2269 | |
| 2270 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2271 | * hdd_enable_power_management() - API to Enable Power Management |
| 2272 | * |
| 2273 | * API invokes Bus Interface Layer power management functionality |
| 2274 | * |
| 2275 | * Return: None |
| 2276 | */ |
| 2277 | static void hdd_enable_power_management(void) |
| 2278 | { |
| 2279 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2280 | |
| 2281 | if (!hif_ctx) { |
| 2282 | hdd_err("Bus Interface Context is Invalid"); |
| 2283 | return; |
| 2284 | } |
| 2285 | |
| 2286 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 2287 | } |
| 2288 | |
| 2289 | /** |
| 2290 | * hdd_disable_power_management() - API to disable Power Management |
| 2291 | * |
| 2292 | * API disable Bus Interface Layer Power management functionality |
| 2293 | * |
| 2294 | * Return: None |
| 2295 | */ |
| 2296 | static void hdd_disable_power_management(void) |
| 2297 | { |
| 2298 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2299 | |
| 2300 | if (!hif_ctx) { |
| 2301 | hdd_err("Bus Interface Context is Invalid"); |
| 2302 | return; |
| 2303 | } |
| 2304 | |
| 2305 | hif_disable_power_management(hif_ctx); |
| 2306 | } |
| 2307 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2308 | void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2309 | { |
| 2310 | void *hif_sc; |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2311 | size_t target_hw_name_len; |
| 2312 | const char *target_hw_name; |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2313 | uint8_t *buf; |
| 2314 | uint32_t buf_len; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2315 | |
| 2316 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
| 2317 | if (!hif_sc) { |
| 2318 | hdd_err("HIF context is NULL"); |
| 2319 | return; |
| 2320 | } |
| 2321 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2322 | hif_get_hw_info(hif_sc, &hdd_ctx->target_hw_version, |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2323 | &hdd_ctx->target_hw_revision, |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2324 | &target_hw_name); |
| 2325 | |
| 2326 | if (hdd_ctx->target_hw_name) |
| 2327 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2328 | |
| 2329 | target_hw_name_len = strlen(target_hw_name) + 1; |
| 2330 | hdd_ctx->target_hw_name = qdf_mem_malloc(target_hw_name_len); |
| 2331 | if (hdd_ctx->target_hw_name) |
| 2332 | qdf_mem_copy(hdd_ctx->target_hw_name, target_hw_name, |
| 2333 | target_hw_name_len); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2334 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2335 | buf = qdf_mem_malloc(WE_MAX_STR_LEN); |
| 2336 | if (buf) { |
| 2337 | buf_len = hdd_wlan_get_version(hdd_ctx, WE_MAX_STR_LEN, buf); |
| 2338 | hdd_info("%s", buf); |
| 2339 | qdf_mem_free(buf); |
| 2340 | } |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2341 | } |
| 2342 | |
| 2343 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2344 | * hdd_update_cds_ac_specs_params() - update cds ac_specs params |
| 2345 | * @hdd_ctx: Pointer to hdd context |
| 2346 | * |
| 2347 | * Return: none |
| 2348 | */ |
| 2349 | static void |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2350 | hdd_update_cds_ac_specs_params(struct hdd_context *hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2351 | { |
| 2352 | uint8_t num_entries = 0; |
| 2353 | uint8_t tx_sched_wrr_param[TX_SCHED_WRR_PARAMS_NUM]; |
| 2354 | uint8_t *tx_sched_wrr_ac; |
| 2355 | int i; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2356 | struct cds_context *cds_ctx; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2357 | |
| 2358 | if (NULL == hdd_ctx) |
| 2359 | return; |
| 2360 | |
| 2361 | if (NULL == hdd_ctx->config) { |
| 2362 | /* Do nothing if hdd_ctx is invalid */ |
| 2363 | hdd_err("%s: Warning: hdd_ctx->cfg_ini is NULL", __func__); |
| 2364 | return; |
| 2365 | } |
| 2366 | |
| 2367 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2368 | |
| 2369 | if (!cds_ctx) { |
| 2370 | hdd_err("Invalid CDS Context"); |
| 2371 | return; |
| 2372 | } |
| 2373 | |
| 2374 | for (i = 0; i < OL_TX_NUM_WMM_AC; i++) { |
| 2375 | switch (i) { |
| 2376 | case OL_TX_WMM_AC_BE: |
| 2377 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_be; |
| 2378 | break; |
| 2379 | case OL_TX_WMM_AC_BK: |
| 2380 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_bk; |
| 2381 | break; |
| 2382 | case OL_TX_WMM_AC_VI: |
| 2383 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vi; |
| 2384 | break; |
| 2385 | case OL_TX_WMM_AC_VO: |
| 2386 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vo; |
| 2387 | break; |
| 2388 | default: |
| 2389 | tx_sched_wrr_ac = NULL; |
| 2390 | break; |
| 2391 | } |
| 2392 | |
| 2393 | hdd_string_to_u8_array(tx_sched_wrr_ac, |
| 2394 | tx_sched_wrr_param, |
| 2395 | &num_entries, |
| 2396 | sizeof(tx_sched_wrr_param)); |
| 2397 | |
| 2398 | if (num_entries == TX_SCHED_WRR_PARAMS_NUM) { |
| 2399 | cds_ctx->ac_specs[i].wrr_skip_weight = |
| 2400 | tx_sched_wrr_param[0]; |
| 2401 | cds_ctx->ac_specs[i].credit_threshold = |
| 2402 | tx_sched_wrr_param[1]; |
| 2403 | cds_ctx->ac_specs[i].send_limit = |
| 2404 | tx_sched_wrr_param[2]; |
| 2405 | cds_ctx->ac_specs[i].credit_reserve = |
| 2406 | tx_sched_wrr_param[3]; |
| 2407 | cds_ctx->ac_specs[i].discard_weight = |
| 2408 | tx_sched_wrr_param[4]; |
| 2409 | } |
| 2410 | |
| 2411 | num_entries = 0; |
| 2412 | } |
| 2413 | } |
| 2414 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2415 | uint32_t hdd_wlan_get_version(struct hdd_context *hdd_ctx, |
| 2416 | const size_t version_len, uint8_t *version) |
| 2417 | { |
| 2418 | uint32_t size; |
| 2419 | uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0; |
| 2420 | |
| 2421 | if (!hdd_ctx) { |
| 2422 | hdd_err("Invalid context, HDD context is null"); |
| 2423 | return 0; |
| 2424 | } |
| 2425 | |
Ashish Kumar Dhanotiya | 7353f88 | 2018-05-15 12:50:19 +0530 | [diff] [blame] | 2426 | if (!version || version_len == 0) { |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2427 | hdd_err("Invalid buffer pointr or buffer len\n"); |
| 2428 | return 0; |
| 2429 | } |
| 2430 | |
| 2431 | msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 2432 | mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 2433 | siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 2434 | crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 2435 | sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28; |
| 2436 | |
| 2437 | size = scnprintf(version, version_len, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2438 | "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] | 2439 | QWLAN_VERSIONSTR, |
| 2440 | msp_id, mspid, siid, crmid, sub_id, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2441 | hdd_ctx->target_hw_name, |
| 2442 | hdd_ctx->hw_bd_info.bdf_version, |
| 2443 | hdd_ctx->hw_bd_info.ref_design_id, |
| 2444 | hdd_ctx->hw_bd_info.customer_id, |
| 2445 | hdd_ctx->hw_bd_info.project_id, |
| 2446 | hdd_ctx->hw_bd_info.board_data_rev); |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2447 | |
| 2448 | return size; |
| 2449 | } |
| 2450 | |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 2451 | int hdd_set_11ax_rate(struct hdd_adapter *adapter, int set_value, |
| 2452 | struct sap_config *sap_config) |
| 2453 | { |
| 2454 | uint8_t preamble = 0, nss = 0, rix = 0; |
| 2455 | int ret; |
| 2456 | mac_handle_t mac_handle = adapter->hdd_ctx->mac_handle; |
| 2457 | |
| 2458 | if (!sap_config) { |
| 2459 | if (!sme_is_feature_supported_by_fw(DOT11AX)) { |
| 2460 | hdd_err("Target does not support 11ax"); |
| 2461 | return -EIO; |
| 2462 | } |
| 2463 | } else if (sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax && |
| 2464 | sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax_ONLY) { |
| 2465 | hdd_err("Invalid hw mode, SAP hw_mode= 0x%x, ch = %d", |
| 2466 | sap_config->SapHw_mode, sap_config->channel); |
| 2467 | return -EIO; |
| 2468 | } |
| 2469 | |
| 2470 | if (set_value != 0xff) { |
| 2471 | rix = RC_2_RATE_IDX_11AX(set_value); |
| 2472 | preamble = WMI_RATE_PREAMBLE_HE; |
| 2473 | nss = HT_RC_2_STREAMS_11AX(set_value); |
| 2474 | |
| 2475 | set_value = hdd_assemble_rate_code(preamble, nss, rix); |
| 2476 | } else { |
| 2477 | ret = sme_set_auto_rate_he_ltf(mac_handle, adapter->session_id, |
| 2478 | QCA_WLAN_HE_LTF_AUTO); |
| 2479 | } |
| 2480 | |
| 2481 | hdd_info("SET_11AX_RATE val %d rix %d preamble %x nss %d", |
| 2482 | set_value, rix, preamble, nss); |
| 2483 | |
| 2484 | ret = wma_cli_set_command(adapter->session_id, |
| 2485 | WMI_VDEV_PARAM_FIXED_RATE, |
| 2486 | set_value, VDEV_CMD); |
| 2487 | |
| 2488 | return ret; |
| 2489 | } |
| 2490 | |
| 2491 | int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate) |
| 2492 | { |
| 2493 | int set_value; |
| 2494 | |
| 2495 | if (sme_is_feature_supported_by_fw(DOT11AX)) |
| 2496 | set_value = WMI_ASSEMBLE_RATECODE_V1(rate, nss, preamble); |
| 2497 | else |
| 2498 | set_value = (preamble << 6) | (nss << 4) | rate; |
| 2499 | |
| 2500 | return set_value; |
| 2501 | } |
| 2502 | |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2503 | #ifdef FEATURE_WLAN_WAPI |
| 2504 | /** |
| 2505 | * hdd_wapi_security_sta_exist() - return wapi security sta exist or not |
| 2506 | * |
| 2507 | * This API returns the wapi security station exist or not |
| 2508 | * |
| 2509 | * Return: true - wapi security station exist |
| 2510 | */ |
| 2511 | static bool hdd_wapi_security_sta_exist(void) |
| 2512 | { |
| 2513 | struct hdd_adapter *adapter = NULL; |
| 2514 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 2515 | |
| 2516 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 2517 | if ((adapter->device_mode == QDF_STA_MODE) && |
| 2518 | adapter->wapi_info.wapi_mode && |
| 2519 | (adapter->wapi_info.wapi_auth_mode != WAPI_AUTH_MODE_OPEN)) |
| 2520 | return true; |
| 2521 | } |
| 2522 | return false; |
| 2523 | } |
| 2524 | #else |
| 2525 | static bool hdd_wapi_security_sta_exist(void) |
| 2526 | { |
| 2527 | return false; |
| 2528 | } |
| 2529 | #endif |
| 2530 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2531 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2532 | static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev( |
| 2533 | struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) |
| 2534 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2535 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2536 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2537 | |
| 2538 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 2539 | if (!adapter) { |
| 2540 | hdd_err("Adapter is NULL"); |
| 2541 | return PM_MAX_NUM_OF_MODE; |
| 2542 | } |
| 2543 | |
| 2544 | return policy_mgr_convert_device_mode_to_qdf_type( |
| 2545 | adapter->device_mode); |
| 2546 | } |
| 2547 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2548 | static void hdd_register_policy_manager_callback( |
| 2549 | struct wlan_objmgr_psoc *psoc) |
| 2550 | { |
| 2551 | struct policy_mgr_hdd_cbacks hdd_cbacks; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 2552 | |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2553 | qdf_mem_zero(&hdd_cbacks, sizeof(hdd_cbacks)); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2554 | hdd_cbacks.sap_restart_chan_switch_cb = |
Jeff Johnson | 2381294 | 2017-10-06 11:33:55 -0700 | [diff] [blame] | 2555 | hdd_sap_restart_chan_switch_cb; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2556 | hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = |
| 2557 | wlan_hdd_get_channel_for_sap_restart; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2558 | hdd_cbacks.get_mode_for_non_connected_vdev = |
| 2559 | wlan_hdd_get_mode_for_non_connected_vdev; |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 2560 | hdd_cbacks.hdd_get_device_mode = hdd_get_device_mode; |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2561 | hdd_cbacks.hdd_wapi_security_sta_exist = |
| 2562 | hdd_wapi_security_sta_exist; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2563 | if (QDF_STATUS_SUCCESS != |
| 2564 | policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { |
| 2565 | hdd_err("HDD callback registration with policy manager failed"); |
| 2566 | } |
| 2567 | } |
| 2568 | #else |
| 2569 | static void hdd_register_policy_manager_callback( |
| 2570 | struct wlan_objmgr_psoc *psoc) |
| 2571 | { |
| 2572 | } |
| 2573 | #endif |
| 2574 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2575 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2576 | { |
| 2577 | struct nan_callbacks cb_obj = {0}; |
| 2578 | |
| 2579 | cb_obj.ndi_open = hdd_ndi_open; |
| 2580 | cb_obj.ndi_close = hdd_ndi_close; |
| 2581 | cb_obj.ndi_start = hdd_ndi_start; |
| 2582 | cb_obj.ndi_delete = hdd_ndi_delete; |
| 2583 | cb_obj.drv_ndi_create_rsp_handler = hdd_ndi_drv_ndi_create_rsp_handler; |
| 2584 | cb_obj.drv_ndi_delete_rsp_handler = hdd_ndi_drv_ndi_delete_rsp_handler; |
| 2585 | |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2586 | cb_obj.new_peer_ind = hdd_ndp_new_peer_handler; |
| 2587 | cb_obj.get_peer_idx = hdd_ndp_get_peer_idx; |
Naveen Rawat | b3143ea | 2017-03-26 22:25:46 -0700 | [diff] [blame] | 2588 | cb_obj.peer_departed_ind = hdd_ndp_peer_departed_handler; |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2589 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2590 | os_if_nan_register_hdd_callbacks(hdd_ctx->psoc, &cb_obj); |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2591 | } |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2592 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2593 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2594 | /** |
| 2595 | * hdd_check_for_leaks() - Perform runtime memory leak checks |
Dustin Brown | a6246dd | 2018-05-24 14:35:58 -0700 | [diff] [blame] | 2596 | * @hdd_ctx: the global HDD context |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2597 | * @is_ssr: true if SSR is in progress |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2598 | * |
| 2599 | * This API triggers runtime memory leak detection. This feature enforces the |
| 2600 | * policy that any memory allocated at runtime must also be released at runtime. |
| 2601 | * |
| 2602 | * Allocating memory at runtime and releasing it at unload is effectively a |
| 2603 | * memory leak for configurations which never unload (e.g. LONU, statically |
| 2604 | * compiled driver). Such memory leaks are NOT false positives, and must be |
| 2605 | * fixed. |
| 2606 | * |
| 2607 | * Return: None |
| 2608 | */ |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2609 | 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] | 2610 | { |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2611 | /* DO NOT REMOVE these checks; for false positives, read above first */ |
| 2612 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2613 | wlan_objmgr_psoc_check_for_peer_leaks(hdd_ctx->psoc); |
| 2614 | wlan_objmgr_psoc_check_for_vdev_leaks(hdd_ctx->psoc); |
| 2615 | wlan_objmgr_psoc_check_for_pdev_leaks(hdd_ctx->psoc); |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2616 | |
| 2617 | /* many adapter resources are not freed by design during SSR */ |
| 2618 | if (is_ssr) |
| 2619 | return; |
| 2620 | |
Dustin Brown | 677e086 | 2017-10-10 16:30:09 -0700 | [diff] [blame] | 2621 | qdf_mc_timer_check_for_leaks(); |
Dustin Brown | 8e71150 | 2017-12-07 16:49:11 -0800 | [diff] [blame] | 2622 | qdf_nbuf_map_check_for_leaks(); |
Dustin Brown | e6b9d5a | 2017-12-14 15:18:49 -0800 | [diff] [blame] | 2623 | qdf_mem_check_for_leaks(); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2624 | } |
| 2625 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2626 | #define hdd_debug_domain_set(domain) qdf_debug_domain_set(domain) |
| 2627 | #else |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2628 | static inline void hdd_check_for_leaks(struct hdd_context *hdd_ctx, bool is_ssr) |
| 2629 | { } |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2630 | |
| 2631 | #define hdd_debug_domain_set(domain) |
| 2632 | #endif /* CONFIG_LEAK_DETECTION */ |
| 2633 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2634 | /** |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2635 | * hdd_update_country_code - Update country code |
| 2636 | * @hdd_ctx: HDD context |
| 2637 | * |
| 2638 | * Update country code based on module parameter country_code |
| 2639 | * |
| 2640 | * Return: 0 on success and errno on failure |
| 2641 | */ |
| 2642 | static int hdd_update_country_code(struct hdd_context *hdd_ctx) |
| 2643 | { |
| 2644 | if (!country_code) |
| 2645 | return 0; |
| 2646 | |
| 2647 | return hdd_reg_set_country(hdd_ctx, country_code); |
| 2648 | } |
| 2649 | |
| 2650 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2651 | * hdd_wlan_start_modules() - Single driver state machine for starting modules |
| 2652 | * @hdd_ctx: HDD context |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2653 | * @reinit: flag to indicate from SSR or normal path |
| 2654 | * |
| 2655 | * This function maintains the driver state machine it will be invoked from |
| 2656 | * startup, reinit and change interface. Depending on the driver state shall |
| 2657 | * perform the opening of the modules. |
| 2658 | * |
| 2659 | * Return: 0 for success; non-zero for failure |
| 2660 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2661 | int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, bool reinit) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2662 | { |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2663 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2664 | qdf_device_t qdf_dev; |
| 2665 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2666 | bool unint = false; |
| 2667 | void *hif_ctx; |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2668 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2669 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2670 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2671 | if (!qdf_dev) { |
| 2672 | hdd_err("QDF Device Context is Invalid return"); |
| 2673 | return -EINVAL; |
| 2674 | } |
| 2675 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 2676 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2677 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2678 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2679 | if (hdd_ctx->driver_status == DRIVER_MODULES_ENABLED) { |
| 2680 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2681 | hdd_debug("Driver modules already Enabled"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2682 | hdd_exit(); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2683 | return 0; |
| 2684 | } |
| 2685 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2686 | hdd_ctx->start_modules_in_progress = true; |
| 2687 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2688 | switch (hdd_ctx->driver_status) { |
| 2689 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2690 | hdd_info("Wlan transitioning (UNINITIALIZED -> CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2691 | unint = true; |
| 2692 | /* Fall through dont add break here */ |
| 2693 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 2694 | hdd_info("Wlan transitioning (CLOSED -> ENABLED)"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2695 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2696 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2697 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2698 | if (!reinit && !unint) { |
| 2699 | ret = pld_power_on(qdf_dev->dev); |
| 2700 | if (ret) { |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2701 | hdd_err("Failed to power up device; errno:%d", |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2702 | ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2703 | goto release_lock; |
| 2704 | } |
| 2705 | } |
Yuanyuan Liu | f8fe4bc | 2017-06-07 16:55:58 -0700 | [diff] [blame] | 2706 | |
| 2707 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 2708 | hdd_ctx->config->enable_fw_log); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2709 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 2710 | qdf_dev->bus_type, |
| 2711 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 2712 | HIF_ENABLE_TYPE_PROBE); |
| 2713 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2714 | hdd_err("Failed to open hif; errno: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2715 | goto power_down; |
| 2716 | } |
| 2717 | |
| 2718 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2719 | if (!hif_ctx) { |
| 2720 | hdd_err("hif context is null!!"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2721 | ret = -EINVAL; |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2722 | goto power_down; |
| 2723 | } |
| 2724 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2725 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 2726 | if (status != QDF_STATUS_SUCCESS) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2727 | hdd_err("No Memory to Create BMI Context; status: %d", |
| 2728 | status); |
| 2729 | ret = qdf_status_to_os_return(status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2730 | goto hif_close; |
| 2731 | } |
| 2732 | |
jitiphil | 4c256a3 | 2018-09-07 08:51:52 +0530 | [diff] [blame] | 2733 | ucfg_ipa_component_config_update(hdd_ctx->psoc); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2734 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2735 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 2736 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2737 | status = hdd_component_psoc_open(hdd_ctx->psoc); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 2738 | if (QDF_IS_STATUS_ERROR(status)) { |
| 2739 | hdd_err("Failed to Open legacy components; status: %d", |
| 2740 | status); |
| 2741 | ret = qdf_status_to_os_return(status); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 2742 | goto cds_free; |
| 2743 | } |
| 2744 | |
| 2745 | ret = hdd_update_config(hdd_ctx); |
| 2746 | if (ret) { |
| 2747 | hdd_err("Failed to update configuration; errno: %d", |
| 2748 | ret); |
| 2749 | goto cds_free; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 2750 | } |
| 2751 | |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 2752 | status = wbuff_module_init(); |
| 2753 | if (QDF_IS_STATUS_ERROR(status)) |
| 2754 | hdd_err("WBUFF init unsuccessful; status: %d", status); |
| 2755 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2756 | status = cds_open(hdd_ctx->psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2757 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2758 | hdd_err("Failed to Open CDS; status: %d", status); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2759 | ret = qdf_status_to_os_return(status); |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 2760 | goto psoc_close; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2761 | } |
| 2762 | |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 2763 | hdd_ctx->mac_handle = cds_get_context(QDF_MODULE_ID_SME); |
| 2764 | |
Manjunathappa Prakash | b6b4ff1 | 2018-06-04 12:32:33 -0700 | [diff] [blame] | 2765 | if (hdd_ctx->config->rx_thread_affinity_mask) |
| 2766 | cds_set_rx_thread_cpu_mask( |
| 2767 | hdd_ctx->config->rx_thread_affinity_mask); |
| 2768 | |
| 2769 | /* initialize components configurations after psoc open */ |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2770 | ret = hdd_update_components_config(hdd_ctx); |
| 2771 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2772 | hdd_err("Failed to update component configs; errno: %d", |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2773 | ret); |
| 2774 | goto close; |
| 2775 | } |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2776 | status = cds_dp_open(hdd_ctx->psoc); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2777 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2778 | hdd_err("Failed to Open cds post open; status: %d", |
| 2779 | status); |
| 2780 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2781 | goto close; |
| 2782 | } |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2783 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2784 | /* |
| 2785 | * NAN compoenet requires certian operations like, open adapter, |
| 2786 | * close adapter, etc. to be initiated by HDD, for those |
| 2787 | * register HDD callbacks with UMAC's NAN componenet. |
| 2788 | */ |
| 2789 | hdd_nan_register_callbacks(hdd_ctx); |
| 2790 | |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 2791 | status = cds_pre_enable(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2792 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2793 | hdd_err("Failed to pre-enable CDS; status: %d", status); |
| 2794 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2795 | goto cds_txrx_free; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2796 | } |
| 2797 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2798 | hdd_register_policy_manager_callback( |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2799 | hdd_ctx->psoc); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2800 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2801 | hdd_sysfs_create_version_interface(hdd_ctx->psoc); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2802 | hdd_update_hw_sw_info(hdd_ctx); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2803 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2804 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2805 | hdd_err("in ftm mode, no need to configure cds modules"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2806 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2807 | break; |
| 2808 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2809 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2810 | ret = hdd_configure_cds(hdd_ctx); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2811 | if (ret) { |
| 2812 | hdd_err("Failed to Enable cds modules; errno: %d", ret); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2813 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2814 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2815 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2816 | hdd_enable_power_management(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2817 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2818 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2819 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2820 | default: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2821 | QDF_DEBUG_PANIC("Unknown driver state:%d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2822 | hdd_ctx->driver_status); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2823 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2824 | goto release_lock; |
| 2825 | } |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2826 | |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 2827 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
| 2828 | hdd_info("Wlan transitioned (now ENABLED)"); |
| 2829 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2830 | hdd_ctx->start_modules_in_progress = false; |
Dustin Brown | ad698ae | 2018-09-05 17:19:30 -0700 | [diff] [blame] | 2831 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2832 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2833 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2834 | hdd_exit(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2835 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2836 | return 0; |
| 2837 | |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2838 | post_disable: |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 2839 | cds_post_disable(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2840 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2841 | cds_txrx_free: |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2842 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->psoc); |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2843 | |
| 2844 | if (tgt_hdl && target_psoc_get_wmi_ready(tgt_hdl)) { |
| 2845 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 2846 | dispatcher_pdev_close(hdd_ctx->pdev); |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2847 | hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 2848 | } |
| 2849 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2850 | cds_dp_close(hdd_ctx->psoc); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2851 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2852 | close: |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2853 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2854 | hdd_info("Wlan transition aborted (now CLOSED)"); |
| 2855 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2856 | cds_close(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2857 | |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 2858 | psoc_close: |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2859 | hdd_component_psoc_close(hdd_ctx->psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2860 | cds_deinit_ini_config(); |
| 2861 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2862 | cds_free: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2863 | ol_cds_free(); |
| 2864 | |
| 2865 | hif_close: |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2866 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2867 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2868 | power_down: |
| 2869 | if (!reinit && !unint) |
| 2870 | pld_power_off(qdf_dev->dev); |
| 2871 | release_lock: |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2872 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2873 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Abhinav Kumar | 7ae9b7b | 2017-12-19 15:11:54 +0530 | [diff] [blame] | 2874 | if (hdd_ctx->target_hw_name) { |
| 2875 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2876 | hdd_ctx->target_hw_name = NULL; |
| 2877 | } |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2878 | |
| 2879 | hdd_check_for_leaks(hdd_ctx, reinit); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2880 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2881 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2882 | hdd_exit(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2883 | |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2884 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2885 | } |
| 2886 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2887 | #ifdef WIFI_POS_CONVERGED |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2888 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2889 | { |
| 2890 | int ret = os_if_wifi_pos_register_nl(); |
| 2891 | |
| 2892 | if (ret) |
| 2893 | hdd_err("os_if_wifi_pos_register_nl failed"); |
| 2894 | |
| 2895 | return ret; |
| 2896 | } |
| 2897 | |
| 2898 | static int hdd_deactivate_wifi_pos(void) |
| 2899 | { |
| 2900 | int ret = os_if_wifi_pos_deregister_nl(); |
| 2901 | |
| 2902 | if (ret) |
| 2903 | hdd_err("os_if_wifi_pos_deregister_nl failed"); |
| 2904 | |
| 2905 | return ret; |
| 2906 | } |
| 2907 | |
| 2908 | /** |
| 2909 | * hdd_populate_wifi_pos_cfg - populates wifi_pos parameters |
| 2910 | * @hdd_ctx: hdd context |
| 2911 | * |
| 2912 | * Return: status of operation |
| 2913 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2914 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2915 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2916 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2917 | struct hdd_config *cfg = hdd_ctx->config; |
| 2918 | |
| 2919 | wifi_pos_set_oem_target_type(psoc, hdd_ctx->target_type); |
| 2920 | wifi_pos_set_oem_fw_version(psoc, hdd_ctx->target_fw_version); |
| 2921 | wifi_pos_set_drv_ver_major(psoc, QWLAN_VERSION_MAJOR); |
| 2922 | wifi_pos_set_drv_ver_minor(psoc, QWLAN_VERSION_MINOR); |
| 2923 | wifi_pos_set_drv_ver_patch(psoc, QWLAN_VERSION_PATCH); |
| 2924 | wifi_pos_set_drv_ver_build(psoc, QWLAN_VERSION_BUILD); |
| 2925 | wifi_pos_set_dwell_time_min(psoc, cfg->nNeighborScanMinChanTime); |
| 2926 | wifi_pos_set_dwell_time_max(psoc, cfg->nNeighborScanMaxChanTime); |
| 2927 | } |
| 2928 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2929 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2930 | { |
| 2931 | return oem_activate_service(hdd_ctx); |
| 2932 | } |
| 2933 | |
| 2934 | static int hdd_deactivate_wifi_pos(void) |
| 2935 | { |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 2936 | return oem_deactivate_service(); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2937 | } |
| 2938 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2939 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2940 | { |
| 2941 | } |
| 2942 | #endif |
| 2943 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2944 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2945 | * __hdd_open() - HDD Open function |
| 2946 | * @dev: Pointer to net_device structure |
| 2947 | * |
| 2948 | * This is called in response to ifconfig up |
| 2949 | * |
| 2950 | * Return: 0 for success; non-zero for failure |
| 2951 | */ |
| 2952 | static int __hdd_open(struct net_device *dev) |
| 2953 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2954 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2955 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2956 | int ret; |
| 2957 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2958 | hdd_enter_dev(dev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2959 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2960 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2961 | |
Ashish Kumar Dhanotiya | 15a7db5 | 2017-08-03 10:27:34 +0530 | [diff] [blame] | 2962 | /* Nothing to be done if device is unloading */ |
| 2963 | if (cds_is_driver_unloading()) { |
| 2964 | hdd_err("Driver is unloading can not open the hdd"); |
| 2965 | return -EBUSY; |
| 2966 | } |
| 2967 | |
Dustin Brown | 0184775 | 2017-10-25 13:56:27 -0700 | [diff] [blame] | 2968 | if (cds_is_driver_recovering()) { |
| 2969 | hdd_err("WLAN is currently recovering; Please try again."); |
| 2970 | return -EBUSY; |
| 2971 | } |
| 2972 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 2973 | if (qdf_atomic_read(&hdd_ctx->con_mode_flag)) { |
| 2974 | hdd_err("con_mode_handler is in progress; Please try again."); |
| 2975 | return -EBUSY; |
| 2976 | } |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2977 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 2978 | mutex_lock(&hdd_init_deinit_lock); |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 2979 | hdd_start_driver_ops_timer(eHDD_DRV_OP_IFF_UP); |
| 2980 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2981 | /* |
| 2982 | * This scenario can be hit in cases where in the wlan driver after |
| 2983 | * registering the netdevices and there is a failure in driver |
| 2984 | * initialization. So return error gracefully because the netdevices |
| 2985 | * will be de-registered as part of the load failure. |
| 2986 | */ |
| 2987 | |
| 2988 | if (!cds_is_driver_loaded()) { |
| 2989 | hdd_err("Failed to start the wlan driver!!"); |
| 2990 | ret = -EIO; |
| 2991 | goto err_hdd_hdd_init_deinit_lock; |
| 2992 | } |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2993 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2994 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2995 | ret = hdd_wlan_start_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2996 | if (ret) { |
| 2997 | hdd_err("Failed to start WLAN modules return"); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2998 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2999 | } |
| 3000 | |
| 3001 | |
| 3002 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 3003 | ret = hdd_start_adapter(adapter); |
| 3004 | if (ret) { |
| 3005 | hdd_err("Failed to start adapter :%d", |
| 3006 | adapter->device_mode); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3007 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3008 | } |
| 3009 | } |
| 3010 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3011 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 3012 | 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] | 3013 | hdd_debug("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3014 | /* Enable TX queues only when we are connected */ |
| 3015 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3016 | WLAN_START_ALL_NETIF_QUEUE, |
| 3017 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3018 | } |
| 3019 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3020 | /* Enable carrier and transmit queues for NDI */ |
| 3021 | if (WLAN_HDD_IS_NDI(adapter)) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 3022 | hdd_debug("Enabling Tx Queues"); |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3023 | wlan_hdd_netif_queue_control(adapter, |
| 3024 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 3025 | WLAN_CONTROL_PATH); |
| 3026 | } |
| 3027 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3028 | hdd_populate_wifi_pos_cfg(hdd_ctx); |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 3029 | hdd_lpass_notify_start(hdd_ctx, adapter); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3030 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3031 | err_hdd_hdd_init_deinit_lock: |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 3032 | hdd_stop_driver_ops_timer(); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3033 | mutex_unlock(&hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3034 | return ret; |
| 3035 | } |
| 3036 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3037 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3038 | /** |
| 3039 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 3040 | * @dev: Pointer to net_device structure |
| 3041 | * |
| 3042 | * This is called in response to ifconfig up |
| 3043 | * |
| 3044 | * Return: 0 for success; non-zero for failure |
| 3045 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3046 | static int hdd_open(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3047 | { |
| 3048 | int ret; |
| 3049 | |
| 3050 | cds_ssr_protect(__func__); |
| 3051 | ret = __hdd_open(dev); |
| 3052 | cds_ssr_unprotect(__func__); |
| 3053 | |
| 3054 | return ret; |
| 3055 | } |
| 3056 | |
| 3057 | /** |
| 3058 | * __hdd_stop() - HDD stop function |
| 3059 | * @dev: Pointer to net_device structure |
| 3060 | * |
| 3061 | * This is called in response to ifconfig down |
| 3062 | * |
| 3063 | * Return: 0 for success; non-zero for failure |
| 3064 | */ |
| 3065 | static int __hdd_stop(struct net_device *dev) |
| 3066 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3067 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3068 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3069 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3070 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3071 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3072 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3073 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3074 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3075 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3076 | |
| 3077 | ret = wlan_hdd_validate_context(hdd_ctx); |
Arunk Khandavalli | 987c8d5 | 2018-06-21 17:40:31 +0530 | [diff] [blame] | 3078 | if (ret) { |
| 3079 | set_bit(DOWN_DURING_SSR, &adapter->event_flags); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3080 | return ret; |
Arunk Khandavalli | 987c8d5 | 2018-06-21 17:40:31 +0530 | [diff] [blame] | 3081 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3082 | |
| 3083 | /* Nothing to be done if the interface is not opened */ |
| 3084 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3085 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3086 | return -ENODEV; |
| 3087 | } |
| 3088 | |
| 3089 | /* Make sure the interface is marked as closed */ |
| 3090 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3091 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3092 | mac_handle = hdd_ctx->mac_handle; |
| 3093 | |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3094 | hdd_debug("Disabling Auto Power save timer"); |
| 3095 | sme_ps_disable_auto_ps_timer( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3096 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3097 | adapter->session_id); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3098 | |
| 3099 | /* |
| 3100 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 3101 | * be called on that interface |
| 3102 | */ |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 3103 | hdd_debug("Disabling queues, adapter device mode: %s(%d)", |
| 3104 | hdd_device_mode_to_string(adapter->device_mode), |
| 3105 | adapter->device_mode); |
Kabilan Kannan | 8dac350 | 2017-10-30 12:40:27 -0700 | [diff] [blame] | 3106 | |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 3107 | wlan_hdd_netif_queue_control(adapter, |
| 3108 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 3109 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3110 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 3111 | if (adapter->device_mode == QDF_STA_MODE) |
| 3112 | hdd_lpass_notify_stop(hdd_ctx); |
| 3113 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3114 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3115 | * NAN data interface is different in some sense. The traffic on NDI is |
| 3116 | * bursty in nature and depends on the need to transfer. The service |
| 3117 | * layer may down the interface after the usage and up again when |
| 3118 | * required. In some sense, the NDI is expected to be available |
| 3119 | * (like SAP) iface until NDI delete request is issued by the service |
| 3120 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 3121 | * interface (NDI). |
| 3122 | */ |
| 3123 | if (WLAN_HDD_IS_NDI(adapter)) |
| 3124 | return 0; |
| 3125 | |
| 3126 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3127 | * The interface is marked as down for outside world (aka kernel) |
| 3128 | * But the driver is pretty much alive inside. The driver needs to |
| 3129 | * tear down the existing connection on the netdev (session) |
| 3130 | * cleanup the data pipes and wait until the control plane is stabilized |
| 3131 | * for this interface. The call also needs to wait until the above |
| 3132 | * mentioned actions are completed before returning to the caller. |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3133 | * Notice that hdd_stop_adapter is requested not to close the session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3134 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 3135 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 3136 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3137 | |
| 3138 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 3139 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 3140 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3141 | |
| 3142 | /* |
Hanumanth Reddy Pothula | 3862ca9 | 2018-01-12 16:44:10 +0530 | [diff] [blame] | 3143 | * Upon wifi turn off, DUT has to flush the scan results so if |
| 3144 | * this is the last cli iface, flush the scan database. |
| 3145 | */ |
| 3146 | if (!hdd_is_cli_iface_up(hdd_ctx)) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3147 | sme_scan_flush_result(mac_handle); |
Hanumanth Reddy Pothula | 3862ca9 | 2018-01-12 16:44:10 +0530 | [diff] [blame] | 3148 | |
| 3149 | /* |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3150 | * Find if any iface is up. If any iface is up then can't put device to |
| 3151 | * sleep/power save mode |
| 3152 | */ |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 3153 | if (hdd_check_for_opened_interfaces(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3154 | hdd_debug("Closing all modules from the hdd_stop"); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 3155 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 3156 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 3157 | hdd_prevent_suspend_timeout( |
| 3158 | hdd_ctx->config->iface_change_wait_time, |
| 3159 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3160 | } |
| 3161 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3162 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3163 | return 0; |
| 3164 | } |
| 3165 | |
| 3166 | /** |
| 3167 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 3168 | * @dev: pointer to net_device structure |
| 3169 | * |
| 3170 | * This is called in response to ifconfig down |
| 3171 | * |
| 3172 | * Return: 0 for success and error number for failure |
| 3173 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3174 | static int hdd_stop(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3175 | { |
| 3176 | int ret; |
| 3177 | |
| 3178 | cds_ssr_protect(__func__); |
| 3179 | ret = __hdd_stop(dev); |
| 3180 | cds_ssr_unprotect(__func__); |
| 3181 | |
| 3182 | return ret; |
| 3183 | } |
| 3184 | |
| 3185 | /** |
| 3186 | * __hdd_uninit() - HDD uninit function |
| 3187 | * @dev: Pointer to net_device structure |
| 3188 | * |
| 3189 | * This is called during the netdev unregister to uninitialize all data |
| 3190 | * associated with the device |
| 3191 | * |
| 3192 | * Return: None |
| 3193 | */ |
| 3194 | static void __hdd_uninit(struct net_device *dev) |
| 3195 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3196 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3197 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3198 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3199 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3200 | |
| 3201 | do { |
| 3202 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3203 | hdd_err("Invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3204 | break; |
| 3205 | } |
| 3206 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3207 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3208 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3209 | hdd_err("NULL hdd_ctx"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3210 | break; |
| 3211 | } |
| 3212 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3213 | if (dev != adapter->dev) |
| 3214 | hdd_err("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3215 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3216 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3217 | |
| 3218 | /* after uninit our adapter structure will no longer be valid */ |
| 3219 | adapter->dev = NULL; |
| 3220 | adapter->magic = 0; |
| 3221 | } while (0); |
| 3222 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3223 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3224 | } |
| 3225 | |
| 3226 | /** |
| 3227 | * hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 3228 | * @dev: pointer to net_device structure |
| 3229 | * |
| 3230 | * This is called during the netdev unregister to uninitialize all data |
| 3231 | * associated with the device |
| 3232 | * |
| 3233 | * Return: none |
| 3234 | */ |
| 3235 | static void hdd_uninit(struct net_device *dev) |
| 3236 | { |
| 3237 | cds_ssr_protect(__func__); |
| 3238 | __hdd_uninit(dev); |
| 3239 | cds_ssr_unprotect(__func__); |
| 3240 | } |
| 3241 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3242 | static int hdd_open_cesium_nl_sock(void) |
| 3243 | { |
| 3244 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3245 | struct netlink_kernel_cfg cfg = { |
| 3246 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 3247 | .input = NULL |
| 3248 | }; |
| 3249 | #endif |
| 3250 | int ret = 0; |
| 3251 | |
| 3252 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3253 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3254 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 3255 | THIS_MODULE, |
| 3256 | #endif |
| 3257 | &cfg); |
| 3258 | #else |
| 3259 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3260 | WLAN_NLINK_MCAST_GRP_ID, |
| 3261 | NULL, NULL, THIS_MODULE); |
| 3262 | #endif |
| 3263 | |
| 3264 | if (cesium_nl_srv_sock == NULL) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3265 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3266 | ret = -ECONNREFUSED; |
| 3267 | } |
| 3268 | |
| 3269 | return ret; |
| 3270 | } |
| 3271 | |
| 3272 | static void hdd_close_cesium_nl_sock(void) |
| 3273 | { |
| 3274 | if (NULL != cesium_nl_srv_sock) { |
| 3275 | netlink_kernel_release(cesium_nl_srv_sock); |
| 3276 | cesium_nl_srv_sock = NULL; |
| 3277 | } |
| 3278 | } |
| 3279 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3280 | /** |
| 3281 | * __hdd_set_mac_address() - set the user specified mac address |
| 3282 | * @dev: Pointer to the net device. |
| 3283 | * @addr: Pointer to the sockaddr. |
| 3284 | * |
| 3285 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3286 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3287 | * |
| 3288 | * Return: 0 for success, non zero for failure |
| 3289 | */ |
| 3290 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3291 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3292 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Ashish Kumar Dhanotiya | e533f6c | 2018-06-19 21:16:07 +0530 | [diff] [blame] | 3293 | struct hdd_adapter *adapter_temp; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3294 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3295 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3296 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3297 | int ret; |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3298 | struct qdf_mac_addr mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3299 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3300 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3301 | |
Hanumanth Reddy Pothula | 5c7a781 | 2018-03-09 12:55:32 +0530 | [diff] [blame] | 3302 | if (netif_running(dev)) { |
| 3303 | hdd_err("On iface up, set mac address change isn't supported"); |
| 3304 | return -EBUSY; |
| 3305 | } |
| 3306 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3307 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3308 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 3309 | if (0 != ret) |
| 3310 | return ret; |
| 3311 | |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3312 | 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] | 3313 | adapter_temp = hdd_get_adapter_by_macaddr(hdd_ctx, mac_addr.bytes); |
| 3314 | if (adapter_temp) { |
| 3315 | if (!qdf_str_cmp(adapter_temp->dev->name, dev->name)) |
| 3316 | return 0; |
| 3317 | hdd_err("%s adapter exist with same address " MAC_ADDRESS_STR, |
| 3318 | adapter_temp->dev->name, |
Ashish Kumar Dhanotiya | f974f33 | 2018-04-19 16:03:15 +0530 | [diff] [blame] | 3319 | MAC_ADDR_ARRAY(mac_addr.bytes)); |
| 3320 | return -EINVAL; |
| 3321 | } |
| 3322 | |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 3323 | qdf_ret_status = wlan_hdd_validate_mac_address(&mac_addr); |
| 3324 | if (QDF_IS_STATUS_ERROR(qdf_ret_status)) |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3325 | return -EINVAL; |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3326 | |
Ashish Kumar Dhanotiya | 8bfef12 | 2018-04-18 16:48:27 +0530 | [diff] [blame] | 3327 | hdd_info("Changing MAC to " MAC_ADDRESS_STR " of the interface %s ", |
| 3328 | MAC_ADDR_ARRAY(mac_addr.bytes), dev->name); |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3329 | |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3330 | memcpy(&adapter->mac_addr, psta_mac_addr->sa_data, ETH_ALEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3331 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 3332 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3333 | hdd_exit(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3334 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3335 | } |
| 3336 | |
| 3337 | /** |
| 3338 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
| 3339 | * function from SSR |
| 3340 | * @dev: pointer to net_device structure |
| 3341 | * @addr: Pointer to the sockaddr |
| 3342 | * |
| 3343 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3344 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3345 | * |
| 3346 | * Return: 0 for success. |
| 3347 | */ |
| 3348 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3349 | { |
| 3350 | int ret; |
| 3351 | |
| 3352 | cds_ssr_protect(__func__); |
| 3353 | ret = __hdd_set_mac_address(dev, addr); |
| 3354 | cds_ssr_unprotect(__func__); |
| 3355 | |
| 3356 | return ret; |
| 3357 | } |
| 3358 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3359 | uint8_t *wlan_hdd_get_intf_addr(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3360 | { |
| 3361 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3362 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3363 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3364 | if (0 == ((hdd_ctx->config->intfAddrMask) & (1 << i))) |
| 3365 | break; |
| 3366 | } |
| 3367 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3368 | if (QDF_MAX_CONCURRENCY_PERSONA == i) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3369 | return NULL; |
| 3370 | |
| 3371 | hdd_ctx->config->intfAddrMask |= (1 << i); |
| 3372 | return &hdd_ctx->config->intfMacAddr[i].bytes[0]; |
| 3373 | } |
| 3374 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 3375 | void wlan_hdd_release_intf_addr(struct hdd_context *hdd_ctx, |
| 3376 | uint8_t *releaseAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3377 | { |
| 3378 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3379 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3380 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3381 | if (!memcmp(releaseAddr, |
| 3382 | &hdd_ctx->config->intfMacAddr[i].bytes[0], |
| 3383 | 6)) { |
| 3384 | hdd_ctx->config->intfAddrMask &= ~(1 << i); |
| 3385 | break; |
| 3386 | } |
| 3387 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3388 | } |
| 3389 | |
| 3390 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 3391 | /** |
| 3392 | * __hdd_set_multicast_list() - set the multicast address list |
| 3393 | * @dev: Pointer to the WLAN device. |
| 3394 | * @skb: Pointer to OS packet (sk_buff). |
| 3395 | * |
| 3396 | * This funciton sets the multicast address list. |
| 3397 | * |
| 3398 | * Return: None |
| 3399 | */ |
| 3400 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 3401 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3402 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3403 | int i = 0, errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3404 | struct netdev_hw_addr *ha; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3405 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3406 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3407 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3408 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3409 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3410 | hdd_enter_dev(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3411 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3412 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 3413 | |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3414 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 3415 | if (errno) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3416 | goto out; |
| 3417 | |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3418 | errno = hdd_validate_adapter(adapter); |
| 3419 | if (errno) |
Dustin Brown | c788acb | 2017-08-01 17:43:51 -0700 | [diff] [blame] | 3420 | goto out; |
| 3421 | |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3422 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 3423 | hdd_err("%s: Driver module is closed", __func__); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3424 | goto out; |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3425 | } |
| 3426 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3427 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
| 3428 | if (!mc_list_request) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3429 | hdd_err("Cannot allocate mc_list_request"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3430 | goto out; |
| 3431 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3432 | |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3433 | /* Delete already configured multicast address list */ |
| 3434 | if (adapter->mc_addr_list.mc_cnt > 0) { |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3435 | hdd_debug("clear previously configured MC address list"); |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3436 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3437 | pmo_mc_list_change_notify); |
| 3438 | } |
| 3439 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3440 | if (dev->flags & IFF_ALLMULTI) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3441 | hdd_debug("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3442 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3443 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3444 | } else { |
| 3445 | mc_count = netdev_mc_count(dev); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3446 | if (mc_count > pmo_ucfg_max_mc_addr_supported(psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3447 | hdd_debug("Exceeded max MC filter addresses (%d). Allowing all MC frames by disabling MC address filtering", |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3448 | pmo_ucfg_max_mc_addr_supported(psoc)); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3449 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3450 | pmo_mc_list_change_notify); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3451 | goto free_req; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3452 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3453 | netdev_for_each_mc_addr(ha, dev) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3454 | hdd_debug("ha_addr[%d] "MAC_ADDRESS_STR, |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 3455 | i, MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3456 | if (i == mc_count) |
| 3457 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3458 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 3459 | 0, ETH_ALEN); |
| 3460 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 3461 | ha->addr, ETH_ALEN); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3462 | hdd_debug("mlist[%d] = %pM", i, |
| 3463 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3464 | i++; |
| 3465 | } |
| 3466 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3467 | |
| 3468 | mc_list_request->psoc = psoc; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3469 | mc_list_request->vdev_id = adapter->session_id; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3470 | mc_list_request->count = mc_count; |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3471 | |
| 3472 | errno = hdd_cache_mc_addr_list(mc_list_request); |
| 3473 | if (errno) { |
| 3474 | hdd_err("Failed to cache MC address list for vdev %u; errno:%d", |
| 3475 | adapter->session_id, errno); |
| 3476 | goto free_req; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3477 | } |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3478 | |
| 3479 | hdd_enable_mc_addr_filtering(adapter, pmo_mc_list_change_notify); |
| 3480 | |
| 3481 | free_req: |
| 3482 | qdf_mem_free(mc_list_request); |
| 3483 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3484 | out: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3485 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3486 | } |
| 3487 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3488 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3489 | /** |
| 3490 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
| 3491 | * @dev: pointer to net_device |
| 3492 | * |
| 3493 | * Return: none |
| 3494 | */ |
| 3495 | static void hdd_set_multicast_list(struct net_device *dev) |
| 3496 | { |
| 3497 | cds_ssr_protect(__func__); |
| 3498 | __hdd_set_multicast_list(dev); |
| 3499 | cds_ssr_unprotect(__func__); |
| 3500 | } |
| 3501 | #endif |
| 3502 | |
| 3503 | /** |
| 3504 | * hdd_select_queue() - used by Linux OS to decide which queue to use first |
| 3505 | * @dev: Pointer to the WLAN device. |
| 3506 | * @skb: Pointer to OS packet (sk_buff). |
| 3507 | * |
| 3508 | * This function is registered with the Linux OS for network |
| 3509 | * core to decide which queue to use first. |
| 3510 | * |
| 3511 | * Return: ac, Queue Index/access category corresponding to UP in IP header |
| 3512 | */ |
| 3513 | static uint16_t hdd_select_queue(struct net_device *dev, struct sk_buff *skb |
| 3514 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) |
| 3515 | , void *accel_priv |
| 3516 | #endif |
| 3517 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 3518 | , select_queue_fallback_t fallback |
| 3519 | #endif |
| 3520 | ) |
| 3521 | { |
| 3522 | return hdd_wmm_select_queue(dev, skb); |
| 3523 | } |
| 3524 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3525 | static const struct net_device_ops wlan_drv_ops = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3526 | .ndo_open = hdd_open, |
| 3527 | .ndo_stop = hdd_stop, |
| 3528 | .ndo_uninit = hdd_uninit, |
| 3529 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 3530 | .ndo_tx_timeout = hdd_tx_timeout, |
| 3531 | .ndo_get_stats = hdd_get_stats, |
| 3532 | .ndo_do_ioctl = hdd_ioctl, |
| 3533 | .ndo_set_mac_address = hdd_set_mac_address, |
| 3534 | .ndo_select_queue = hdd_select_queue, |
| 3535 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3536 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3537 | #endif |
| 3538 | }; |
| 3539 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 3540 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3541 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3542 | static const struct net_device_ops wlan_mon_drv_ops = { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3543 | .ndo_open = hdd_mon_open, |
| 3544 | .ndo_stop = hdd_stop, |
| 3545 | .ndo_get_stats = hdd_get_stats, |
| 3546 | }; |
| 3547 | |
| 3548 | /** |
| 3549 | * hdd_set_station_ops() - update net_device ops for monitor mode |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3550 | * @dev: Handle to struct net_device to be updated. |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3551 | * Return: None |
| 3552 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3553 | void hdd_set_station_ops(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3554 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3555 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3556 | dev->netdev_ops = &wlan_mon_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3557 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3558 | dev->netdev_ops = &wlan_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3559 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 3560 | #else |
| 3561 | void hdd_set_station_ops(struct net_device *dev) |
| 3562 | { |
| 3563 | dev->netdev_ops = &wlan_drv_ops; |
| 3564 | } |
| 3565 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3566 | |
| 3567 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3568 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 3569 | * @hdd_ctx: global hdd context |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3570 | * @mac_addr: mac address to assign to the interface |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3571 | * @name: User-visible name of the interface |
| 3572 | * |
| 3573 | * hdd adapter pointer would point to the netdev->priv space, this function |
Jeff Johnson | 6201829 | 2018-05-06 16:18:35 -0700 | [diff] [blame] | 3574 | * would retrieve the pointer, and setup the hdd adapter configuration. |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3575 | * |
| 3576 | * Return: the pointer to hdd adapter, otherwise NULL |
| 3577 | */ |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3578 | static struct hdd_adapter * |
| 3579 | hdd_alloc_station_adapter(struct hdd_context *hdd_ctx, tSirMacAddr mac_addr, |
| 3580 | unsigned char name_assign_type, const char *name) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3581 | { |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3582 | struct net_device *dev; |
| 3583 | struct hdd_adapter *adapter; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 3584 | struct hdd_station_ctx *sta_ctx; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3585 | QDF_STATUS qdf_status; |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3586 | |
| 3587 | /* cfg80211 initialization and registration */ |
| 3588 | dev = alloc_netdev_mq(sizeof(*adapter), name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3589 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3590 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3591 | #endif |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3592 | (cds_get_conparam() == QDF_GLOBAL_MONITOR_MODE ? |
| 3593 | hdd_mon_mode_ether_setup : ether_setup), |
| 3594 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3595 | |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3596 | if (!dev) { |
| 3597 | hdd_err("Failed to allocate new net_device '%s'", name); |
| 3598 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3599 | } |
| 3600 | |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3601 | adapter = netdev_priv(dev); |
| 3602 | |
| 3603 | qdf_mem_zero(adapter, sizeof(*adapter)); |
| 3604 | sta_ctx = &adapter->session.station; |
| 3605 | qdf_mem_set(sta_ctx->conn_info.staId, sizeof(sta_ctx->conn_info.staId), |
| 3606 | HDD_WLAN_INVALID_STA_ID); |
| 3607 | adapter->dev = dev; |
| 3608 | adapter->hdd_ctx = hdd_ctx; |
| 3609 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
| 3610 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3611 | |
| 3612 | qdf_status = qdf_event_create(&adapter->qdf_session_open_event); |
| 3613 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 3614 | goto free_net_dev; |
| 3615 | |
| 3616 | qdf_status = qdf_event_create(&adapter->qdf_session_close_event); |
| 3617 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 3618 | goto free_net_dev; |
| 3619 | |
| 3620 | adapter->offloads_configured = false; |
| 3621 | adapter->is_link_up_service_needed = false; |
| 3622 | adapter->disconnection_in_progress = false; |
| 3623 | adapter->send_mode_change = true; |
| 3624 | |
| 3625 | /* Init the net_device structure */ |
| 3626 | strlcpy(dev->name, name, IFNAMSIZ); |
| 3627 | |
| 3628 | qdf_mem_copy(dev->dev_addr, mac_addr, sizeof(tSirMacAddr)); |
| 3629 | qdf_mem_copy(adapter->mac_addr.bytes, mac_addr, sizeof(tSirMacAddr)); |
| 3630 | dev->watchdog_timeo = HDD_TX_TIMEOUT; |
| 3631 | |
| 3632 | if (hdd_ctx->config->enable_ip_tcp_udp_checksum_offload) |
| 3633 | dev->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
| 3634 | dev->features |= NETIF_F_RXCSUM; |
| 3635 | |
| 3636 | hdd_set_tso_flags(hdd_ctx, dev); |
| 3637 | hdd_set_station_ops(adapter->dev); |
| 3638 | |
| 3639 | hdd_dev_setup_destructor(dev); |
| 3640 | dev->ieee80211_ptr = &adapter->wdev; |
| 3641 | dev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
| 3642 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
| 3643 | adapter->wdev.netdev = dev; |
| 3644 | |
| 3645 | /* set dev's parent to underlying device */ |
| 3646 | SET_NETDEV_DEV(dev, hdd_ctx->parent_dev); |
| 3647 | hdd_wmm_init(adapter); |
| 3648 | spin_lock_init(&adapter->pause_map_lock); |
| 3649 | adapter->start_time = qdf_system_ticks(); |
| 3650 | adapter->last_time = adapter->start_time; |
| 3651 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3652 | return adapter; |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3653 | |
| 3654 | free_net_dev: |
| 3655 | free_netdev(adapter->dev); |
| 3656 | |
| 3657 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3658 | } |
| 3659 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3660 | 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] | 3661 | { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3662 | struct net_device *dev = adapter->dev; |
| 3663 | int ret; |
| 3664 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 3665 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3666 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3667 | if (rtnl_held) { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3668 | if (strnchr(dev->name, IFNAMSIZ - 1, '%')) { |
| 3669 | |
| 3670 | ret = dev_alloc_name(dev, dev->name); |
| 3671 | if (ret < 0) { |
| 3672 | hdd_err( |
| 3673 | "unable to get dev name: %s, err = 0x%x", |
| 3674 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3675 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3676 | } |
| 3677 | } |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3678 | |
| 3679 | ret = register_netdevice(dev); |
| 3680 | if (ret) { |
| 3681 | hdd_err("register_netdevice(%s) failed, err = 0x%x", |
| 3682 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3683 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3684 | } |
| 3685 | } else { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3686 | ret = register_netdev(dev); |
| 3687 | if (ret) { |
| 3688 | hdd_err("register_netdev(%s) failed, err = 0x%x", |
| 3689 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3690 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3691 | } |
| 3692 | } |
| 3693 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 3694 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3695 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3696 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3697 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3698 | } |
| 3699 | |
Pragaspathi Thilagaraj | 3551caa | 2018-09-26 15:52:56 +0530 | [diff] [blame] | 3700 | QDF_STATUS hdd_sme_open_session_callback(uint8_t session_id, |
| 3701 | QDF_STATUS qdf_status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3702 | { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3703 | struct hdd_adapter *adapter; |
| 3704 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3705 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3706 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3707 | if (!hdd_ctx) { |
| 3708 | hdd_err("Invalid HDD_CTX"); |
| 3709 | return QDF_STATUS_E_FAILURE; |
| 3710 | } |
| 3711 | |
| 3712 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 3713 | if (NULL == adapter) { |
Naveen Rawat | 23a3b91 | 2018-05-30 17:45:52 -0700 | [diff] [blame] | 3714 | hdd_err("NULL adapter for %d", session_id); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3715 | return QDF_STATUS_E_INVAL; |
| 3716 | } |
Pragaspathi Thilagaraj | 3551caa | 2018-09-26 15:52:56 +0530 | [diff] [blame] | 3717 | |
| 3718 | if (qdf_status == QDF_STATUS_SUCCESS) |
| 3719 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3720 | |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3721 | qdf_event_set(&adapter->qdf_session_open_event); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3722 | hdd_debug("session %d opened", adapter->session_id); |
| 3723 | |
| 3724 | return QDF_STATUS_SUCCESS; |
| 3725 | } |
| 3726 | |
| 3727 | QDF_STATUS hdd_sme_close_session_callback(uint8_t session_id) |
| 3728 | { |
| 3729 | struct hdd_adapter *adapter; |
| 3730 | struct hdd_context *hdd_ctx; |
| 3731 | |
| 3732 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3733 | if (!hdd_ctx) { |
| 3734 | hdd_err("Invalid HDD_CTX"); |
| 3735 | return QDF_STATUS_E_FAILURE; |
| 3736 | } |
| 3737 | |
| 3738 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3739 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3740 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3741 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3742 | } |
| 3743 | |
| 3744 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3745 | hdd_err("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3746 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3747 | } |
| 3748 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3749 | /* |
| 3750 | * For NAN Data interface, the close session results in the final |
| 3751 | * indication to the userspace |
| 3752 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 3753 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3754 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3755 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3756 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3757 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3758 | /* |
| 3759 | * We can be blocked while waiting for scheduled work to be |
| 3760 | * flushed, and the adapter structure can potentially be freed, in |
| 3761 | * which case the magic will have been reset. So make sure the |
| 3762 | * magic is still good, and hence the adapter structure is still |
| 3763 | * valid, before signaling completion |
| 3764 | */ |
| 3765 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3766 | qdf_event_set(&adapter->qdf_session_close_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3767 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3768 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3769 | } |
| 3770 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3771 | int hdd_vdev_ready(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3772 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3773 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3774 | |
Dustin Brown | 89fa06e | 2018-09-07 10:47:27 -0700 | [diff] [blame] | 3775 | status = pmo_vdev_ready(adapter->vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3776 | if (QDF_IS_STATUS_ERROR(status)) |
| 3777 | return qdf_status_to_os_return(status); |
| 3778 | |
Dustin Brown | 89fa06e | 2018-09-07 10:47:27 -0700 | [diff] [blame] | 3779 | status = ucfg_reg_11d_vdev_created_update(adapter->vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3780 | if (QDF_IS_STATUS_ERROR(status)) |
| 3781 | return qdf_status_to_os_return(status); |
| 3782 | |
| 3783 | if (wma_capability_enhanced_mcast_filter()) |
Dustin Brown | 89fa06e | 2018-09-07 10:47:27 -0700 | [diff] [blame] | 3784 | status = pmo_ucfg_enhanced_mc_filter_enable(adapter->vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3785 | else |
Dustin Brown | 89fa06e | 2018-09-07 10:47:27 -0700 | [diff] [blame] | 3786 | status = pmo_ucfg_enhanced_mc_filter_disable(adapter->vdev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3787 | |
| 3788 | return qdf_status_to_os_return(status); |
| 3789 | } |
| 3790 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3791 | int hdd_vdev_destroy(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3792 | { |
| 3793 | QDF_STATUS status; |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 3794 | int errno; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3795 | struct hdd_context *hdd_ctx; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3796 | uint8_t vdev_id; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3797 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3798 | vdev_id = adapter->session_id; |
| 3799 | hdd_info("destroying vdev %d", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3800 | |
| 3801 | /* vdev created sanity check */ |
| 3802 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 3803 | hdd_err("vdev %u does not exist", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3804 | return -EINVAL; |
| 3805 | } |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 3806 | |
Dustin Brown | 89fa06e | 2018-09-07 10:47:27 -0700 | [diff] [blame] | 3807 | status = ucfg_reg_11d_vdev_delete_update(adapter->vdev); |
| 3808 | ucfg_scan_set_vdev_del_in_progress(adapter->vdev); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3809 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3810 | /* close sme session (destroy vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3811 | qdf_event_reset(&adapter->qdf_session_close_event); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3812 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3813 | status = sme_close_session(hdd_ctx->mac_handle, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3814 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 3815 | hdd_err("failed to close sme session; status:%d", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3816 | goto release_vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3817 | } |
| 3818 | |
| 3819 | /* block on a completion variable until sme session is closed */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3820 | status = qdf_wait_for_event_completion( |
| 3821 | &adapter->qdf_session_close_event, |
| 3822 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 3823 | |
| 3824 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3825 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3826 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3827 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3828 | hdd_ndp_session_end_handler(adapter); |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 3829 | |
| 3830 | if (status == QDF_STATUS_E_TIMEOUT) |
| 3831 | hdd_err("timed out waiting for sme close session"); |
| 3832 | else if (adapter->qdf_session_close_event.force_set) |
| 3833 | hdd_info("SSR occurred during sme close session"); |
| 3834 | else |
| 3835 | hdd_err("failed to wait for sme close session; status:%u", |
| 3836 | status); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3837 | } |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3838 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3839 | release_vdev: |
Dustin Brown | 89fa06e | 2018-09-07 10:47:27 -0700 | [diff] [blame] | 3840 | ucfg_scan_clear_vdev_del_in_progress(adapter->vdev); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3841 | |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3842 | /* do vdev logical destroy via objmgr */ |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 3843 | errno = hdd_objmgr_release_and_destroy_vdev(adapter); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3844 | if (errno) { |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 3845 | hdd_err("failed to destroy objmgr vdev; errno:%d", errno); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3846 | return errno; |
| 3847 | } |
| 3848 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3849 | hdd_info("vdev %d destroyed successfully", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3850 | |
| 3851 | return 0; |
| 3852 | } |
| 3853 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3854 | static int hdd_set_sme_session_param(struct hdd_adapter *adapter, |
| 3855 | struct sme_session_params *session_param, |
Jeff Johnson | 6a18c96 | 2018-07-01 09:09:37 -0700 | [diff] [blame] | 3856 | csr_roam_complete_cb callback, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3857 | void *callback_ctx) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3858 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3859 | uint32_t type; |
| 3860 | uint32_t sub_type; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3861 | QDF_STATUS status; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3862 | |
| 3863 | /* determine vdev (sub)type */ |
| 3864 | status = cds_get_vdev_types(adapter->device_mode, &type, &sub_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3865 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3866 | hdd_err("failed to get vdev type: %d", status); |
| 3867 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3868 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3869 | session_param->sme_session_id = adapter->session_id; |
| 3870 | session_param->self_mac_addr = (uint8_t *)&adapter->mac_addr; |
| 3871 | session_param->type_of_persona = type; |
| 3872 | session_param->subtype_of_persona = sub_type; |
| 3873 | session_param->session_open_cb = hdd_sme_open_session_callback; |
| 3874 | session_param->session_close_cb = hdd_sme_close_session_callback; |
| 3875 | session_param->callback = callback; |
| 3876 | session_param->callback_ctx = callback_ctx; |
| 3877 | |
| 3878 | return 0; |
| 3879 | } |
| 3880 | |
| 3881 | int hdd_vdev_create(struct hdd_adapter *adapter, |
Jeff Johnson | 6a18c96 | 2018-07-01 09:09:37 -0700 | [diff] [blame] | 3882 | csr_roam_complete_cb callback, void *ctx) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3883 | { |
| 3884 | QDF_STATUS status; |
| 3885 | int errno; |
| 3886 | struct hdd_context *hdd_ctx; |
| 3887 | struct sme_session_params sme_session_params = {0}; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3888 | |
| 3889 | hdd_info("creating new vdev"); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3890 | |
| 3891 | /* do vdev create via objmgr */ |
| 3892 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 3893 | errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->pdev, adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3894 | if (errno) { |
| 3895 | hdd_err("failed to create objmgr vdev: %d", errno); |
| 3896 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3897 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3898 | |
| 3899 | /* Open a SME session (prepare vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3900 | status = qdf_event_reset(&adapter->qdf_session_open_event); |
| 3901 | if (QDF_STATUS_SUCCESS != status) { |
| 3902 | hdd_err("failed to reinit session open event"); |
| 3903 | return -EINVAL; |
| 3904 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3905 | errno = hdd_set_sme_session_param(adapter, &sme_session_params, |
| 3906 | callback, ctx); |
| 3907 | if (errno) { |
| 3908 | hdd_err("failed to populating SME params"); |
| 3909 | goto objmgr_vdev_destroy_procedure; |
| 3910 | } |
| 3911 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3912 | status = sme_open_session(hdd_ctx->mac_handle, &sme_session_params); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3913 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3914 | hdd_err("failed to open sme session: %d", status); |
| 3915 | errno = qdf_status_to_os_return(status); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3916 | goto objmgr_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3917 | } |
| 3918 | |
| 3919 | /* block on a completion variable until sme session is opened */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3920 | status = qdf_wait_for_event_completion(&adapter->qdf_session_open_event, |
| 3921 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 3922 | if (QDF_STATUS_SUCCESS != status) { |
| 3923 | if (adapter->qdf_session_open_event.force_set) { |
| 3924 | /* |
| 3925 | * SSR/PDR has caused shutdown, which has forcefully |
| 3926 | * set the event. Return without the closing session. |
| 3927 | */ |
| 3928 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3929 | hdd_err("Session open event forcefully set"); |
| 3930 | return -EINVAL; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3931 | } |
Jeff Johnson | c66d310 | 2018-02-28 11:58:26 -0800 | [diff] [blame] | 3932 | |
| 3933 | if (QDF_STATUS_E_TIMEOUT == status) |
| 3934 | hdd_err("Session failed to open within timeout period"); |
| 3935 | else |
| 3936 | hdd_err("Failed to wait for session open event(status-%d)", |
| 3937 | status); |
| 3938 | errno = -ETIMEDOUT; |
| 3939 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3940 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3941 | } |
| 3942 | |
Pragaspathi Thilagaraj | 3551caa | 2018-09-26 15:52:56 +0530 | [diff] [blame] | 3943 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 3944 | hdd_err("Session failed to open due to vdev create failure"); |
| 3945 | errno = -EINVAL; |
| 3946 | goto objmgr_vdev_destroy_procedure; |
| 3947 | } |
| 3948 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3949 | /* firmware ready for component communication, raise vdev_ready event */ |
| 3950 | errno = hdd_vdev_ready(adapter); |
| 3951 | if (errno) { |
| 3952 | hdd_err("failed to dispatch vdev ready event: %d", errno); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3953 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3954 | } |
| 3955 | |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 3956 | if (adapter->device_mode == QDF_STA_MODE) { |
| 3957 | hdd_debug("setting RTT mac randomization param: %d", |
| 3958 | hdd_ctx->config->enable_rtt_mac_randomization); |
| 3959 | errno = sme_cli_set_command(adapter->session_id, |
| 3960 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_INITIATOR_RANDOM_MAC, |
| 3961 | hdd_ctx->config->enable_rtt_mac_randomization, |
| 3962 | VDEV_CMD); |
| 3963 | if (0 != errno) |
| 3964 | hdd_err("RTT mac randomization param set failed %d", |
| 3965 | errno); |
| 3966 | } |
| 3967 | |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 3968 | if (adapter->device_mode == QDF_STA_MODE || |
| 3969 | adapter->device_mode == QDF_P2P_CLIENT_MODE) |
Dustin Brown | 89fa06e | 2018-09-07 10:47:27 -0700 | [diff] [blame] | 3970 | wlan_vdev_set_max_peer_count(adapter->vdev, |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 3971 | HDD_MAX_VDEV_PEER_COUNT); |
| 3972 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3973 | hdd_info("vdev %d created successfully", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3974 | |
| 3975 | return 0; |
| 3976 | |
| 3977 | /* |
| 3978 | * Due to legacy constraints, we need to destroy in the same order as |
| 3979 | * create. So, split error handling into 2 cases to accommodate. |
| 3980 | */ |
| 3981 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3982 | objmgr_vdev_destroy_procedure: |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3983 | QDF_BUG(!hdd_objmgr_release_and_destroy_vdev(adapter)); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3984 | |
| 3985 | return errno; |
| 3986 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3987 | hdd_vdev_destroy_procedure: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3988 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
| 3989 | |
| 3990 | return errno; |
| 3991 | } |
| 3992 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3993 | QDF_STATUS hdd_init_station_mode(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3994 | { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 3995 | struct hdd_station_ctx *sta_ctx = &adapter->session.station; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3996 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3997 | QDF_STATUS status; |
| 3998 | int ret_val; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3999 | mac_handle_t mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4000 | bool bval = false; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4001 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4002 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4003 | mac_handle = hdd_ctx->mac_handle; |
| 4004 | sme_set_curr_device_mode(mac_handle, adapter->device_mode); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4005 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 4006 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 4007 | hdd_err("unable to get vht_enable2x2"); |
| 4008 | sme_set_pdev_ht_vht_ies(mac_handle, bval); |
| 4009 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4010 | sme_set_vdev_ies_per_band(mac_handle, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4011 | |
Jeff Johnson | 7f2c591 | 2018-03-23 11:42:28 -0700 | [diff] [blame] | 4012 | hdd_roam_profile_init(adapter); |
| 4013 | hdd_register_wext(adapter->dev); |
| 4014 | |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 4015 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4016 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4017 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 4018 | sizeof(sta_ctx->conn_info.staId), HDD_WLAN_INVALID_STA_ID); |
Hanumanth Reddy Pothula | b2d729c | 2017-05-30 11:49:53 +0530 | [diff] [blame] | 4019 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 4020 | /* set fast roaming capability in sme session */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4021 | status = sme_config_fast_roaming(mac_handle, adapter->session_id, |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 4022 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4023 | /* Set the default operation channel */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4024 | sta_ctx->conn_info.operationChannel = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4025 | hdd_ctx->config->OperatingChannel; |
| 4026 | |
| 4027 | /* Make the default Auth Type as OPEN */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4028 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4029 | |
| 4030 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4031 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4032 | hdd_err("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4033 | status, status); |
| 4034 | goto error_init_txrx; |
| 4035 | } |
| 4036 | |
| 4037 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4038 | |
| 4039 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4040 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4041 | hdd_err("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4042 | status, status); |
| 4043 | goto error_wmm_init; |
| 4044 | } |
| 4045 | |
| 4046 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4047 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4048 | ret_val = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4049 | WMI_PDEV_PARAM_BURST_ENABLE, |
Dundi Raviteja | 3aa01be | 2018-05-21 18:58:59 +0530 | [diff] [blame] | 4050 | HDD_ENABLE_SIFS_BURST_DEFAULT, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4051 | PDEV_CMD); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4052 | if (ret_val) |
| 4053 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", ret_val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4054 | |
Poddar, Siddarth | 4b3f731 | 2017-11-02 17:00:20 +0530 | [diff] [blame] | 4055 | /* |
| 4056 | * In case of USB tethering, LRO is disabled. If SSR happened |
| 4057 | * during that time, then as part of SSR init, do not enable |
| 4058 | * the LRO again. Keep the LRO state same as before SSR. |
| 4059 | */ |
Alok Kumar | 90a7309 | 2018-08-03 13:55:09 +0530 | [diff] [blame] | 4060 | if (hdd_ctx->config->lro_enable && |
| 4061 | !(qdf_atomic_read(&hdd_ctx->vendor_disable_lro_flag))) |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 4062 | adapter->dev->features |= NETIF_F_LRO; |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 4063 | |
| 4064 | /* rcpi info initialization */ |
| 4065 | qdf_mem_zero(&adapter->rcpi, sizeof(adapter->rcpi)); |
| 4066 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4067 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4068 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4069 | error_wmm_init: |
| 4070 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4071 | hdd_deinit_tx_rx(adapter); |
| 4072 | error_init_txrx: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4073 | hdd_unregister_wext(adapter->dev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4074 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4075 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4076 | return status; |
| 4077 | } |
| 4078 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4079 | /** |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4080 | * hdd_deinit_station_mode() - De-initialize the station adapter |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4081 | * @hdd_ctx: global hdd context |
| 4082 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4083 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 4084 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4085 | * |
| 4086 | * This function De-initializes the STA/P2P/OCB adapter. |
| 4087 | * |
| 4088 | * Return: None. |
| 4089 | */ |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4090 | static void hdd_deinit_station_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4091 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4092 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4093 | { |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4094 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4095 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 4096 | if (adapter->dev) { |
| 4097 | if (rtnl_held) |
| 4098 | adapter->dev->wireless_handlers = NULL; |
| 4099 | else { |
| 4100 | rtnl_lock(); |
| 4101 | adapter->dev->wireless_handlers = NULL; |
| 4102 | rtnl_unlock(); |
| 4103 | } |
| 4104 | } |
| 4105 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4106 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 4107 | hdd_deinit_tx_rx(adapter); |
| 4108 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4109 | } |
| 4110 | |
| 4111 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 4112 | hdd_wmm_adapter_close(adapter); |
| 4113 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4114 | } |
| 4115 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4116 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4117 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4118 | } |
| 4119 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4120 | void hdd_deinit_adapter(struct hdd_context *hdd_ctx, |
| 4121 | struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4122 | bool rtnl_held) |
| 4123 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4124 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4125 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4126 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4127 | case QDF_STA_MODE: |
| 4128 | case QDF_P2P_CLIENT_MODE: |
| 4129 | case QDF_P2P_DEVICE_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4130 | case QDF_IBSS_MODE: |
| 4131 | case QDF_NDI_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4132 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4133 | hdd_deinit_station_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4134 | break; |
| 4135 | } |
| 4136 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4137 | case QDF_SAP_MODE: |
| 4138 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4139 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4140 | hdd_deinit_ap_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4141 | break; |
| 4142 | } |
| 4143 | |
| 4144 | default: |
| 4145 | break; |
| 4146 | } |
| 4147 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4148 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4149 | } |
| 4150 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4151 | static void hdd_cleanup_adapter(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4152 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4153 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4154 | struct net_device *dev = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4155 | |
| 4156 | if (adapter) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4157 | dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4158 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4159 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4160 | return; |
| 4161 | } |
| 4162 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4163 | hdd_nud_deinit_tracking(adapter); |
| 4164 | qdf_mutex_destroy(&adapter->disconnection_status_lock); |
Nachiket Kukade | 5f0ce4f | 2018-06-15 19:47:37 +0530 | [diff] [blame] | 4165 | hdd_apf_context_destroy(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4166 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 4167 | wlan_hdd_debugfs_csr_deinit(adapter); |
| 4168 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4169 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 4170 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4171 | /* |
| 4172 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 4173 | * the driver is almost closed and cannot handle either control |
| 4174 | * messages or data. However, unregister_netdevice() call above will |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4175 | * eventually invoke hdd_stop(ndo_close) driver callback, which attempts |
| 4176 | * to close the active connections(basically excites control path) which |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4177 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 4178 | * the interface is closed and restricts any operations on that |
| 4179 | */ |
| 4180 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 4181 | |
| 4182 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4183 | if (rtnl_held) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4184 | unregister_netdevice(dev); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4185 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4186 | unregister_netdev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4187 | /* |
| 4188 | * Note that the adapter is no longer valid at this point |
| 4189 | * since the memory has been reclaimed |
| 4190 | */ |
| 4191 | } |
| 4192 | } |
| 4193 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4194 | 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] | 4195 | tSirMacAddr macAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4196 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4197 | struct hdd_adapter *adapter; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4198 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4199 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 4200 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 4201 | macAddr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4202 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4203 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4204 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4205 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4206 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4207 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4208 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4209 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 4210 | /** |
| 4211 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 4212 | * @hdd_ctx: HDD Context |
| 4213 | * @adapter: HDD Adapter |
| 4214 | * |
| 4215 | * This function set the FW Debug log level based on the INI. |
| 4216 | * |
| 4217 | * Return: None |
| 4218 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4219 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4220 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4221 | { |
| 4222 | uint8_t count = 0, numentries = 0, |
| 4223 | moduleloglevel[FW_MODULE_LOG_LEVEL_STRING_LENGTH]; |
| 4224 | uint32_t value = 0; |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4225 | QDF_STATUS status; |
| 4226 | uint16_t enable_fw_log_level, enable_fw_log_type; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4227 | int ret; |
| 4228 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4229 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 4230 | (!hdd_ctx->config->enable_fw_log)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4231 | 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] | 4232 | return; |
| 4233 | } |
| 4234 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4235 | /* Enable FW logs based on INI configuration */ |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4236 | status = ucfg_fwol_get_enable_fw_log_type(hdd_ctx->psoc, |
| 4237 | &enable_fw_log_type); |
| 4238 | if (QDF_IS_STATUS_ERROR(status)) |
| 4239 | return; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4240 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4241 | WMI_DBGLOG_TYPE, |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4242 | enable_fw_log_type, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4243 | DBG_CMD); |
| 4244 | if (ret != 0) |
| 4245 | hdd_err("Failed to enable FW log type ret %d", |
| 4246 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4247 | |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4248 | status = ucfg_fwol_get_enable_fw_log_level(hdd_ctx->psoc, |
| 4249 | &enable_fw_log_level); |
| 4250 | if (QDF_IS_STATUS_ERROR(status)) |
| 4251 | return; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4252 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4253 | WMI_DBGLOG_LOG_LEVEL, |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4254 | enable_fw_log_level, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4255 | DBG_CMD); |
| 4256 | if (ret != 0) |
| 4257 | hdd_err("Failed to enable FW log level ret %d", |
| 4258 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4259 | |
| 4260 | hdd_string_to_u8_array( |
| 4261 | hdd_ctx->config->enableFwModuleLogLevel, |
| 4262 | moduleloglevel, |
| 4263 | &numentries, |
| 4264 | FW_MODULE_LOG_LEVEL_STRING_LENGTH); |
| 4265 | |
| 4266 | while (count < numentries) { |
| 4267 | /* |
| 4268 | * FW module log level input string looks like |
| 4269 | * below: |
| 4270 | * gFwDebugModuleLoglevel=<FW Module ID>, |
| 4271 | * <Log Level>,... |
| 4272 | * For example: |
| 4273 | * gFwDebugModuleLoglevel= |
| 4274 | * 1,0,2,1,3,2,4,3,5,4,6,5,7,6 |
| 4275 | * Above input string means : |
| 4276 | * For FW module ID 1 enable log level 0 |
| 4277 | * For FW module ID 2 enable log level 1 |
| 4278 | * For FW module ID 3 enable log level 2 |
| 4279 | * For FW module ID 4 enable log level 3 |
| 4280 | * For FW module ID 5 enable log level 4 |
| 4281 | * For FW module ID 6 enable log level 5 |
| 4282 | * For FW module ID 7 enable log level 6 |
| 4283 | */ |
| 4284 | |
Nishank Aggarwal | e239d96 | 2017-03-03 12:26:02 +0530 | [diff] [blame] | 4285 | if ((moduleloglevel[count] > WLAN_MODULE_ID_MAX) |
| 4286 | || (moduleloglevel[count + 1] > DBGLOG_LVL_MAX)) { |
| 4287 | hdd_err("Module id %d and dbglog level %d input length is more than max", |
| 4288 | moduleloglevel[count], |
| 4289 | moduleloglevel[count + 1]); |
| 4290 | return; |
| 4291 | } |
| 4292 | |
| 4293 | value = moduleloglevel[count] << 16; |
| 4294 | value |= moduleloglevel[count + 1]; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4295 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4296 | WMI_DBGLOG_MOD_LOG_LEVEL, |
| 4297 | value, DBG_CMD); |
| 4298 | if (ret != 0) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4299 | hdd_err("Failed to enable FW module log level %d ret %d", |
| 4300 | value, ret); |
| 4301 | |
| 4302 | count += 2; |
| 4303 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4304 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4305 | } |
| 4306 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4307 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4308 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4309 | { |
| 4310 | } |
| 4311 | |
| 4312 | #endif |
| 4313 | |
| 4314 | /** |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4315 | * hdd_configure_chain_mask() - programs chain mask to firmware |
| 4316 | * @adapter: HDD adapter |
| 4317 | * |
| 4318 | * Return: 0 on success or errno on failure |
| 4319 | */ |
| 4320 | static int hdd_configure_chain_mask(struct hdd_adapter *adapter) |
| 4321 | { |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4322 | QDF_STATUS status; |
| 4323 | struct wma_caps_per_phy non_dbs_phy_cap; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4324 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4325 | bool bval = false; |
| 4326 | |
| 4327 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 4328 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 4329 | hdd_err("unable to get vht_enable2x2"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4330 | |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 4331 | hdd_debug("enable2x2: %d, lte_coex: %d, disable_DBS: %d", |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4332 | bval, hdd_ctx->lte_coex_ant_share, |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 4333 | hdd_ctx->config->dual_mac_feature_disable); |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4334 | hdd_debug("enable_bt_chain_separation %d", |
| 4335 | hdd_ctx->config->enable_bt_chain_separation); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4336 | |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4337 | status = wma_get_caps_for_phyidx_hwmode(&non_dbs_phy_cap, |
| 4338 | HW_MODE_DBS_NONE, |
| 4339 | CDS_BAND_ALL); |
| 4340 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4341 | hdd_err("couldn't get phy caps. skip chain mask programming"); |
| 4342 | return qdf_status_to_os_return(status); |
| 4343 | } |
| 4344 | |
| 4345 | if (non_dbs_phy_cap.tx_chain_mask_2G < 3 || |
| 4346 | non_dbs_phy_cap.rx_chain_mask_2G < 3 || |
| 4347 | non_dbs_phy_cap.tx_chain_mask_5G < 3 || |
| 4348 | non_dbs_phy_cap.rx_chain_mask_5G < 3) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4349 | hdd_debug("firmware not capable. skip chain mask programming"); |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4350 | return 0; |
| 4351 | } |
| 4352 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4353 | if (bval && !hdd_ctx->config->enable_bt_chain_separation) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4354 | hdd_debug("2x2 enabled. skip chain mask programming"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4355 | return 0; |
| 4356 | } |
| 4357 | |
Naveen Rawat | b54c72b | 2018-02-05 10:39:06 -0800 | [diff] [blame] | 4358 | if (hdd_ctx->config->dual_mac_feature_disable != |
| 4359 | DISABLE_DBS_CXN_AND_SCAN) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4360 | hdd_debug("DBS enabled(%d). skip chain mask programming", |
| 4361 | hdd_ctx->config->dual_mac_feature_disable); |
Naveen Rawat | b54c72b | 2018-02-05 10:39:06 -0800 | [diff] [blame] | 4362 | return 0; |
| 4363 | } |
| 4364 | |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4365 | if (hdd_ctx->lte_coex_ant_share) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4366 | hdd_debug("lte ant sharing enabled. skip chainmask programming"); |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4367 | return 0; |
| 4368 | } |
| 4369 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 4370 | status = ucfg_mlme_configure_chain_mask(hdd_ctx->psoc, |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 4371 | adapter->session_id); |
| 4372 | if (status != QDF_STATUS_SUCCESS) |
| 4373 | goto error; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4374 | |
| 4375 | return 0; |
| 4376 | |
| 4377 | error: |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 4378 | hdd_err("WMI PDEV set param failed"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4379 | return -EINVAL; |
| 4380 | } |
| 4381 | |
| 4382 | /** |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4383 | * hdd_send_coex_config_params() - Send coex config params to FW |
| 4384 | * @hdd_ctx: HDD context |
| 4385 | * @adapter: Primary adapter context |
| 4386 | * |
| 4387 | * This function is used to send all coex config related params to FW |
| 4388 | * |
| 4389 | * Return: 0 on success and -EINVAL on failure |
| 4390 | */ |
| 4391 | static int hdd_send_coex_config_params(struct hdd_context *hdd_ctx, |
| 4392 | struct hdd_adapter *adapter) |
| 4393 | { |
| 4394 | struct coex_config_params coex_cfg_params = {0}; |
| 4395 | struct wlan_fwol_coex_config config = {0}; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 4396 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4397 | QDF_STATUS status; |
| 4398 | |
| 4399 | if (!hdd_ctx) { |
| 4400 | hdd_err("hdd_ctx is invalid"); |
| 4401 | goto err; |
| 4402 | } |
| 4403 | |
| 4404 | if (!adapter) { |
| 4405 | hdd_err("adapter is invalid"); |
| 4406 | goto err; |
| 4407 | } |
| 4408 | |
| 4409 | if (!psoc) { |
| 4410 | hdd_err("HDD psoc is invalid"); |
| 4411 | goto err; |
| 4412 | } |
| 4413 | |
| 4414 | status = ucfg_fwol_get_coex_config_params(psoc, &config); |
| 4415 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4416 | hdd_err("Unable to get coex config params"); |
| 4417 | goto err; |
| 4418 | } |
| 4419 | |
| 4420 | coex_cfg_params.vdev_id = adapter->session_id; |
| 4421 | coex_cfg_params.config_type = WMI_COEX_CONFIG_TX_POWER; |
| 4422 | coex_cfg_params.config_arg1 = config.max_tx_power_for_btc; |
| 4423 | |
| 4424 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4425 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4426 | hdd_err("Failed to send coex Tx power"); |
| 4427 | goto err; |
| 4428 | } |
| 4429 | |
| 4430 | coex_cfg_params.config_type = WMI_COEX_CONFIG_HANDOVER_RSSI; |
| 4431 | coex_cfg_params.config_arg1 = config.wlan_low_rssi_threshold; |
| 4432 | |
| 4433 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4434 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4435 | hdd_err("Failed to send coex handover RSSI"); |
| 4436 | goto err; |
| 4437 | } |
| 4438 | |
| 4439 | coex_cfg_params.config_type = WMI_COEX_CONFIG_BTC_MODE; |
| 4440 | coex_cfg_params.config_arg1 = config.btc_mode; |
| 4441 | |
| 4442 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4443 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4444 | hdd_err("Failed to send coex BTC mode"); |
| 4445 | goto err; |
| 4446 | } |
| 4447 | |
| 4448 | coex_cfg_params.config_type = WMI_COEX_CONFIG_ANTENNA_ISOLATION; |
| 4449 | coex_cfg_params.config_arg1 = config.antenna_isolation; |
| 4450 | |
| 4451 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4452 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4453 | hdd_err("Failed to send coex antenna isolation"); |
| 4454 | goto err; |
| 4455 | } |
| 4456 | |
| 4457 | coex_cfg_params.config_type = WMI_COEX_CONFIG_BT_LOW_RSSI_THRESHOLD; |
| 4458 | coex_cfg_params.config_arg1 = config.bt_low_rssi_threshold; |
| 4459 | |
| 4460 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4461 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4462 | hdd_err("Failed to send coex BT low RSSI threshold"); |
| 4463 | goto err; |
| 4464 | } |
| 4465 | |
| 4466 | coex_cfg_params.config_type = WMI_COEX_CONFIG_BT_INTERFERENCE_LEVEL; |
| 4467 | coex_cfg_params.config_arg1 = config.bt_interference_low_ll; |
| 4468 | coex_cfg_params.config_arg2 = config.bt_interference_low_ul; |
| 4469 | coex_cfg_params.config_arg3 = config.bt_interference_medium_ll; |
| 4470 | coex_cfg_params.config_arg4 = config.bt_interference_medium_ul; |
| 4471 | coex_cfg_params.config_arg5 = config.bt_interference_high_ll; |
| 4472 | coex_cfg_params.config_arg6 = config.bt_interference_high_ul; |
| 4473 | |
| 4474 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4475 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4476 | hdd_err("Failed to send coex BT interference level"); |
| 4477 | goto err; |
| 4478 | } |
| 4479 | return 0; |
| 4480 | err: |
| 4481 | return -EINVAL; |
| 4482 | } |
| 4483 | |
| 4484 | /** |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4485 | * hdd_set_fw_params() - Set parameters to firmware |
| 4486 | * @adapter: HDD adapter |
| 4487 | * |
| 4488 | * This function Sets various parameters to fw once the |
| 4489 | * adapter is started. |
| 4490 | * |
| 4491 | * Return: 0 on success or errno on failure |
| 4492 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4493 | int hdd_set_fw_params(struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4494 | { |
| 4495 | int ret; |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4496 | uint16_t upper_brssi_thresh, lower_brssi_thresh, rts_profile; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4497 | bool enable_dtim_1chrx; |
| 4498 | QDF_STATUS status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4499 | struct hdd_context *hdd_ctx; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4500 | bool bval = false; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4501 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4502 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4503 | |
| 4504 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 4505 | if (!hdd_ctx) |
| 4506 | return -EINVAL; |
| 4507 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4508 | if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 4509 | hdd_debug("FTM Mode is active; nothing to do"); |
| 4510 | return 0; |
| 4511 | } |
| 4512 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4513 | ret = sme_cli_set_command(adapter->session_id, |
Ashish Kumar Dhanotiya | b8630ab | 2017-07-21 14:18:14 +0530 | [diff] [blame] | 4514 | WMI_PDEV_PARAM_DTIM_SYNTH, |
| 4515 | hdd_ctx->config->enable_lprx, PDEV_CMD); |
| 4516 | if (ret) { |
| 4517 | hdd_err("Failed to set LPRx"); |
| 4518 | goto error; |
| 4519 | } |
| 4520 | |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4521 | |
| 4522 | ret = sme_cli_set_command( |
| 4523 | adapter->session_id, |
| 4524 | WMI_PDEV_PARAM_1CH_DTIM_OPTIMIZED_CHAIN_SELECTION, |
| 4525 | hdd_ctx->config->enable_dtim_selection_diversity, |
| 4526 | PDEV_CMD); |
| 4527 | if (ret) { |
| 4528 | hdd_err("Failed to set DTIM_OPTIMIZED_CHAIN_SELECTION"); |
| 4529 | goto error; |
| 4530 | } |
| 4531 | |
Ashish Kumar Dhanotiya | 48dac7d | 2018-03-28 14:59:50 +0530 | [diff] [blame] | 4532 | ret = sme_cli_set_command( |
| 4533 | adapter->session_id, |
| 4534 | WMI_PDEV_PARAM_TX_SCH_DELAY, |
| 4535 | hdd_ctx->config->enable_tx_sch_delay, |
| 4536 | PDEV_CMD); |
| 4537 | if (ret) { |
| 4538 | hdd_err("Failed to set WMI_PDEV_PARAM_TX_SCH_DELAY"); |
| 4539 | goto error; |
| 4540 | } |
| 4541 | |
Ashish Kumar Dhanotiya | 959b38c | 2018-04-06 21:07:57 +0530 | [diff] [blame] | 4542 | ret = sme_cli_set_command( |
| 4543 | adapter->session_id, |
| 4544 | WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE, |
| 4545 | hdd_ctx->config->enable_secondary_rate, |
| 4546 | PDEV_CMD); |
| 4547 | if (ret) { |
| 4548 | hdd_err("Failed to set WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE"); |
| 4549 | goto error; |
| 4550 | } |
| 4551 | |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4552 | if (adapter->device_mode == QDF_STA_MODE) { |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4553 | status = ucfg_get_upper_brssi_thresh(hdd_ctx->psoc, |
| 4554 | &upper_brssi_thresh); |
| 4555 | if (QDF_IS_STATUS_ERROR(status)) |
| 4556 | return -EINVAL; |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4557 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4558 | sme_set_smps_cfg(adapter->session_id, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4559 | HDD_STA_SMPS_PARAM_UPPER_BRSSI_THRESH, |
| 4560 | upper_brssi_thresh); |
| 4561 | |
| 4562 | status = ucfg_get_lower_brssi_thresh(hdd_ctx->psoc, |
| 4563 | &lower_brssi_thresh); |
| 4564 | if (QDF_IS_STATUS_ERROR(status)) |
| 4565 | return -EINVAL; |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4566 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4567 | sme_set_smps_cfg(adapter->session_id, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4568 | HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH, |
| 4569 | lower_brssi_thresh); |
| 4570 | |
| 4571 | status = ucfg_get_enable_dtim_1chrx(hdd_ctx->psoc, |
| 4572 | &enable_dtim_1chrx); |
| 4573 | if (QDF_IS_STATUS_ERROR(status)) |
| 4574 | return -EINVAL; |
| 4575 | |
| 4576 | sme_set_smps_cfg(adapter->session_id, |
| 4577 | HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE, |
| 4578 | enable_dtim_1chrx); |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4579 | } |
| 4580 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4581 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 4582 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 4583 | hdd_err("unable to get vht_enable2x2"); |
| 4584 | |
| 4585 | if (bval) { |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4586 | hdd_debug("configuring 2x2 mode fw params"); |
| 4587 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 4588 | ret = sme_set_cck_tx_fir_override(hdd_ctx->mac_handle, |
| 4589 | adapter->session_id); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4590 | if (ret) { |
| 4591 | hdd_err("WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE set failed %d", |
| 4592 | ret); |
| 4593 | goto error; |
| 4594 | } |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4595 | |
| 4596 | if (hdd_configure_chain_mask(adapter)) |
| 4597 | goto error; |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4598 | } else { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4599 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 4600 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4601 | hdd_debug("configuring 1x1 mode fw params"); |
| 4602 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4603 | /* |
| 4604 | * Disable DTIM 1 chain Rx when in 1x1, |
| 4605 | * we are passing two value |
| 4606 | * as param_id << 29 | param_value. |
| 4607 | * Below param_value = 0(disable) |
| 4608 | */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4609 | ret = sme_cli_set_command(adapter->session_id, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4610 | WMI_STA_SMPS_PARAM_CMDID, |
| 4611 | HDD_DTIM_1CHAIN_RX_ID << |
| 4612 | HDD_SMPS_PARAM_VALUE_S, |
| 4613 | VDEV_CMD); |
| 4614 | if (ret) { |
| 4615 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 4616 | goto error; |
| 4617 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4618 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4619 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 4620 | #undef HDD_SMPS_PARAM_VALUE_S |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4621 | |
| 4622 | if (hdd_configure_chain_mask(adapter)) |
| 4623 | goto error; |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4624 | } |
| 4625 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 4626 | ret = sme_set_enable_mem_deep_sleep(hdd_ctx->mac_handle, |
| 4627 | adapter->session_id); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4628 | if (ret) { |
| 4629 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", ret); |
| 4630 | goto error; |
| 4631 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4632 | |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4633 | status = ucfg_fwol_get_rts_profile(hdd_ctx->psoc, &rts_profile); |
| 4634 | if (QDF_IS_STATUS_ERROR(status)) |
| 4635 | return -EINVAL; |
| 4636 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4637 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4638 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4639 | rts_profile, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4640 | VDEV_CMD); |
| 4641 | if (ret) { |
| 4642 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 4643 | goto error; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4644 | } |
| 4645 | |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4646 | hdd_debug("SET AMSDU num %d", hdd_ctx->config->max_amsdu_num); |
| 4647 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4648 | ret = wma_cli_set_command(adapter->session_id, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4649 | GEN_VDEV_PARAM_AMSDU, |
| 4650 | hdd_ctx->config->max_amsdu_num, |
| 4651 | GEN_CMD); |
| 4652 | if (ret != 0) { |
| 4653 | hdd_err("GEN_VDEV_PARAM_AMSDU set failed %d", ret); |
| 4654 | goto error; |
| 4655 | } |
| 4656 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4657 | hdd_set_fw_log_params(hdd_ctx, adapter); |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4658 | |
| 4659 | ret = hdd_send_coex_config_params(hdd_ctx, adapter); |
| 4660 | if (ret) { |
| 4661 | hdd_warn("Error initializing coex config params"); |
| 4662 | goto error; |
| 4663 | } |
| 4664 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4665 | hdd_exit(); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4666 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4667 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4668 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4669 | error: |
| 4670 | return -EINVAL; |
| 4671 | } |
| 4672 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4673 | /** |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 4674 | * hdd_init_completion() - Initialize Completion Variables |
| 4675 | * @adapter: HDD adapter |
| 4676 | * |
| 4677 | * This function Initialize the completion variables for |
| 4678 | * a particular adapter |
| 4679 | * |
| 4680 | * Return: None |
| 4681 | */ |
| 4682 | static void hdd_init_completion(struct hdd_adapter *adapter) |
| 4683 | { |
| 4684 | init_completion(&adapter->disconnect_comp_var); |
| 4685 | init_completion(&adapter->roaming_comp_var); |
| 4686 | init_completion(&adapter->linkup_event_var); |
| 4687 | init_completion(&adapter->cancel_rem_on_chan_var); |
| 4688 | init_completion(&adapter->rem_on_chan_ready_event); |
| 4689 | init_completion(&adapter->sta_authorized_event); |
| 4690 | init_completion(&adapter->offchannel_tx_event); |
| 4691 | init_completion(&adapter->tx_action_cnf_event); |
| 4692 | init_completion(&adapter->ibss_peer_info_comp); |
| 4693 | init_completion(&adapter->lfr_fw_status.disable_lfr_event); |
| 4694 | } |
| 4695 | |
| 4696 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4697 | * hdd_open_adapter() - open and setup the hdd adatper |
| 4698 | * @hdd_ctx: global hdd context |
| 4699 | * @session_type: type of the interface to be created |
| 4700 | * @iface_name: User-visible name of the interface |
| 4701 | * @macAddr: MAC address to assign to the interface |
| 4702 | * @name_assign_type: the name of assign type of the netdev |
| 4703 | * @rtnl_held: the rtnl lock hold flag |
| 4704 | * |
| 4705 | * This function open and setup the hdd adpater according to the device |
| 4706 | * type request, assign the name, the mac address assigned, and then prepared |
| 4707 | * the hdd related parameters, queue, lock and ready to start. |
| 4708 | * |
| 4709 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 4710 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4711 | 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] | 4712 | const char *iface_name, tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4713 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4714 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4715 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4716 | struct hdd_adapter *adapter = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4717 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4718 | |
| 4719 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 4720 | /* |
| 4721 | * Max limit reached on the number of vdevs configured by the |
| 4722 | * host. Return error |
| 4723 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4724 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 4725 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4726 | return NULL; |
| 4727 | } |
| 4728 | |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 4729 | status = wlan_hdd_validate_mac_address((struct qdf_mac_addr *)macAddr); |
| 4730 | if (QDF_IS_STATUS_ERROR(status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4731 | /* Not received valid macAddr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4732 | 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] | 4733 | return NULL; |
| 4734 | } |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 4735 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4736 | status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4737 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4738 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 4739 | " already exists", |
| 4740 | MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4741 | return NULL; |
| 4742 | } |
| 4743 | |
| 4744 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4745 | case QDF_STA_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4746 | /* Reset locally administered bit if the device mode is STA */ |
| 4747 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr); |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 4748 | hdd_debug("locally administered bit reset in sta mode: " |
| 4749 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4750 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4751 | case QDF_P2P_CLIENT_MODE: |
| 4752 | case QDF_P2P_DEVICE_MODE: |
| 4753 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 4754 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4755 | case QDF_MONITOR_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4756 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4757 | name_assign_type, |
| 4758 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4759 | |
| 4760 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4761 | hdd_err("failed to allocate adapter for session %d", |
| 4762 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4763 | return NULL; |
| 4764 | } |
| 4765 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4766 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4767 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4768 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4769 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4770 | else if (QDF_MONITOR_MODE == session_type) |
| 4771 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4772 | else |
| 4773 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4774 | |
| 4775 | adapter->device_mode = session_type; |
| 4776 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4777 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4778 | /* |
| 4779 | * Workqueue which gets scheduled in IPv4 notification |
| 4780 | * callback |
| 4781 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4782 | INIT_WORK(&adapter->ipv4_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4783 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4784 | |
| 4785 | #ifdef WLAN_NS_OFFLOAD |
| 4786 | /* |
| 4787 | * Workqueue which gets scheduled in IPv6 |
| 4788 | * notification callback. |
| 4789 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4790 | INIT_WORK(&adapter->ipv6_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4791 | hdd_ipv6_notifier_work_queue); |
| 4792 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4793 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4794 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4795 | goto err_free_netdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4796 | |
| 4797 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4798 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4799 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4800 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4801 | WLAN_CONTROL_PATH); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4802 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4803 | hdd_nud_init_tracking(adapter); |
| 4804 | |
| 4805 | qdf_mutex_create(&adapter->disconnection_status_lock); |
| 4806 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4807 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4808 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4809 | case QDF_P2P_GO_MODE: |
| 4810 | case QDF_SAP_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4811 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr, |
| 4812 | name_assign_type, |
| 4813 | (uint8_t *) iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4814 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4815 | hdd_err("failed to allocate adapter for session %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4816 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4817 | return NULL; |
| 4818 | } |
| 4819 | |
| 4820 | adapter->wdev.iftype = |
| 4821 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4822 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4823 | NL80211_IFTYPE_P2P_GO; |
| 4824 | adapter->device_mode = session_type; |
| 4825 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 4826 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4827 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4828 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4829 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4830 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4831 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4832 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4833 | WLAN_CONTROL_PATH); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4834 | |
| 4835 | /* |
| 4836 | * Workqueue which gets scheduled in IPv4 notification |
| 4837 | * callback |
| 4838 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4839 | INIT_WORK(&adapter->ipv4_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4840 | hdd_ipv4_notifier_work_queue); |
| 4841 | |
| 4842 | #ifdef WLAN_NS_OFFLOAD |
| 4843 | /* |
| 4844 | * Workqueue which gets scheduled in IPv6 |
| 4845 | * notification callback. |
| 4846 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4847 | INIT_WORK(&adapter->ipv6_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4848 | hdd_ipv6_notifier_work_queue); |
| 4849 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4850 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4851 | case QDF_FTM_MODE: |
| 4852 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4853 | name_assign_type, |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 4854 | iface_name); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4855 | if (NULL == adapter) { |
| 4856 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 4857 | return NULL; |
| 4858 | } |
| 4859 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4860 | adapter->device_mode = session_type; |
| 4861 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4862 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4863 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4864 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4865 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4866 | hdd_debug("Disabling queues"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4867 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4868 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4869 | WLAN_CONTROL_PATH); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4870 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4871 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4872 | hdd_err("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4873 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4874 | return NULL; |
| 4875 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4876 | |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 4877 | hdd_init_completion(adapter); |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 4878 | INIT_WORK(&adapter->scan_block_work, wlan_hdd_cfg80211_scan_block_cb); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 4879 | qdf_list_create(&adapter->blocked_scan_request_q, WLAN_MAX_SCAN_COUNT); |
| 4880 | qdf_mutex_create(&adapter->blocked_scan_request_q_lock); |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 4881 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4882 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4883 | /* Add it to the hdd's session list. */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4884 | status = hdd_add_adapter_back(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4885 | } |
| 4886 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4887 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4888 | if (NULL != adapter) { |
| 4889 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4890 | adapter = NULL; |
| 4891 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4892 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4893 | return NULL; |
| 4894 | } |
Nachiket Kukade | 5f0ce4f | 2018-06-15 19:47:37 +0530 | [diff] [blame] | 4895 | hdd_apf_context_init(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4896 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4897 | if (QDF_STATUS_SUCCESS == status) { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 4898 | policy_mgr_set_concurrency_mode(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4899 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4900 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4901 | /* Adapter successfully added. Increment the vdev count */ |
| 4902 | hdd_ctx->current_intf_count++; |
| 4903 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4904 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4905 | hdd_ctx->current_intf_count); |
| 4906 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 4907 | hdd_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4908 | } |
| 4909 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4910 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 4911 | hdd_err("Interface %s wow debug_fs init failed", |
| 4912 | netdev_name(adapter->dev)); |
| 4913 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 4914 | hdd_register_hl_netdev_fc_timer(adapter, |
| 4915 | hdd_tx_resume_timer_expired_handler); |
| 4916 | |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 4917 | hdd_info("%s interface created. iftype: %d", netdev_name(adapter->dev), |
| 4918 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4919 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 4920 | if (adapter->device_mode == QDF_STA_MODE) |
| 4921 | wlan_hdd_debugfs_csr_init(adapter); |
| 4922 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4923 | return adapter; |
| 4924 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4925 | err_free_netdev: |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4926 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 4927 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4928 | |
| 4929 | return NULL; |
| 4930 | } |
| 4931 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 4932 | static void __hdd_close_adapter(struct hdd_context *hdd_ctx, |
| 4933 | struct hdd_adapter *adapter, |
| 4934 | bool rtnl_held) |
| 4935 | { |
| 4936 | qdf_list_destroy(&adapter->blocked_scan_request_q); |
| 4937 | qdf_mutex_destroy(&adapter->blocked_scan_request_q_lock); |
| 4938 | policy_mgr_clear_concurrency_mode(hdd_ctx->psoc, adapter->device_mode); |
| 4939 | |
| 4940 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4941 | |
| 4942 | if (hdd_ctx->current_intf_count != 0) |
| 4943 | hdd_ctx->current_intf_count--; |
| 4944 | } |
| 4945 | |
| 4946 | void hdd_close_adapter(struct hdd_context *hdd_ctx, |
| 4947 | struct hdd_adapter *adapter, |
| 4948 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4949 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4950 | /* |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 4951 | * Stop the global bus bandwidth timer while touching the adapter list |
| 4952 | * to avoid bad memory access by the timer handler. |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4953 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4954 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4955 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4956 | hdd_remove_adapter(hdd_ctx, adapter); |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 4957 | __hdd_close_adapter(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4958 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4959 | /* conditionally restart the bw timer */ |
| 4960 | hdd_bus_bw_compute_timer_try_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4961 | } |
| 4962 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 4963 | 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] | 4964 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4965 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4966 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4967 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4968 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 4969 | while (QDF_IS_STATUS_SUCCESS(hdd_remove_front_adapter(hdd_ctx, |
| 4970 | &adapter))) { |
| 4971 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
| 4972 | __hdd_close_adapter(hdd_ctx, adapter, rtnl_held); |
| 4973 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4974 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4975 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4976 | } |
| 4977 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4978 | void wlan_hdd_reset_prob_rspies(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4979 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4980 | struct qdf_mac_addr *bssid = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4981 | tSirUpdateIE updateIE; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4982 | mac_handle_t mac_handle; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4983 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4984 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4985 | case QDF_STA_MODE: |
| 4986 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4987 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4988 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4989 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4990 | bssid = &sta_ctx->conn_info.bssId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4991 | break; |
| 4992 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4993 | case QDF_SAP_MODE: |
| 4994 | case QDF_P2P_GO_MODE: |
| 4995 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4996 | { |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4997 | bssid = &adapter->mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4998 | break; |
| 4999 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5000 | case QDF_FTM_MODE: |
| 5001 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5002 | default: |
| 5003 | /* |
| 5004 | * wlan_hdd_reset_prob_rspies should not have been called |
| 5005 | * for these kind of devices |
| 5006 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5007 | hdd_err("Unexpected request for the current device type %d", |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5008 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5009 | return; |
| 5010 | } |
| 5011 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 5012 | qdf_copy_macaddr(&updateIE.bssid, bssid); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5013 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5014 | updateIE.ieBufferlength = 0; |
| 5015 | updateIE.pAdditionIEBuffer = NULL; |
| 5016 | updateIE.append = true; |
| 5017 | updateIE.notify = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5018 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 5019 | if (sme_update_add_ie(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5020 | &updateIE, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5021 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5022 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5023 | } |
| 5024 | } |
| 5025 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5026 | QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx, |
| 5027 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5028 | { |
Liangwei Dong | ad89c76 | 2018-06-01 01:56:23 -0400 | [diff] [blame] | 5029 | return hdd_stop_adapter_ext(hdd_ctx, adapter, 0); |
| 5030 | } |
| 5031 | |
| 5032 | QDF_STATUS hdd_stop_adapter_ext(struct hdd_context *hdd_ctx, |
| 5033 | struct hdd_adapter *adapter, |
| 5034 | enum hdd_adapter_stop_flag_t flag) |
| 5035 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5036 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5037 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5038 | union iwreq_data wrqu; |
| 5039 | tSirUpdateIE updateIE; |
| 5040 | unsigned long rc; |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 5041 | tsap_config_t *sap_config; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5042 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5043 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5044 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5045 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 5046 | if (adapter->session_id != HDD_SESSION_ID_INVALID) |
| 5047 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 5048 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5049 | hdd_nud_ignore_tracking(adapter, true); |
| 5050 | hdd_nud_reset_tracking(adapter); |
Alok Kumar | 016a1ac | 2018-09-16 09:55:50 +0530 | [diff] [blame] | 5051 | hdd_nud_flush_work(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5052 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5053 | hdd_debug("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5054 | wlan_hdd_netif_queue_control(adapter, |
| 5055 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5056 | WLAN_CONTROL_PATH); |
Tushnim Bhattacharyya | 9bd058f | 2017-12-27 14:01:31 -0800 | [diff] [blame] | 5057 | /* |
| 5058 | * if this is the last active connection check & stop the |
| 5059 | * opportunistic timer first |
| 5060 | */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5061 | if (((policy_mgr_get_connection_count(hdd_ctx->psoc) == 1) && |
| 5062 | (policy_mgr_mode_specific_connection_count(hdd_ctx->psoc, |
Tushnim Bhattacharyya | 9bd058f | 2017-12-27 14:01:31 -0800 | [diff] [blame] | 5063 | policy_mgr_convert_device_mode_to_qdf_type( |
| 5064 | adapter->device_mode), NULL) == 1)) || |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5065 | !policy_mgr_get_connection_count(hdd_ctx->psoc)) |
Tushnim Bhattacharyya | 9bd058f | 2017-12-27 14:01:31 -0800 | [diff] [blame] | 5066 | policy_mgr_check_and_stop_opportunistic_timer( |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5067 | hdd_ctx->psoc, adapter->session_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5068 | |
| 5069 | mac_handle = hdd_ctx->mac_handle; |
| 5070 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5071 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5072 | case QDF_STA_MODE: |
| 5073 | case QDF_P2P_CLIENT_MODE: |
| 5074 | case QDF_IBSS_MODE: |
| 5075 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5076 | case QDF_NDI_MODE: |
| 5077 | if ((QDF_NDI_MODE == adapter->device_mode) || |
| 5078 | hdd_conn_is_connected( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5079 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)) || |
| 5080 | hdd_is_connecting( |
| 5081 | WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5082 | INIT_COMPLETION(adapter->disconnect_comp_var); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5083 | roam_profile = hdd_roam_profile(adapter); |
| 5084 | /* For NDI do not use roam_profile */ |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5085 | if (QDF_NDI_MODE == adapter->device_mode) |
| 5086 | qdf_ret_status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5087 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5088 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5089 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5090 | else if (roam_profile->BSSType == |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5091 | eCSR_BSS_TYPE_START_IBSS) |
| 5092 | qdf_ret_status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5093 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5094 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5095 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Abhinav Kumar | 19a7a40 | 2018-07-12 17:36:57 +0530 | [diff] [blame] | 5096 | else if (adapter->device_mode == QDF_STA_MODE) |
| 5097 | wlan_hdd_disconnect(adapter, |
| 5098 | eCSR_DISCONNECT_REASON_DEAUTH); |
| 5099 | else |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5100 | qdf_ret_status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5101 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5102 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5103 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5104 | /* success implies disconnect command got |
| 5105 | * queued up successfully |
| 5106 | */ |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5107 | if (qdf_ret_status == QDF_STATUS_SUCCESS && |
| 5108 | QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5109 | rc = wait_for_completion_timeout( |
| 5110 | &adapter->disconnect_comp_var, |
| 5111 | msecs_to_jiffies |
| 5112 | (WLAN_WAIT_TIME_DISCONNECT)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5113 | if (!rc) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5114 | hdd_warn("disconn_comp_var wait fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5115 | } |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5116 | if (qdf_ret_status != QDF_STATUS_SUCCESS) |
| 5117 | hdd_warn("failed to post disconnect"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5118 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5119 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5120 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5121 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 5122 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 5123 | } |
Wu Gao | aceec6c | 2017-08-30 16:08:21 +0800 | [diff] [blame] | 5124 | wlan_hdd_scan_abort(adapter); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5125 | |
Wu Gao | 4a1ec8c | 2018-07-23 19:18:40 +0800 | [diff] [blame] | 5126 | wlan_hdd_cleanup_actionframe(adapter); |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 5127 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 5128 | hdd_clear_fils_connection_info(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5129 | |
| 5130 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5131 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5132 | #endif |
| 5133 | |
| 5134 | hdd_deregister_tx_flow_control(adapter); |
| 5135 | |
| 5136 | #ifdef WLAN_NS_OFFLOAD |
| 5137 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5138 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5139 | #endif |
| 5140 | #endif |
| 5141 | |
Hanumanth Reddy Pothula | 0586014 | 2017-07-26 18:45:27 +0530 | [diff] [blame] | 5142 | if (adapter->device_mode == QDF_STA_MODE) |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 5143 | wlan_cfg80211_sched_scan_stop(hdd_ctx->pdev, |
Hanumanth Reddy Pothula | 0586014 | 2017-07-26 18:45:27 +0530 | [diff] [blame] | 5144 | adapter->dev); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5145 | |
| 5146 | if (wlan_hdd_try_disconnect(adapter)) { |
| 5147 | hdd_err("Error: Can't disconnect adapter"); |
| 5148 | return QDF_STATUS_E_FAILURE; |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 5149 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5150 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 5151 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5152 | break; |
| 5153 | |
Rajeev Kumar | 3b90620 | 2018-02-01 10:55:14 -0800 | [diff] [blame] | 5154 | case QDF_MONITOR_MODE: |
| 5155 | wlan_hdd_scan_abort(adapter); |
| 5156 | hdd_deregister_tx_flow_control(adapter); |
| 5157 | hdd_vdev_destroy(adapter); |
| 5158 | break; |
| 5159 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5160 | case QDF_SAP_MODE: |
Will Huang | 7049bae | 2018-08-13 17:25:02 +0800 | [diff] [blame] | 5161 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 5162 | cds_flush_delayed_work(&adapter->acs_pending_work); |
| 5163 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 5164 | } |
wadesong | f9b15ed | 2017-12-14 14:12:32 +0800 | [diff] [blame] | 5165 | wlan_hdd_scan_abort(adapter); |
Govind Singh | 1dab23b | 2017-08-12 13:31:00 +0530 | [diff] [blame] | 5166 | /* Flush IPA exception path packets */ |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 5167 | sap_config = &adapter->session.ap.sap_config; |
| 5168 | if (sap_config) |
| 5169 | wlansap_reset_sap_config_add_ie(sap_config, |
| 5170 | eUPDATE_IE_ALL); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 5171 | ucfg_ipa_flush(hdd_ctx->pdev); |
Liangwei Dong | ad89c76 | 2018-06-01 01:56:23 -0400 | [diff] [blame] | 5172 | if (!(flag & HDD_IN_CAC_WORK_TH_CONTEXT)) |
| 5173 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
Jeff Johnson | 46807cd | 2018-04-29 21:32:22 -0700 | [diff] [blame] | 5174 | /* fallthrough */ |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5175 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5176 | case QDF_P2P_GO_MODE: |
Krunal Soni | 2220839 | 2017-09-29 18:10:34 -0700 | [diff] [blame] | 5177 | cds_flush_work(&adapter->sap_stop_bss_work); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5178 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5179 | /* Any softap specific cleanup here... */ |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5180 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5181 | wlan_hdd_undo_acs(adapter); |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5182 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5183 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5184 | |
| 5185 | hdd_deregister_tx_flow_control(adapter); |
| 5186 | |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 5187 | hdd_destroy_acs_timer(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5188 | mutex_lock(&hdd_ctx->sap_lock); |
| 5189 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5190 | QDF_STATUS status; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5191 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5192 | |
| 5193 | /* Stop Bss. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5194 | status = wlansap_stop_bss( |
| 5195 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5196 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5197 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 5198 | struct hdd_hostapd_state *hostapd_state = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5199 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5200 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5201 | qdf_stop_bss_event); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5202 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 5203 | qdf_wait_for_event_completion( |
| 5204 | &hostapd_state->qdf_stop_bss_event, |
Vignesh Viswanathan | 865daaa | 2018-10-11 19:30:44 +0530 | [diff] [blame] | 5205 | SME_CMD_START_STOP_BSS_TIMEOUT); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5206 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5207 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5208 | hdd_err("failure waiting for wlansap_stop_bss %d", |
| 5209 | qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5210 | } |
| 5211 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5212 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5213 | } |
| 5214 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5215 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5216 | adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5217 | adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5218 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5219 | adapter->device_mode, |
| 5220 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5221 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 5222 | qdf_copy_macaddr(&updateIE.bssid, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5223 | &adapter->mac_addr); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5224 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5225 | updateIE.ieBufferlength = 0; |
| 5226 | updateIE.pAdditionIEBuffer = NULL; |
| 5227 | updateIE.append = false; |
| 5228 | updateIE.notify = false; |
| 5229 | /* Probe bcn reset */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5230 | if (sme_update_add_ie(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5231 | &updateIE, eUPDATE_IE_PROBE_BCN) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5232 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5233 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5234 | } |
| 5235 | /* Assoc resp reset */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5236 | if (sme_update_add_ie(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5237 | &updateIE, |
| 5238 | eUPDATE_IE_ASSOC_RESP) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5239 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5240 | hdd_err("Could not pass on ASSOC_RSP data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5241 | } |
| 5242 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 5243 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5244 | } |
Jiachao Wu | b1e1ddd | 2018-05-21 12:04:15 +0800 | [diff] [blame] | 5245 | clear_bit(SOFTAP_INIT_DONE, &adapter->event_flags); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5246 | qdf_mem_free(adapter->session.ap.beacon); |
| 5247 | adapter->session.ap.beacon = NULL; |
Jiachao Wu | b1e1ddd | 2018-05-21 12:04:15 +0800 | [diff] [blame] | 5248 | |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5249 | /* |
| 5250 | * If Do_Not_Break_Stream was enabled clear avoid channel list. |
| 5251 | */ |
Dustin Brown | 89fa06e | 2018-09-07 10:47:27 -0700 | [diff] [blame] | 5252 | if (policy_mgr_is_dnsc_set(adapter->vdev)) |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5253 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0); |
| 5254 | |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5255 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5256 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5257 | #endif |
| 5258 | |
| 5259 | #ifdef WLAN_NS_OFFLOAD |
| 5260 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5261 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5262 | #endif |
| 5263 | #endif |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5264 | |
| 5265 | hdd_vdev_destroy(adapter); |
| 5266 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5267 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5268 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5269 | case QDF_OCB_MODE: |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 5270 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5271 | (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX), |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 5272 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.staId[0]); |
Zhang Qian | 79d0d13 | 2018-02-05 13:40:16 +0800 | [diff] [blame] | 5273 | hdd_deregister_tx_flow_control(adapter); |
| 5274 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5275 | break; |
| 5276 | default: |
| 5277 | break; |
| 5278 | } |
| 5279 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 5280 | hdd_deregister_hl_netdev_fc_timer(adapter); |
| 5281 | |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5282 | if (adapter->scan_info.default_scan_ies) { |
| 5283 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 5284 | adapter->scan_info.default_scan_ies = NULL; |
| 5285 | } |
| 5286 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5287 | hdd_exit(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5288 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5289 | } |
| 5290 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5291 | /** |
| 5292 | * hdd_deinit_all_adapters - deinit all adapters |
| 5293 | * @hdd_ctx: HDD context |
| 5294 | * @rtnl_held: True if RTNL lock held |
| 5295 | * |
| 5296 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5297 | 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] | 5298 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5299 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5300 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5301 | hdd_enter(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5302 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5303 | hdd_for_each_adapter(hdd_ctx, adapter) |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5304 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5305 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5306 | hdd_exit(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5307 | } |
| 5308 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5309 | QDF_STATUS hdd_stop_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5310 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5311 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5312 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5313 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5314 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5315 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5316 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5317 | hdd_for_each_adapter(hdd_ctx, adapter) |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5318 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5319 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5320 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5321 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5322 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5323 | } |
| 5324 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5325 | static void hdd_reset_scan_operation(struct hdd_context *hdd_ctx, |
| 5326 | struct hdd_adapter *adapter) |
| 5327 | { |
| 5328 | switch (adapter->device_mode) { |
| 5329 | case QDF_STA_MODE: |
| 5330 | case QDF_P2P_CLIENT_MODE: |
| 5331 | case QDF_IBSS_MODE: |
| 5332 | case QDF_P2P_DEVICE_MODE: |
| 5333 | case QDF_NDI_MODE: |
| 5334 | wlan_hdd_scan_abort(adapter); |
| 5335 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5336 | if (adapter->device_mode == QDF_STA_MODE) |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 5337 | wlan_cfg80211_sched_scan_stop(hdd_ctx->pdev, |
| 5338 | adapter->dev); |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5339 | break; |
| 5340 | case QDF_P2P_GO_MODE: |
| 5341 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5342 | break; |
| 5343 | case QDF_SAP_MODE: |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5344 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5345 | wlan_hdd_undo_acs(adapter); |
| 5346 | break; |
| 5347 | default: |
| 5348 | break; |
| 5349 | } |
| 5350 | } |
| 5351 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5352 | QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5353 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5354 | struct hdd_adapter *adapter; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5355 | struct hdd_station_ctx *sta_ctx; |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5356 | struct qdf_mac_addr peerMacAddr; |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5357 | int sta_id; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 5358 | bool value; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5359 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5360 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5361 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5362 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5363 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5364 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 5365 | hdd_info("[SSR] reset adapter with device mode %s(%d)", |
| 5366 | hdd_device_mode_to_string(adapter->device_mode), |
| 5367 | adapter->device_mode); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5368 | |
| 5369 | if ((adapter->device_mode == QDF_STA_MODE) || |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5370 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5371 | /* Stop tdls timers */ |
Dustin Brown | 89fa06e | 2018-09-07 10:47:27 -0700 | [diff] [blame] | 5372 | hdd_notify_tdls_reset_adapter(adapter->vdev); |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5373 | adapter->session.station.hdd_reassoc_scenario = false; |
| 5374 | } |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 5375 | ucfg_mlme_get_sap_internal_restart(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 5376 | if (value && |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5377 | adapter->device_mode == QDF_SAP_MODE) { |
| 5378 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5379 | WLAN_STOP_ALL_NETIF_QUEUE, |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5380 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5381 | if (test_bit(SOFTAP_BSS_STARTED, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5382 | &adapter->event_flags)) |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5383 | hdd_sap_indicate_disconnect_for_sta(adapter); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5384 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
| 5385 | } else { |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5386 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5387 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5388 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5389 | } |
Nijun Gong | 104ccc7 | 2018-08-07 10:43:56 +0800 | [diff] [blame] | 5390 | /* |
| 5391 | * Clear fc flag if it was set before SSR to avoid TX queues |
| 5392 | * permanently stopped after SSR. |
| 5393 | * Here WLAN_START_ALL_NETIF_QUEUE will actually not start any |
| 5394 | * queue since it's blocked by reason WLAN_CONTROL_PATH. |
| 5395 | */ |
| 5396 | if (adapter->pause_map & (1 << WLAN_DATA_FLOW_CONTROL)) |
| 5397 | wlan_hdd_netif_queue_control(adapter, |
| 5398 | WLAN_START_ALL_NETIF_QUEUE, |
| 5399 | WLAN_DATA_FLOW_CONTROL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5400 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5401 | hdd_reset_scan_operation(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5402 | |
| 5403 | hdd_deinit_tx_rx(adapter); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5404 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5405 | adapter->device_mode, adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5406 | hdd_green_ap_start_state_mc(hdd_ctx, adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5407 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5408 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 5409 | hdd_wmm_adapter_close(adapter); |
| 5410 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 5411 | } |
| 5412 | |
Vignesh Viswanathan | 2eb1874 | 2017-09-08 11:18:59 +0530 | [diff] [blame] | 5413 | if (adapter->device_mode == QDF_STA_MODE) |
| 5414 | hdd_clear_fils_connection_info(adapter); |
| 5415 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5416 | if (adapter->device_mode == QDF_SAP_MODE) { |
Jingxiang Ge | ec11359 | 2018-08-09 15:40:39 +0800 | [diff] [blame] | 5417 | wlansap_cleanup_cac_timer( |
| 5418 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5419 | /* |
| 5420 | * If adapter is SAP, set session ID to invalid |
| 5421 | * since SAP session will be cleanup during SSR. |
| 5422 | */ |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 5423 | wlansap_set_invalid_session( |
| 5424 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5425 | } |
| 5426 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5427 | /* Delete connection peers if any to avoid peer object leaks */ |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5428 | if (adapter->device_mode == QDF_STA_MODE || |
| 5429 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5430 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5431 | qdf_copy_macaddr(&peerMacAddr, |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5432 | &sta_ctx->conn_info.bssId); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5433 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5434 | } else if (adapter->device_mode == QDF_P2P_GO_MODE) { |
Wu Gao | 6b81fc5 | 2018-05-24 19:27:27 +0800 | [diff] [blame] | 5435 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5436 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) { |
| 5437 | if (adapter->sta_info[sta_id].in_use) { |
| 5438 | hdd_debug("[SSR] deregister STA with ID %d", |
| 5439 | sta_id); |
| 5440 | hdd_softap_deregister_sta(adapter, |
| 5441 | sta_id); |
| 5442 | adapter->sta_info[sta_id].in_use = 0; |
| 5443 | } |
| 5444 | } |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5445 | } |
| 5446 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5447 | hdd_nud_ignore_tracking(adapter, true); |
Alok Kumar | 016a1ac | 2018-09-16 09:55:50 +0530 | [diff] [blame] | 5448 | hdd_nud_reset_tracking(adapter); |
| 5449 | hdd_nud_flush_work(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5450 | hdd_set_disconnect_status(adapter, false); |
| 5451 | |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5452 | hdd_softap_deinit_tx_rx(adapter); |
Tiger Yu | 8c38770 | 2018-07-06 16:56:42 +0800 | [diff] [blame] | 5453 | hdd_deregister_tx_flow_control(adapter); |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5454 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 5455 | /* Destroy vdev which will be recreated during reinit. */ |
| 5456 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5457 | } |
| 5458 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5459 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5460 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5461 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5462 | } |
| 5463 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5464 | bool hdd_check_for_opened_interfaces(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5465 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5466 | struct hdd_adapter *adapter; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5467 | bool close_modules = true; |
| 5468 | |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5469 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 5470 | hdd_info("FTM mode, don't close the module"); |
| 5471 | return false; |
| 5472 | } |
| 5473 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5474 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5475 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags) || |
| 5476 | test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5477 | hdd_debug("Still other ifaces are up cannot close modules"); |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5478 | close_modules = false; |
| 5479 | break; |
| 5480 | } |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5481 | } |
| 5482 | |
| 5483 | return close_modules; |
| 5484 | } |
| 5485 | |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 5486 | bool hdd_is_interface_up(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5487 | { |
| 5488 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 5489 | return true; |
| 5490 | else |
| 5491 | return false; |
| 5492 | } |
| 5493 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5494 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
bings | bdcd4a2 | 2017-06-20 09:27:00 +0800 | [diff] [blame] | 5495 | && !defined(WITH_BACKPORTS) && !defined(IEEE80211_PRIVACY) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5496 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5497 | struct ieee80211_channel *channel, |
| 5498 | const u8 *bssid, const u8 *ssid, |
| 5499 | size_t ssid_len) |
| 5500 | { |
| 5501 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5502 | ssid, ssid_len, |
| 5503 | WLAN_CAPABILITY_ESS, |
| 5504 | WLAN_CAPABILITY_ESS); |
| 5505 | } |
| 5506 | #else |
| 5507 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5508 | struct ieee80211_channel *channel, |
| 5509 | const u8 *bssid, const u8 *ssid, |
| 5510 | size_t ssid_len) |
| 5511 | { |
| 5512 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5513 | ssid, ssid_len, |
| 5514 | IEEE80211_BSS_TYPE_ESS, |
| 5515 | IEEE80211_PRIVACY_ANY); |
| 5516 | } |
| 5517 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5518 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5519 | #if defined CFG80211_CONNECT_BSS || \ |
| 5520 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5521 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5522 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5523 | /** |
| 5524 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 5525 | * @timeout_reason: reason for connect timeout |
| 5526 | * |
| 5527 | * This function is used to convert host timeout |
| 5528 | * reason enum to kernel specific enum. |
| 5529 | * |
| 5530 | * Return: nl timeout enum |
| 5531 | */ |
| 5532 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 5533 | tSirResultCodes timeout_reason) |
| 5534 | { |
| 5535 | switch (timeout_reason) { |
| 5536 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 5537 | return NL80211_TIMEOUT_SCAN; |
| 5538 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 5539 | return NL80211_TIMEOUT_AUTH; |
| 5540 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 5541 | return NL80211_TIMEOUT_ASSOC; |
| 5542 | default: |
| 5543 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 5544 | } |
| 5545 | } |
| 5546 | |
| 5547 | /** |
| 5548 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 5549 | * @dev: network device |
| 5550 | * @bssid: bssid to which we want to associate |
| 5551 | * @timeout_reason: reason for connect timeout |
| 5552 | * |
| 5553 | * This API is used to send connection timeout reason to supplicant |
| 5554 | * |
| 5555 | * Return: void |
| 5556 | */ |
| 5557 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5558 | const u8 *bssid, |
| 5559 | tSirResultCodes timeout_reason) |
| 5560 | { |
| 5561 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5562 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5563 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5564 | |
| 5565 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 5566 | nl_timeout_reason); |
| 5567 | } |
| 5568 | |
| 5569 | /** |
| 5570 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 5571 | * @dev: network device |
| 5572 | * @bssid: bssid to which we want to associate |
| 5573 | * @req_ie: Request Information Element |
| 5574 | * @req_ie_len: len of the req IE |
| 5575 | * @resp_ie: Response IE |
| 5576 | * @resp_ie_len: len of ht response IE |
| 5577 | * @status: status |
| 5578 | * @gfp: Kernel Flag |
| 5579 | * @timeout_reason: reason for connect timeout |
| 5580 | * |
| 5581 | * Return: void |
| 5582 | */ |
| 5583 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5584 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5585 | size_t req_ie_len, const u8 *resp_ie, |
| 5586 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5587 | tSirResultCodes timeout_reason) |
| 5588 | { |
| 5589 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5590 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5591 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5592 | |
| 5593 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5594 | resp_ie, resp_ie_len, status, gfp, |
| 5595 | nl_timeout_reason); |
| 5596 | } |
| 5597 | #else |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5598 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5599 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5600 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5601 | const u8 *bssid, |
| 5602 | tSirResultCodes timeout_reason) |
| 5603 | { |
| 5604 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 5605 | } |
| 5606 | #endif |
| 5607 | |
| 5608 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5609 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5610 | size_t req_ie_len, const u8 *resp_ie, |
| 5611 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5612 | tSirResultCodes timeout_reason) |
| 5613 | { |
| 5614 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5615 | resp_ie, resp_ie_len, status, gfp); |
| 5616 | } |
| 5617 | #endif |
| 5618 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5619 | /** |
| 5620 | * hdd_connect_bss() - API to send connection status to supplicant |
| 5621 | * @dev: network device |
| 5622 | * @bssid: bssid to which we want to associate |
| 5623 | * @req_ie: Request Information Element |
| 5624 | * @req_ie_len: len of the req IE |
| 5625 | * @resp_ie: Response IE |
| 5626 | * @resp_ie_len: len of ht response IE |
| 5627 | * @status: status |
| 5628 | * @gfp: Kernel Flag |
| 5629 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5630 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5631 | * |
| 5632 | * The API is a wrapper to send connection status to supplicant |
| 5633 | * |
| 5634 | * Return: Void |
| 5635 | */ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5636 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5637 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5638 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5639 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5640 | size_t req_ie_len, const u8 *resp_ie, |
| 5641 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5642 | bool connect_timeout, |
| 5643 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5644 | { |
| 5645 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5646 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5647 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5648 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5649 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5650 | } |
| 5651 | #else |
| 5652 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5653 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5654 | size_t req_ie_len, const u8 *resp_ie, |
| 5655 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5656 | bool connect_timeout, |
| 5657 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5658 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5659 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5660 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5661 | } |
| 5662 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5663 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5664 | #if defined(WLAN_FEATURE_FILS_SK) |
| 5665 | #if defined(CFG80211_CONNECT_DONE) || \ |
| 5666 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
| 5667 | #if defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 5668 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5669 | /** |
| 5670 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 5671 | * @fils_params: connect response to supplicant |
| 5672 | * @fils_kek: FILS kek |
| 5673 | * @fils_kek_len: FILS kek length |
| 5674 | * @pmk: FILS PMK |
| 5675 | * @pmk_len: FILS PMK length |
| 5676 | * @pmkid: PMKID |
| 5677 | * @fils_seq_num: FILS Seq number |
| 5678 | * |
| 5679 | * Return: None |
| 5680 | */ |
| 5681 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5682 | *fils_params, const uint8_t *fils_kek, |
| 5683 | size_t fils_kek_len, const uint8_t *pmk, |
| 5684 | size_t pmk_len, const uint8_t *pmkid, |
| 5685 | uint16_t fils_seq_num) |
| 5686 | { |
| 5687 | /* Increament seq number to be used for next FILS */ |
| 5688 | fils_params->fils_erp_next_seq_num = fils_seq_num + 1; |
| 5689 | fils_params->update_erp_next_seq_num = true; |
| 5690 | fils_params->fils_kek = fils_kek; |
| 5691 | fils_params->fils_kek_len = fils_kek_len; |
| 5692 | fils_params->pmk = pmk; |
| 5693 | fils_params->pmk_len = pmk_len; |
| 5694 | fils_params->pmkid = pmkid; |
| 5695 | } |
| 5696 | #else |
| 5697 | static inline void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5698 | *fils_params, const uint8_t |
| 5699 | *fils_kek, size_t fils_kek_len, |
| 5700 | const uint8_t *pmk, size_t pmk_len, |
| 5701 | const uint8_t *pmkid, |
| 5702 | uint16_t fils_seq_num) |
| 5703 | { } |
| 5704 | #endif |
| 5705 | |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5706 | void hdd_update_hlp_info(struct net_device *dev, |
| 5707 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5708 | { |
| 5709 | struct sk_buff *skb; |
| 5710 | uint16_t skb_len; |
| 5711 | struct llc_snap_hdr_t *llc_hdr; |
| 5712 | QDF_STATUS status; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5713 | uint8_t *hlp_data; |
| 5714 | uint16_t hlp_data_len; |
| 5715 | struct fils_join_rsp_params *roam_fils_params |
| 5716 | = roam_info->fils_join_rsp; |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5717 | struct hdd_adapter *padapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5718 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5719 | if (!roam_fils_params) { |
| 5720 | hdd_err("FILS Roam Param NULL"); |
| 5721 | return; |
| 5722 | } |
| 5723 | |
Srinivas Girigowda | 3cc8e91 | 2017-11-28 18:11:57 -0800 | [diff] [blame] | 5724 | if (!roam_fils_params->hlp_data_len) { |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5725 | hdd_err("FILS HLP Data NULL, len %d", |
| 5726 | roam_fils_params->hlp_data_len); |
| 5727 | return; |
| 5728 | } |
| 5729 | |
| 5730 | hlp_data = roam_fils_params->hlp_data; |
| 5731 | hlp_data_len = roam_fils_params->hlp_data_len; |
| 5732 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5733 | /* Calculate skb length */ |
| 5734 | skb_len = (2 * ETH_ALEN) + hlp_data_len; |
| 5735 | skb = qdf_nbuf_alloc(NULL, skb_len, 0, 4, false); |
| 5736 | if (skb == NULL) { |
| 5737 | hdd_err("HLP packet nbuf alloc fails"); |
| 5738 | return; |
| 5739 | } |
| 5740 | |
| 5741 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->dst_mac.bytes, |
| 5742 | QDF_MAC_ADDR_SIZE); |
| 5743 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->src_mac.bytes, |
| 5744 | QDF_MAC_ADDR_SIZE); |
| 5745 | |
| 5746 | llc_hdr = (struct llc_snap_hdr_t *) hlp_data; |
| 5747 | if (IS_SNAP(llc_hdr)) { |
| 5748 | hlp_data += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5749 | hlp_data_len += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5750 | } |
| 5751 | |
| 5752 | qdf_mem_copy(skb_put(skb, hlp_data_len), hlp_data, hlp_data_len); |
| 5753 | |
| 5754 | /* |
| 5755 | * This HLP packet is formed from HLP info encapsulated |
| 5756 | * in assoc response frame which is AEAD encrypted. |
| 5757 | * Hence, this checksum validation can be set unnecessary. |
| 5758 | * i.e. network layer need not worry about checksum. |
| 5759 | */ |
| 5760 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 5761 | |
| 5762 | status = hdd_rx_packet_cbk(padapter, skb); |
| 5763 | if (QDF_IS_STATUS_ERROR(status)) { |
| 5764 | hdd_err("Sending HLP packet fails"); |
| 5765 | return; |
| 5766 | } |
| 5767 | hdd_debug("send HLP packet to netif successfully"); |
| 5768 | } |
| 5769 | |
| 5770 | /** |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5771 | * hdd_connect_done() - Wrapper API to call cfg80211_connect_done |
| 5772 | * @dev: network device |
| 5773 | * @bssid: bssid to which we want to associate |
| 5774 | * @bss: cfg80211 bss info |
| 5775 | * @roam_info: information about connected bss |
| 5776 | * @req_ie: Request Information Element |
| 5777 | * @req_ie_len: len of the req IE |
| 5778 | * @resp_ie: Response IE |
| 5779 | * @resp_ie_len: len of ht response IE |
| 5780 | * @status: status |
| 5781 | * @gfp: allocation flags |
| 5782 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5783 | * @timeout_reason: reason for connect timeout |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5784 | * |
| 5785 | * This API is used as wrapper to send FILS key/sequence number |
| 5786 | * params etc. to supplicant in case of FILS connection |
| 5787 | * |
| 5788 | * Return: None |
| 5789 | */ |
| 5790 | static void hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5791 | struct cfg80211_bss *bss, |
| 5792 | struct csr_roam_info *roam_info, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5793 | const u8 *req_ie, size_t req_ie_len, |
| 5794 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5795 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5796 | tSirResultCodes timeout_reason) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5797 | { |
| 5798 | struct cfg80211_connect_resp_params fils_params; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5799 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5800 | struct fils_join_rsp_params *roam_fils_params = |
| 5801 | roam_info->fils_join_rsp; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5802 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5803 | qdf_mem_zero(&fils_params, sizeof(fils_params)); |
| 5804 | |
| 5805 | if (!roam_fils_params) { |
| 5806 | fils_params.status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 5807 | } else { |
| 5808 | fils_params.status = status; |
| 5809 | fils_params.bssid = bssid; |
Srinivas Girigowda | e975f53 | 2018-01-05 14:03:05 -0800 | [diff] [blame] | 5810 | fils_params.timeout_reason = |
| 5811 | hdd_convert_timeout_reason(timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5812 | fils_params.req_ie = req_ie; |
| 5813 | fils_params.req_ie_len = req_ie_len; |
| 5814 | fils_params.resp_ie = resp_ie; |
| 5815 | fils_params.resp_ie_len = resp_ie_len; |
| 5816 | fils_params.bss = bss; |
| 5817 | hdd_populate_fils_params(&fils_params, roam_fils_params->kek, |
| 5818 | roam_fils_params->kek_len, |
| 5819 | roam_fils_params->fils_pmk, |
| 5820 | roam_fils_params->fils_pmk_len, |
| 5821 | roam_fils_params->fils_pmkid, |
| 5822 | roam_info->fils_seq_num); |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 5823 | hdd_save_gtk_params(adapter, roam_info, false); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5824 | } |
| 5825 | hdd_debug("FILS indicate connect status %d seq no %d", |
| 5826 | fils_params.status, |
| 5827 | fils_params.fils_erp_next_seq_num); |
| 5828 | |
| 5829 | cfg80211_connect_done(dev, &fils_params, gfp); |
| 5830 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5831 | if (roam_fils_params && roam_fils_params->hlp_data_len) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5832 | hdd_update_hlp_info(dev, roam_info); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5833 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5834 | /* Clear all the FILS key info */ |
| 5835 | if (roam_fils_params && roam_fils_params->fils_pmk) |
| 5836 | qdf_mem_free(roam_fils_params->fils_pmk); |
| 5837 | if (roam_fils_params) |
| 5838 | qdf_mem_free(roam_fils_params); |
| 5839 | roam_info->fils_join_rsp = NULL; |
| 5840 | } |
| 5841 | #else |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5842 | static inline void |
| 5843 | hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5844 | struct cfg80211_bss *bss, struct csr_roam_info *roam_info, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5845 | const u8 *req_ie, size_t req_ie_len, |
| 5846 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
| 5847 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5848 | tSirResultCodes timeout_reason) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5849 | { } |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5850 | #endif |
| 5851 | #endif |
| 5852 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5853 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 5854 | (defined(CFG80211_CONNECT_DONE) || \ |
| 5855 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5856 | /** |
| 5857 | * hdd_fils_update_connect_results() - API to send fils connection status to |
| 5858 | * supplicant. |
| 5859 | * @dev: network device |
| 5860 | * @bssid: bssid to which we want to associate |
| 5861 | * @bss: cfg80211 bss info |
| 5862 | * @roam_info: information about connected bss |
| 5863 | * @req_ie: Request Information Element |
| 5864 | * @req_ie_len: len of the req IE |
| 5865 | * @resp_ie: Response IE |
| 5866 | * @resp_ie_len: len of ht response IE |
| 5867 | * @status: status |
| 5868 | * @gfp: allocation flags |
| 5869 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5870 | * @timeout_reason: reason for connect timeout |
| 5871 | * |
| 5872 | * The API is a wrapper to send connection status to supplicant |
| 5873 | * |
| 5874 | * Return: 0 if success else failure |
| 5875 | */ |
| 5876 | static int hdd_fils_update_connect_results(struct net_device *dev, |
| 5877 | const u8 *bssid, |
| 5878 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5879 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5880 | size_t req_ie_len, const u8 *resp_ie, |
| 5881 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5882 | bool connect_timeout, |
| 5883 | tSirResultCodes timeout_reason) |
| 5884 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5885 | hdd_enter(); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5886 | if (!roam_info || !roam_info->is_fils_connection) |
| 5887 | return -EINVAL; |
| 5888 | |
| 5889 | hdd_connect_done(dev, bssid, bss, roam_info, req_ie, req_ie_len, |
| 5890 | resp_ie, resp_ie_len, status, gfp, connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5891 | timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5892 | return 0; |
| 5893 | } |
| 5894 | #else |
| 5895 | static inline int hdd_fils_update_connect_results(struct net_device *dev, |
| 5896 | const u8 *bssid, |
| 5897 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5898 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5899 | size_t req_ie_len, const u8 *resp_ie, |
| 5900 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5901 | bool connect_timeout, |
| 5902 | tSirResultCodes timeout_reason) |
| 5903 | { |
| 5904 | return -EINVAL; |
| 5905 | } |
| 5906 | #endif |
| 5907 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5908 | /** |
| 5909 | * hdd_connect_result() - API to send connection status to supplicant |
| 5910 | * @dev: network device |
| 5911 | * @bssid: bssid to which we want to associate |
| 5912 | * @roam_info: information about connected bss |
| 5913 | * @req_ie: Request Information Element |
| 5914 | * @req_ie_len: len of the req IE |
| 5915 | * @resp_ie: Response IE |
| 5916 | * @resp_ie_len: len of ht response IE |
| 5917 | * @status: status |
| 5918 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5919 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5920 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5921 | * |
| 5922 | * The API is a wrapper to send connection status to supplicant |
| 5923 | * and allow runtime suspend |
| 5924 | * |
| 5925 | * Return: Void |
| 5926 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5927 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5928 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5929 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5930 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5931 | bool connect_timeout, |
| 5932 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5933 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5934 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5935 | struct cfg80211_bss *bss = NULL; |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 5936 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5937 | |
| 5938 | if (WLAN_STATUS_SUCCESS == status) { |
| 5939 | struct ieee80211_channel *chan; |
| 5940 | int freq; |
| 5941 | int chan_no = roam_info->pBssDesc->channelId; |
| 5942 | |
| 5943 | if (chan_no <= 14) |
| 5944 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5945 | HDD_NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5946 | else |
| 5947 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5948 | HDD_NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5949 | |
| 5950 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
| 5951 | bss = hdd_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
| 5952 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 5953 | roam_info->u.pConnectedProfile->SSID.length); |
| 5954 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5955 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5956 | if (hdd_fils_update_connect_results(dev, bssid, bss, |
| 5957 | roam_info, req_ie, req_ie_len, resp_ie, |
| 5958 | resp_ie_len, status, gfp, connect_timeout, |
| 5959 | timeout_reason) != 0) { |
| 5960 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 5961 | req_ie_len, resp_ie, resp_ie_len, |
| 5962 | status, gfp, connect_timeout, timeout_reason); |
| 5963 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5964 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5965 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5966 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5967 | } |
| 5968 | #else |
| 5969 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5970 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5971 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5972 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5973 | bool connect_timeout, |
| 5974 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5975 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5976 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 5977 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5978 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5979 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 5980 | resp_ie, resp_ie_len, status, gfp); |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 5981 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5982 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5983 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5984 | } |
| 5985 | #endif |
| 5986 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 5987 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 5988 | int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan, |
| 5989 | uint32_t bandwidth) |
| 5990 | { |
| 5991 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 5992 | struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 5993 | struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info; |
| 5994 | QDF_STATUS status; |
Jeff Johnson | 43837af | 2018-10-17 12:44:05 -0700 | [diff] [blame^] | 5995 | mac_handle_t mac_handle = hdd_ctx->mac_handle; |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 5996 | struct qdf_mac_addr bssid; |
| 5997 | struct csr_roam_profile roam_profile; |
| 5998 | struct ch_params ch_params; |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 5999 | eConnectionState connstate; |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6000 | |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6001 | if (hdd_get_conparam() != QDF_GLOBAL_MONITOR_MODE && |
| 6002 | adapter->device_mode != QDF_STA_MODE) { |
| 6003 | 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] | 6004 | return -EINVAL; |
| 6005 | } |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6006 | if (adapter->device_mode == QDF_STA_MODE && |
| 6007 | hdd_ctx->config->enable_change_channel_bandwidth) { |
| 6008 | connstate = sta_ctx->conn_info.connState; |
| 6009 | if (eConnectionState_Associated == connstate || |
| 6010 | eConnectionState_Connecting == connstate) { |
| 6011 | return -EINVAL; |
| 6012 | } |
| 6013 | } |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6014 | |
Visweswara Tanuku | 006313a | 2018-04-12 12:26:34 +0530 | [diff] [blame] | 6015 | /* Validate Channel */ |
| 6016 | if (!WLAN_REG_IS_24GHZ_CH(chan) && !WLAN_REG_IS_5GHZ_CH(chan)) { |
| 6017 | hdd_err("Channel %d Not supported", chan); |
| 6018 | return -EINVAL; |
| 6019 | } |
| 6020 | |
| 6021 | if (WLAN_REG_IS_24GHZ_CH(chan)) { |
| 6022 | if (bandwidth == CH_WIDTH_80MHZ) { |
| 6023 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 6024 | return -EINVAL; |
| 6025 | } |
| 6026 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 14) && |
| 6027 | (bandwidth != CH_WIDTH_MAX)) { |
| 6028 | hdd_err("Only BW20 possible on channel 14"); |
| 6029 | return -EINVAL; |
| 6030 | } |
| 6031 | } |
| 6032 | |
| 6033 | if (WLAN_REG_IS_5GHZ_CH(chan)) { |
| 6034 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 165) && |
| 6035 | (bandwidth != CH_WIDTH_MAX)) { |
| 6036 | hdd_err("Only BW20 possible on channel 165"); |
| 6037 | return -EINVAL; |
| 6038 | } |
| 6039 | } |
| 6040 | |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6041 | hdd_debug("Set monitor mode Channel %d", chan); |
| 6042 | qdf_mem_zero(&roam_profile, sizeof(roam_profile)); |
| 6043 | roam_profile.ChannelInfo.ChannelList = &ch_info->channel; |
| 6044 | roam_profile.ChannelInfo.numOfChannels = 1; |
| 6045 | roam_profile.phyMode = ch_info->phy_mode; |
| 6046 | roam_profile.ch_params.ch_width = bandwidth; |
| 6047 | hdd_select_cbmode(adapter, chan, &roam_profile.ch_params); |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6048 | if (hdd_ctx->config->enable_change_channel_bandwidth && |
Jeff Johnson | 43837af | 2018-10-17 12:44:05 -0700 | [diff] [blame^] | 6049 | (!sme_find_session_by_bssid(mac_handle, adapter->mac_addr.bytes))) { |
| 6050 | status = sme_create_mon_session(mac_handle, |
Rajeev Kumar Sirasanagandla | e3b5991 | 2018-08-24 15:53:31 +0530 | [diff] [blame] | 6051 | adapter->mac_addr.bytes, |
| 6052 | adapter->session_id); |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6053 | if (status != QDF_STATUS_SUCCESS) { |
| 6054 | hdd_err("Status: %d Failed to create session.", |
| 6055 | status); |
| 6056 | return qdf_status_to_os_return(status); |
| 6057 | } |
| 6058 | } |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6059 | qdf_mem_copy(bssid.bytes, adapter->mac_addr.bytes, |
| 6060 | QDF_MAC_ADDR_SIZE); |
| 6061 | |
| 6062 | ch_params.ch_width = bandwidth; |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 6063 | wlan_reg_set_channel_params(hdd_ctx->pdev, chan, 0, &ch_params); |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6064 | if (ch_params.ch_width == CH_WIDTH_INVALID) { |
| 6065 | hdd_err("Invalid capture channel or bandwidth for a country"); |
| 6066 | return -EINVAL; |
| 6067 | } |
| 6068 | if (wlan_hdd_change_hw_mode_for_given_chnl(adapter, chan, |
| 6069 | POLICY_MGR_UPDATE_REASON_SET_OPER_CHAN)) { |
| 6070 | hdd_err("Failed to change hw mode"); |
| 6071 | return -EINVAL; |
| 6072 | } |
| 6073 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 6074 | status = sme_roam_channel_change_req(hdd_ctx->mac_handle, |
| 6075 | bssid, &ch_params, |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6076 | &roam_profile); |
| 6077 | if (status) { |
| 6078 | hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode", |
| 6079 | status); |
| 6080 | } |
| 6081 | |
| 6082 | adapter->mon_chan = chan; |
| 6083 | adapter->mon_bandwidth = bandwidth; |
| 6084 | return qdf_status_to_os_return(status); |
| 6085 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 6086 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6087 | |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6088 | #ifdef MSM_PLATFORM |
| 6089 | /** |
| 6090 | * hdd_stop_p2p_go() - call cfg80211 API to stop P2P GO |
| 6091 | * @adapter: pointer to adapter |
| 6092 | * |
| 6093 | * This function calls cfg80211 API to stop P2P GO |
| 6094 | * |
| 6095 | * Return: None |
| 6096 | */ |
| 6097 | static void hdd_stop_p2p_go(struct hdd_adapter *adapter) |
| 6098 | { |
| 6099 | hdd_debug("[SSR] send stop ap to supplicant"); |
| 6100 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 6101 | } |
| 6102 | |
| 6103 | static inline void hdd_delete_sta(struct hdd_adapter *adapter) |
| 6104 | { |
| 6105 | } |
| 6106 | #else |
| 6107 | static inline void hdd_stop_p2p_go(struct hdd_adapter *adapter) |
| 6108 | { |
| 6109 | } |
| 6110 | |
| 6111 | /** |
| 6112 | * hdd_delete_sta() - call cfg80211 API to delete STA |
| 6113 | * @adapter: pointer to adapter |
| 6114 | * |
| 6115 | * This function calls cfg80211 API to delete STA |
| 6116 | * |
| 6117 | * Return: None |
| 6118 | */ |
| 6119 | static void hdd_delete_sta(struct hdd_adapter *adapter) |
| 6120 | { |
| 6121 | struct qdf_mac_addr bcast_mac = QDF_MAC_ADDR_BCAST_INIT; |
| 6122 | |
| 6123 | hdd_debug("[SSR] send restart supplicant"); |
| 6124 | /* event supplicant to restart */ |
| 6125 | cfg80211_del_sta(adapter->dev, |
| 6126 | (const u8 *)&bcast_mac.bytes[0], |
| 6127 | GFP_KERNEL); |
| 6128 | } |
| 6129 | #endif |
| 6130 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6131 | QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6132 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6133 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6134 | eConnectionState connState; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 6135 | bool value; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6136 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6137 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6138 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6139 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6140 | if (!hdd_is_interface_up(adapter)) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6141 | continue; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6142 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 6143 | hdd_debug("[SSR] start adapter with device mode %s(%d)", |
| 6144 | hdd_device_mode_to_string(adapter->device_mode), |
| 6145 | adapter->device_mode); |
| 6146 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6147 | hdd_wmm_init(adapter); |
| 6148 | |
| 6149 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6150 | case QDF_STA_MODE: |
| 6151 | case QDF_P2P_CLIENT_MODE: |
| 6152 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6153 | |
| 6154 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 6155 | ->conn_info.connState; |
| 6156 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6157 | hdd_start_station_adapter(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6158 | /* Open the gates for HDD to receive Wext commands */ |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 6159 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6160 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6161 | /* Indicate disconnect event to supplicant |
| 6162 | * if associated previously |
| 6163 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6164 | if (eConnectionState_Associated == connState || |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 6165 | eConnectionState_IbssConnected == connState || |
| 6166 | eConnectionState_NotConnected == connState || |
| 6167 | eConnectionState_IbssDisconnected == connState || |
| 6168 | eConnectionState_Disconnecting == connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6169 | union iwreq_data wrqu; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6170 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6171 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 6172 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 6173 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 6174 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 6175 | &wrqu, NULL); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 6176 | adapter->session.station. |
Jeff Johnson | 690fe95 | 2017-10-25 11:48:39 -0700 | [diff] [blame] | 6177 | hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6178 | |
| 6179 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 6180 | wlan_hdd_cfg80211_indicate_disconnect( |
| 6181 | adapter->dev, false, |
| 6182 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6183 | } else if (eConnectionState_Connecting == connState) { |
| 6184 | /* |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6185 | * Indicate connect failure to supplicant if we |
| 6186 | * were in the process of connecting |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6187 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6188 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6189 | NULL, 0, NULL, 0, |
| 6190 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6191 | GFP_KERNEL, false, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6192 | } |
| 6193 | |
| 6194 | hdd_register_tx_flow_control(adapter, |
| 6195 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 6196 | hdd_tx_resume_cb, |
| 6197 | hdd_tx_flow_control_is_pause); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6198 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 6199 | hdd_lpass_notify_start(hdd_ctx, adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6200 | hdd_nud_ignore_tracking(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6201 | break; |
| 6202 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6203 | case QDF_SAP_MODE: |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 6204 | ucfg_mlme_get_sap_internal_restart(hdd_ctx->psoc, |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 6205 | &value); |
| 6206 | if (value) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6207 | hdd_start_ap_adapter(adapter); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 6208 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6209 | break; |
| 6210 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6211 | case QDF_P2P_GO_MODE: |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6212 | hdd_delete_sta(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6213 | break; |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6214 | case QDF_MONITOR_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6215 | hdd_start_station_adapter(adapter); |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6216 | hdd_set_mon_rx_cb(adapter->dev); |
| 6217 | wlan_hdd_set_mon_chan(adapter, adapter->mon_chan, |
| 6218 | adapter->mon_bandwidth); |
| 6219 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6220 | default: |
| 6221 | break; |
| 6222 | } |
Krunal Soni | 9c2ee03 | 2017-07-18 13:49:54 -0700 | [diff] [blame] | 6223 | /* |
| 6224 | * Action frame registered in one adapter which will |
| 6225 | * applicable to all interfaces |
| 6226 | */ |
| 6227 | wlan_hdd_cfg80211_register_frames(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6228 | } |
| 6229 | |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6230 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6231 | if (!hdd_is_interface_up(adapter)) |
| 6232 | continue; |
| 6233 | |
| 6234 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
| 6235 | hdd_stop_p2p_go(adapter); |
| 6236 | } |
| 6237 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6238 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6239 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6240 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6241 | } |
| 6242 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6243 | QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6244 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6245 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6246 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6247 | qdf_list_node_t *node; |
| 6248 | |
| 6249 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6250 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6251 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6252 | status = qdf_list_peek_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6253 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6254 | |
| 6255 | if (QDF_IS_STATUS_ERROR(status)) |
| 6256 | return status; |
| 6257 | |
| 6258 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6259 | |
| 6260 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6261 | } |
| 6262 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6263 | QDF_STATUS hdd_get_next_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6264 | struct hdd_adapter *current_adapter, |
| 6265 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6266 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6267 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6268 | qdf_list_node_t *node; |
| 6269 | |
| 6270 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6271 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6272 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6273 | status = qdf_list_peek_next(&hdd_ctx->hdd_adapters, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6274 | ¤t_adapter->node, |
| 6275 | &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6276 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6277 | |
| 6278 | if (QDF_IS_STATUS_ERROR(status)) |
| 6279 | return status; |
| 6280 | |
| 6281 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6282 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6283 | return status; |
| 6284 | } |
| 6285 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6286 | QDF_STATUS hdd_remove_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6287 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6288 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6289 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6290 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6291 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6292 | status = qdf_list_remove_node(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6293 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6294 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6295 | return status; |
| 6296 | } |
| 6297 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6298 | QDF_STATUS hdd_remove_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6299 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6300 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6301 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6302 | qdf_list_node_t *node; |
| 6303 | |
| 6304 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6305 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6306 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6307 | status = qdf_list_remove_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6308 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6309 | |
| 6310 | if (QDF_IS_STATUS_ERROR(status)) |
| 6311 | return status; |
| 6312 | |
| 6313 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6314 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6315 | return status; |
| 6316 | } |
| 6317 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6318 | QDF_STATUS hdd_add_adapter_back(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6319 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6320 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6321 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6322 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6323 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6324 | status = qdf_list_insert_back(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6325 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6326 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6327 | return status; |
| 6328 | } |
| 6329 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6330 | QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6331 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6332 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6333 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6334 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6335 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6336 | status = qdf_list_insert_front(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6337 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6338 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6339 | return status; |
| 6340 | } |
| 6341 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6342 | 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] | 6343 | tSirMacAddr macAddr) |
| 6344 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6345 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6346 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6347 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6348 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 6349 | macAddr, sizeof(tSirMacAddr))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6350 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6351 | } |
| 6352 | |
| 6353 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6354 | } |
| 6355 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6356 | 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] | 6357 | uint32_t vdev_id) |
| 6358 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6359 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6360 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6361 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6362 | if (adapter->session_id == vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6363 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6364 | } |
| 6365 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6366 | return NULL; |
| 6367 | } |
| 6368 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6369 | /** |
| 6370 | * hdd_get_adapter_by_sme_session_id() - Return adapter with |
| 6371 | * the sessionid |
| 6372 | * @hdd_ctx: hdd context. |
| 6373 | * @sme_session_id: sme session is for the adapter to get. |
| 6374 | * |
| 6375 | * This function is used to get the adapter with provided session id |
| 6376 | * |
| 6377 | * Return: adapter pointer if found |
| 6378 | * |
| 6379 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 6380 | struct hdd_adapter * |
| 6381 | hdd_get_adapter_by_sme_session_id(struct hdd_context *hdd_ctx, |
| 6382 | uint32_t sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6383 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6384 | struct hdd_adapter *adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6385 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6386 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6387 | if (adapter->session_id == sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6388 | return adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6389 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6390 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6391 | return NULL; |
| 6392 | } |
| 6393 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6394 | 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] | 6395 | const char *iface_name) |
| 6396 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6397 | struct hdd_adapter *adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6398 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6399 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6400 | if (!qdf_str_cmp(adapter->dev->name, iface_name)) |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6401 | return adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6402 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6403 | |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6404 | return NULL; |
| 6405 | } |
| 6406 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6407 | /** |
| 6408 | * hdd_get_adapter() - to get adapter matching the mode |
| 6409 | * @hdd_ctx: hdd context |
| 6410 | * @mode: adapter mode |
| 6411 | * |
| 6412 | * This routine will return the pointer to adapter matching |
| 6413 | * with the passed mode. |
| 6414 | * |
| 6415 | * Return: pointer to adapter or null |
| 6416 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6417 | struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6418 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6419 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6420 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6421 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6422 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6423 | if (adapter->device_mode == mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6424 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6425 | } |
| 6426 | |
| 6427 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6428 | } |
| 6429 | |
Jeff Johnson | 36a0abf | 2018-05-20 11:24:25 -0700 | [diff] [blame] | 6430 | enum QDF_OPMODE hdd_get_device_mode(uint32_t session_id) |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 6431 | { |
| 6432 | struct hdd_context *hdd_ctx; |
| 6433 | struct hdd_adapter *adapter; |
| 6434 | |
| 6435 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 6436 | if (!hdd_ctx) { |
| 6437 | hdd_err("Invalid HDD context"); |
| 6438 | return QDF_MAX_NO_OF_MODE; |
| 6439 | } |
| 6440 | |
| 6441 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 6442 | if (!adapter) { |
| 6443 | hdd_err("Invalid HDD adapter"); |
| 6444 | return QDF_MAX_NO_OF_MODE; |
| 6445 | } |
| 6446 | |
| 6447 | return adapter->device_mode; |
| 6448 | } |
| 6449 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6450 | /** |
| 6451 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 6452 | * @hdd_ctx: Pointer to the HDD context. |
| 6453 | * @mode: Device mode for which operating channel is required. |
Jeff Johnson | 77f89bb | 2018-05-06 16:21:36 -0700 | [diff] [blame] | 6454 | * Supported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6455 | * QDF_STA_MODE, |
| 6456 | * QDF_P2P_CLIENT_MODE, |
| 6457 | * QDF_SAP_MODE, |
| 6458 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6459 | * |
| 6460 | * This API returns the operating channel of the requested device mode |
| 6461 | * |
| 6462 | * Return: channel number. "0" id the requested device is not found OR it is |
| 6463 | * not connected. |
| 6464 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6465 | uint8_t hdd_get_operating_channel(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6466 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6467 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6468 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6469 | uint8_t operatingChannel = 0; |
| 6470 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6471 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6472 | if (mode == adapter->device_mode) { |
| 6473 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6474 | case QDF_STA_MODE: |
| 6475 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6476 | if (hdd_conn_is_connected |
| 6477 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6478 | (adapter))) { |
| 6479 | operatingChannel = |
| 6480 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6481 | (adapter))->conn_info. |
| 6482 | operationChannel; |
| 6483 | } |
| 6484 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6485 | case QDF_SAP_MODE: |
| 6486 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6487 | /* softap connection info */ |
| 6488 | if (test_bit |
| 6489 | (SOFTAP_BSS_STARTED, |
| 6490 | &adapter->event_flags)) |
| 6491 | operatingChannel = |
| 6492 | (WLAN_HDD_GET_AP_CTX_PTR |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 6493 | (adapter))->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6494 | break; |
| 6495 | default: |
| 6496 | break; |
| 6497 | } |
| 6498 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6499 | /* Found the device of interest. break the loop */ |
| 6500 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6501 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6502 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6503 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6504 | return operatingChannel; |
| 6505 | } |
| 6506 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6507 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6508 | hdd_ctx) |
| 6509 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6510 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6511 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6512 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6513 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6514 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6515 | if (adapter->device_mode == QDF_STA_MODE || |
| 6516 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6517 | adapter->device_mode == QDF_IBSS_MODE || |
| 6518 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6519 | adapter->device_mode == QDF_SAP_MODE || |
| 6520 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6521 | hdd_unregister_wext(adapter->dev); |
| 6522 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6523 | } |
| 6524 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6525 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6526 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6527 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6528 | } |
| 6529 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6530 | 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] | 6531 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6532 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6533 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6534 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6535 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6536 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6537 | if (adapter->device_mode == QDF_STA_MODE || |
| 6538 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6539 | adapter->device_mode == QDF_IBSS_MODE || |
| 6540 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6541 | adapter->device_mode == QDF_SAP_MODE || |
| 6542 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 6543 | wlan_abort_scan(hdd_ctx->pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6544 | adapter->session_id, INVALID_SCAN_ID, |
Vignesh Viswanathan | 19611c8 | 2018-01-16 16:20:40 +0530 | [diff] [blame] | 6545 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6546 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6547 | } |
| 6548 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6549 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6550 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6551 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6552 | } |
| 6553 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6554 | /** |
| 6555 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 6556 | * adapters |
| 6557 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 6558 | * |
| 6559 | * return: QDF_STATUS_SUCCESS |
| 6560 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6561 | 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] | 6562 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6563 | struct hdd_adapter *adapter; |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6564 | int err; |
| 6565 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6566 | hdd_enter(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6567 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6568 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6569 | if (adapter->device_mode == QDF_STA_MODE || |
| 6570 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6571 | adapter->device_mode == QDF_IBSS_MODE || |
| 6572 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6573 | adapter->device_mode == QDF_SAP_MODE || |
| 6574 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6575 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 6576 | if (err) |
| 6577 | hdd_err("Unable to stop scheduled scan"); |
| 6578 | } |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6579 | } |
| 6580 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6581 | hdd_exit(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6582 | |
| 6583 | return QDF_STATUS_SUCCESS; |
| 6584 | } |
| 6585 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6586 | #ifdef WLAN_NS_OFFLOAD |
| 6587 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6588 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6589 | * @hdd_ctx: Pointer to hdd context |
| 6590 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6591 | * Unregister for IPv6 address change notifications. |
| 6592 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6593 | * Return: None |
| 6594 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6595 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6596 | { |
| 6597 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6598 | } |
| 6599 | |
| 6600 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6601 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6602 | * @hdd_ctx: Pointer to hdd context |
| 6603 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6604 | * Register for IPv6 address change notifications. |
| 6605 | * |
| 6606 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6607 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6608 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6609 | { |
| 6610 | int ret; |
| 6611 | |
| 6612 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 6613 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6614 | if (ret) { |
| 6615 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 6616 | goto out; |
| 6617 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6618 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6619 | hdd_debug("Registered IPv6 notifier"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6620 | out: |
| 6621 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6622 | } |
| 6623 | #else |
| 6624 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6625 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6626 | * @hdd_ctx: Pointer to hdd context |
| 6627 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6628 | * Unregister for IPv6 address change notifications. |
| 6629 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6630 | * Return: None |
| 6631 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6632 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6633 | { |
| 6634 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6635 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6636 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6637 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6638 | * @hdd_ctx: Pointer to hdd context |
| 6639 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6640 | * Register for IPv6 address change notifications. |
| 6641 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6642 | * Return: None |
| 6643 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6644 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6645 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6646 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6647 | } |
| 6648 | #endif |
| 6649 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6650 | void hdd_set_disconnect_status(struct hdd_adapter *adapter, bool status) |
| 6651 | { |
| 6652 | qdf_mutex_acquire(&adapter->disconnection_status_lock); |
| 6653 | adapter->disconnection_in_progress = status; |
| 6654 | qdf_mutex_release(&adapter->disconnection_status_lock); |
| 6655 | hdd_debug("setting disconnection status: %d", status); |
| 6656 | } |
| 6657 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6658 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6659 | * hdd_register_notifiers - Register netdev notifiers. |
| 6660 | * @hdd_ctx: HDD context |
| 6661 | * |
| 6662 | * Register netdev notifiers like IPv4 and IPv6. |
| 6663 | * |
| 6664 | * Return: 0 on success and errno on failure |
| 6665 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6666 | static int hdd_register_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6667 | { |
| 6668 | int ret; |
| 6669 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6670 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 6671 | if (ret) |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6672 | goto out; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6673 | |
| 6674 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 6675 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 6676 | if (ret) { |
| 6677 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 6678 | goto unregister_ip6_notifier; |
| 6679 | } |
| 6680 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6681 | ret = hdd_nud_register_netevent_notifier(hdd_ctx); |
| 6682 | if (ret) { |
| 6683 | hdd_err("Failed to register netevent notifier: %d", |
| 6684 | ret); |
| 6685 | goto unregister_inetaddr_notifier; |
| 6686 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6687 | return 0; |
| 6688 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6689 | unregister_inetaddr_notifier: |
| 6690 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6691 | unregister_ip6_notifier: |
| 6692 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6693 | out: |
| 6694 | return ret; |
| 6695 | |
| 6696 | } |
| 6697 | |
| 6698 | /** |
| 6699 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 6700 | * @hdd_ctx: HDD context |
| 6701 | * |
| 6702 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 6703 | * |
| 6704 | * Return: None. |
| 6705 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6706 | void hdd_unregister_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6707 | { |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6708 | hdd_nud_unregister_netevent_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6709 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 6710 | |
| 6711 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6712 | } |
| 6713 | |
| 6714 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6715 | * hdd_exit_netlink_services - Exit netlink services |
| 6716 | * @hdd_ctx: HDD context |
| 6717 | * |
| 6718 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6719 | * nl service. |
| 6720 | * |
| 6721 | * Return: None. |
| 6722 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6723 | static void hdd_exit_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6724 | { |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 6725 | spectral_scan_deactivate_service(); |
| 6726 | cnss_diag_deactivate_service(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6727 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6728 | ptt_sock_deactivate_svc(); |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 6729 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6730 | |
| 6731 | nl_srv_exit(); |
| 6732 | } |
| 6733 | |
| 6734 | /** |
| 6735 | * hdd_init_netlink_services- Init netlink services |
| 6736 | * @hdd_ctx: HDD context |
| 6737 | * |
| 6738 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6739 | * nl service. |
| 6740 | * |
| 6741 | * Return: 0 on success and errno on failure. |
| 6742 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6743 | static int hdd_init_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6744 | { |
| 6745 | int ret; |
| 6746 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6747 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6748 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6749 | hdd_err("nl_srv_init failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6750 | goto out; |
| 6751 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6752 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6753 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 6754 | ret = hdd_activate_wifi_pos(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6755 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6756 | hdd_err("hdd_activate_wifi_pos failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6757 | goto err_nl_srv; |
| 6758 | } |
| 6759 | |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 6760 | ptt_sock_activate_svc(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6761 | |
| 6762 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 6763 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6764 | hdd_err("hdd_open_cesium_nl_sock failed ret: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6765 | |
| 6766 | ret = cnss_diag_activate_service(); |
| 6767 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6768 | hdd_err("cnss_diag_activate_service failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6769 | goto err_close_cesium; |
| 6770 | } |
| 6771 | |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 6772 | spectral_scan_activate_service(); |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 6773 | |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6774 | return 0; |
| 6775 | |
| 6776 | err_close_cesium: |
| 6777 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6778 | ptt_sock_deactivate_svc(); |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 6779 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6780 | err_nl_srv: |
| 6781 | nl_srv_exit(); |
| 6782 | out: |
| 6783 | return ret; |
| 6784 | } |
| 6785 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6786 | /** |
| 6787 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 6788 | * @hdd_ctx: HDD context. |
| 6789 | * |
| 6790 | * Destroy RX wakelock. |
| 6791 | * |
| 6792 | * Return: None. |
| 6793 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6794 | static void hdd_rx_wake_lock_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6795 | { |
| 6796 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 6797 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6798 | |
| 6799 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6800 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 6801 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6802 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6803 | * Create RX wakelock. |
| 6804 | * |
| 6805 | * Return: None. |
| 6806 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6807 | static void hdd_rx_wake_lock_create(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6808 | { |
| 6809 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 6810 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6811 | |
| 6812 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6813 | * hdd_context_deinit() - Deinitialize HDD context |
| 6814 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6815 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6816 | * Deinitialize HDD context along with all the feature specific contexts but |
| 6817 | * do not free hdd context itself. Caller of this API is supposed to free |
| 6818 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6819 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6820 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6821 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6822 | static int hdd_context_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6823 | { |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6824 | qdf_wake_lock_destroy(&hdd_ctx->monitor_mode_wakelock); |
| 6825 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6826 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6827 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6828 | hdd_sap_context_destroy(hdd_ctx); |
| 6829 | |
| 6830 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 6831 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6832 | hdd_scan_context_destroy(hdd_ctx); |
| 6833 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6834 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6835 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6836 | return 0; |
| 6837 | } |
| 6838 | |
| 6839 | /** |
| 6840 | * hdd_context_destroy() - Destroy HDD context |
| 6841 | * @hdd_ctx: HDD context to be destroyed. |
| 6842 | * |
| 6843 | * Free config and HDD context as well as destroy all the resources. |
| 6844 | * |
| 6845 | * Return: None |
| 6846 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6847 | static void hdd_context_destroy(struct hdd_context *hdd_ctx) |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6848 | { |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 6849 | cds_set_context(QDF_MODULE_ID_HDD, NULL); |
Arunk Khandavalli | 3d267b4 | 2017-05-02 18:58:59 +0530 | [diff] [blame] | 6850 | |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 6851 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 6852 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6853 | hdd_context_deinit(hdd_ctx); |
| 6854 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6855 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6856 | hdd_ctx->config = NULL; |
| 6857 | |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 6858 | cfg_release(); |
| 6859 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6860 | wiphy_free(hdd_ctx->wiphy); |
| 6861 | } |
| 6862 | |
| 6863 | /** |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 6864 | * wlan_destroy_bug_report_lock() - Destroy bug report lock |
| 6865 | * |
| 6866 | * This function is used to destroy bug report lock |
| 6867 | * |
| 6868 | * Return: None |
| 6869 | */ |
| 6870 | static void wlan_destroy_bug_report_lock(void) |
| 6871 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 6872 | struct cds_context *p_cds_context; |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 6873 | |
| 6874 | p_cds_context = cds_get_global_context(); |
| 6875 | if (!p_cds_context) { |
| 6876 | hdd_err("cds context is NULL"); |
| 6877 | return; |
| 6878 | } |
| 6879 | |
| 6880 | qdf_spinlock_destroy(&p_cds_context->bug_report_lock); |
| 6881 | } |
| 6882 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 6883 | #ifdef DISABLE_CHANNEL_LIST |
| 6884 | static void wlan_hdd_cache_chann_mutex_destroy(struct hdd_context *hdd_ctx) |
| 6885 | { |
| 6886 | qdf_mutex_destroy(&hdd_ctx->cache_channel_lock); |
| 6887 | } |
| 6888 | #else |
| 6889 | static void wlan_hdd_cache_chann_mutex_destroy(struct hdd_context *hdd_ctx) |
| 6890 | { |
| 6891 | } |
| 6892 | #endif |
| 6893 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 6894 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6895 | * hdd_wlan_exit() - HDD WLAN exit function |
| 6896 | * @hdd_ctx: Pointer to the HDD Context |
| 6897 | * |
| 6898 | * This is the driver exit point (invoked during rmmod) |
| 6899 | * |
| 6900 | * Return: None |
| 6901 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6902 | static void hdd_wlan_exit(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6903 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6904 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6905 | int driver_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6906 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6907 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6908 | |
Dustin Brown | 6470aba | 2018-09-05 09:49:58 -0700 | [diff] [blame] | 6909 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
| 6910 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6911 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6912 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6913 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6914 | if (QDF_TIMER_STATE_RUNNING == |
| 6915 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 6916 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6917 | } |
| 6918 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6919 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6920 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 6921 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6922 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6923 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6924 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6925 | hdd_ctx->last_acs_channel_list = NULL; |
| 6926 | hdd_ctx->num_of_channels = 0; |
| 6927 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6928 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6929 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6930 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 6931 | driver_status = hdd_ctx->driver_status; |
| 6932 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 6933 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6934 | /* |
| 6935 | * Powersave Offload Case |
| 6936 | * Disable Idle Power Save Mode |
| 6937 | */ |
| 6938 | hdd_set_idle_ps_config(hdd_ctx, false); |
Sandeep Puligilla | 8fa28fd | 2017-11-02 12:19:33 -0700 | [diff] [blame] | 6939 | /* clear the scan queue in all the scenarios */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 6940 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->pdev, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6941 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6942 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 6943 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 6944 | /* |
| 6945 | * Cancel any outstanding scan requests. We are about to close |
| 6946 | * all of our adapters, but an adapter structure is what SME |
| 6947 | * passes back to our callback function. Hence if there |
| 6948 | * are any outstanding scan requests then there is a |
| 6949 | * race condition between when the adapter is closed and |
| 6950 | * when the callback is invoked. We try to resolve that |
| 6951 | * race condition here by canceling any outstanding scans |
| 6952 | * before we close the adapters. |
| 6953 | * Note that the scans may be cancelled in an asynchronous |
| 6954 | * manner, so ideally there needs to be some kind of |
| 6955 | * synchronization. Rather than introduce a new |
| 6956 | * synchronization here, we will utilize the fact that we are |
| 6957 | * about to Request Full Power, and since that is synchronized, |
| 6958 | * the expectation is that by the time Request Full Power has |
| 6959 | * completed, all scans will be cancelled |
| 6960 | */ |
| 6961 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6962 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 6963 | hdd_stop_all_adapters(hdd_ctx); |
bings | 29c9986 | 2017-11-01 13:54:13 +0800 | [diff] [blame] | 6964 | hdd_deinit_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6965 | } |
| 6966 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 6967 | unregister_reboot_notifier(&system_reboot_notifier); |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6968 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 6969 | |
Rachit Kankane | 3080733 | 2018-06-27 18:39:36 +0530 | [diff] [blame] | 6970 | qdf_dp_trace_deinit(); |
| 6971 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 6972 | hdd_wlan_stop_modules(hdd_ctx, false); |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 6973 | |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 6974 | hdd_bus_bandwidth_deinit(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 6975 | hdd_driver_memdump_deinit(); |
| 6976 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 6977 | qdf_nbuf_deinit_replenish_timer(); |
| 6978 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6979 | if (QDF_GLOBAL_MONITOR_MODE == hdd_get_conparam()) { |
| 6980 | hdd_info("Release wakelock for monitor mode!"); |
| 6981 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 6982 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 6983 | } |
| 6984 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 6985 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
| 6986 | qdf_spinlock_destroy(&hdd_ctx->sta_update_info_lock); |
| 6987 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 6988 | wlan_hdd_cache_chann_mutex_destroy(hdd_ctx); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 6989 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 6990 | osif_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6991 | |
Dustin Brown | d005ad8 | 2018-01-19 10:32:13 -0800 | [diff] [blame] | 6992 | hdd_close_all_adapters(hdd_ctx, false); |
| 6993 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 6994 | wlansap_global_deinit(); |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6995 | /* |
| 6996 | * If there is re_init failure wiphy would have already de-registered |
| 6997 | * check the wiphy status before un-registering again |
| 6998 | */ |
Ashish Kumar Dhanotiya | e16feb7 | 2017-03-31 19:39:37 +0530 | [diff] [blame] | 6999 | if (wiphy && wiphy->registered) { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7000 | wiphy_unregister(wiphy); |
| 7001 | wlan_hdd_cfg80211_deinit(wiphy); |
| 7002 | hdd_lpass_notify_stop(hdd_ctx); |
| 7003 | } |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 7004 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7005 | hdd_exit_netlink_services(hdd_ctx); |
| 7006 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 7007 | #ifdef FEATURE_WLAN_CH_AVOID |
| 7008 | mutex_destroy(&hdd_ctx->avoid_freq_lock); |
| 7009 | #endif |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 7010 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 7011 | driver_status = hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 7012 | if (driver_status) |
| 7013 | hdd_err("Psoc delete failed"); |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 7014 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7015 | hdd_context_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7016 | } |
| 7017 | |
| 7018 | void __hdd_wlan_exit(void) |
| 7019 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7020 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7021 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7022 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7023 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7024 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7025 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7026 | hdd_err("Invalid HDD Context"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7027 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7028 | return; |
| 7029 | } |
| 7030 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7031 | /* Do all the cleanup before deregistering the driver */ |
| 7032 | hdd_wlan_exit(hdd_ctx); |
Mohit Khanna | ebf8a86 | 2016-04-28 17:53:59 -0700 | [diff] [blame] | 7033 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7034 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7035 | } |
| 7036 | |
| 7037 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7038 | /** |
| 7039 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7040 | * @data: pointer to struct hdd_context |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7041 | * |
| 7042 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 7043 | * Then new ACS request will do a fresh scan without reusing the cached |
| 7044 | * scan information. |
| 7045 | * |
| 7046 | * Return: void |
| 7047 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 7048 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7049 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7050 | struct hdd_context *hdd_ctx = (struct hdd_context *) data; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7051 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7052 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7053 | hdd_debug("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7054 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7055 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 7056 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 7057 | hdd_ctx->last_acs_channel_list = NULL; |
| 7058 | hdd_ctx->num_of_channels = 0; |
| 7059 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7060 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7061 | mac_handle = hdd_ctx->mac_handle; |
| 7062 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7063 | return; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7064 | sme_scan_flush_result(mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7065 | } |
| 7066 | #endif |
| 7067 | |
| 7068 | #ifdef QCA_HT_2040_COEX |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 7069 | int hdd_wlan_set_ht2040_mode(struct hdd_adapter *adapter, uint16_t sta_id, |
| 7070 | struct qdf_mac_addr sta_mac, int channel_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7071 | { |
| 7072 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7073 | QDF_STATUS qdf_status; |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 7074 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7075 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7076 | |
| 7077 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7078 | |
| 7079 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7080 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7081 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7082 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7083 | mac_handle = hdd_ctx->mac_handle; |
| 7084 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7085 | return -EINVAL; |
| 7086 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7087 | qdf_status = sme_notify_ht2040_mode(mac_handle, sta_id, sta_mac, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7088 | adapter->session_id, channel_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7089 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7090 | hdd_err("Fail to send notification with ht2040 mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7091 | return -EINVAL; |
| 7092 | } |
| 7093 | |
| 7094 | return 0; |
| 7095 | } |
| 7096 | #endif |
| 7097 | |
| 7098 | /** |
| 7099 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 7100 | * @state: state |
| 7101 | * |
| 7102 | * This function notifies FW with modem power status |
| 7103 | * |
| 7104 | * Return: 0 if successful, error number otherwise |
| 7105 | */ |
| 7106 | int hdd_wlan_notify_modem_power_state(int state) |
| 7107 | { |
| 7108 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7109 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7110 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7111 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7112 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7113 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7114 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7115 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7116 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7117 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7118 | mac_handle = hdd_ctx->mac_handle; |
| 7119 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7120 | return -EINVAL; |
| 7121 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7122 | qdf_status = sme_notify_modem_power_state(mac_handle, state); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7123 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7124 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7125 | state); |
| 7126 | return -EINVAL; |
| 7127 | } |
| 7128 | return 0; |
| 7129 | } |
| 7130 | |
| 7131 | /** |
| 7132 | * |
| 7133 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 7134 | * @adapter - Pointer to the HDD |
| 7135 | * |
| 7136 | * Return: None |
| 7137 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7138 | QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7139 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7140 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7141 | |
| 7142 | /* |
| 7143 | * Send ready indication to the HDD. This will kick off the MAC |
| 7144 | * into a 'running' state and should kick off an initial scan. |
| 7145 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7146 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->mac_handle); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7147 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7148 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 7149 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7150 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7151 | } |
| 7152 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7153 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7154 | } |
| 7155 | |
Sourav Mohapatra | 92ea8d6 | 2018-02-05 10:03:10 +0530 | [diff] [blame] | 7156 | struct hdd_adapter *hdd_get_first_valid_adapter(struct hdd_context *hdd_ctx) |
| 7157 | { |
| 7158 | struct hdd_adapter *adapter; |
| 7159 | |
| 7160 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 7161 | if (adapter && adapter->magic == WLAN_HDD_ADAPTER_MAGIC) |
| 7162 | return adapter; |
| 7163 | } |
| 7164 | |
| 7165 | return NULL; |
| 7166 | } |
| 7167 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7168 | /* wake lock APIs for HDD */ |
| 7169 | void hdd_prevent_suspend(uint32_t reason) |
| 7170 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 7171 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7172 | } |
| 7173 | |
| 7174 | void hdd_allow_suspend(uint32_t reason) |
| 7175 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 7176 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7177 | } |
| 7178 | |
| 7179 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 7180 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 7181 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 7182 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7183 | } |
| 7184 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7185 | /* Initialize channel list in sme based on the country code */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7186 | QDF_STATUS hdd_set_sme_chan_list(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7187 | { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7188 | return sme_init_chan_list(hdd_ctx->mac_handle, |
Amar Singhal | 6f8592b | 2017-04-26 14:31:58 -0700 | [diff] [blame] | 7189 | hdd_ctx->reg.alpha2, |
| 7190 | hdd_ctx->reg.cc_src); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7191 | } |
| 7192 | |
| 7193 | /** |
| 7194 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 7195 | * @hdd_ctx: Pointer to the hdd context |
| 7196 | * |
| 7197 | * HDD function to know if hardware supports 5GHz |
| 7198 | * |
| 7199 | * Return: true if hardware supports 5GHz |
| 7200 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7201 | bool hdd_is_5g_supported(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7202 | { |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 7203 | if (!hdd_ctx) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7204 | return true; |
| 7205 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 7206 | if (hdd_ctx->curr_band != BAND_2G) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7207 | return true; |
| 7208 | else |
| 7209 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7210 | } |
| 7211 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7212 | static int hdd_wiphy_init(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7213 | { |
| 7214 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7215 | int ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7216 | |
| 7217 | wiphy = hdd_ctx->wiphy; |
| 7218 | |
| 7219 | /* |
| 7220 | * The channel information in |
| 7221 | * wiphy needs to be initialized before wiphy registration |
| 7222 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7223 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 7224 | if (ret_val) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7225 | hdd_err("regulatory init failed"); |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7226 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7227 | } |
| 7228 | |
| 7229 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 7230 | wiphy->wowlan = &wowlan_support_reg_init; |
| 7231 | #else |
| 7232 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 7233 | WIPHY_WOWLAN_MAGIC_PKT | |
| 7234 | WIPHY_WOWLAN_DISCONNECT | |
| 7235 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 7236 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 7237 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 7238 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 7239 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 7240 | |
| 7241 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 7242 | WOW_MAX_FILTERS_PER_LIST); |
| 7243 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 7244 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 7245 | #endif |
Liangwei Dong | 0da1426 | 2018-07-03 03:30:23 -0400 | [diff] [blame] | 7246 | if (hdd_ctx->obss_scan_offload) { |
| 7247 | hdd_debug("wmi_service_obss_scan supported"); |
| 7248 | } else if (hdd_ctx->config->nChannelBondingMode24GHz) { |
| 7249 | hdd_debug("enable wpa_supp obss_scan"); |
| 7250 | wiphy->features |= NL80211_FEATURE_NEED_OBSS_SCAN; |
| 7251 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7252 | |
| 7253 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7254 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7255 | if (0 > ret_val) { |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7256 | hdd_err("wiphy registration failed"); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7257 | return ret_val; |
| 7258 | } |
Amar Singhal | ac26de2 | 2018-06-22 12:53:06 -0700 | [diff] [blame] | 7259 | |
Kiran Kumar Lokere | 0508af9 | 2018-04-23 18:38:32 -0700 | [diff] [blame] | 7260 | /* Check the kernel version for upstream commit aced43ce780dc5 that |
| 7261 | * has support for processing user cell_base hints when wiphy is |
| 7262 | * self managed or check the backport flag for the same. |
| 7263 | */ |
Amar Singhal | ac26de2 | 2018-06-22 12:53:06 -0700 | [diff] [blame] | 7264 | #if defined CFG80211_USER_HINT_CELL_BASE_SELF_MANAGED || \ |
| 7265 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)) |
Kiran Kumar Lokere | 0508af9 | 2018-04-23 18:38:32 -0700 | [diff] [blame] | 7266 | hdd_send_wiphy_regd_sync_event(hdd_ctx); |
| 7267 | #endif |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7268 | |
Amar Singhal | 2d81201 | 2018-02-03 15:06:47 +0800 | [diff] [blame] | 7269 | pld_increment_driver_load_cnt(hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7270 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7271 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7272 | } |
| 7273 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7274 | #ifdef MSM_PLATFORM |
| 7275 | /** |
| 7276 | * hdd_display_periodic_stats() - Function to display periodic stats |
| 7277 | * @hdd_ctx - handle to hdd context |
| 7278 | * @bool data_in_interval - true, if data detected in bw time interval |
| 7279 | * |
| 7280 | * The periodicity is determined by hdd_ctx->config->periodic_stats_disp_time. |
| 7281 | * Stats show up in wlan driver logs. |
| 7282 | * |
| 7283 | * Returns: None |
| 7284 | */ |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7285 | static void hdd_display_periodic_stats(struct hdd_context *hdd_ctx, |
| 7286 | bool data_in_interval) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7287 | { |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7288 | static uint32_t counter; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7289 | static bool data_in_time_period; |
| 7290 | ol_txrx_pdev_handle pdev; |
| 7291 | |
| 7292 | if (hdd_ctx->config->periodic_stats_disp_time == 0) |
| 7293 | return; |
| 7294 | |
| 7295 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 7296 | if (!pdev) { |
| 7297 | hdd_err("pdev is NULL"); |
| 7298 | return; |
| 7299 | } |
| 7300 | |
| 7301 | counter++; |
| 7302 | if (data_in_interval) |
| 7303 | data_in_time_period = data_in_interval; |
| 7304 | |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7305 | if (counter * hdd_ctx->config->bus_bw_compute_interval >= |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7306 | hdd_ctx->config->periodic_stats_disp_time * 1000) { |
| 7307 | if (data_in_time_period) { |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7308 | wlan_hdd_display_txrx_stats(hdd_ctx); |
| 7309 | dp_txrx_dump_stats(cds_get_context(QDF_MODULE_ID_SOC)); |
| 7310 | cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC), |
| 7311 | CDP_RX_RING_STATS, |
| 7312 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7313 | cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC), |
| 7314 | CDP_TXRX_PATH_STATS, |
| 7315 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7316 | wlan_hdd_display_netif_queue_history |
| 7317 | (hdd_ctx, QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7318 | qdf_dp_trace_dump_stats(); |
| 7319 | } |
| 7320 | counter = 0; |
| 7321 | data_in_time_period = false; |
| 7322 | } |
| 7323 | } |
| 7324 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7325 | /** |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7326 | * hdd_clear_rps_cpu_mask - clear RPS CPU mask for interfaces |
| 7327 | * @hdd_ctx: pointer to struct hdd_context |
| 7328 | * |
| 7329 | * Return: none |
| 7330 | */ |
| 7331 | static void hdd_clear_rps_cpu_mask(struct hdd_context *hdd_ctx) |
| 7332 | { |
| 7333 | struct hdd_adapter *adapter; |
| 7334 | |
| 7335 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 7336 | hdd_send_rps_disable_ind(adapter); |
| 7337 | } |
| 7338 | |
| 7339 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7340 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7341 | * @hdd_ctx - handle to hdd context |
| 7342 | * @tx_packets - transmit packet count |
| 7343 | * @rx_packets - receive packet count |
| 7344 | * |
| 7345 | * The function controls the bus bandwidth and dynamic control of |
| 7346 | * tcp delayed ack configuration |
| 7347 | * |
| 7348 | * Returns: None |
| 7349 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7350 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7351 | static void hdd_pld_request_bus_bandwidth(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 7352 | const uint64_t tx_packets, |
| 7353 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7354 | { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7355 | u64 total_pkts = tx_packets + rx_packets; |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7356 | uint64_t temp_tx = 0, avg_rx = 0; |
| 7357 | uint64_t no_rx_offload_pkts = 0, avg_no_rx_offload_pkts = 0; |
| 7358 | uint64_t rx_offload_pkts = 0, avg_rx_offload_pkts = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7359 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7360 | static enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7361 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7362 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7363 | uint16_t index = 0; |
| 7364 | bool vote_level_change = false; |
| 7365 | bool rx_level_change = false; |
| 7366 | bool tx_level_change = false; |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7367 | bool rxthread_high_tput_req = false; |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7368 | bool dptrace_high_tput_req; |
Srinivas Girigowda | 5033534 | 2018-09-07 15:21:01 -0700 | [diff] [blame] | 7369 | |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7370 | if (total_pkts > hdd_ctx->config->bus_bw_high_threshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7371 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7372 | else if (total_pkts > hdd_ctx->config->bus_bw_medium_threshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7373 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7374 | else if (total_pkts > hdd_ctx->config->bus_bw_low_threshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7375 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 7376 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7377 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7378 | |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7379 | dptrace_high_tput_req = |
| 7380 | next_vote_level > PLD_BUS_WIDTH_NONE ? true : false; |
| 7381 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7382 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7383 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 7384 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7385 | hdd_ctx->cur_vote_level = next_vote_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7386 | vote_level_change = true; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7387 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7388 | if ((next_vote_level == PLD_BUS_WIDTH_LOW) || |
| 7389 | (next_vote_level == PLD_BUS_WIDTH_NONE)) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7390 | if (hdd_ctx->hbw_requested) { |
| 7391 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 7392 | hdd_ctx->hbw_requested = false; |
| 7393 | } |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7394 | if (hdd_ctx->dynamic_rps) |
| 7395 | hdd_clear_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7396 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7397 | if (!hdd_ctx->hbw_requested) { |
| 7398 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 7399 | hdd_ctx->hbw_requested = true; |
| 7400 | } |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7401 | if (hdd_ctx->dynamic_rps) |
| 7402 | hdd_set_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7403 | } |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7404 | |
Manjunathappa Prakash | cb6df76 | 2018-05-29 18:54:58 -0700 | [diff] [blame] | 7405 | if (hdd_ctx->config->napi_cpu_affinity_mask) |
| 7406 | hdd_napi_apply_throughput_policy(hdd_ctx, |
| 7407 | tx_packets, |
| 7408 | rx_packets); |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7409 | |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7410 | if (rx_packets < hdd_ctx->config->bus_bw_low_threshold) |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7411 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, true); |
| 7412 | else |
| 7413 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7414 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7415 | |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7416 | qdf_dp_trace_apply_tput_policy(dptrace_high_tput_req); |
| 7417 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7418 | /* |
| 7419 | * Includes tcp+udp, if perf core is required for tcp, then |
| 7420 | * perf core is also required for udp. |
| 7421 | */ |
| 7422 | no_rx_offload_pkts = hdd_ctx->no_rx_offload_pkt_cnt; |
| 7423 | hdd_ctx->no_rx_offload_pkt_cnt = 0; |
| 7424 | rx_offload_pkts = rx_packets - no_rx_offload_pkts; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7425 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7426 | avg_no_rx_offload_pkts = (no_rx_offload_pkts + |
| 7427 | hdd_ctx->prev_no_rx_offload_pkts) / 2; |
| 7428 | hdd_ctx->prev_no_rx_offload_pkts = no_rx_offload_pkts; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 7429 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7430 | avg_rx_offload_pkts = (rx_offload_pkts + |
| 7431 | hdd_ctx->prev_rx_offload_pkts) / 2; |
| 7432 | hdd_ctx->prev_rx_offload_pkts = rx_offload_pkts; |
| 7433 | |
| 7434 | avg_rx = avg_no_rx_offload_pkts + avg_rx_offload_pkts; |
| 7435 | /* |
| 7436 | * Takes care to set Rx_thread affinity for below case |
| 7437 | * 1)LRO/GRO not supported ROME case |
| 7438 | * 2)when rx_ol is disabled in cases like concurrency etc |
| 7439 | * 3)For UDP cases |
| 7440 | */ |
| 7441 | if (avg_no_rx_offload_pkts > |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7442 | hdd_ctx->config->bus_bw_high_threshold) |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7443 | rxthread_high_tput_req = true; |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7444 | else |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7445 | rxthread_high_tput_req = false; |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7446 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7447 | if (cds_sched_handle_throughput_req(rxthread_high_tput_req)) |
| 7448 | hdd_warn("Rx thread high_tput(%d) affinity request failed", |
| 7449 | rxthread_high_tput_req); |
| 7450 | |
| 7451 | /* fine-tuning parameters for RX Flows */ |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7452 | if (avg_rx > hdd_ctx->config->tcp_delack_thres_high) { |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 7453 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 7454 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 7455 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 7456 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7457 | } else { |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7458 | hdd_ctx->rx_high_ind_cnt = 0; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7459 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7460 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7461 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7462 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7463 | struct wlan_rx_tp_data rx_tp_data = {0}; |
| 7464 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7465 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Jeff Johnson | b9feee4 | 2018-07-08 10:34:48 -0700 | [diff] [blame] | 7466 | next_rx_level, avg_rx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7467 | hdd_ctx->cur_rx_level = next_rx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7468 | rx_level_change = true; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7469 | /* Send throughput indication only if it is enabled. |
| 7470 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 7471 | * to default delayed ack. Note that this will disable the |
| 7472 | * dynamic delayed ack mechanism across the system |
| 7473 | */ |
Manjunathappa Prakash | bfd1276 | 2018-04-29 22:44:52 -0700 | [diff] [blame] | 7474 | if (hdd_ctx->en_tcp_delack_no_lro) |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7475 | rx_tp_data.rx_tp_flags |= TCP_DEL_ACK_IND; |
| 7476 | |
Mohit Khanna | 6272fb68 | 2017-04-13 09:34:36 -0700 | [diff] [blame] | 7477 | if (hdd_ctx->config->enable_tcp_adv_win_scale) |
| 7478 | rx_tp_data.rx_tp_flags |= TCP_ADV_WIN_SCL; |
| 7479 | |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7480 | rx_tp_data.level = next_rx_level; |
| 7481 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7482 | WLAN_SVC_WLAN_TP_IND, &rx_tp_data, |
| 7483 | sizeof(rx_tp_data)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7484 | } |
| 7485 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7486 | /* fine-tuning parameters for TX Flows */ |
| 7487 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 7488 | hdd_ctx->prev_tx = tx_packets; |
| 7489 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 7490 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 7491 | else |
| 7492 | next_tx_level = WLAN_SVC_TP_LOW; |
| 7493 | |
Prakash Manjunathappa | e73e3b5 | 2018-02-27 18:56:22 -0800 | [diff] [blame] | 7494 | if ((hdd_ctx->config->enable_tcp_limit_output) && |
| 7495 | (hdd_ctx->cur_tx_level != next_tx_level)) { |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7496 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 7497 | next_tx_level, temp_tx); |
| 7498 | hdd_ctx->cur_tx_level = next_tx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7499 | tx_level_change = true; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 7500 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7501 | WLAN_SVC_WLAN_TP_TX_IND, |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7502 | &next_tx_level, |
| 7503 | sizeof(next_tx_level)); |
| 7504 | } |
| 7505 | |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7506 | index = hdd_ctx->hdd_txrx_hist_idx; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7507 | if (vote_level_change || tx_level_change || rx_level_change) { |
| 7508 | hdd_ctx->hdd_txrx_hist[index].next_tx_level = next_tx_level; |
| 7509 | hdd_ctx->hdd_txrx_hist[index].next_rx_level = next_rx_level; |
| 7510 | hdd_ctx->hdd_txrx_hist[index].next_vote_level = next_vote_level; |
| 7511 | hdd_ctx->hdd_txrx_hist[index].interval_rx = rx_packets; |
| 7512 | hdd_ctx->hdd_txrx_hist[index].interval_tx = tx_packets; |
| 7513 | hdd_ctx->hdd_txrx_hist[index].qtime = qdf_get_log_timestamp(); |
| 7514 | hdd_ctx->hdd_txrx_hist_idx++; |
| 7515 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
| 7516 | } |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7517 | |
| 7518 | hdd_display_periodic_stats(hdd_ctx, (total_pkts > 0) ? true : false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7519 | } |
| 7520 | |
| 7521 | #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] | 7522 | static void __hdd_bus_bw_work_handler(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7523 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7524 | struct hdd_context *hdd_ctx = container_of(work, struct hdd_context, |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7525 | bus_bw_work); |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7526 | struct hdd_adapter *adapter = NULL, *con_sap_adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7527 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 7528 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 7529 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7530 | uint64_t total_tx = 0, total_rx = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7531 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7532 | bool connected = false; |
| 7533 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 7534 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7535 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7536 | return; |
| 7537 | |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 7538 | if (hdd_ctx->is_wiphy_suspended) |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7539 | goto restart_timer; |
| 7540 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7541 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 7542 | /* |
| 7543 | * Validate magic so we don't end up accessing |
| 7544 | * an invalid adapter. |
| 7545 | */ |
| 7546 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 7547 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7548 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7549 | if ((adapter->device_mode == QDF_STA_MODE || |
| 7550 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7551 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.connState |
| 7552 | != eConnectionState_Associated) { |
| 7553 | |
| 7554 | continue; |
| 7555 | } |
| 7556 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7557 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 7558 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 7559 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active == false) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7560 | |
| 7561 | continue; |
| 7562 | } |
| 7563 | |
| 7564 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 7565 | adapter->prev_tx_packets); |
| 7566 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 7567 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7568 | |
| 7569 | if (adapter->device_mode == QDF_SAP_MODE || |
| 7570 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 7571 | adapter->device_mode == QDF_IBSS_MODE) { |
| 7572 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 7573 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 7574 | cds_get_context(QDF_MODULE_ID_SOC), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7575 | adapter->session_id, |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7576 | &fwd_tx_packets, &fwd_rx_packets); |
| 7577 | if (ret == A_OK) { |
| 7578 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 7579 | fwd_tx_packets, |
| 7580 | adapter->prev_fwd_tx_packets); |
| 7581 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 7582 | fwd_tx_packets, |
| 7583 | adapter->prev_fwd_rx_packets); |
| 7584 | } |
| 7585 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7586 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7587 | if (adapter->device_mode == QDF_SAP_MODE) |
| 7588 | con_sap_adapter = adapter; |
| 7589 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7590 | total_rx += adapter->stats.rx_packets; |
| 7591 | total_tx += adapter->stats.tx_packets; |
| 7592 | |
| 7593 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 7594 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 7595 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7596 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 7597 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7598 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 7599 | connected = true; |
| 7600 | } |
| 7601 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7602 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7603 | hdd_err("bus bandwidth timer running in disconnected state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7604 | return; |
| 7605 | } |
| 7606 | |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7607 | /* add intra bss forwarded tx and rx packets */ |
| 7608 | tx_packets += fwd_tx_packets_diff; |
| 7609 | rx_packets += fwd_rx_packets_diff; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7610 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 7611 | if (ucfg_ipa_is_fw_wdi_activated(hdd_ctx->pdev)) { |
| 7612 | ucfg_ipa_uc_stat_query(hdd_ctx->pdev, &ipa_tx_packets, |
| 7613 | &ipa_rx_packets); |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7614 | tx_packets += (uint64_t)ipa_tx_packets; |
| 7615 | rx_packets += (uint64_t)ipa_rx_packets; |
| 7616 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7617 | if (con_sap_adapter) { |
| 7618 | con_sap_adapter->stats.tx_packets += ipa_tx_packets; |
| 7619 | con_sap_adapter->stats.rx_packets += ipa_rx_packets; |
| 7620 | } |
| 7621 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 7622 | ucfg_ipa_set_perf_level(hdd_ctx->pdev, tx_packets, rx_packets); |
| 7623 | ucfg_ipa_uc_stat_request(hdd_ctx->pdev, 2); |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7624 | } |
| 7625 | |
| 7626 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7627 | |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7628 | restart_timer: |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 7629 | /* ensure periodic timer should still be running before restarting it */ |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7630 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 7631 | if (hdd_ctx->bus_bw_timer_running) |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 7632 | qdf_timer_mod(&hdd_ctx->bus_bw_timer, |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7633 | hdd_ctx->config->bus_bw_compute_interval); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7634 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7635 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7636 | |
Rajeev Kumar | b2b5e69 | 2018-08-31 15:12:40 -0700 | [diff] [blame] | 7637 | static void hdd_bus_bw_work_handler(struct work_struct *work) |
| 7638 | { |
| 7639 | cds_ssr_protect(__func__); |
| 7640 | __hdd_bus_bw_work_handler(work); |
| 7641 | cds_ssr_unprotect(__func__); |
| 7642 | } |
| 7643 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7644 | /** |
| 7645 | * __hdd_bus_bw_cbk() - Bus bandwidth data structure callback. |
| 7646 | * @arg: Argument of timer function |
| 7647 | * |
| 7648 | * Schedule a workqueue in this function where all the processing is done. |
| 7649 | * |
| 7650 | * Return: None. |
| 7651 | */ |
| 7652 | static void __hdd_bus_bw_cbk(void *arg) |
| 7653 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7654 | struct hdd_context *hdd_ctx = (struct hdd_context *) arg; |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7655 | |
| 7656 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7657 | return; |
| 7658 | |
| 7659 | schedule_work(&hdd_ctx->bus_bw_work); |
| 7660 | } |
| 7661 | |
| 7662 | /** |
| 7663 | * hdd_bus_bw_cbk() - Wrapper for bus bw callback for SSR protection. |
| 7664 | * @arg: Argument of timer function |
| 7665 | * |
| 7666 | * Return: None. |
| 7667 | */ |
| 7668 | static void hdd_bus_bw_cbk(void *arg) |
| 7669 | { |
| 7670 | cds_ssr_protect(__func__); |
| 7671 | __hdd_bus_bw_cbk(arg); |
| 7672 | cds_ssr_unprotect(__func__); |
| 7673 | } |
| 7674 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7675 | int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7676 | { |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 7677 | hdd_enter(); |
| 7678 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7679 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 7680 | INIT_WORK(&hdd_ctx->bus_bw_work, hdd_bus_bw_work_handler); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7681 | hdd_ctx->bus_bw_timer_running = false; |
| 7682 | qdf_spinlock_create(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 7683 | qdf_timer_init(NULL, &hdd_ctx->bus_bw_timer, hdd_bus_bw_cbk, |
| 7684 | (void *)hdd_ctx, QDF_TIMER_TYPE_SW); |
| 7685 | |
| 7686 | hdd_exit(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7687 | |
| 7688 | return 0; |
| 7689 | } |
| 7690 | |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 7691 | void hdd_bus_bandwidth_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7692 | { |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 7693 | hdd_enter(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7694 | |
Rajeev Kumar | c27efb6 | 2018-08-31 14:21:22 -0700 | [diff] [blame] | 7695 | QDF_BUG(!hdd_ctx->bus_bw_timer_running); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 7696 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7697 | qdf_timer_free(&hdd_ctx->bus_bw_timer); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7698 | qdf_spinlock_destroy(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 7699 | |
| 7700 | hdd_exit(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7701 | } |
Lin Bai | c5c0688 | 2017-09-21 13:58:43 +0800 | [diff] [blame] | 7702 | |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 7703 | #endif /* MSM_PLATFORM */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7704 | |
| 7705 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7706 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 7707 | * @hdd_ctx: hdd context |
| 7708 | * |
| 7709 | * Return: 0 for success or error code |
| 7710 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7711 | 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] | 7712 | { |
| 7713 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 7714 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
| 7715 | if (hdd_ctx->hdd_txrx_hist == NULL) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7716 | hdd_err("Failed malloc for hdd_txrx_hist"); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7717 | return -ENOMEM; |
| 7718 | } |
| 7719 | return 0; |
| 7720 | } |
| 7721 | |
| 7722 | /** |
| 7723 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 7724 | * @hdd_ctx: hdd context |
| 7725 | * |
| 7726 | * Return: none |
| 7727 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7728 | void wlan_hdd_deinit_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7729 | { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7730 | if (!hdd_ctx || hdd_ctx->hdd_txrx_hist == NULL) |
| 7731 | return; |
| 7732 | |
| 7733 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 7734 | hdd_ctx->hdd_txrx_hist = NULL; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7735 | } |
| 7736 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7737 | static uint8_t *convert_level_to_string(uint32_t level) |
| 7738 | { |
| 7739 | switch (level) { |
| 7740 | /* initialize the wlan sub system */ |
| 7741 | case WLAN_SVC_TP_NONE: |
| 7742 | return "NONE"; |
| 7743 | case WLAN_SVC_TP_LOW: |
| 7744 | return "LOW"; |
| 7745 | case WLAN_SVC_TP_MEDIUM: |
| 7746 | return "MED"; |
| 7747 | case WLAN_SVC_TP_HIGH: |
| 7748 | return "HIGH"; |
| 7749 | default: |
| 7750 | return "INVAL"; |
| 7751 | } |
| 7752 | } |
| 7753 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7754 | |
| 7755 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7756 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 7757 | * @hdd_ctx: hdd context |
| 7758 | * |
| 7759 | * Return: none |
| 7760 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7761 | void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7762 | { |
| 7763 | int i; |
| 7764 | |
| 7765 | #ifdef MSM_PLATFORM |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 7766 | hdd_nofl_info("BW compute Interval: %dms", |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7767 | hdd_ctx->config->bus_bw_compute_interval); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 7768 | 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] | 7769 | hdd_ctx->config->bus_bw_high_threshold, |
| 7770 | hdd_ctx->config->bus_bw_medium_threshold, |
| 7771 | hdd_ctx->config->bus_bw_low_threshold); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 7772 | hdd_nofl_info("Enable TCP DEL ACK: %d", |
| 7773 | hdd_ctx->en_tcp_delack_no_lro); |
| 7774 | hdd_nofl_info("TCP DEL High TH: %d TCP DEL Low TH: %d", |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7775 | hdd_ctx->config->tcp_delack_thres_high, |
| 7776 | hdd_ctx->config->tcp_delack_thres_low); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 7777 | hdd_nofl_info("TCP TX HIGH TP TH: %d (Use to set tcp_output_bytes_limit)", |
| 7778 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7779 | #endif |
| 7780 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 7781 | hdd_nofl_info("Total entries: %d Current index: %d", |
| 7782 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7783 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 7784 | 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] | 7785 | |
| 7786 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7787 | /* using hdd_log to avoid printing function name */ |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7788 | if (hdd_ctx->hdd_txrx_hist[i].qtime > 0) |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 7789 | hdd_nofl_info("[%3d][%15llu]: %6llu, %6llu, %s, %s, %s", |
| 7790 | i, hdd_ctx->hdd_txrx_hist[i].qtime, |
| 7791 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
| 7792 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
| 7793 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7794 | hdd_ctx->hdd_txrx_hist[i]. |
| 7795 | next_vote_level), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 7796 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7797 | hdd_ctx->hdd_txrx_hist[i]. |
| 7798 | next_rx_level), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 7799 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7800 | hdd_ctx->hdd_txrx_hist[i]. |
| 7801 | next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7802 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7803 | } |
| 7804 | |
| 7805 | /** |
| 7806 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 7807 | * @hdd_ctx: hdd context |
| 7808 | * |
| 7809 | * Return: none |
| 7810 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7811 | void wlan_hdd_clear_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7812 | { |
| 7813 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7814 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 7815 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7816 | } |
| 7817 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7818 | /* length of the netif queue log needed per adapter */ |
| 7819 | #define ADAP_NETIFQ_LOG_LEN ((20 * WLAN_REASON_TYPE_MAX) + 50) |
| 7820 | |
| 7821 | /** |
| 7822 | * |
| 7823 | * hdd_display_netif_queue_history_compact() - display compact netifq history |
| 7824 | * @hdd_ctx: hdd context |
| 7825 | * |
| 7826 | * Return: none |
| 7827 | */ |
| 7828 | static void |
| 7829 | hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx) |
| 7830 | { |
| 7831 | int adapter_num = 0; |
| 7832 | int i; |
| 7833 | int bytes_written; |
| 7834 | u32 tbytes; |
| 7835 | qdf_time_t total, pause, unpause, curr_time, delta; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7836 | char temp_str[20 * WLAN_REASON_TYPE_MAX]; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7837 | char *comb_log_str; |
| 7838 | uint32_t comb_log_str_size; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7839 | struct hdd_adapter *adapter = NULL; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7840 | |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 7841 | comb_log_str_size = (ADAP_NETIFQ_LOG_LEN * CSR_ROAM_SESSION_MAX) + 1; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7842 | comb_log_str = qdf_mem_malloc(comb_log_str_size); |
| 7843 | if (!comb_log_str) { |
| 7844 | hdd_err("failed to alloc comb_log_str"); |
| 7845 | return; |
| 7846 | } |
| 7847 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7848 | bytes_written = 0; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7849 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7850 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7851 | curr_time = qdf_system_ticks(); |
| 7852 | total = curr_time - adapter->start_time; |
| 7853 | delta = curr_time - adapter->last_time; |
| 7854 | |
| 7855 | if (adapter->pause_map) { |
| 7856 | pause = adapter->total_pause_time + delta; |
| 7857 | unpause = adapter->total_unpause_time; |
| 7858 | } else { |
| 7859 | unpause = adapter->total_unpause_time + delta; |
| 7860 | pause = adapter->total_pause_time; |
| 7861 | } |
| 7862 | |
| 7863 | tbytes = 0; |
| 7864 | qdf_mem_set(temp_str, 0, sizeof(temp_str)); |
| 7865 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7866 | if (adapter->queue_oper_stats[i].pause_count == 0) |
| 7867 | continue; |
| 7868 | tbytes += |
| 7869 | snprintf( |
| 7870 | &temp_str[tbytes], |
| 7871 | (tbytes >= sizeof(temp_str) ? |
| 7872 | 0 : sizeof(temp_str) - tbytes), |
| 7873 | "%d(%d,%d) ", |
| 7874 | i, |
| 7875 | adapter->queue_oper_stats[i]. |
| 7876 | pause_count, |
| 7877 | adapter->queue_oper_stats[i]. |
| 7878 | unpause_count); |
| 7879 | } |
| 7880 | if (tbytes >= sizeof(temp_str)) |
| 7881 | hdd_warn("log truncated"); |
| 7882 | |
| 7883 | bytes_written += snprintf(&comb_log_str[bytes_written], |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7884 | bytes_written >= comb_log_str_size ? 0 : |
| 7885 | comb_log_str_size - bytes_written, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7886 | "[%d %d] (%d) %u/%ums %s|", |
| 7887 | adapter->session_id, adapter->device_mode, |
| 7888 | adapter->pause_map, |
| 7889 | qdf_system_ticks_to_msecs(pause), |
| 7890 | qdf_system_ticks_to_msecs(total), |
| 7891 | temp_str); |
| 7892 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7893 | adapter_num++; |
| 7894 | } |
| 7895 | |
| 7896 | /* using QDF_TRACE to avoid printing function name */ |
| 7897 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO_LOW, |
| 7898 | "STATS |%s", comb_log_str); |
| 7899 | |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7900 | if (bytes_written >= comb_log_str_size) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7901 | hdd_warn("log string truncated"); |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7902 | |
| 7903 | qdf_mem_free(comb_log_str); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7904 | } |
| 7905 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7906 | /** |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7907 | * wlan_hdd_display_netif_queue_history() - display netif queue history |
Jeff Johnson | 58adbcf | 2017-09-03 08:53:31 -0700 | [diff] [blame] | 7908 | * @hdd_ctx: hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7909 | * |
| 7910 | * Return: none |
| 7911 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7912 | void |
| 7913 | wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx, |
| 7914 | enum qdf_stats_verbosity_level verb_lvl) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7915 | { |
| 7916 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7917 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7918 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7919 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7920 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7921 | if (verb_lvl == QDF_STATS_VERBOSITY_LEVEL_LOW) { |
| 7922 | hdd_display_netif_queue_history_compact(hdd_ctx); |
| 7923 | return; |
| 7924 | } |
| 7925 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7926 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 7927 | hdd_nofl_info("Netif queue operation statistics:"); |
| 7928 | hdd_nofl_info("Session_id %d device mode %d", |
| 7929 | adapter->session_id, adapter->device_mode); |
| 7930 | hdd_nofl_info("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7931 | curr_time = qdf_system_ticks(); |
| 7932 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7933 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7934 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7935 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7936 | unpause = adapter->total_unpause_time; |
| 7937 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7938 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7939 | pause = adapter->total_pause_time; |
| 7940 | } |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 7941 | hdd_nofl_info("Total: %ums Pause: %ums Unpause: %ums", |
| 7942 | qdf_system_ticks_to_msecs(total), |
| 7943 | qdf_system_ticks_to_msecs(pause), |
| 7944 | qdf_system_ticks_to_msecs(unpause)); |
| 7945 | hdd_nofl_info("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7946 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7947 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7948 | qdf_time_t pause_delta = 0; |
| 7949 | |
| 7950 | if (adapter->pause_map & (1 << i)) |
| 7951 | pause_delta = delta; |
| 7952 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7953 | /* using hdd_log to avoid printing function name */ |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 7954 | hdd_nofl_info("%s: %d: %d: %ums", |
| 7955 | hdd_reason_type_to_string(i), |
| 7956 | adapter->queue_oper_stats[i].pause_count, |
| 7957 | adapter->queue_oper_stats[i]. |
| 7958 | unpause_count, |
| 7959 | qdf_system_ticks_to_msecs( |
| 7960 | adapter->queue_oper_stats[i]. |
| 7961 | total_pause_time + pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7962 | } |
| 7963 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 7964 | hdd_nofl_info("Netif queue operation history:"); |
| 7965 | hdd_nofl_info("Total entries: %d current index %d", |
| 7966 | WLAN_HDD_MAX_HISTORY_ENTRY, |
| 7967 | adapter->history_index); |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7968 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 7969 | hdd_nofl_info("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7970 | |
| 7971 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7972 | /* using hdd_log to avoid printing function name */ |
| 7973 | if (adapter->queue_oper_history[i].time == 0) |
| 7974 | continue; |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 7975 | hdd_nofl_info("%d: %u: %s: %s: %x", |
| 7976 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7977 | adapter->queue_oper_history[i].time), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 7978 | hdd_action_type_to_string( |
| 7979 | adapter->queue_oper_history[i]. |
| 7980 | netif_action), |
| 7981 | hdd_reason_type_to_string( |
| 7982 | adapter->queue_oper_history[i]. |
| 7983 | netif_reason), |
| 7984 | adapter->queue_oper_history[i].pause_map); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7985 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7986 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7987 | } |
| 7988 | |
| 7989 | /** |
| 7990 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 7991 | * @hdd_ctx: hdd context |
| 7992 | * |
| 7993 | * Return: none |
| 7994 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7995 | void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7996 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7997 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7998 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7999 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8000 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8001 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8002 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8003 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8004 | adapter->history_index = 0; |
| 8005 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 8006 | adapter->total_pause_time = 0; |
| 8007 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8008 | } |
| 8009 | } |
| 8010 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8011 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 8012 | /** |
| 8013 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 8014 | * @hdd_ctx: hdd global context |
| 8015 | * |
| 8016 | * Return: none |
| 8017 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8018 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8019 | { |
| 8020 | uint8_t i; |
| 8021 | |
| 8022 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 8023 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 8024 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 8025 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 8026 | } |
| 8027 | } |
| 8028 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8029 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8030 | { |
| 8031 | } |
| 8032 | #endif |
| 8033 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8034 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 8035 | /** |
| 8036 | * 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] | 8037 | * @phddctx: struct hdd_context structure pointer |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8038 | * @enable: enable or disable this behaviour |
| 8039 | * |
| 8040 | * Return: int |
| 8041 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8042 | 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] | 8043 | { |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8044 | struct wow_pulse_mode wow_pulse_set_info; |
| 8045 | QDF_STATUS status; |
| 8046 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8047 | hdd_debug("wow pulse enable flag is %d", enable); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8048 | |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 8049 | if (!ucfg_pmo_is_wow_pulse_enabled(phddctx->psoc)) |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8050 | return 0; |
| 8051 | |
| 8052 | /* prepare the request to send to SME */ |
| 8053 | if (enable == true) { |
| 8054 | wow_pulse_set_info.wow_pulse_enable = true; |
| 8055 | wow_pulse_set_info.wow_pulse_pin = |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 8056 | ucfg_pmo_get_wow_pulse_pin(phddctx->psoc); |
| 8057 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8058 | wow_pulse_set_info.wow_pulse_interval_high = |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 8059 | ucfg_pmo_get_wow_pulse_interval_high(phddctx->psoc); |
| 8060 | |
| 8061 | wow_pulse_set_info.wow_pulse_interval_low = |
| 8062 | ucfg_pmo_get_wow_pulse_interval_low(phddctx->psoc); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8063 | } else { |
| 8064 | wow_pulse_set_info.wow_pulse_enable = false; |
| 8065 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 8066 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 8067 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 8068 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8069 | hdd_debug("enable %d pin %d low %d high %d", |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8070 | wow_pulse_set_info.wow_pulse_enable, |
| 8071 | wow_pulse_set_info.wow_pulse_pin, |
| 8072 | wow_pulse_set_info.wow_pulse_interval_low, |
| 8073 | wow_pulse_set_info.wow_pulse_interval_high); |
| 8074 | |
| 8075 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 8076 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8077 | hdd_debug("sme_set_wow_pulse failure!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8078 | return -EIO; |
| 8079 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8080 | hdd_debug("sme_set_wow_pulse success!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8081 | return 0; |
| 8082 | } |
| 8083 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8084 | 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] | 8085 | { |
| 8086 | return 0; |
| 8087 | } |
| 8088 | #endif |
| 8089 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8090 | #ifdef WLAN_FEATURE_FASTPATH |
| 8091 | /** |
| 8092 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 8093 | * @hdd_cfg: hdd config |
| 8094 | * @context: lower layer context |
| 8095 | * |
| 8096 | * Return: none |
| 8097 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8098 | void hdd_enable_fastpath(struct hdd_config *hdd_cfg, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8099 | void *context) |
| 8100 | { |
| 8101 | if (hdd_cfg->fastpath_enable) |
| 8102 | hif_enable_fastpath(context); |
| 8103 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8104 | #endif |
| 8105 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8106 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8107 | /** |
| 8108 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8109 | * @hdd_handle: opaque handle for the hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8110 | * @level: thermal level |
| 8111 | * |
| 8112 | * Change IPA data path to SW path when the thermal throttle level greater |
| 8113 | * than 0, and restore the original data path when throttle level is 0 |
| 8114 | * |
| 8115 | * Return: none |
| 8116 | */ |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8117 | 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] | 8118 | { |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8119 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8120 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8121 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 8122 | if (level > THROTTLE_LEVEL_0) |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 8123 | ucfg_ipa_send_mcc_scc_msg(hdd_ctx->pdev, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8124 | else |
| 8125 | /* restore original concurrency mode */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 8126 | 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] | 8127 | } |
| 8128 | |
| 8129 | /** |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8130 | * hdd_get_safe_channel() - Get safe channel from current regulatory |
| 8131 | * @hdd_ctx: pointer to hdd context |
| 8132 | * @adapter: pointer to softap adapter |
| 8133 | * |
| 8134 | * This function is used to get safe channel from current regulatory valid |
| 8135 | * channels to restart SAP if failed to get safe channel from PCL. |
| 8136 | * |
| 8137 | * Return: Channel number to restart SAP in case of success. In case of any |
| 8138 | * failure, the channel number returned is zero. |
| 8139 | */ |
| 8140 | static uint8_t |
| 8141 | hdd_get_safe_channel(struct hdd_context *hdd_ctx, |
| 8142 | struct hdd_adapter *adapter) |
| 8143 | { |
| 8144 | struct sir_pcl_list pcl = {0}; |
| 8145 | uint32_t i, j; |
| 8146 | bool found = false; |
| 8147 | int ret; |
| 8148 | |
| 8149 | /* Try for safe channel from all valid channel */ |
| 8150 | pcl.pcl_len = MAX_NUM_CHAN; |
| 8151 | ret = hdd_get_valid_chan(hdd_ctx, pcl.pcl_list, |
| 8152 | &pcl.pcl_len); |
| 8153 | if (ret) { |
| 8154 | hdd_err("error %d in getting valid channel list", ret); |
| 8155 | return INVALID_CHANNEL_ID; |
| 8156 | } |
| 8157 | |
| 8158 | for (i = 0; i < pcl.pcl_len; i++) { |
| 8159 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
| 8160 | found = false; |
| 8161 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
| 8162 | if (pcl.pcl_list[i] == |
| 8163 | hdd_ctx->unsafe_channel_list[j]) { |
| 8164 | hdd_debug("unsafe chan:%d", pcl.pcl_list[i]); |
| 8165 | found = true; |
| 8166 | break; |
| 8167 | } |
| 8168 | } |
| 8169 | |
| 8170 | if (found) |
| 8171 | continue; |
| 8172 | |
| 8173 | if ((pcl.pcl_list[i] >= |
| 8174 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
| 8175 | (pcl.pcl_list[i] <= |
| 8176 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
| 8177 | hdd_debug("found safe chan:%d", pcl.pcl_list[i]); |
| 8178 | return pcl.pcl_list[i]; |
| 8179 | } |
| 8180 | } |
| 8181 | |
| 8182 | return INVALID_CHANNEL_ID; |
| 8183 | } |
| 8184 | |
| 8185 | #else |
| 8186 | /** |
| 8187 | * hdd_set_thermal_level_cb() - set thermal level callback function |
| 8188 | * @hdd_handle: opaque handle for the hdd context |
| 8189 | * @level: thermal level |
| 8190 | * |
| 8191 | * Change IPA data path to SW path when the thermal throttle level greater |
| 8192 | * than 0, and restore the original data path when throttle level is 0 |
| 8193 | * |
| 8194 | * Return: none |
| 8195 | */ |
| 8196 | static void hdd_set_thermal_level_cb(hdd_handle_t hdd_handle, u_int8_t level) |
| 8197 | { |
| 8198 | } |
| 8199 | |
| 8200 | /** |
| 8201 | * hdd_get_safe_channel() - Get safe channel from current regulatory |
| 8202 | * @hdd_ctx: pointer to hdd context |
| 8203 | * @adapter: pointer to softap adapter |
| 8204 | * |
| 8205 | * This function is used to get safe channel from current regulatory valid |
| 8206 | * channels to restart SAP if failed to get safe channel from PCL. |
| 8207 | * |
| 8208 | * Return: Channel number to restart SAP in case of success. In case of any |
| 8209 | * failure, the channel number returned is zero. |
| 8210 | */ |
| 8211 | static uint8_t |
| 8212 | hdd_get_safe_channel(struct hdd_context *hdd_ctx, |
| 8213 | struct hdd_adapter *adapter) |
| 8214 | { |
| 8215 | return 0; |
| 8216 | } |
| 8217 | #endif |
| 8218 | |
| 8219 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8220 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 8221 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 8222 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8223 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8224 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 8225 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 8226 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8227 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8228 | * Return: Channel number to restart SAP in case of success. In case of any |
| 8229 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8230 | */ |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8231 | static uint8_t |
| 8232 | 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] | 8233 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8234 | struct sir_pcl_list pcl; |
| 8235 | QDF_STATUS status; |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8236 | uint32_t i; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8237 | mac_handle_t mac_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8238 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8239 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8240 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8241 | if (!hdd_ctx) { |
| 8242 | hdd_err("invalid HDD context"); |
| 8243 | return INVALID_CHANNEL_ID; |
| 8244 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8245 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8246 | mac_handle = hdd_ctx->mac_handle; |
| 8247 | if (!mac_handle) { |
| 8248 | hdd_err("invalid MAC handle"); |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 8249 | return INVALID_CHANNEL_ID; |
| 8250 | } |
| 8251 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 8252 | status = policy_mgr_get_pcl_for_existing_conn(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8253 | PM_SAP_MODE, pcl.pcl_list, &pcl.pcl_len, |
bings | 37bd58f | 2017-07-20 16:49:26 +0800 | [diff] [blame] | 8254 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list), |
| 8255 | false); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8256 | if (QDF_IS_STATUS_ERROR(status)) { |
| 8257 | hdd_err("Get PCL failed"); |
| 8258 | return INVALID_CHANNEL_ID; |
| 8259 | } |
| 8260 | |
Frank Liu | dc2cefb | 2017-06-21 15:38:18 +0800 | [diff] [blame] | 8261 | /* |
| 8262 | * In some scenarios, like hw dbs disabled, sap+sap case, if operating |
| 8263 | * channel is unsafe channel, the pcl may be empty, instead of return, |
| 8264 | * try to choose a safe channel from acs range. |
| 8265 | */ |
| 8266 | if (!pcl.pcl_len) |
| 8267 | hdd_debug("pcl length is zero!"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8268 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8269 | hdd_debug("start:%d end:%d", |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8270 | adapter->session.ap.sap_config.acs_cfg.start_ch, |
| 8271 | adapter->session.ap.sap_config.acs_cfg.end_ch); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8272 | |
| 8273 | /* PCL already takes unsafe channel into account */ |
| 8274 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8275 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8276 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8277 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8278 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8279 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8280 | hdd_debug("found PCL safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8281 | return pcl.pcl_list[i]; |
| 8282 | } |
| 8283 | } |
| 8284 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8285 | hdd_debug("no safe channel from PCL found in ACS range"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8286 | |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8287 | return hdd_get_safe_channel(hdd_ctx, adapter); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8288 | } |
| 8289 | |
| 8290 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8291 | * hdd_switch_sap_channel() - Move SAP to the given channel |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8292 | * @adapter: AP adapter |
| 8293 | * @channel: Channel |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8294 | * @forced: Force to switch channel, ignore SCC/MCC check |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8295 | * |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8296 | * Moves the SAP interface by invoking the function which |
| 8297 | * executes the callback to perform channel switch using (E)CSA. |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8298 | * |
| 8299 | * Return: None |
| 8300 | */ |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8301 | void hdd_switch_sap_channel(struct hdd_adapter *adapter, uint8_t channel, |
| 8302 | bool forced) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8303 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 8304 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8305 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8306 | mac_handle_t mac_handle; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8307 | |
| 8308 | if (!adapter) { |
| 8309 | hdd_err("invalid adapter"); |
| 8310 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8311 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8312 | |
| 8313 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 8314 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8315 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 8316 | if (!mac_handle) { |
| 8317 | hdd_err("invalid MAC handle"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8318 | return; |
| 8319 | } |
| 8320 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8321 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8322 | |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 8323 | hdd_ap_ctx->sap_config.channel = channel; |
Himanshu Agarwal | f5c5b10 | 2018-05-22 20:13:57 +0530 | [diff] [blame] | 8324 | hdd_ap_ctx->sap_config.ch_params.ch_width = CH_WIDTH_MAX; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8325 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8326 | hdd_debug("chan:%d width:%d", |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 8327 | channel, hdd_ap_ctx->sap_config.ch_width_orig); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8328 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 8329 | wlan_reg_set_channel_params(hdd_ctx->pdev, |
| 8330 | hdd_ap_ctx->sap_config.channel, |
| 8331 | hdd_ap_ctx->sap_config.sec_ch, |
| 8332 | &hdd_ap_ctx->sap_config.ch_params); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8333 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 8334 | policy_mgr_change_sap_channel_with_csa(hdd_ctx->psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 8335 | adapter->session_id, channel, |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8336 | hdd_ap_ctx->sap_config.ch_width_orig, forced); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8337 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8338 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8339 | 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] | 8340 | { |
| 8341 | struct hdd_external_acs_timer_context *timer_context; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8342 | int status; |
| 8343 | QDF_STATUS qdf_status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8344 | |
| 8345 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 8346 | |
| 8347 | if (QDF_TIMER_STATE_RUNNING == |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8348 | qdf_mc_timer_get_current_state(&adapter->session. |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8349 | ap.vendor_acs_timer)) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8350 | qdf_mc_timer_stop(&adapter->session.ap.vendor_acs_timer); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8351 | } |
| 8352 | timer_context = (struct hdd_external_acs_timer_context *) |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8353 | adapter->session.ap.vendor_acs_timer.user_data; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8354 | timer_context->reason = reason; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8355 | qdf_status = |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8356 | qdf_mc_timer_start(&adapter->session.ap.vendor_acs_timer, |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8357 | WLAN_VENDOR_ACS_WAIT_TIME); |
| 8358 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 8359 | hdd_err("failed to start external acs timer"); |
| 8360 | return -ENOSPC; |
| 8361 | } |
| 8362 | /* Update config to application */ |
| 8363 | status = hdd_cfg80211_update_acs_config(adapter, reason); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 8364 | hdd_info("Updated ACS config to nl with reason %d", reason); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8365 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8366 | return status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8367 | } |
| 8368 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8369 | #if defined(FEATURE_WLAN_CH_AVOID) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8370 | /** |
| 8371 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 8372 | * @hdd_ctx: hdd context pointer |
| 8373 | * |
| 8374 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 8375 | * and if ACS is enabled, driver will ask userspace to restart the |
| 8376 | * sap. User space on LTE coex indication restart driver. |
| 8377 | * |
| 8378 | * Return - none |
| 8379 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8380 | void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8381 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8382 | struct hdd_adapter *adapter; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8383 | uint32_t i; |
| 8384 | bool found = false; |
| 8385 | uint8_t restart_chan; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 8386 | bool value; |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 8387 | QDF_STATUS status; |
| 8388 | bool is_acs_support_for_dfs_ltecoex = cfg_default(CFG_USER_ACS_DFS_LTE); |
| 8389 | bool is_vendor_acs_support = |
| 8390 | cfg_default(CFG_USER_AUTO_CHANNEL_SELECTION); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8391 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8392 | hdd_for_each_adapter(hdd_ctxt, adapter) { |
| 8393 | if (!(adapter->device_mode == QDF_SAP_MODE && |
| 8394 | adapter->session.ap.sap_config.acs_cfg.acs_mode)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8395 | hdd_debug("skip device mode:%d acs:%d", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8396 | adapter->device_mode, |
| 8397 | adapter->session.ap.sap_config. |
| 8398 | acs_cfg.acs_mode); |
| 8399 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8400 | } |
| 8401 | |
| 8402 | found = false; |
Tushnim Bhattacharyya | d2e085d | 2018-06-18 11:58:50 -0700 | [diff] [blame] | 8403 | /* |
| 8404 | * If STA+SAP is doing SCC & g_sta_sap_scc_on_lte_coex_chan |
| 8405 | * is set, no need to move SAP. |
| 8406 | */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 8407 | if (policy_mgr_is_sta_sap_scc(hdd_ctxt->psoc, |
Tushnim Bhattacharyya | d2e085d | 2018-06-18 11:58:50 -0700 | [diff] [blame] | 8408 | adapter->session.ap.operating_channel) && |
| 8409 | hdd_ctxt->config->sta_sap_scc_on_lte_coex_chan) |
| 8410 | hdd_debug("SAP is allowed on SCC channel, no need to move SAP"); |
| 8411 | else { |
| 8412 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
| 8413 | if (adapter->session.ap.operating_channel == |
| 8414 | hdd_ctxt->unsafe_channel_list[i]) { |
| 8415 | found = true; |
| 8416 | hdd_debug("operating ch:%d is unsafe", |
| 8417 | adapter->session.ap.operating_channel); |
| 8418 | break; |
| 8419 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8420 | } |
| 8421 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8422 | if (!found) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8423 | hdd_debug("ch:%d is safe. no need to change channel", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8424 | adapter->session.ap.operating_channel); |
| 8425 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8426 | } |
| 8427 | |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 8428 | status = ucfg_mlme_get_acs_support_for_dfs_ltecoex( |
| 8429 | hdd_ctxt->psoc, |
| 8430 | &is_acs_support_for_dfs_ltecoex); |
| 8431 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8432 | hdd_err("get_acs_support_for_dfs_ltecoex failed,set def"); |
| 8433 | |
| 8434 | status = ucfg_mlme_get_vendor_acs_support( |
| 8435 | hdd_ctxt->psoc, |
| 8436 | &is_vendor_acs_support); |
| 8437 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8438 | hdd_err("get_vendor_acs_support failed, set default"); |
| 8439 | |
| 8440 | if (is_vendor_acs_support && is_acs_support_for_dfs_ltecoex) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8441 | hdd_update_acs_timer_reason(adapter, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8442 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8443 | continue; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8444 | } else |
| 8445 | restart_chan = |
| 8446 | hdd_get_safe_channel_from_pcl_and_acs_range( |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8447 | adapter); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8448 | if (!restart_chan) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8449 | hdd_err("fail to restart SAP"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8450 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8451 | /* |
| 8452 | * SAP restart due to unsafe channel. While |
| 8453 | * restarting the SAP, make sure to clear |
| 8454 | * acs_channel, channel to reset to |
| 8455 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8456 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8457 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8458 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8459 | hdd_debug("sending coex indication"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8460 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 8461 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 8462 | ucfg_mlme_get_sap_internal_restart(hdd_ctxt->psoc, |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 8463 | &value); |
| 8464 | hdd_debug("driver to start sap: %d", value); |
| 8465 | if (value) |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8466 | hdd_switch_sap_channel(adapter, restart_chan, |
| 8467 | true); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 8468 | else |
| 8469 | return; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8470 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8471 | } |
| 8472 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 8473 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8474 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8475 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 8476 | * @hdd_ctx: HDD global context |
| 8477 | * |
| 8478 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8479 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8480 | * down to the lower layers. Then subscribe to subsequent channel |
| 8481 | * avoidance events. |
| 8482 | * |
| 8483 | * Return: None |
| 8484 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8485 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8486 | { |
| 8487 | uint16_t unsafe_channel_count; |
| 8488 | int index; |
| 8489 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8490 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 8491 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8492 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8493 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8494 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8495 | hdd_debug("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8496 | hdd_ctx->unsafe_channel_count); |
| 8497 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8498 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8499 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8500 | |
| 8501 | for (index = 0; index < unsafe_channel_count; index++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8502 | hdd_debug("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8503 | hdd_ctx->unsafe_channel_list[index]); |
| 8504 | |
| 8505 | } |
| 8506 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8507 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8508 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8509 | static void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8510 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8511 | { |
| 8512 | uint8_t restart_chan; |
| 8513 | |
| 8514 | restart_chan = hdd_get_safe_channel_from_pcl_and_acs_range(adapter); |
| 8515 | if (!restart_chan) { |
| 8516 | hdd_alert("fail to restart SAP"); |
| 8517 | return; |
| 8518 | } |
| 8519 | |
| 8520 | /* SAP restart due to unsafe channel. While restarting |
| 8521 | * the SAP, make sure to clear acs_channel, channel to |
| 8522 | * reset to 0. Otherwise these settings will override |
| 8523 | * the ACS while restart. |
| 8524 | */ |
| 8525 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8526 | |
| 8527 | hdd_debug("sending coex indication"); |
| 8528 | |
| 8529 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 8530 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8531 | hdd_switch_sap_channel(adapter, restart_chan, true); |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8532 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8533 | |
| 8534 | int hdd_clone_local_unsafe_chan(struct hdd_context *hdd_ctx, |
| 8535 | uint16_t **local_unsafe_list, uint16_t *local_unsafe_list_count) |
| 8536 | { |
| 8537 | uint32_t size; |
| 8538 | uint16_t *unsafe_list; |
| 8539 | uint16_t chan_count; |
| 8540 | |
| 8541 | if (!hdd_ctx || !local_unsafe_list_count || !local_unsafe_list_count) |
| 8542 | return -EINVAL; |
| 8543 | |
| 8544 | chan_count = QDF_MIN(hdd_ctx->unsafe_channel_count, |
| 8545 | NUM_CHANNELS); |
| 8546 | if (chan_count) { |
| 8547 | size = chan_count * sizeof(hdd_ctx->unsafe_channel_list[0]); |
| 8548 | unsafe_list = qdf_mem_malloc(size); |
| 8549 | if (!unsafe_list) { |
| 8550 | hdd_err("No memory for unsafe chan list size%d", |
| 8551 | size); |
| 8552 | return -ENOMEM; |
| 8553 | } |
| 8554 | qdf_mem_copy(unsafe_list, hdd_ctx->unsafe_channel_list, size); |
| 8555 | } else { |
| 8556 | unsafe_list = NULL; |
| 8557 | } |
| 8558 | |
| 8559 | *local_unsafe_list = unsafe_list; |
| 8560 | *local_unsafe_list_count = chan_count; |
| 8561 | |
| 8562 | return 0; |
| 8563 | } |
| 8564 | |
| 8565 | bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx, |
| 8566 | uint16_t *local_unsafe_list, uint16_t local_unsafe_list_count) |
| 8567 | { |
| 8568 | int i, j; |
| 8569 | |
| 8570 | if (local_unsafe_list_count != hdd_ctx->unsafe_channel_count) |
| 8571 | return true; |
| 8572 | if (local_unsafe_list_count == 0) |
| 8573 | return false; |
| 8574 | for (i = 0; i < local_unsafe_list_count; i++) { |
| 8575 | for (j = 0; j < local_unsafe_list_count; j++) |
| 8576 | if (local_unsafe_list[i] == |
| 8577 | hdd_ctx->unsafe_channel_list[j]) |
| 8578 | break; |
| 8579 | if (j >= local_unsafe_list_count) |
| 8580 | break; |
| 8581 | } |
| 8582 | if (i >= local_unsafe_list_count) { |
| 8583 | hdd_info("unsafe chan list same"); |
| 8584 | return false; |
| 8585 | } |
| 8586 | |
| 8587 | return true; |
| 8588 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8589 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8590 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8591 | { |
| 8592 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8593 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8594 | static inline void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8595 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8596 | { |
| 8597 | hdd_debug("Channel avoidance is not enabled; Abort SAP restart"); |
| 8598 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8599 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8600 | |
| 8601 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8602 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 8603 | * user space |
| 8604 | * @frame_ind: Management frame data to be informed. |
| 8605 | * |
| 8606 | * This function is used to indicate management frame to |
| 8607 | * user space |
| 8608 | * |
| 8609 | * Return: None |
| 8610 | * |
| 8611 | */ |
| 8612 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 8613 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8614 | struct hdd_context *hdd_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8615 | struct hdd_adapter *adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8616 | int i; |
Pragaspathi Thilagaraj | 28ffc04 | 2018-07-18 15:19:36 +0530 | [diff] [blame] | 8617 | struct ieee80211_mgmt *mgmt = |
| 8618 | (struct ieee80211_mgmt *)frame_ind->frameBuf; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8619 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 8620 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 8621 | if (wlan_hdd_validate_context(hdd_ctx)) |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8622 | return; |
| 8623 | |
Pragaspathi Thilagaraj | 28ffc04 | 2018-07-18 15:19:36 +0530 | [diff] [blame] | 8624 | if (frame_ind->frame_len < ieee80211_hdrlen(mgmt->frame_control)) { |
| 8625 | hdd_err(" Invalid frame length"); |
| 8626 | return; |
| 8627 | } |
| 8628 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8629 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
| 8630 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 8631 | adapter = |
| 8632 | hdd_get_adapter_by_sme_session_id(hdd_ctx, i); |
| 8633 | if (adapter) |
| 8634 | break; |
| 8635 | } |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 8636 | } else if (SME_SESSION_ID_BROADCAST == frame_ind->sessionId) { |
| 8637 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 8638 | if ((NULL != adapter) && |
| 8639 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) { |
| 8640 | __hdd_indicate_mgmt_frame(adapter, |
| 8641 | frame_ind->frame_len, |
| 8642 | frame_ind->frameBuf, |
| 8643 | frame_ind->frameType, |
| 8644 | frame_ind->rxChan, |
| 8645 | frame_ind->rxRssi); |
| 8646 | } |
| 8647 | } |
| 8648 | adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8649 | } else { |
| 8650 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 8651 | frame_ind->sessionId); |
| 8652 | } |
| 8653 | |
| 8654 | if ((NULL != adapter) && |
| 8655 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 8656 | __hdd_indicate_mgmt_frame(adapter, |
| 8657 | frame_ind->frame_len, |
| 8658 | frame_ind->frameBuf, |
| 8659 | frame_ind->frameType, |
| 8660 | frame_ind->rxChan, |
| 8661 | frame_ind->rxRssi); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8662 | } |
| 8663 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8664 | void hdd_acs_response_timeout_handler(void *context) |
| 8665 | { |
| 8666 | struct hdd_external_acs_timer_context *timer_context = |
| 8667 | (struct hdd_external_acs_timer_context *)context; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8668 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8669 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8670 | uint8_t reason; |
| 8671 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8672 | hdd_enter(); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8673 | if (!timer_context) { |
| 8674 | hdd_err("invlaid timer context"); |
| 8675 | return; |
| 8676 | } |
| 8677 | adapter = timer_context->adapter; |
| 8678 | reason = timer_context->reason; |
| 8679 | |
| 8680 | |
| 8681 | if ((!adapter) || |
| 8682 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 8683 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 8684 | return; |
| 8685 | } |
| 8686 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8687 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 8688 | return; |
| 8689 | |
| 8690 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 8691 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 8692 | else |
| 8693 | return; |
| 8694 | |
| 8695 | hdd_err("ACS timeout happened for %s reason %d", |
| 8696 | adapter->dev->name, reason); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8697 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8698 | switch (reason) { |
| 8699 | /* SAP init case */ |
| 8700 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 8701 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 8702 | false); |
| 8703 | wlan_hdd_cfg80211_start_acs(adapter); |
| 8704 | break; |
| 8705 | /* DFS detected on current channel */ |
| 8706 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 8707 | wlan_sap_update_next_channel( |
| 8708 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8709 | sme_update_new_channel_event(hdd_ctx->mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 8710 | adapter->session_id); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8711 | break; |
| 8712 | /* LTE coex event on current channel */ |
| 8713 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 8714 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 8715 | break; |
| 8716 | default: |
| 8717 | hdd_info("invalid reason for timer invoke"); |
| 8718 | |
| 8719 | } |
| 8720 | } |
| 8721 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8722 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8723 | * hdd_override_ini_config - Override INI config |
| 8724 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8725 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8726 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8727 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8728 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8729 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8730 | static void hdd_override_ini_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8731 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8732 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8733 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
| 8734 | hdd_ctx->config->enableDFSChnlScan = enable_dfs_chan_scan; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8735 | hdd_debug("Module enable_dfs_chan_scan set to %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8736 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8737 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8738 | if (0 == enable_11d || 1 == enable_11d) { |
| 8739 | hdd_ctx->config->Is11dSupportEnabled = enable_11d; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8740 | hdd_debug("Module enable_11d set to %d", enable_11d); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8741 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 8742 | |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 8743 | if (hdd_ctx->config->action_oui_enable && !ucfg_action_oui_enabled()) { |
| 8744 | hdd_ctx->config->action_oui_enable = 0; |
| 8745 | hdd_err("Ignore ini: %s, since no action_oui component", |
| 8746 | CFG_ENABLE_ACTION_OUI); |
| 8747 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8748 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8749 | |
Ashish Kumar Dhanotiya | 12f6821 | 2018-09-04 22:00:14 +0530 | [diff] [blame] | 8750 | #ifdef ENABLE_MTRACE_LOG |
| 8751 | static void hdd_set_mtrace_for_each(struct hdd_context *hdd_ctx) |
| 8752 | { |
| 8753 | uint8_t module_id = 0; |
| 8754 | int qdf_print_idx = -1; |
| 8755 | |
| 8756 | qdf_print_idx = qdf_get_pidx(); |
| 8757 | for (module_id = 0; module_id < QDF_MODULE_ID_MAX; module_id++) |
| 8758 | qdf_print_set_category_verbose( |
| 8759 | qdf_print_idx, |
| 8760 | module_id, QDF_TRACE_LEVEL_TRACE, |
| 8761 | hdd_ctx->config->enable_mtrace); |
| 8762 | } |
| 8763 | #else |
| 8764 | static void hdd_set_mtrace_for_each(struct hdd_context *hdd_ctx) |
| 8765 | { |
| 8766 | } |
| 8767 | |
| 8768 | #endif |
| 8769 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8770 | /** |
| 8771 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 8772 | * @hdd_ctx - HDD context |
| 8773 | * |
| 8774 | * Set trace level for each module based on INI config. |
| 8775 | * |
| 8776 | * Return: None |
| 8777 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8778 | 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] | 8779 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 8780 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMI, |
| 8781 | hdd_ctx->config->qdf_trace_enable_wdi); |
| 8782 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD, |
| 8783 | hdd_ctx->config->qdf_trace_enable_hdd); |
| 8784 | hdd_qdf_trace_enable(QDF_MODULE_ID_SME, |
| 8785 | hdd_ctx->config->qdf_trace_enable_sme); |
| 8786 | hdd_qdf_trace_enable(QDF_MODULE_ID_PE, |
| 8787 | hdd_ctx->config->qdf_trace_enable_pe); |
| 8788 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMA, |
| 8789 | hdd_ctx->config->qdf_trace_enable_wma); |
| 8790 | hdd_qdf_trace_enable(QDF_MODULE_ID_SYS, |
| 8791 | hdd_ctx->config->qdf_trace_enable_sys); |
| 8792 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF, |
| 8793 | hdd_ctx->config->qdf_trace_enable_qdf); |
| 8794 | hdd_qdf_trace_enable(QDF_MODULE_ID_SAP, |
| 8795 | hdd_ctx->config->qdf_trace_enable_sap); |
| 8796 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SOFTAP, |
| 8797 | hdd_ctx->config->qdf_trace_enable_hdd_sap); |
| 8798 | hdd_qdf_trace_enable(QDF_MODULE_ID_BMI, |
| 8799 | hdd_ctx->config->qdf_trace_enable_bmi); |
| 8800 | hdd_qdf_trace_enable(QDF_MODULE_ID_CFG, |
| 8801 | hdd_ctx->config->qdf_trace_enable_cfg); |
| 8802 | hdd_qdf_trace_enable(QDF_MODULE_ID_EPPING, |
| 8803 | hdd_ctx->config->qdf_trace_enable_epping); |
| 8804 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF_DEVICE, |
| 8805 | hdd_ctx->config->qdf_trace_enable_qdf_devices); |
| 8806 | hdd_qdf_trace_enable(QDF_MODULE_ID_TXRX, |
Houston Hoffman | fbf0510 | 2017-08-28 11:37:01 -0700 | [diff] [blame] | 8807 | hdd_ctx->config->qdf_trace_enable_txrx); |
| 8808 | hdd_qdf_trace_enable(QDF_MODULE_ID_DP, |
| 8809 | hdd_ctx->config->qdf_trace_enable_dp); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 8810 | hdd_qdf_trace_enable(QDF_MODULE_ID_HTC, |
| 8811 | hdd_ctx->config->qdf_trace_enable_htc); |
| 8812 | hdd_qdf_trace_enable(QDF_MODULE_ID_HIF, |
| 8813 | hdd_ctx->config->qdf_trace_enable_hif); |
| 8814 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SAP_DATA, |
| 8815 | hdd_ctx->config->qdf_trace_enable_hdd_sap_data); |
| 8816 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_DATA, |
| 8817 | hdd_ctx->config->qdf_trace_enable_hdd_data); |
Naveen Rawat | 7df3186 | 2017-03-01 17:09:30 -0800 | [diff] [blame] | 8818 | hdd_qdf_trace_enable(QDF_MODULE_ID_WIFIPOS, |
| 8819 | hdd_ctx->config->qdf_trace_enable_wifi_pos); |
Naveen Rawat | f2b0dbd | 2017-03-27 10:00:15 -0700 | [diff] [blame] | 8820 | hdd_qdf_trace_enable(QDF_MODULE_ID_NAN, |
| 8821 | hdd_ctx->config->qdf_trace_enable_nan); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 8822 | hdd_qdf_trace_enable(QDF_MODULE_ID_REGULATORY, |
| 8823 | hdd_ctx->config->qdf_trace_enable_regulatory); |
Naveen Rawat | 3cb779e | 2018-02-16 16:36:10 -0800 | [diff] [blame] | 8824 | hdd_qdf_trace_enable(QDF_MODULE_ID_CP_STATS, |
| 8825 | hdd_ctx->config->qdf_trace_enable_cp_stats); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 8826 | hdd_qdf_trace_enable(QDF_MODULE_ID_MLME, 0xffff); |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 8827 | hdd_qdf_trace_enable(QDF_MODULE_ID_FWOL, 0xffff); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 8828 | |
Ashish Kumar Dhanotiya | 12f6821 | 2018-09-04 22:00:14 +0530 | [diff] [blame] | 8829 | hdd_set_mtrace_for_each(hdd_ctx); |
| 8830 | |
Nirav Shah | 5c083da | 2018-08-03 13:46:02 +0530 | [diff] [blame] | 8831 | hdd_cfg_print_global_config(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8832 | } |
| 8833 | |
| 8834 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8835 | * hdd_context_init() - Initialize HDD context |
| 8836 | * @hdd_ctx: HDD context. |
| 8837 | * |
| 8838 | * Initialize HDD context along with all the feature specific contexts. |
| 8839 | * |
| 8840 | * return: 0 on success and errno on failure. |
| 8841 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8842 | static int hdd_context_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8843 | { |
| 8844 | int ret; |
| 8845 | |
| 8846 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 8847 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 8848 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8849 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 8850 | init_completion(&hdd_ctx->ready_to_suspend); |
| 8851 | |
| 8852 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8853 | qdf_spinlock_create(&hdd_ctx->sta_update_info_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8854 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8855 | |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 8856 | qdf_list_create(&hdd_ctx->hdd_adapters, 0); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8857 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8858 | ret = hdd_scan_context_init(hdd_ctx); |
| 8859 | if (ret) |
| 8860 | goto list_destroy; |
| 8861 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8862 | hdd_rx_wake_lock_create(hdd_ctx); |
| 8863 | |
| 8864 | ret = hdd_sap_context_init(hdd_ctx); |
| 8865 | if (ret) |
| 8866 | goto scan_destroy; |
| 8867 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8868 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 8869 | |
| 8870 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 8871 | |
| 8872 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 8873 | hdd_ctx->config); |
| 8874 | if (ret) |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 8875 | goto sap_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8876 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 8877 | qdf_wake_lock_create(&hdd_ctx->monitor_mode_wakelock, |
| 8878 | "monitor_mode_wakelock"); |
| 8879 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8880 | return 0; |
| 8881 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8882 | sap_destroy: |
| 8883 | hdd_sap_context_destroy(hdd_ctx); |
| 8884 | |
| 8885 | scan_destroy: |
| 8886 | hdd_scan_context_destroy(hdd_ctx); |
| 8887 | hdd_rx_wake_lock_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8888 | list_destroy: |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8889 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 8890 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8891 | return ret; |
| 8892 | } |
| 8893 | |
| 8894 | /** |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8895 | * hdd_iface_change_callback() - Function invoked when stop modules expires |
| 8896 | * @priv: pointer to hdd context |
| 8897 | * |
| 8898 | * This function is invoked when the timer waiting for the interface change |
| 8899 | * expires, it shall cut-down the power to wlan and stop all the modules. |
| 8900 | * |
| 8901 | * Return: void |
| 8902 | */ |
| 8903 | static void hdd_iface_change_callback(void *priv) |
| 8904 | { |
| 8905 | struct hdd_context *hdd_ctx = (struct hdd_context *) priv; |
| 8906 | int ret; |
| 8907 | int status = wlan_hdd_validate_context(hdd_ctx); |
| 8908 | |
| 8909 | if (status) |
| 8910 | return; |
| 8911 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8912 | hdd_enter(); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8913 | hdd_debug("Interface change timer expired close the modules!"); |
| 8914 | ret = hdd_wlan_stop_modules(hdd_ctx, false); |
| 8915 | if (ret) |
| 8916 | hdd_err("Failed to stop modules"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8917 | hdd_exit(); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8918 | } |
| 8919 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8920 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 8921 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 8922 | { |
| 8923 | wlan_logging_set_log_to_console(hdd_ctx->config-> |
| 8924 | wlan_logging_to_console); |
| 8925 | wlan_logging_set_active(hdd_ctx->config->wlan_logging_enable); |
| 8926 | } |
| 8927 | #else |
| 8928 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 8929 | { } |
| 8930 | #endif |
| 8931 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 8932 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 8933 | static void hdd_init_wlan_logging_params(struct hdd_config *config, |
| 8934 | struct wlan_objmgr_psoc *psoc) |
| 8935 | { |
| 8936 | config->wlan_logging_enable = cfg_get(psoc, CFG_WLAN_LOGGING_SUPPORT); |
| 8937 | |
| 8938 | config->wlan_logging_to_console = |
| 8939 | cfg_get(psoc, CFG_WLAN_LOGGING_CONSOLE_SUPPORT); |
| 8940 | } |
| 8941 | #else |
| 8942 | static void hdd_init_wlan_logging_params(struct hdd_config *config, |
| 8943 | struct wlan_objmgr_psoc *psoc) |
| 8944 | { |
| 8945 | } |
| 8946 | #endif |
| 8947 | |
| 8948 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 8949 | static void hdd_init_wlan_auto_shutdown(struct hdd_config *config, |
| 8950 | struct wlan_objmgr_psoc *psoc) |
| 8951 | { |
| 8952 | config->wlan_auto_shutdown = cfg_get(psoc, CFG_WLAN_AUTO_SHUTDOWN); |
| 8953 | } |
| 8954 | #else |
| 8955 | static void hdd_init_wlan_auto_shutdown(struct hdd_config *config, |
| 8956 | struct wlan_objmgr_psoc *psoc) |
| 8957 | { |
| 8958 | } |
| 8959 | #endif |
| 8960 | |
| 8961 | #ifndef REMOVE_PKT_LOG |
| 8962 | static void hdd_init_packet_log(struct hdd_config *config, |
| 8963 | struct wlan_objmgr_psoc *psoc) |
| 8964 | { |
| 8965 | config->enable_packet_log = cfg_get(psoc, CFG_ENABLE_PACKET_LOG); |
| 8966 | } |
| 8967 | #else |
| 8968 | static void hdd_init_packet_log(struct hdd_config *config, |
| 8969 | struct wlan_objmgr_psoc *psoc) |
| 8970 | { |
| 8971 | } |
| 8972 | #endif |
| 8973 | |
| 8974 | /** |
| 8975 | * hdd_cfg_params_init() - Initialize hdd params in hdd_config strucuture |
| 8976 | * @hdd_ctx - Pointer to HDD context |
| 8977 | * |
| 8978 | * Return: None |
| 8979 | */ |
| 8980 | static void hdd_cfg_params_init(struct hdd_context *hdd_ctx) |
| 8981 | { |
| 8982 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
| 8983 | struct hdd_config *config = hdd_ctx->config; |
| 8984 | |
| 8985 | if (!psoc) { |
| 8986 | hdd_err("Invalid psoc"); |
| 8987 | return; |
| 8988 | } |
| 8989 | |
| 8990 | if (!config) { |
| 8991 | hdd_err("Invalid hdd config"); |
| 8992 | return; |
| 8993 | } |
| 8994 | |
| 8995 | config->bug_on_reinit_failure = cfg_get(psoc, |
| 8996 | CFG_BUG_ON_REINIT_FAILURE); |
| 8997 | |
| 8998 | config->is_ramdump_enabled = cfg_get(psoc, |
| 8999 | CFG_ENABLE_RAMDUMP_COLLECTION); |
| 9000 | |
| 9001 | config->iface_change_wait_time = cfg_get(psoc, |
| 9002 | CFG_INTERFACE_CHANGE_WAIT); |
| 9003 | |
| 9004 | config->multicast_host_fw_msgs = cfg_get(psoc, |
| 9005 | CFG_MULTICAST_HOST_FW_MSGS); |
| 9006 | |
| 9007 | config->private_wext_control = cfg_get(psoc, CFG_PRIVATE_WEXT_CONTROL); |
| 9008 | config->timer_multiplier = cfg_get(psoc, CFG_TIMER_MULTIPLIER); |
| 9009 | config->enablefwprint = cfg_get(psoc, CFG_ENABLE_FW_UART_PRINT); |
| 9010 | config->enable_fw_log = cfg_get(psoc, CFG_ENABLE_FW_LOG); |
| 9011 | |
| 9012 | hdd_init_wlan_auto_shutdown(config, psoc); |
| 9013 | hdd_init_wlan_logging_params(config, psoc); |
| 9014 | hdd_init_packet_log(config, psoc); |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 9015 | hdd_dp_cfg_update(psoc, hdd_ctx); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9016 | } |
| 9017 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 9018 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9019 | * hdd_context_create() - Allocate and inialize HDD context. |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9020 | * @dev: Device Pointer to the underlying device |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9021 | * |
| 9022 | * Allocate and initialize HDD context. HDD context is allocated as part of |
| 9023 | * wiphy allocation and then context is initialized. |
| 9024 | * |
| 9025 | * Return: HDD context on success and ERR_PTR on failure |
| 9026 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9027 | static struct hdd_context *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9028 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9029 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9030 | int ret = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9031 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9032 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9033 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9034 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9035 | hdd_ctx = hdd_cfg80211_wiphy_alloc(sizeof(struct hdd_context)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9036 | if (hdd_ctx == NULL) { |
| 9037 | ret = -ENOMEM; |
| 9038 | goto err_out; |
| 9039 | } |
| 9040 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 9041 | qdf_create_delayed_work(&hdd_ctx->iface_idle_work, |
| 9042 | hdd_iface_change_callback, |
| 9043 | (void *)hdd_ctx); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9044 | |
| 9045 | mutex_init(&hdd_ctx->iface_change_lock); |
| 9046 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9047 | hdd_ctx->parent_dev = dev; |
Sreelakshmi Konamki | b53c629 | 2017-03-01 13:13:23 +0530 | [diff] [blame] | 9048 | hdd_ctx->last_scan_reject_session_id = 0xFF; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9049 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9050 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9051 | if (hdd_ctx->config == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9052 | hdd_err("Failed to alloc memory for HDD config!"); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9053 | ret = -ENOMEM; |
| 9054 | goto err_free_hdd_context; |
| 9055 | } |
| 9056 | |
| 9057 | /* Read and parse the qcom_cfg.ini file */ |
| 9058 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9059 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9060 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9061 | WLAN_INI_FILE); |
| 9062 | ret = -EINVAL; |
| 9063 | goto err_free_config; |
| 9064 | } |
| 9065 | |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 9066 | status = cfg_parse(WLAN_INI_FILE); |
| 9067 | if (QDF_IS_STATUS_ERROR(status)) |
| 9068 | hdd_err("Failed to parse cfg %s; status:%d\n", |
| 9069 | WLAN_INI_FILE, status); |
| 9070 | |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9071 | ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, DEFAULT_PSOC_ID); |
| 9072 | if (ret) { |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9073 | QDF_DEBUG_PANIC("Psoc creation fails!"); |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9074 | goto err_free_config; |
| 9075 | } |
| 9076 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9077 | hdd_cfg_params_init(hdd_ctx); |
| 9078 | |
Dustin Brown | 7f93993 | 2017-05-18 15:02:17 -0700 | [diff] [blame] | 9079 | hdd_debug("setting timer multiplier: %u", |
| 9080 | hdd_ctx->config->timer_multiplier); |
| 9081 | qdf_timer_set_multiplier(hdd_ctx->config->timer_multiplier); |
| 9082 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9083 | cds_set_fatal_event(cfg_get(hdd_ctx->psoc, |
| 9084 | CFG_ENABLE_FATAL_EVENT_TRIGGER)); |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 9085 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9086 | hdd_override_ini_config(hdd_ctx); |
| 9087 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9088 | ret = hdd_context_init(hdd_ctx); |
| 9089 | |
| 9090 | if (ret) |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9091 | goto err_hdd_objmgr_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9092 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9093 | /* Uses to enabled logging after SSR */ |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 9094 | hdd_ctx->fw_log_settings.enable = hdd_ctx->config->enable_fw_log; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9095 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9096 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9097 | goto skip_multicast_logging; |
| 9098 | |
| 9099 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 9100 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 9101 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 9102 | if (ret) |
| 9103 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 9104 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 9105 | ret = hdd_init_netlink_services(hdd_ctx); |
| 9106 | if (ret) |
| 9107 | goto err_deinit_txrx_histogram; |
| 9108 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 9109 | hdd_set_wlan_logging(hdd_ctx); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 9110 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9111 | skip_multicast_logging: |
| 9112 | hdd_set_trace_level_for_each(hdd_ctx); |
| 9113 | |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 9114 | cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); |
| 9115 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9116 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 9117 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9118 | return hdd_ctx; |
| 9119 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 9120 | err_deinit_txrx_histogram: |
| 9121 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 9122 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 9123 | err_deinit_hdd_context: |
| 9124 | hdd_context_deinit(hdd_ctx); |
| 9125 | |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9126 | err_hdd_objmgr_destroy: |
| 9127 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 9128 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9129 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9130 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9131 | |
| 9132 | err_free_hdd_context: |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9133 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Rajeev Kumar | fa55a69 | 2018-01-09 14:12:41 -0800 | [diff] [blame] | 9134 | wiphy_free(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9135 | |
| 9136 | err_out: |
| 9137 | return ERR_PTR(ret); |
| 9138 | } |
| 9139 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9140 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 9141 | /** |
| 9142 | * hdd_open_p2p_interface - Open P2P interface |
| 9143 | * @hdd_ctx: HDD context |
| 9144 | * @rtnl_held: True if RTNL lock held |
| 9145 | * |
| 9146 | * Open P2P interface during probe. This function called to open the P2P |
| 9147 | * interface at probe along with STA interface. |
| 9148 | * |
| 9149 | * Return: 0 on success and errno on failure |
| 9150 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9151 | static int hdd_open_p2p_interface(struct hdd_context *hdd_ctx, bool rtnl_held) |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9152 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9153 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9154 | uint8_t *p2p_dev_addr; |
Wu Gao | e568979 | 2018-07-05 19:20:13 +0800 | [diff] [blame] | 9155 | bool p2p_dev_addr_admin = false; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9156 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 9157 | cfg_p2p_get_device_addr_admin(hdd_ctx->psoc, &p2p_dev_addr_admin); |
Wu Gao | e568979 | 2018-07-05 19:20:13 +0800 | [diff] [blame] | 9158 | if (p2p_dev_addr_admin && |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9159 | !(hdd_ctx->config->intfMacAddr[0].bytes[0] & 0x02)) { |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 9160 | qdf_mem_copy(hdd_ctx->p2p_device_address.bytes, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9161 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 9162 | sizeof(tSirMacAddr)); |
| 9163 | |
| 9164 | /* |
| 9165 | * Generate the P2P Device Address. This consists of |
| 9166 | * the device's primary MAC address with the locally |
| 9167 | * administered bit set. |
| 9168 | */ |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 9169 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9170 | } else { |
| 9171 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx); |
| 9172 | if (p2p_dev_addr == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9173 | hdd_err("Failed to allocate mac_address for p2p_device"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9174 | return -ENOSPC; |
| 9175 | } |
| 9176 | |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 9177 | qdf_mem_copy(&hdd_ctx->p2p_device_address.bytes[0], |
| 9178 | p2p_dev_addr, QDF_MAC_ADDR_SIZE); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9179 | } |
| 9180 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9181 | adapter = hdd_open_adapter(hdd_ctx, QDF_P2P_DEVICE_MODE, "p2p%d", |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 9182 | &hdd_ctx->p2p_device_address.bytes[0], |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 9183 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9184 | |
| 9185 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9186 | hdd_err("Failed to do hdd_open_adapter for P2P Device Interface"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9187 | return -ENOSPC; |
| 9188 | } |
| 9189 | |
| 9190 | return 0; |
| 9191 | } |
| 9192 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9193 | static inline int hdd_open_p2p_interface(struct hdd_context *hdd_ctx, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9194 | bool rtnl_held) |
| 9195 | { |
| 9196 | return 0; |
| 9197 | } |
| 9198 | #endif |
| 9199 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9200 | static int hdd_open_ocb_interface(struct hdd_context *hdd_ctx, bool rtnl_held) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9201 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9202 | struct hdd_adapter *adapter; |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9203 | int ret = 0; |
| 9204 | |
| 9205 | adapter = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, "wlanocb%d", |
| 9206 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 9207 | NET_NAME_UNKNOWN, rtnl_held); |
| 9208 | if (adapter == NULL) { |
| 9209 | hdd_err("Failed to open 802.11p interface"); |
| 9210 | ret = -ENOSPC; |
| 9211 | } |
| 9212 | |
| 9213 | return ret; |
| 9214 | } |
| 9215 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9216 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9217 | * hdd_start_station_adapter()- Start the Station Adapter |
| 9218 | * @adapter: HDD adapter |
| 9219 | * |
| 9220 | * This function initializes the adapter for the station mode. |
| 9221 | * |
| 9222 | * Return: 0 on success or errno on failure. |
| 9223 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9224 | int hdd_start_station_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9225 | { |
| 9226 | QDF_STATUS status; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9227 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9228 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 9229 | hdd_enter_dev(adapter->dev); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9230 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 9231 | hdd_err("session is already opened, %d", |
| 9232 | adapter->session_id); |
| 9233 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 9234 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9235 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9236 | ret = hdd_vdev_create(adapter, hdd_sme_roam_callback, adapter); |
| 9237 | if (ret) { |
| 9238 | hdd_err("failed to create vdev: %d", ret); |
| 9239 | return ret; |
| 9240 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9241 | status = hdd_init_station_mode(adapter); |
| 9242 | |
| 9243 | if (QDF_STATUS_SUCCESS != status) { |
| 9244 | hdd_err("Error Initializing station mode: %d", status); |
| 9245 | return qdf_status_to_os_return(status); |
| 9246 | } |
| 9247 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9248 | hdd_register_tx_flow_control(adapter, |
| 9249 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 9250 | hdd_tx_resume_cb, |
| 9251 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9252 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9253 | hdd_exit(); |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 9254 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9255 | return 0; |
| 9256 | } |
| 9257 | |
| 9258 | /** |
| 9259 | * hdd_start_ap_adapter()- Start AP Adapter |
| 9260 | * @adapter: HDD adapter |
| 9261 | * |
| 9262 | * This function initializes the adapter for the AP mode. |
| 9263 | * |
| 9264 | * Return: 0 on success errno on failure. |
| 9265 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9266 | int hdd_start_ap_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9267 | { |
| 9268 | QDF_STATUS status; |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9269 | bool is_ssr = false; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9270 | int ret; |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9271 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9272 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9273 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9274 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9275 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 9276 | hdd_err("session is already opened, %d", |
| 9277 | adapter->session_id); |
| 9278 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 9279 | } |
| 9280 | /* |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9281 | * In SSR case no need to create new sap context. |
| 9282 | * Otherwise create sap context first and then create |
| 9283 | * vdev as while creating the vdev, driver needs to |
| 9284 | * register SAP callback and that callback uses sap context |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9285 | */ |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9286 | if (adapter->session.ap.sap_context) { |
| 9287 | is_ssr = true; |
| 9288 | } else if (!hdd_sap_create_ctx(adapter)) { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9289 | hdd_err("sap creation failed"); |
| 9290 | return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); |
| 9291 | } |
| 9292 | |
| 9293 | ret = hdd_vdev_create(adapter, wlansap_roam_callback, |
| 9294 | adapter->session.ap.sap_context); |
| 9295 | if (ret) { |
| 9296 | hdd_err("failed to create vdev, status:%d", ret); |
| 9297 | hdd_sap_destroy_ctx(adapter); |
| 9298 | return ret; |
| 9299 | } |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9300 | |
| 9301 | if (adapter->device_mode == QDF_SAP_MODE) |
| 9302 | sme_cli_set_command(adapter->session_id, |
| 9303 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_RESPONDER_ROLE, |
| 9304 | (bool)(hdd_ctx->config->fine_time_meas_cap & |
| 9305 | WMI_FW_AP_RTT_RESPR), |
| 9306 | VDEV_CMD); |
| 9307 | |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9308 | status = hdd_init_ap_mode(adapter, is_ssr); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9309 | |
| 9310 | if (QDF_STATUS_SUCCESS != status) { |
| 9311 | hdd_err("Error Initializing the AP mode: %d", status); |
| 9312 | return qdf_status_to_os_return(status); |
| 9313 | } |
| 9314 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9315 | hdd_register_tx_flow_control(adapter, |
| 9316 | hdd_softap_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 9317 | hdd_softap_tx_resume_cb, |
| 9318 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9319 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9320 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9321 | return 0; |
| 9322 | } |
| 9323 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 9324 | static int hdd_open_concurrent_interface(struct hdd_context *hdd_ctx, |
| 9325 | bool rtnl_held) |
| 9326 | { |
| 9327 | struct hdd_adapter *adapter; |
| 9328 | |
| 9329 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, |
| 9330 | hdd_ctx->config->enableConcurrentSTA, |
| 9331 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 9332 | NET_NAME_UNKNOWN, rtnl_held); |
| 9333 | |
| 9334 | if (!adapter) |
| 9335 | return -ENOSPC; |
| 9336 | |
| 9337 | return 0; |
| 9338 | } |
| 9339 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9340 | /** |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9341 | * hdd_open_interfaces - Open all required interfaces |
| 9342 | * hdd_ctx: HDD context |
| 9343 | * rtnl_held: True if RTNL lock is held |
| 9344 | * |
| 9345 | * Open all the interfaces like STA, P2P and OCB based on the configuration. |
| 9346 | * |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9347 | * Return: 0 if all interfaces were created, otherwise negative errno |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9348 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9349 | static int hdd_open_interfaces(struct hdd_context *hdd_ctx, bool rtnl_held) |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9350 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9351 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9352 | int ret; |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 9353 | uint8_t dot11p_mode; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9354 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 9355 | /* open monitor mode adapter if con_mode is monitor mode */ |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 9356 | if (con_mode == QDF_GLOBAL_MONITOR_MODE || |
| 9357 | con_mode == QDF_GLOBAL_FTM_MODE) { |
| 9358 | uint8_t session_type = (con_mode == QDF_GLOBAL_MONITOR_MODE) ? |
| 9359 | QDF_MONITOR_MODE : QDF_FTM_MODE; |
| 9360 | |
| 9361 | adapter = hdd_open_adapter(hdd_ctx, session_type, "wlan%d", |
| 9362 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 9363 | NET_NAME_UNKNOWN, rtnl_held); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 9364 | if (!adapter) { |
| 9365 | hdd_err("open adapter failed"); |
| 9366 | return -ENOSPC; |
| 9367 | } |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 9368 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 9369 | return 0; |
| 9370 | } |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 9371 | ucfg_mlme_get_dot11p_mode(hdd_ctx->psoc, &dot11p_mode); |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 9372 | if (dot11p_mode == CFG_11P_STANDALONE) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9373 | /* Create only 802.11p interface */ |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9374 | return hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9375 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9376 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, "wlan%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9377 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 9378 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9379 | |
| 9380 | if (adapter == NULL) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9381 | return -ENOSPC; |
| 9382 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 9383 | if (strlen(hdd_ctx->config->enableConcurrentSTA) != 0) { |
| 9384 | ret = hdd_open_concurrent_interface(hdd_ctx, rtnl_held); |
| 9385 | if (ret) |
| 9386 | hdd_err("Cannot create concurrent STA interface"); |
| 9387 | } |
| 9388 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9389 | ret = hdd_open_p2p_interface(hdd_ctx, rtnl_held); |
| 9390 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9391 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9392 | |
| 9393 | /* Open 802.11p Interface */ |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 9394 | if (dot11p_mode == CFG_11P_CONCURRENT) { |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9395 | ret = hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
| 9396 | if (ret) |
| 9397 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9398 | } |
| 9399 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9400 | return 0; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9401 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9402 | err_close_adapters: |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9403 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9404 | return ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9405 | } |
| 9406 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9407 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9408 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 9409 | /** |
| 9410 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 9411 | * @cds_cfg: CDS Configuration |
| 9412 | * @hdd_ctx: Pointer to hdd context |
| 9413 | * |
| 9414 | * Return: none |
| 9415 | */ |
| 9416 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 9417 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9418 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9419 | { |
| 9420 | cds_cfg->tx_flow_stop_queue_th = |
| 9421 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 9422 | cds_cfg->tx_flow_start_queue_offset = |
| 9423 | hdd_ctx->config->TxFlowStartQueueOffset; |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 9424 | /* configuration for DP RX Threads */ |
| 9425 | cds_cfg->enable_dp_rx_threads = hdd_ctx->enable_dp_rx_threads; |
| 9426 | 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] | 9427 | } |
| 9428 | #else |
| 9429 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 9430 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9431 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9432 | { |
| 9433 | } |
| 9434 | #endif |
| 9435 | |
| 9436 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 9437 | /** |
| 9438 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 9439 | * @cds_cfg: CDS Configuration |
| 9440 | * @hdd_ctx: Pointer to hdd context |
| 9441 | * |
| 9442 | * Return: none |
| 9443 | */ |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 9444 | 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] | 9445 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9446 | { |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 9447 | bool is_rate_limit_enabled; |
| 9448 | QDF_STATUS status; |
| 9449 | |
| 9450 | status = ucfg_fwol_get_is_rate_limit_enabled(hdd_ctx->psoc, |
| 9451 | &is_rate_limit_enabled); |
| 9452 | if (QDF_IS_STATUS_ERROR(status)) |
| 9453 | return; |
| 9454 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9455 | cds_cfg->ra_ratelimit_interval = |
| 9456 | hdd_ctx->config->RArateLimitInterval; |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 9457 | cds_cfg->is_ra_ratelimit_enabled = is_rate_limit_enabled; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9458 | } |
| 9459 | #else |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 9460 | 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] | 9461 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9462 | { |
| 9463 | } |
| 9464 | #endif |
| 9465 | |
| 9466 | /** |
| 9467 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 9468 | * @hdd_ctx: HDD Context |
| 9469 | * |
| 9470 | * Return: 0 for Success, errno on failure |
| 9471 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9472 | static int hdd_update_cds_config(struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9473 | { |
| 9474 | struct cds_config_info *cds_cfg; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9475 | int value; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9476 | uint8_t band_capability; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9477 | uint8_t ito_repeat_count; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 9478 | bool crash_inject; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9479 | bool self_recovery; |
| 9480 | bool fw_timeout_crash; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9481 | QDF_STATUS status; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9482 | |
| 9483 | cds_cfg = (struct cds_config_info *)qdf_mem_malloc(sizeof(*cds_cfg)); |
| 9484 | if (!cds_cfg) { |
| 9485 | hdd_err("failed to allocate cds config"); |
| 9486 | return -ENOMEM; |
| 9487 | } |
| 9488 | |
Srinivas Girigowda | 35b0031 | 2017-06-27 21:52:03 -0700 | [diff] [blame] | 9489 | cds_cfg->driver_type = QDF_DRIVER_TYPE_PRODUCTION; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9490 | cds_cfg->sta_maxlimod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9491 | |
| 9492 | /* |
| 9493 | * Copy the DFS Phyerr Filtering Offload status. |
| 9494 | * This parameter reflects the value of the |
| 9495 | * dfs_phyerr_filter_offload flag as set in the ini. |
| 9496 | */ |
| 9497 | cds_cfg->dfs_phyerr_filter_offload = |
| 9498 | hdd_ctx->config->fDfsPhyerrFilterOffload; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9499 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9500 | status = ucfg_mlme_get_crash_inject(hdd_ctx->psoc, &crash_inject); |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 9501 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9502 | hdd_err("Failed to get crash inject ini config"); |
| 9503 | goto exit; |
| 9504 | } |
| 9505 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9506 | status = ucfg_mlme_get_self_recovery(hdd_ctx->psoc, &self_recovery); |
| 9507 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9508 | hdd_err("Failed to get self recovery ini config"); |
| 9509 | goto exit; |
| 9510 | } |
| 9511 | |
| 9512 | status = ucfg_mlme_get_fw_timeout_crash(hdd_ctx->psoc, |
| 9513 | &fw_timeout_crash); |
| 9514 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9515 | hdd_err("Failed to get fw timeout crash ini config"); |
| 9516 | goto exit; |
| 9517 | } |
| 9518 | |
| 9519 | status = ucfg_mlme_get_ito_repeat_count(hdd_ctx->psoc, |
| 9520 | &ito_repeat_count); |
| 9521 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9522 | hdd_err("Failed to get ITO repeat count ini config"); |
| 9523 | goto exit; |
| 9524 | } |
| 9525 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 9526 | cds_cfg->force_target_assert_enabled = crash_inject; |
SaidiReddy Yenuga | cc733af | 2016-11-09 17:45:42 +0530 | [diff] [blame] | 9527 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 9528 | ucfg_mlme_get_sap_max_offload_peers(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9529 | cds_cfg->ap_maxoffload_peers = value; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 9530 | ucfg_mlme_get_sap_max_offload_reorder_buffs(hdd_ctx->psoc, |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9531 | &value); |
| 9532 | cds_cfg->ap_maxoffload_reorderbuffs = value; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9533 | |
| 9534 | cds_cfg->ap_disable_intrabss_fwd = |
| 9535 | hdd_ctx->config->apDisableIntraBssFwd; |
| 9536 | |
| 9537 | cds_cfg->dfs_pri_multiplier = |
| 9538 | hdd_ctx->config->dfsRadarPriMultiplier; |
| 9539 | cds_cfg->reorder_offload = |
| 9540 | hdd_ctx->config->reorderOffloadSupport; |
| 9541 | |
| 9542 | /* IPA micro controller data path offload resource config item */ |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 9543 | cds_cfg->uc_offload_enabled = ucfg_ipa_uc_is_enabled(); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9544 | cds_cfg->uc_txbuf_size = hdd_ctx->config->IpaUcTxBufSize; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9545 | if (!is_power_of_2(hdd_ctx->config->IpaUcRxIndRingCount)) { |
| 9546 | /* IpaUcRxIndRingCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9547 | hdd_debug("Round down IpaUcRxIndRingCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9548 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9549 | hdd_ctx->config->IpaUcRxIndRingCount = |
| 9550 | rounddown_pow_of_two( |
| 9551 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9552 | if (!hdd_ctx->config->IpaUcRxIndRingCount) { |
| 9553 | hdd_err("Failed to round down IpaUcRxIndRingCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9554 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9555 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9556 | hdd_debug("IpaUcRxIndRingCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9557 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9558 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9559 | cds_cfg->uc_rxind_ringcount = |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9560 | hdd_ctx->config->IpaUcRxIndRingCount; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9561 | cds_cfg->uc_tx_partition_base = |
| 9562 | hdd_ctx->config->IpaUcTxPartitionBase; |
| 9563 | cds_cfg->max_scan = hdd_ctx->config->max_scan_count; |
| 9564 | |
| 9565 | cds_cfg->ip_tcp_udp_checksum_offload = |
| 9566 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
Jeff Johnson | e2ba3cd | 2017-10-30 20:02:09 -0700 | [diff] [blame] | 9567 | cds_cfg->enable_rxthread = hdd_ctx->enable_rxthread; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9568 | cds_cfg->ce_classify_enabled = |
| 9569 | hdd_ctx->config->ce_classify_enabled; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9570 | 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] | 9571 | ucfg_mlme_get_sap_max_peers(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9572 | cds_cfg->max_station = value; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 9573 | cds_cfg->sub_20_channel_width = WLAN_SUB_20_CH_WIDTH_NONE; |
Manjunathappa Prakash | fff753c | 2016-09-01 19:34:56 -0700 | [diff] [blame] | 9574 | cds_cfg->flow_steering_enabled = hdd_ctx->config->flow_steering_enable; |
Orhan K AKYILDIZ | 30e8cbc | 2017-08-11 18:00:28 -0700 | [diff] [blame] | 9575 | cds_cfg->max_msdus_per_rxinorderind = |
| 9576 | hdd_ctx->config->max_msdus_per_rxinorderind; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9577 | cds_cfg->self_recovery_enabled = self_recovery; |
| 9578 | cds_cfg->fw_timeout_crash = fw_timeout_crash; |
Nachiket Kukade | e547a48 | 2018-05-22 16:43:30 +0530 | [diff] [blame] | 9579 | cds_cfg->active_uc_apf_mode = hdd_ctx->config->active_uc_apf_mode; |
| 9580 | 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] | 9581 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9582 | cds_cfg->ito_repeat_count = ito_repeat_count; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9583 | |
| 9584 | status = ucfg_mlme_get_band_capability(hdd_ctx->psoc, &band_capability); |
| 9585 | if (QDF_IS_STATUS_ERROR(status)) |
| 9586 | goto exit; |
| 9587 | |
| 9588 | cds_cfg->bandcapability = band_capability; |
Zhu Jianmin | a2f8e8d | 2018-02-11 16:37:10 +0800 | [diff] [blame] | 9589 | cds_cfg->delay_before_vdev_stop = |
| 9590 | hdd_ctx->config->delay_before_vdev_stop; |
Rachit Kankane | 0106e38 | 2018-05-16 18:59:28 +0530 | [diff] [blame] | 9591 | cds_cfg->num_vdevs = hdd_ctx->config->num_vdevs; |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 9592 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9593 | hdd_ra_populate_cds_config(cds_cfg, hdd_ctx); |
| 9594 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 9595 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9596 | cds_init_ini_config(cds_cfg); |
| 9597 | return 0; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9598 | |
| 9599 | exit: |
| 9600 | qdf_mem_free(cds_cfg); |
| 9601 | return -EINVAL; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9602 | } |
| 9603 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9604 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9605 | * hdd_update_user_config() - API to update user configuration |
| 9606 | * parameters to obj mgr which are used by multiple components |
| 9607 | * @hdd_ctx: HDD Context |
| 9608 | * |
| 9609 | * Return: 0 for Success, errno on failure |
| 9610 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9611 | static int hdd_update_user_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9612 | { |
| 9613 | struct wlan_objmgr_psoc_user_config *user_config; |
Wu Gao | e568979 | 2018-07-05 19:20:13 +0800 | [diff] [blame] | 9614 | bool skip_dfs_in_p2p_search = false; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9615 | uint8_t band_capability; |
| 9616 | QDF_STATUS status; |
| 9617 | |
| 9618 | status = ucfg_mlme_get_band_capability(hdd_ctx->psoc, &band_capability); |
| 9619 | if (QDF_IS_STATUS_ERROR(status)) |
| 9620 | return -EIO; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9621 | |
| 9622 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
| 9623 | if (user_config == NULL) { |
| 9624 | hdd_alert("Failed to alloc memory for user_config!"); |
| 9625 | return -ENOMEM; |
| 9626 | } |
| 9627 | |
| 9628 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
| 9629 | user_config->dual_mac_feature_disable = |
| 9630 | hdd_ctx->config->dual_mac_feature_disable; |
| 9631 | user_config->indoor_channel_support = |
| 9632 | hdd_ctx->config->indoor_channel_support; |
| 9633 | user_config->is_11d_support_enabled = |
| 9634 | hdd_ctx->config->Is11dSupportEnabled; |
| 9635 | user_config->is_11h_support_enabled = |
| 9636 | hdd_ctx->config->Is11hSupportEnabled; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 9637 | cfg_p2p_get_skip_dfs_channel_p2p_search(hdd_ctx->psoc, |
Wu Gao | e568979 | 2018-07-05 19:20:13 +0800 | [diff] [blame] | 9638 | &skip_dfs_in_p2p_search); |
| 9639 | 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] | 9640 | user_config->band_capability = band_capability; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 9641 | wlan_objmgr_psoc_set_user_config(hdd_ctx->psoc, user_config); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9642 | |
| 9643 | qdf_mem_free(user_config); |
| 9644 | return 0; |
| 9645 | } |
| 9646 | |
| 9647 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9648 | * hdd_init_thermal_info - Initialize thermal level |
| 9649 | * @hdd_ctx: HDD context |
| 9650 | * |
| 9651 | * Initialize thermal level at SME layer and set the thermal level callback |
| 9652 | * which would be called when a configured thermal threshold is hit. |
| 9653 | * |
| 9654 | * Return: 0 on success and errno on failure |
| 9655 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9656 | static int hdd_init_thermal_info(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9657 | { |
| 9658 | tSmeThermalParams thermal_param; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9659 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9660 | mac_handle_t mac_handle; |
Dundi Raviteja | 47ac709 | 2018-09-07 10:40:28 +0530 | [diff] [blame] | 9661 | struct wlan_fwol_thermal_temp thermal_temp = {0}; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9662 | |
| 9663 | thermal_param.smeThermalMgmtEnabled = |
| 9664 | hdd_ctx->config->thermalMitigationEnable; |
| 9665 | thermal_param.smeThrottlePeriod = hdd_ctx->config->throttlePeriod; |
| 9666 | |
Poddar, Siddarth | 8390502 | 2016-04-16 17:56:08 -0700 | [diff] [blame] | 9667 | thermal_param.sme_throttle_duty_cycle_tbl[0] = |
| 9668 | hdd_ctx->config->throttle_dutycycle_level0; |
| 9669 | thermal_param.sme_throttle_duty_cycle_tbl[1] = |
| 9670 | hdd_ctx->config->throttle_dutycycle_level1; |
| 9671 | thermal_param.sme_throttle_duty_cycle_tbl[2] = |
| 9672 | hdd_ctx->config->throttle_dutycycle_level2; |
| 9673 | thermal_param.sme_throttle_duty_cycle_tbl[3] = |
| 9674 | hdd_ctx->config->throttle_dutycycle_level3; |
| 9675 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 9676 | status = ucfg_fwol_get_thermal_temp(hdd_ctx->psoc, &thermal_temp); |
Dundi Raviteja | 47ac709 | 2018-09-07 10:40:28 +0530 | [diff] [blame] | 9677 | if (QDF_IS_STATUS_ERROR(status)) |
| 9678 | return qdf_status_to_os_return(status); |
| 9679 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9680 | thermal_param.smeThermalLevels[0].smeMinTempThreshold = |
Dundi Raviteja | 47ac709 | 2018-09-07 10:40:28 +0530 | [diff] [blame] | 9681 | thermal_temp.thermal_temp_min_level0; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9682 | thermal_param.smeThermalLevels[0].smeMaxTempThreshold = |
Dundi Raviteja | 47ac709 | 2018-09-07 10:40:28 +0530 | [diff] [blame] | 9683 | thermal_temp.thermal_temp_max_level0; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9684 | thermal_param.smeThermalLevels[1].smeMinTempThreshold = |
Dundi Raviteja | 47ac709 | 2018-09-07 10:40:28 +0530 | [diff] [blame] | 9685 | thermal_temp.thermal_temp_min_level1; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9686 | thermal_param.smeThermalLevels[1].smeMaxTempThreshold = |
Dundi Raviteja | 47ac709 | 2018-09-07 10:40:28 +0530 | [diff] [blame] | 9687 | thermal_temp.thermal_temp_max_level1; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9688 | thermal_param.smeThermalLevels[2].smeMinTempThreshold = |
Dundi Raviteja | 47ac709 | 2018-09-07 10:40:28 +0530 | [diff] [blame] | 9689 | thermal_temp.thermal_temp_min_level2; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9690 | thermal_param.smeThermalLevels[2].smeMaxTempThreshold = |
Dundi Raviteja | 47ac709 | 2018-09-07 10:40:28 +0530 | [diff] [blame] | 9691 | thermal_temp.thermal_temp_max_level2; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9692 | thermal_param.smeThermalLevels[3].smeMinTempThreshold = |
Dundi Raviteja | 47ac709 | 2018-09-07 10:40:28 +0530 | [diff] [blame] | 9693 | thermal_temp.thermal_temp_min_level3; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9694 | thermal_param.smeThermalLevels[3].smeMaxTempThreshold = |
Dundi Raviteja | 47ac709 | 2018-09-07 10:40:28 +0530 | [diff] [blame] | 9695 | thermal_temp.thermal_temp_max_level3; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9696 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9697 | mac_handle = hdd_ctx->mac_handle; |
| 9698 | status = sme_init_thermal_info(mac_handle, thermal_param); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9699 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9700 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 9701 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9702 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9703 | sme_add_set_thermal_level_callback(mac_handle, |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9704 | hdd_set_thermal_level_cb); |
| 9705 | |
| 9706 | return 0; |
| 9707 | |
| 9708 | } |
| 9709 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9710 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 9711 | /** |
| 9712 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 9713 | * |
| 9714 | * Hold RTNL lock |
| 9715 | * |
| 9716 | * Return: True if held and false otherwise |
| 9717 | */ |
| 9718 | static inline bool hdd_hold_rtnl_lock(void) |
| 9719 | { |
| 9720 | rtnl_lock(); |
| 9721 | return true; |
| 9722 | } |
| 9723 | |
| 9724 | /** |
| 9725 | * hdd_release_rtnl_lock - Release RTNL lock |
| 9726 | * |
| 9727 | * Release RTNL lock |
| 9728 | * |
| 9729 | * Return: None |
| 9730 | */ |
| 9731 | static inline void hdd_release_rtnl_lock(void) |
| 9732 | { |
| 9733 | rtnl_unlock(); |
| 9734 | } |
| 9735 | #else |
| 9736 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 9737 | static inline void hdd_release_rtnl_lock(void) { } |
| 9738 | #endif |
| 9739 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9740 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9741 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9742 | /* MAX iwpriv command support */ |
| 9743 | #define PKTLOG_SET_BUFF_SIZE 3 |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9744 | #define PKTLOG_CLEAR_BUFF 4 |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9745 | #define MAX_PKTLOG_SIZE 16 |
| 9746 | |
| 9747 | /** |
| 9748 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 9749 | * @hdd_ctx: hdd context |
| 9750 | * @set_value2: pktlog buffer size value |
| 9751 | * |
| 9752 | * |
| 9753 | * Return: 0 for success or error. |
| 9754 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9755 | 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] | 9756 | { |
| 9757 | struct sir_wifi_start_log start_log = { 0 }; |
| 9758 | QDF_STATUS status; |
| 9759 | |
| 9760 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9761 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 9762 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9763 | start_log.user_triggered = 1; |
| 9764 | start_log.size = set_value2; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9765 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9766 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9767 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9768 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9769 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9770 | hdd_exit(); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9771 | return -EINVAL; |
| 9772 | } |
| 9773 | |
| 9774 | return 0; |
| 9775 | } |
| 9776 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9777 | /** |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9778 | * hdd_pktlog_clear_buff() - clear pktlog buffer |
| 9779 | * @hdd_ctx: hdd context |
| 9780 | * |
| 9781 | * Return: 0 for success or error. |
| 9782 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9783 | static int hdd_pktlog_clear_buff(struct hdd_context *hdd_ctx) |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9784 | { |
| 9785 | struct sir_wifi_start_log start_log; |
| 9786 | QDF_STATUS status; |
| 9787 | |
| 9788 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9789 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 9790 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9791 | start_log.user_triggered = 1; |
| 9792 | start_log.size = 0; |
| 9793 | start_log.is_pktlog_buff_clear = true; |
| 9794 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9795 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9796 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9797 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9798 | hdd_exit(); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9799 | return -EINVAL; |
| 9800 | } |
| 9801 | |
| 9802 | return 0; |
| 9803 | } |
| 9804 | |
| 9805 | |
| 9806 | /** |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9807 | * hdd_process_pktlog_command() - process pktlog command |
| 9808 | * @hdd_ctx: hdd context |
| 9809 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9810 | * @set_value2: pktlog buffer size value |
| 9811 | * |
| 9812 | * This function process pktlog command. |
| 9813 | * set_value2 only matters when set_value is 3 (set buff size) |
| 9814 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9815 | * |
| 9816 | * Return: 0 for success or error. |
| 9817 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9818 | 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] | 9819 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9820 | { |
| 9821 | int ret; |
| 9822 | bool enable; |
| 9823 | uint8_t user_triggered = 0; |
| 9824 | |
| 9825 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9826 | if (0 != ret) |
| 9827 | return ret; |
| 9828 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9829 | hdd_debug("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9830 | |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9831 | if (set_value > PKTLOG_CLEAR_BUFF) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9832 | hdd_err("invalid pktlog value %d", set_value); |
| 9833 | return -EINVAL; |
| 9834 | } |
| 9835 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9836 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 9837 | if (set_value2 <= 0) { |
| 9838 | hdd_err("invalid pktlog size %d", set_value2); |
| 9839 | return -EINVAL; |
| 9840 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
| 9841 | hdd_err("Pktlog buff size is too large. max value is 16MB.\n"); |
| 9842 | return -EINVAL; |
| 9843 | } |
| 9844 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9845 | } else if (set_value == PKTLOG_CLEAR_BUFF) { |
| 9846 | return hdd_pktlog_clear_buff(hdd_ctx); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9847 | } |
| 9848 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9849 | /* |
| 9850 | * set_value = 0 then disable packetlog |
| 9851 | * set_value = 1 enable packetlog forcefully |
| 9852 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 9853 | * enable packetlog with AUTO type. |
| 9854 | */ |
| 9855 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 9856 | true : false; |
| 9857 | |
| 9858 | if (1 == set_value) { |
| 9859 | enable = true; |
| 9860 | user_triggered = 1; |
| 9861 | } |
| 9862 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9863 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9864 | } |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 9865 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9866 | /** |
| 9867 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 9868 | * @hdd_ctx: HDD context |
| 9869 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9870 | * @user_triggered: triggered through iwpriv |
| 9871 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9872 | * |
| 9873 | * Return: 0 on success; error number otherwise |
| 9874 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9875 | int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9876 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9877 | { |
| 9878 | struct sir_wifi_start_log start_log; |
| 9879 | QDF_STATUS status; |
| 9880 | |
| 9881 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9882 | start_log.verbose_level = |
| 9883 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9884 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9885 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9886 | start_log.size = size; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9887 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 9888 | /* |
| 9889 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 9890 | * commands. Host uses this flag to decide whether to send pktlog |
| 9891 | * disable command to fw without sending pktlog enable command |
| 9892 | * previously. For eg, If vendor sends pktlog disable command without |
| 9893 | * sending pktlog enable command, then host discards the packet |
| 9894 | * but for iwpriv command, host will send it to fw. |
| 9895 | */ |
| 9896 | start_log.is_iwpriv_command = 1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9897 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9898 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9899 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9900 | hdd_exit(); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9901 | return -EINVAL; |
| 9902 | } |
| 9903 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 9904 | if (enable == true) |
| 9905 | hdd_ctx->is_pktlog_enabled = 1; |
| 9906 | else |
| 9907 | hdd_ctx->is_pktlog_enabled = 0; |
| 9908 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9909 | return 0; |
| 9910 | } |
| 9911 | #endif /* REMOVE_PKT_LOG */ |
| 9912 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9913 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9914 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 9915 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9916 | * @dev: Device Pointer |
| 9917 | * @num: Number of Valid Mac address |
| 9918 | * |
| 9919 | * Return: Pointer to MAC address buffer |
| 9920 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9921 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 9922 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9923 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9924 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9925 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9926 | |
| 9927 | /** |
| 9928 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 9929 | * @hdd_ctx: HDD Context |
| 9930 | * @num: Number of random mac addresses needed |
| 9931 | * |
| 9932 | * Generate random addresses using bit manipulation on the base mac address |
| 9933 | * |
| 9934 | * Return: None |
| 9935 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9936 | 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] | 9937 | { |
| 9938 | uint32_t start_idx = QDF_MAX_CONCURRENCY_PERSONA - num; |
| 9939 | uint32_t iter; |
| 9940 | struct hdd_config *ini = hdd_ctx->config; |
| 9941 | uint8_t *buf = NULL; |
| 9942 | uint8_t macaddr_b3, tmp_br3; |
| 9943 | uint8_t *src = ini->intfMacAddr[0].bytes; |
| 9944 | |
| 9945 | for (iter = start_idx; iter < QDF_MAX_CONCURRENCY_PERSONA; ++iter) { |
| 9946 | buf = ini->intfMacAddr[iter].bytes; |
| 9947 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 9948 | macaddr_b3 = buf[3]; |
| 9949 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + iter) & |
| 9950 | INTF_MACADDR_MASK; |
| 9951 | macaddr_b3 += tmp_br3; |
| 9952 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 9953 | buf[0] |= 0x02; |
| 9954 | buf[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9955 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9956 | } |
| 9957 | } |
| 9958 | |
| 9959 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9960 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9961 | * @hdd_ctx: HDD Context |
| 9962 | * |
| 9963 | * API to get mac addresses from platform driver and update the driver |
| 9964 | * structures and configure FW with the base mac address. |
| 9965 | * Return: int |
| 9966 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9967 | static int hdd_platform_wlan_mac(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9968 | { |
| 9969 | uint32_t no_of_mac_addr, iter; |
| 9970 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 9971 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 9972 | uint8_t *addr, *buf; |
| 9973 | struct device *dev = hdd_ctx->parent_dev; |
| 9974 | struct hdd_config *ini = hdd_ctx->config; |
| 9975 | tSirMacAddr mac_addr; |
| 9976 | QDF_STATUS status; |
| 9977 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9978 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9979 | |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 9980 | if (no_of_mac_addr == 0 || !addr) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9981 | return -EINVAL; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9982 | |
| 9983 | if (no_of_mac_addr > max_mac_addr) |
| 9984 | no_of_mac_addr = max_mac_addr; |
| 9985 | |
| 9986 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 9987 | |
| 9988 | for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { |
| 9989 | buf = ini->intfMacAddr[iter].bytes; |
| 9990 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9991 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9992 | } |
| 9993 | |
| 9994 | status = sme_set_custom_mac_addr(mac_addr); |
| 9995 | |
| 9996 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9997 | return -EAGAIN; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9998 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9999 | if (no_of_mac_addr < max_mac_addr) |
| 10000 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 10001 | no_of_mac_addr); |
| 10002 | return 0; |
| 10003 | } |
| 10004 | |
| 10005 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10006 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 10007 | * @hdd_ctx: HDD Context |
| 10008 | * |
| 10009 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 10010 | * will generate its own MAC and update it to FW. |
| 10011 | * |
| 10012 | * Return: 0 for success |
| 10013 | * Non-zero error code for failure |
| 10014 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10015 | 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] | 10016 | { |
| 10017 | tSirMacAddr customMacAddr; |
| 10018 | QDF_STATUS status; |
| 10019 | |
| 10020 | qdf_mem_copy(&customMacAddr, |
| 10021 | &hdd_ctx->config->intfMacAddr[0].bytes[0], |
| 10022 | sizeof(tSirMacAddr)); |
| 10023 | status = sme_set_custom_mac_addr(customMacAddr); |
| 10024 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10025 | return -EAGAIN; |
| 10026 | return 0; |
| 10027 | } |
| 10028 | |
| 10029 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10030 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 10031 | * @hdd_ctx: HDD Context |
| 10032 | * |
| 10033 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 10034 | * is provisioned with mac addresses, driver uses it, else it will use |
| 10035 | * wlan_mac.bin to update HW MAC addresses. |
| 10036 | * |
| 10037 | * Return: None |
| 10038 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10039 | static void hdd_initialize_mac_address(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10040 | { |
| 10041 | QDF_STATUS status; |
| 10042 | int ret; |
| 10043 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10044 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10045 | if (!ret) { |
| 10046 | hdd_info("using MAC address from platform driver"); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10047 | return; |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10048 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10049 | |
| 10050 | status = hdd_update_mac_config(hdd_ctx); |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10051 | if (QDF_IS_STATUS_SUCCESS(status)) { |
| 10052 | hdd_info("using MAC address from wlan_mac.bin"); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10053 | return; |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10054 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10055 | |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10056 | hdd_info("using default MAC address"); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10057 | |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 10058 | if (hdd_ctx->update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10059 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10060 | if (ret) |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 10061 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10062 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10063 | } |
| 10064 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10065 | static int hdd_set_smart_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10066 | { |
| 10067 | int vdev_id = 0; |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 10068 | QDF_STATUS status; |
| 10069 | bool smart_chainmask_enabled; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10070 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10071 | int vpdev = PDEV_CMD; |
| 10072 | int ret; |
| 10073 | |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 10074 | status = ucfg_get_smart_chainmask_enabled(hdd_ctx->psoc, |
| 10075 | &smart_chainmask_enabled); |
| 10076 | if (QDF_IS_STATUS_ERROR(status)) |
| 10077 | return -EINVAL; |
| 10078 | |
| 10079 | ret = sme_cli_set_command(vdev_id, param_id, |
| 10080 | (int)smart_chainmask_enabled, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10081 | if (ret) |
| 10082 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 10083 | |
| 10084 | return ret; |
| 10085 | } |
| 10086 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10087 | static int hdd_set_alternative_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10088 | { |
| 10089 | int vdev_id = 0; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10090 | QDF_STATUS status; |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10091 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10092 | bool alternative_chainmask_enabled; |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10093 | int vpdev = PDEV_CMD; |
| 10094 | int ret; |
| 10095 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10096 | status = ucfg_get_alternative_chainmask_enabled( |
| 10097 | hdd_ctx->psoc, |
| 10098 | &alternative_chainmask_enabled); |
| 10099 | if (QDF_IS_STATUS_ERROR(status)) |
| 10100 | return -EINVAL; |
| 10101 | |
| 10102 | ret = sme_cli_set_command(vdev_id, param_id, |
| 10103 | (int)alternative_chainmask_enabled, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10104 | if (ret) |
| 10105 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 10106 | ret); |
| 10107 | |
| 10108 | return ret; |
| 10109 | } |
| 10110 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10111 | static int hdd_set_ani_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10112 | { |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10113 | QDF_STATUS status; |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10114 | int vdev_id = 0; |
| 10115 | int param_id = WMI_PDEV_PARAM_ANI_ENABLE; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10116 | bool value; |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10117 | int vpdev = PDEV_CMD; |
| 10118 | int ret; |
| 10119 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10120 | status = ucfg_fwol_get_ani_enabled(hdd_ctx->psoc, &value); |
| 10121 | if (QDF_IS_STATUS_ERROR(status)) |
| 10122 | return -EINVAL; |
| 10123 | |
| 10124 | ret = sme_cli_set_command(vdev_id, param_id, (int)value, vpdev); |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10125 | if (ret) |
| 10126 | hdd_err("WMI_PDEV_PARAM_ANI_ENABLE failed %d", ret); |
| 10127 | |
| 10128 | return ret; |
| 10129 | } |
| 10130 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 10131 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10132 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 10133 | * @hdd_ctx: HDD context |
| 10134 | * |
| 10135 | * Pre configurations to be done at lower layer before calling cds enable. |
| 10136 | * |
| 10137 | * Return: 0 on success and errno on failure. |
| 10138 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10139 | static int hdd_pre_enable_configure(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10140 | { |
| 10141 | int ret; |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 10142 | uint8_t val = 0; |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10143 | QDF_STATUS status; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10144 | uint32_t arp_ac_category; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 10145 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10146 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 10147 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Ajit Pal Singh | 5d26961 | 2018-04-19 16:29:12 +0530 | [diff] [blame] | 10148 | /* Register HL netdev flow control callback */ |
| 10149 | cdp_hl_fc_register(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10150 | |
| 10151 | /* |
| 10152 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 10153 | * The cfg download must occur before we update the SME config |
| 10154 | * since the SME config operation must access the cfg database |
| 10155 | */ |
| 10156 | status = hdd_set_sme_config(hdd_ctx); |
| 10157 | |
| 10158 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10159 | hdd_err("Failed hdd_set_sme_config: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10160 | ret = qdf_status_to_os_return(status); |
| 10161 | goto out; |
| 10162 | } |
| 10163 | |
Tushnim Bhattacharyya | ba8ee93 | 2017-03-23 09:27:40 -0700 | [diff] [blame] | 10164 | status = hdd_set_policy_mgr_user_cfg(hdd_ctx); |
| 10165 | if (QDF_STATUS_SUCCESS != status) { |
| 10166 | hdd_alert("Failed hdd_set_policy_mgr_user_cfg: %d", status); |
| 10167 | ret = qdf_status_to_os_return(status); |
| 10168 | goto out; |
| 10169 | } |
| 10170 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10171 | status = ucfg_mlme_get_tx_chainmask_1ss(hdd_ctx->psoc, &val); |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 10172 | if (QDF_STATUS_SUCCESS != status) { |
| 10173 | hdd_err("Get tx_chainmask_1ss from mlme failed"); |
| 10174 | ret = qdf_status_to_os_return(status); |
| 10175 | goto out; |
| 10176 | } |
| 10177 | 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] | 10178 | PDEV_CMD); |
| 10179 | if (0 != ret) { |
| 10180 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 10181 | goto out; |
| 10182 | } |
| 10183 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10184 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 10185 | if (ret) |
| 10186 | goto out; |
| 10187 | |
| 10188 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 10189 | if (ret) |
| 10190 | goto out; |
| 10191 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10192 | ret = hdd_set_ani_enabled(hdd_ctx); |
| 10193 | if (ret) |
| 10194 | goto out; |
| 10195 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10196 | status = ucfg_get_arp_ac_category(hdd_ctx->psoc, &arp_ac_category); |
| 10197 | |
| 10198 | if (QDF_IS_STATUS_ERROR(status)) |
| 10199 | return -EINVAL; |
| 10200 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 10201 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10202 | arp_ac_category, |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 10203 | PDEV_CMD); |
| 10204 | if (0 != ret) { |
| 10205 | hdd_err("WMI_PDEV_PARAM_ARP_AC_OVERRIDE ac: %d ret: %d", |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10206 | arp_ac_category, ret); |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 10207 | goto out; |
| 10208 | } |
| 10209 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10210 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 10211 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10212 | hdd_err("Failed to init channel list: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10213 | ret = qdf_status_to_os_return(status); |
| 10214 | goto out; |
| 10215 | } |
| 10216 | |
| 10217 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 10218 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10219 | hdd_err("config update failed"); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10220 | ret = -EINVAL; |
| 10221 | goto out; |
| 10222 | } |
| 10223 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10224 | /* |
| 10225 | * Set the MAC Address Currently this is used by HAL to add self sta. |
| 10226 | * Remove this once self sta is added as part of session open. |
| 10227 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10228 | 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] | 10229 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 10230 | sizeof(hdd_ctx->config->intfMacAddr[0])); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10231 | |
Jeff Johnson | bae59f9 | 2018-06-01 17:05:43 -0700 | [diff] [blame] | 10232 | if (QDF_IS_STATUS_ERROR(status)) { |
| 10233 | hdd_err("Failed to set MAC Address, status %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10234 | ret = -EINVAL; |
| 10235 | goto out; |
| 10236 | } |
| 10237 | |
| 10238 | hdd_init_channel_avoidance(hdd_ctx); |
| 10239 | |
Ganesh Kondabattini | 408fb8d | 2017-08-08 22:00:20 +0530 | [diff] [blame] | 10240 | /* update enable sap mandatory chan list */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10241 | policy_mgr_enable_disable_sap_mandatory_chan_list(hdd_ctx->psoc, |
Ganesh Kondabattini | 408fb8d | 2017-08-08 22:00:20 +0530 | [diff] [blame] | 10242 | hdd_ctx->config->enable_sap_mandatory_chan_list); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10243 | out: |
| 10244 | return ret; |
| 10245 | } |
| 10246 | |
Rachit Kankane | 026e77a | 2018-07-31 16:21:09 +0530 | [diff] [blame] | 10247 | #ifdef FEATURE_P2P_LISTEN_OFFLOAD |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10248 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10249 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10250 | * @context: context registered with sme_register_p2p_lo_event(). HDD |
| 10251 | * always registers a hdd context pointer |
| 10252 | * @evt:event structure pointer |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10253 | * |
| 10254 | * This is the p2p listen offload stop event handler, it sends vendor |
| 10255 | * event back to supplicant to notify the stop reason. |
| 10256 | * |
| 10257 | * Return: None |
| 10258 | */ |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10259 | static void wlan_hdd_p2p_lo_event_callback(void *context, |
| 10260 | struct sir_p2p_lo_event *evt) |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10261 | { |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10262 | struct hdd_context *hdd_ctx = context; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10263 | struct sk_buff *vendor_event; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10264 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10265 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10266 | hdd_enter(); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10267 | |
| 10268 | if (hdd_ctx == NULL) { |
| 10269 | hdd_err("Invalid HDD context pointer"); |
| 10270 | return; |
| 10271 | } |
| 10272 | |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10273 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id); |
| 10274 | if (!adapter) { |
| 10275 | hdd_err("Cannot find adapter by vdev_id = %d", |
| 10276 | evt->vdev_id); |
| 10277 | return; |
| 10278 | } |
| 10279 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10280 | vendor_event = |
| 10281 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10282 | &(adapter->wdev), sizeof(uint32_t) + NLMSG_HDRLEN, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10283 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 10284 | GFP_KERNEL); |
| 10285 | |
| 10286 | if (!vendor_event) { |
| 10287 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 10288 | return; |
| 10289 | } |
| 10290 | |
| 10291 | if (nla_put_u32(vendor_event, |
| 10292 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 10293 | evt->reason_code)) { |
| 10294 | hdd_err("nla put failed"); |
| 10295 | kfree_skb(vendor_event); |
| 10296 | return; |
| 10297 | } |
| 10298 | |
| 10299 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10300 | hdd_debug("Sent P2P_LISTEN_OFFLOAD_STOP event for vdev_id = %d", |
| 10301 | evt->vdev_id); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10302 | } |
Rachit Kankane | 026e77a | 2018-07-31 16:21:09 +0530 | [diff] [blame] | 10303 | #else |
| 10304 | static void wlan_hdd_p2p_lo_event_callback(void *context, |
| 10305 | struct sir_p2p_lo_event *evt) |
| 10306 | { |
| 10307 | } |
| 10308 | #endif |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10309 | |
Rachit Kankane | f6834c4 | 2018-08-02 18:47:50 +0530 | [diff] [blame] | 10310 | #ifdef FEATURE_WLAN_DYNAMIC_CVM |
| 10311 | static inline int hdd_set_vc_mode_config(struct hdd_context *hdd_ctx) |
| 10312 | { |
| 10313 | return sme_set_vc_mode_config(hdd_ctx->config->vc_mode_cfg_bitmap); |
| 10314 | } |
| 10315 | #else |
| 10316 | static inline int hdd_set_vc_mode_config(struct hdd_context *hdd_ctx) |
| 10317 | { |
| 10318 | return QDF_STATUS_SUCCESS; |
| 10319 | } |
| 10320 | #endif |
| 10321 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10322 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10323 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 10324 | * @hdd_ctx: HDD context |
| 10325 | * |
| 10326 | * This function sends the adaptive dwell time config configuration to the |
| 10327 | * firmware via WMA |
| 10328 | * |
| 10329 | * Return: 0 - success, < 0 - failure |
| 10330 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10331 | static int hdd_adaptive_dwelltime_init(struct hdd_context *hdd_ctx) |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10332 | { |
| 10333 | QDF_STATUS status; |
| 10334 | struct adaptive_dwelltime_params dwelltime_params; |
| 10335 | |
| 10336 | dwelltime_params.is_enabled = |
| 10337 | hdd_ctx->config->adaptive_dwell_mode_enabled; |
| 10338 | dwelltime_params.dwelltime_mode = |
| 10339 | hdd_ctx->config->global_adapt_dwelltime_mode; |
| 10340 | dwelltime_params.lpf_weight = |
| 10341 | hdd_ctx->config->adapt_dwell_lpf_weight; |
| 10342 | dwelltime_params.passive_mon_intval = |
| 10343 | hdd_ctx->config->adapt_dwell_passive_mon_intval; |
| 10344 | dwelltime_params.wifi_act_threshold = |
| 10345 | hdd_ctx->config->adapt_dwell_wifi_act_threshold; |
| 10346 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10347 | status = sme_set_adaptive_dwelltime_config(hdd_ctx->mac_handle, |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10348 | &dwelltime_params); |
| 10349 | |
| 10350 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 10351 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10352 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 10353 | return -EAGAIN; |
| 10354 | } |
| 10355 | return 0; |
| 10356 | } |
| 10357 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10358 | int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10359 | { |
| 10360 | QDF_STATUS status; |
| 10361 | struct wmi_dbs_scan_sel_params dbs_scan_params; |
| 10362 | uint32_t i = 0; |
| 10363 | uint8_t count = 0, numentries = 0; |
| 10364 | uint8_t dbs_scan_config[CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 10365 | * CDS_DBS_SCAN_CLIENTS_MAX]; |
| 10366 | |
| 10367 | /* check if DBS is enabled or supported */ |
Bala Venkatesh | c8236ca | 2018-03-09 12:38:29 +0530 | [diff] [blame] | 10368 | if ((hdd_ctx->config->dual_mac_feature_disable == |
| 10369 | DISABLE_DBS_CXN_AND_SCAN) || |
| 10370 | (hdd_ctx->config->dual_mac_feature_disable == |
| 10371 | ENABLE_DBS_CXN_AND_DISABLE_DBS_SCAN)) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10372 | return -EINVAL; |
| 10373 | |
| 10374 | hdd_string_to_u8_array(hdd_ctx->config->dbs_scan_selection, |
| 10375 | dbs_scan_config, &numentries, |
| 10376 | (CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 10377 | * CDS_DBS_SCAN_CLIENTS_MAX)); |
| 10378 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10379 | if (!numentries) { |
Dustin Brown | 6a8d39b | 2018-08-14 15:27:26 -0700 | [diff] [blame] | 10380 | hdd_debug("Do not send scan_selection_config"); |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10381 | return 0; |
| 10382 | } |
| 10383 | |
| 10384 | /* hdd_set_fw_log_params */ |
| 10385 | dbs_scan_params.num_clients = 0; |
| 10386 | while (count < (numentries - 2)) { |
| 10387 | dbs_scan_params.module_id[i] = dbs_scan_config[count]; |
| 10388 | dbs_scan_params.num_dbs_scans[i] = dbs_scan_config[count + 1]; |
| 10389 | dbs_scan_params.num_non_dbs_scans[i] = |
| 10390 | dbs_scan_config[count + 2]; |
| 10391 | dbs_scan_params.num_clients++; |
| 10392 | hdd_debug("module:%d NDS:%d NNDS:%d", |
| 10393 | dbs_scan_params.module_id[i], |
| 10394 | dbs_scan_params.num_dbs_scans[i], |
| 10395 | dbs_scan_params.num_non_dbs_scans[i]); |
| 10396 | count += CDS_DBS_SCAN_PARAM_PER_CLIENT; |
| 10397 | i++; |
| 10398 | } |
| 10399 | |
| 10400 | dbs_scan_params.pdev_id = 0; |
| 10401 | |
| 10402 | hdd_debug("clients:%d pdev:%d", |
| 10403 | dbs_scan_params.num_clients, dbs_scan_params.pdev_id); |
| 10404 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10405 | status = sme_set_dbs_scan_selection_config(hdd_ctx->mac_handle, |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10406 | &dbs_scan_params); |
| 10407 | hdd_debug("Sending DBS Scan Selection Configuration to fw"); |
| 10408 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10409 | hdd_err("Failed to send DBS Scan selection configuration!"); |
| 10410 | return -EAGAIN; |
| 10411 | } |
| 10412 | return 0; |
| 10413 | } |
| 10414 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10415 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 10416 | /** |
| 10417 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 10418 | * @hdd_ctx: HDD context |
| 10419 | * |
| 10420 | * Set auto shutdown callback to get indications from firmware to indicate |
| 10421 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 10422 | * |
| 10423 | * Return: 0 on success and errno on failure. |
| 10424 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10425 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10426 | { |
| 10427 | QDF_STATUS status; |
| 10428 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 10429 | if (!hdd_ctx->config->wlan_auto_shutdown) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10430 | return 0; |
| 10431 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10432 | status = sme_set_auto_shutdown_cb(hdd_ctx->mac_handle, |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10433 | wlan_hdd_auto_shutdown_cb); |
| 10434 | if (status != QDF_STATUS_SUCCESS) |
| 10435 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 10436 | status); |
| 10437 | |
| 10438 | return qdf_status_to_os_return(status); |
| 10439 | } |
| 10440 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10441 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10442 | { |
| 10443 | return 0; |
| 10444 | } |
| 10445 | #endif |
| 10446 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10447 | #ifdef MWS_COEX |
| 10448 | /** |
| 10449 | * hdd_set_mws_coex() - Set MWS coex configurations |
| 10450 | * @hdd_ctx: HDD context |
| 10451 | * |
| 10452 | * This function sends MWS-COEX 4G quick FTDM and |
| 10453 | * MWS-COEX 5G-NR power limit to FW |
| 10454 | * |
| 10455 | * Return: 0 on success and errno on failure. |
| 10456 | */ |
| 10457 | static int hdd_init_mws_coex(struct hdd_context *hdd_ctx) |
| 10458 | { |
| 10459 | int ret = 0; |
| 10460 | |
| 10461 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_MWSCOEX_4G_ALLOW_QUICK_FTDM, |
| 10462 | hdd_ctx->config->mws_coex_4g_quick_tdm, |
| 10463 | PDEV_CMD); |
| 10464 | if (ret) { |
| 10465 | hdd_warn("Unable to send MWS-COEX 4G quick FTDM policy"); |
| 10466 | return ret; |
| 10467 | } |
| 10468 | |
| 10469 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_MWSCOEX_SET_5GNR_PWR_LIMIT, |
| 10470 | hdd_ctx->config->mws_coex_5g_nr_pwr_limit, |
| 10471 | PDEV_CMD); |
| 10472 | if (ret) { |
| 10473 | hdd_warn("Unable to send MWS-COEX 4G quick FTDM policy"); |
| 10474 | return ret; |
| 10475 | } |
| 10476 | return ret; |
| 10477 | } |
| 10478 | #else |
| 10479 | static int hdd_init_mws_coex(struct hdd_context *hdd_ctx) |
| 10480 | { |
| 10481 | return 0; |
| 10482 | } |
| 10483 | #endif |
| 10484 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10485 | /** |
| 10486 | * hdd_features_init() - Init features |
| 10487 | * @hdd_ctx: HDD context |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10488 | * |
| 10489 | * Initialize features and their feature context after WLAN firmware is up. |
| 10490 | * |
| 10491 | * Return: 0 on success and errno on failure. |
| 10492 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10493 | static int hdd_features_init(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10494 | { |
| 10495 | tSirTxPowerLimit hddtxlimit; |
| 10496 | QDF_STATUS status; |
| 10497 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10498 | mac_handle_t mac_handle; |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 10499 | struct hdd_config *cfg; |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 10500 | bool b_cts2self; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10501 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10502 | hdd_enter(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10503 | |
Dustin Brown | ad698ae | 2018-09-05 17:19:30 -0700 | [diff] [blame] | 10504 | ret = hdd_update_country_code(hdd_ctx); |
| 10505 | if (ret) { |
| 10506 | hdd_err("Failed to update country code; errno:%d", ret); |
| 10507 | return -EINVAL; |
| 10508 | } |
| 10509 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10510 | ret = hdd_init_mws_coex(hdd_ctx); |
| 10511 | if (ret) |
| 10512 | hdd_warn("Error initializing mws-coex"); |
| 10513 | |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 10514 | cfg = hdd_ctx->config; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10515 | /* FW capabilities received, Set the Dot11 mode */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10516 | mac_handle = hdd_ctx->mac_handle; |
| 10517 | sme_setdef_dot11mode(mac_handle); |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 10518 | sme_set_etsi13_srd_ch_in_master_mode(mac_handle, |
| 10519 | cfg-> |
| 10520 | etsi13_srd_chan_in_master_mode); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10521 | |
| 10522 | if (hdd_ctx->config->fIsImpsEnabled) |
| 10523 | hdd_set_idle_ps_config(hdd_ctx, true); |
| 10524 | else |
| 10525 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 10526 | |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 10527 | /* Send Enable/Disable data stall detection cmd to FW */ |
| 10528 | sme_cli_set_command(0, WMI_PDEV_PARAM_DATA_STALL_DETECT_ENABLE, |
| 10529 | hdd_ctx->config->enable_data_stall_det, PDEV_CMD); |
| 10530 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10531 | ucfg_mlme_get_go_cts2self_for_sta(hdd_ctx->psoc, &b_cts2self); |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 10532 | if (b_cts2self) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10533 | sme_set_cts2self_for_p2p_go(mac_handle); |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 10534 | |
Rachit Kankane | f6834c4 | 2018-08-02 18:47:50 +0530 | [diff] [blame] | 10535 | if (hdd_set_vc_mode_config(hdd_ctx)) |
Nachiket Kukade | 8983cf6 | 2017-10-12 18:14:48 +0530 | [diff] [blame] | 10536 | hdd_warn("Error in setting Voltage Corner mode config to FW"); |
| 10537 | |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10538 | if (hdd_rx_ol_init(hdd_ctx)) |
| 10539 | hdd_err("Unable to initialize Rx LRO/GRO in fw"); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10540 | |
| 10541 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 10542 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 10543 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10544 | if (hdd_dbs_scan_selection_init(hdd_ctx)) |
| 10545 | hdd_err("Unable to send DBS scan selection setting to FW"); |
| 10546 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10547 | ret = hdd_init_thermal_info(hdd_ctx); |
| 10548 | if (ret) { |
| 10549 | hdd_err("Error while initializing thermal information"); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10550 | return ret; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10551 | } |
| 10552 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10553 | /** |
| 10554 | * In case of SSR/PDR, if pktlog was enabled manually before |
| 10555 | * SSR/PDR, Then enabled it again automatically after Wlan |
| 10556 | * device up. |
| 10557 | */ |
| 10558 | if (cds_is_driver_recovering()) { |
| 10559 | if (hdd_ctx->is_pktlog_enabled) |
| 10560 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
Alok Kumar | 5a75b9d | 2018-08-31 10:55:43 +0530 | [diff] [blame] | 10561 | } else if (cds_is_packet_log_enabled()) |
| 10562 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 10563 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10564 | hddtxlimit.txPower2g = hdd_ctx->config->TxPower2g; |
| 10565 | hddtxlimit.txPower5g = hdd_ctx->config->TxPower5g; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10566 | status = sme_txpower_limit(mac_handle, &hddtxlimit); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10567 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10568 | hdd_err("Error setting txlimit in sme: %d", status); |
| 10569 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10570 | wlan_hdd_tsf_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10571 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10572 | ret = hdd_register_cb(hdd_ctx); |
| 10573 | if (ret) { |
| 10574 | hdd_err("Failed to register HDD callbacks!"); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10575 | return ret; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10576 | } |
| 10577 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 10578 | status = sme_enable_disable_chanavoidind_event(mac_handle, 0); |
| 10579 | if (QDF_IS_STATUS_ERROR(status) && (status != QDF_STATUS_E_NOSUPPORT)) { |
| 10580 | hdd_err("Failed to disable Chan Avoidance Indication"); |
| 10581 | goto deregister_cb; |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 10582 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10583 | |
| 10584 | /* register P2P Listen Offload event callback */ |
| 10585 | if (wma_is_p2p_lo_capable()) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10586 | sme_register_p2p_lo_event(mac_handle, hdd_ctx, |
| 10587 | wlan_hdd_p2p_lo_event_callback); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10588 | |
| 10589 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 10590 | |
| 10591 | if (ret) |
| 10592 | goto deregister_cb; |
| 10593 | |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10594 | wlan_hdd_init_chan_info(hdd_ctx); |
Varun Reddy Yeturu | 3c9f89c | 2018-04-18 19:10:34 -0700 | [diff] [blame] | 10595 | wlan_hdd_twt_init(hdd_ctx); |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10596 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10597 | hdd_exit(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10598 | return 0; |
| 10599 | |
| 10600 | deregister_cb: |
| 10601 | hdd_deregister_cb(hdd_ctx); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10602 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10603 | return -EINVAL; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10604 | } |
| 10605 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10606 | /** |
| 10607 | * hdd_features_deinit() - Deinit features |
| 10608 | * @hdd_ctx: HDD context |
| 10609 | * |
| 10610 | * De-Initialize features and their feature context. |
| 10611 | * |
| 10612 | * Return: none. |
| 10613 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10614 | static void hdd_features_deinit(struct hdd_context *hdd_ctx) |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10615 | { |
Varun Reddy Yeturu | 3c9f89c | 2018-04-18 19:10:34 -0700 | [diff] [blame] | 10616 | wlan_hdd_twt_deinit(hdd_ctx); |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10617 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10618 | wlan_hdd_tsf_deinit(hdd_ctx); |
| 10619 | } |
| 10620 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10621 | /** |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10622 | * hdd_register_bcn_cb() - register scan beacon callback |
| 10623 | * @hdd_ctx - Pointer to the HDD context |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10624 | * |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10625 | * Return: QDF_STATUS |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10626 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10627 | 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] | 10628 | { |
| 10629 | QDF_STATUS status; |
| 10630 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10631 | status = ucfg_scan_register_bcn_cb(hdd_ctx->psoc, |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10632 | wlan_cfg80211_inform_bss_frame, |
| 10633 | SCAN_CB_TYPE_INFORM_BCN); |
| 10634 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10635 | hdd_err("failed with status code %08d [x%08x]", |
| 10636 | status, status); |
| 10637 | return status; |
| 10638 | } |
| 10639 | |
| 10640 | return QDF_STATUS_SUCCESS; |
| 10641 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10642 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10643 | /** |
Manjunathappa Prakash | a0cbc92 | 2018-05-08 19:48:34 -0700 | [diff] [blame] | 10644 | * hdd_v2_flow_pool_map() - Flow pool create callback when vdev is active |
| 10645 | * @vdev_id: vdev_id, corresponds to flow_pool |
| 10646 | * |
| 10647 | * Return: none. |
| 10648 | */ |
| 10649 | static void hdd_v2_flow_pool_map(int vdev_id) |
| 10650 | { |
| 10651 | QDF_STATUS status; |
| 10652 | |
| 10653 | status = cdp_flow_pool_map(cds_get_context(QDF_MODULE_ID_SOC), |
| 10654 | cds_get_context(QDF_MODULE_ID_TXRX), |
| 10655 | vdev_id); |
| 10656 | /* |
| 10657 | * For Adrastea flow control v2 is based on FW MAP events, |
| 10658 | * so this above callback is not implemented. |
| 10659 | * Hence this is not actual failure. Dont return failure |
| 10660 | */ |
| 10661 | if ((status != QDF_STATUS_SUCCESS) && |
| 10662 | (status != QDF_STATUS_E_INVAL)) { |
| 10663 | hdd_err("vdev_id: %d, failed to create flow pool status %d", |
| 10664 | vdev_id, status); |
| 10665 | } |
| 10666 | } |
| 10667 | |
| 10668 | /** |
| 10669 | * hdd_v2_flow_pool_unmap() - Flow pool create callback when vdev is not active |
| 10670 | * @vdev_id: vdev_id, corresponds to flow_pool |
| 10671 | * |
| 10672 | * Return: none. |
| 10673 | */ |
| 10674 | static void hdd_v2_flow_pool_unmap(int vdev_id) |
| 10675 | { |
| 10676 | cdp_flow_pool_unmap(cds_get_context(QDF_MODULE_ID_SOC), |
| 10677 | cds_get_context(QDF_MODULE_ID_TXRX), vdev_id); |
| 10678 | } |
| 10679 | |
| 10680 | /** |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 10681 | * hdd_action_oui_config() - Configure action_oui strings |
| 10682 | * @hdd_ctx: pointer to hdd context |
| 10683 | * |
| 10684 | * This is a HDD wrapper function which invokes ucfg api |
| 10685 | * of action_oui component to parse action oui strings. |
| 10686 | * |
| 10687 | * Return: None |
| 10688 | */ |
| 10689 | static void hdd_action_oui_config(struct hdd_context *hdd_ctx) |
| 10690 | { |
| 10691 | QDF_STATUS status; |
| 10692 | uint32_t id; |
| 10693 | uint8_t *str; |
| 10694 | |
| 10695 | if (!hdd_ctx->config->action_oui_enable) |
| 10696 | return; |
| 10697 | |
| 10698 | for (id = 0; id < ACTION_OUI_MAXIMUM_ID; id++) { |
| 10699 | str = hdd_ctx->config->action_oui_str[id]; |
| 10700 | if (!qdf_str_len(str)) |
| 10701 | continue; |
| 10702 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10703 | status = ucfg_action_oui_parse(hdd_ctx->psoc, str, id); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 10704 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10705 | hdd_err("Failed to parse action_oui str: %u", id); |
| 10706 | } |
| 10707 | } |
| 10708 | |
| 10709 | /** |
| 10710 | * hdd_action_oui_send() - Send action_oui extensions to firmware |
| 10711 | * @hdd_ctx: pointer to hdd context |
| 10712 | * |
| 10713 | * This is a HDD wrapper function which invokes ucfg api |
| 10714 | * of action_oui component to send action oui extensions to firmware. |
| 10715 | * |
| 10716 | * Return: None |
| 10717 | */ |
| 10718 | static void hdd_action_oui_send(struct hdd_context *hdd_ctx) |
| 10719 | { |
| 10720 | QDF_STATUS status; |
| 10721 | |
| 10722 | if (!hdd_ctx->config->action_oui_enable) |
| 10723 | return; |
| 10724 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10725 | status = ucfg_action_oui_send(hdd_ctx->psoc); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 10726 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10727 | hdd_err("Failed to send one or all action_ouis"); |
| 10728 | } |
| 10729 | |
| 10730 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10731 | * hdd_configure_cds() - Configure cds modules |
| 10732 | * @hdd_ctx: HDD context |
| 10733 | * @adapter: Primary adapter context |
| 10734 | * |
| 10735 | * Enable Cds modules after WLAN firmware is up. |
| 10736 | * |
| 10737 | * Return: 0 on success and errno on failure. |
| 10738 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10739 | int hdd_configure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10740 | { |
| 10741 | int ret; |
| 10742 | QDF_STATUS status; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10743 | int set_value; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10744 | mac_handle_t mac_handle; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10745 | bool enable_rts_sifsbursting; |
| 10746 | uint8_t enable_phy_reg_retention; |
| 10747 | uint8_t max_mpdus_inampdu; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10748 | uint32_t num_abg_tx_chains = 0; |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 10749 | uint16_t num_11b_tx_chains = 0; |
| 10750 | uint16_t num_11ag_tx_chains = 0; |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10751 | struct policy_mgr_dp_cbacks dp_cbs = {0}; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 10752 | bool value; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 10753 | enum pmo_auto_pwr_detect_failure_mode auto_power_fail_mode; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 10754 | bool bval = false; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10755 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10756 | mac_handle = hdd_ctx->mac_handle; |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 10757 | |
| 10758 | hdd_action_oui_send(hdd_ctx); |
| 10759 | |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10760 | if (hdd_ctx->config->is_force_1x1) |
| 10761 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_SET_IOT_PATTERN, |
| 10762 | 1, PDEV_CMD); |
| 10763 | /* set chip power save failure detected callback */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10764 | sme_set_chip_pwr_save_fail_cb(mac_handle, |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10765 | hdd_chip_pwr_save_fail_detected_cb); |
| 10766 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10767 | status = ucfg_get_max_mpdus_inampdu(hdd_ctx->psoc, |
| 10768 | &max_mpdus_inampdu); |
| 10769 | if (status) |
| 10770 | return status; |
| 10771 | |
| 10772 | if (max_mpdus_inampdu) { |
| 10773 | set_value = max_mpdus_inampdu; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10774 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_MAX_MPDUS_IN_AMPDU, |
| 10775 | set_value, PDEV_CMD); |
| 10776 | } |
| 10777 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10778 | status = ucfg_get_enable_rts_sifsbursting(hdd_ctx->psoc, |
| 10779 | &enable_rts_sifsbursting); |
| 10780 | if (status) |
| 10781 | return status; |
| 10782 | |
| 10783 | if (enable_rts_sifsbursting) { |
| 10784 | set_value = enable_rts_sifsbursting; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10785 | sme_cli_set_command(0, |
| 10786 | (int)WMI_PDEV_PARAM_ENABLE_RTS_SIFS_BURSTING, |
| 10787 | set_value, PDEV_CMD); |
| 10788 | } |
| 10789 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 10790 | ucfg_mlme_get_sap_get_peer_info(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 10791 | if (value) { |
| 10792 | set_value = value; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10793 | sme_cli_set_command(0, |
| 10794 | (int)WMI_PDEV_PARAM_PEER_STATS_INFO_ENABLE, |
| 10795 | set_value, PDEV_CMD); |
| 10796 | } |
| 10797 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10798 | status = ucfg_mlme_get_num_11b_tx_chains(hdd_ctx->psoc, |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 10799 | &num_11b_tx_chains); |
| 10800 | if (status != QDF_STATUS_SUCCESS) { |
| 10801 | hdd_err("Failed to get num_11b_tx_chains"); |
| 10802 | goto out; |
| 10803 | } |
| 10804 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10805 | status = ucfg_mlme_get_num_11ag_tx_chains(hdd_ctx->psoc, |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 10806 | &num_11ag_tx_chains); |
| 10807 | if (status != QDF_STATUS_SUCCESS) { |
| 10808 | hdd_err("Failed to get num_11ag_tx_chains"); |
| 10809 | goto out; |
| 10810 | } |
| 10811 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 10812 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 10813 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10814 | hdd_err("unable to get vht_enable2x2"); |
| 10815 | |
| 10816 | if (!bval) { |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10817 | if (num_11b_tx_chains > 1) |
| 10818 | num_11b_tx_chains = 1; |
| 10819 | if (num_11ag_tx_chains > 1) |
| 10820 | num_11ag_tx_chains = 1; |
| 10821 | } |
| 10822 | WMI_PDEV_PARAM_SET_11B_TX_CHAIN_NUM(num_abg_tx_chains, |
| 10823 | num_11b_tx_chains); |
| 10824 | WMI_PDEV_PARAM_SET_11AG_TX_CHAIN_NUM(num_abg_tx_chains, |
| 10825 | num_11ag_tx_chains); |
| 10826 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_ABG_MODE_TX_CHAIN_NUM, |
| 10827 | num_abg_tx_chains, PDEV_CMD); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10828 | |
Paul Zhang | 02526cd | 2018-09-20 17:47:46 +0800 | [diff] [blame] | 10829 | if (!ucfg_reg_is_regdb_offloaded(hdd_ctx->psoc)) |
| 10830 | ucfg_reg_program_default_cc(hdd_ctx->pdev, |
| 10831 | hdd_ctx->reg.reg_domain); |
| 10832 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10833 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 10834 | if (ret) { |
| 10835 | hdd_err("Failed to pre-configure cds"); |
| 10836 | goto out; |
| 10837 | } |
| 10838 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 10839 | /* Always get latest IPA resources allocated from cds_open and configure |
| 10840 | * IPA module before configuring them to FW. Sequence required as crash |
| 10841 | * observed otherwise. |
| 10842 | */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 10843 | if (ucfg_ipa_uc_ol_init(hdd_ctx->pdev, |
| 10844 | cds_get_context(QDF_MODULE_ID_QDF_DEVICE))) { |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 10845 | hdd_err("Failed to setup pipes"); |
| 10846 | goto out; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 10847 | } |
| 10848 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10849 | /* |
| 10850 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 10851 | * else |
| 10852 | */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10853 | status = cds_enable(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10854 | |
| 10855 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10856 | hdd_err("cds_enable failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10857 | goto out; |
| 10858 | } |
| 10859 | |
| 10860 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 10861 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10862 | hdd_err("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10863 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10864 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10865 | status = hdd_register_bcn_cb(hdd_ctx); |
| 10866 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 10867 | hdd_err("hdd_register_bcn_cb failed"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10868 | goto cds_disable; |
| 10869 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10870 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10871 | ret = hdd_features_init(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10872 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10873 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10874 | |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10875 | if (hdd_ctx->ol_enable) |
| 10876 | dp_cbs.hdd_disable_rx_ol_in_concurrency = |
| 10877 | hdd_disable_rx_ol_in_concurrency; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 10878 | dp_cbs.hdd_set_rx_mode_rps_cb = hdd_set_rx_mode_rps; |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 10879 | 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] | 10880 | dp_cbs.hdd_v2_flow_pool_map = hdd_v2_flow_pool_map; |
| 10881 | dp_cbs.hdd_v2_flow_pool_unmap = hdd_v2_flow_pool_unmap; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10882 | status = policy_mgr_register_dp_cb(hdd_ctx->psoc, &dp_cbs); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10883 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 10884 | hdd_debug("Failed to register DP cb with Policy Manager"); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10885 | goto cds_disable; |
| 10886 | } |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10887 | status = policy_mgr_register_mode_change_cb(hdd_ctx->psoc, |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 10888 | wlan_hdd_send_mode_change_event); |
| 10889 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10890 | hdd_debug("Failed to register mode change cb with Policy Manager"); |
| 10891 | goto cds_disable; |
| 10892 | } |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10893 | |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 10894 | if (hdd_green_ap_enable_egap(hdd_ctx)) |
Nachiket Kukade | fbd1afc | 2017-07-12 17:41:54 +0530 | [diff] [blame] | 10895 | hdd_debug("enhance green ap is not enabled"); |
| 10896 | |
Nachiket Kukade | dd30266 | 2017-07-13 17:31:44 +0530 | [diff] [blame] | 10897 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 10898 | hdd_debug("Failed to set wow pulse"); |
| 10899 | |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 10900 | sme_cli_set_command(0, WMI_PDEV_PARAM_GCMP_SUPPORT_ENABLE, |
| 10901 | hdd_ctx->config->gcmp_enabled, PDEV_CMD); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 10902 | |
| 10903 | auto_power_fail_mode = |
| 10904 | ucfg_pmo_get_auto_power_fail_mode(hdd_ctx->psoc); |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 10905 | sme_cli_set_command(0, WMI_PDEV_AUTO_DETECT_POWER_FAILURE, |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 10906 | auto_power_fail_mode, PDEV_CMD); |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 10907 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10908 | status = ucfg_get_enable_phy_reg_retention(hdd_ctx->psoc, |
| 10909 | &enable_phy_reg_retention); |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 10910 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10911 | if (QDF_IS_STATUS_ERROR(status)) |
| 10912 | return -EINVAL; |
| 10913 | |
| 10914 | if (enable_phy_reg_retention) |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 10915 | wma_cli_set_command(0, WMI_PDEV_PARAM_FAST_PWR_TRANSITION, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10916 | enable_phy_reg_retention, PDEV_CMD); |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 10917 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10918 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10919 | |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10920 | cds_disable: |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10921 | cds_disable(hdd_ctx->psoc); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10922 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10923 | out: |
| 10924 | return -EINVAL; |
| 10925 | } |
| 10926 | |
| 10927 | /** |
| 10928 | * hdd_deconfigure_cds() -De-Configure cds |
| 10929 | * @hdd_ctx: HDD context |
| 10930 | * |
| 10931 | * Deconfigure Cds modules before WLAN firmware is down. |
| 10932 | * |
| 10933 | * Return: 0 on success and errno on failure. |
| 10934 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10935 | static int hdd_deconfigure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10936 | { |
| 10937 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10938 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10939 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10940 | hdd_enter(); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10941 | |
| 10942 | /* De-init features */ |
| 10943 | hdd_features_deinit(hdd_ctx); |
| 10944 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10945 | /* De-register the SME callbacks */ |
| 10946 | hdd_deregister_cb(hdd_ctx); |
| 10947 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10948 | qdf_status = policy_mgr_deregister_mode_change_cb(hdd_ctx->psoc); |
Srinivas Girigowda | d241288 | 2018-09-07 15:42:04 -0700 | [diff] [blame] | 10949 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 10950 | hdd_debug("Failed to deregister mode change cb with Policy Manager"); |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 10951 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10952 | qdf_status = cds_disable(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10953 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10954 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 10955 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10956 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10957 | } |
| 10958 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 10959 | 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] | 10960 | hdd_err("Failed to disconnect pipes"); |
| 10961 | ret = -EINVAL; |
| 10962 | } |
| 10963 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10964 | hdd_exit(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10965 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10966 | } |
| 10967 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 10968 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 10969 | static void hdd_deregister_policy_manager_callback( |
| 10970 | struct wlan_objmgr_psoc *psoc) |
| 10971 | { |
| 10972 | if (QDF_STATUS_SUCCESS != |
| 10973 | policy_mgr_deregister_hdd_cb(psoc)) { |
| 10974 | hdd_err("HDD callback deregister with policy manager failed"); |
| 10975 | } |
| 10976 | } |
| 10977 | #else |
| 10978 | static void hdd_deregister_policy_manager_callback( |
| 10979 | struct wlan_objmgr_psoc *psoc) |
| 10980 | { |
| 10981 | } |
| 10982 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10983 | |
| 10984 | /** |
| 10985 | * hdd_wlan_stop_modules - Single driver state machine for stoping modules |
| 10986 | * @hdd_ctx: HDD context |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10987 | * @ftm_mode: ftm mode |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10988 | * |
| 10989 | * This function maintains the driver state machine it will be invoked from |
| 10990 | * exit, shutdown and con_mode change handler. Depending on the driver state |
| 10991 | * shall perform the stopping/closing of the modules. |
| 10992 | * |
| 10993 | * Return: 0 for success; non-zero for failure |
| 10994 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10995 | 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] | 10996 | { |
| 10997 | void *hif_ctx; |
| 10998 | qdf_device_t qdf_ctx; |
| 10999 | QDF_STATUS qdf_status; |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11000 | bool is_recovery_stop = cds_is_driver_recovering(); |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 11001 | int ret = 0; |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11002 | int active_threads; |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 11003 | int debugfs_threads; |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 11004 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11005 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11006 | hdd_enter(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11007 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11008 | hdd_deregister_policy_manager_callback(hdd_ctx->psoc); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 11009 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11010 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 11011 | if (!qdf_ctx) { |
| 11012 | hdd_err("QDF device context NULL"); |
| 11013 | return -EINVAL; |
| 11014 | } |
| 11015 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11016 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 11017 | hdd_ctx->stop_modules_in_progress = true; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 11018 | cds_set_module_stop_in_progress(true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11019 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11020 | active_threads = cds_return_external_threads_count(); |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 11021 | debugfs_threads = hdd_return_debugfs_threads_count(); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11022 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 11023 | if (active_threads > 0 || debugfs_threads > 0 || |
| 11024 | hdd_ctx->is_wiphy_suspended) { |
| 11025 | hdd_warn("External threads %d, Debugfs threads %d, wiphy suspend %d", |
| 11026 | active_threads, debugfs_threads, |
| 11027 | hdd_ctx->is_wiphy_suspended); |
| 11028 | |
| 11029 | if (active_threads) |
| 11030 | cds_print_external_threads(); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11031 | |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 11032 | if (IS_IDLE_STOP && !ftm_mode) { |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11033 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 11034 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 11035 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 11036 | hdd_prevent_suspend_timeout( |
| 11037 | hdd_ctx->config->iface_change_wait_time, |
| 11038 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 11039 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 11040 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11041 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11042 | return 0; |
| 11043 | } |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 11044 | } |
| 11045 | |
Kabilan Kannan | 6edafeb | 2017-11-16 16:34:34 -0800 | [diff] [blame] | 11046 | /* free user wowl patterns */ |
| 11047 | hdd_free_user_wowl_ptrns(); |
| 11048 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11049 | switch (hdd_ctx->driver_status) { |
| 11050 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11051 | hdd_debug("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11052 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11053 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11054 | hdd_debug("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11055 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11056 | case DRIVER_MODULES_ENABLED: |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 11057 | hdd_info("Wlan transitioning (CLOSED <- ENABLED)"); |
| 11058 | |
| 11059 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE) |
| 11060 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11061 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 11062 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11063 | if (hdd_deconfigure_cds(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11064 | hdd_err("Failed to de-configure CDS"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11065 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11066 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11067 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11068 | hdd_debug("successfully Disabled the CDS modules!"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11069 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11070 | break; |
| 11071 | default: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11072 | QDF_DEBUG_PANIC("Unknown driver state:%d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11073 | hdd_ctx->driver_status); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11074 | ret = -EINVAL; |
| 11075 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11076 | } |
| 11077 | |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 11078 | hdd_sysfs_destroy_version_interface(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11079 | hdd_debug("Closing CDS modules!"); |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 11080 | |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 11081 | qdf_status = cds_post_disable(); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 11082 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11083 | hdd_err("Failed to process post CDS disable Modules! :%d", |
| 11084 | qdf_status); |
| 11085 | ret = -EINVAL; |
| 11086 | QDF_ASSERT(0); |
| 11087 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 11088 | |
psimha | deea0a1 | 2017-12-18 14:50:02 -0800 | [diff] [blame] | 11089 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
| 11090 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11091 | qdf_status = cds_dp_close(hdd_ctx->psoc); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 11092 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11093 | hdd_warn("Failed to stop CDS DP: %d", qdf_status); |
| 11094 | ret = -EINVAL; |
| 11095 | QDF_ASSERT(0); |
| 11096 | } |
| 11097 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11098 | qdf_status = cds_close(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11099 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11100 | hdd_warn("Failed to stop CDS: %d", qdf_status); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 11101 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11102 | QDF_ASSERT(0); |
| 11103 | } |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 11104 | |
| 11105 | qdf_status = wbuff_module_deinit(); |
| 11106 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
| 11107 | hdd_err("WBUFF de-init unsuccessful; status: %d", qdf_status); |
| 11108 | |
Sandeep Puligilla | b7beb47 | 2018-08-13 22:54:20 -0700 | [diff] [blame] | 11109 | hdd_component_pdev_close(hdd_ctx->pdev); |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 11110 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11111 | hdd_component_psoc_close(hdd_ctx->psoc); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 11112 | dispatcher_pdev_close(hdd_ctx->pdev); |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 11113 | ret = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 11114 | if (ret) { |
| 11115 | hdd_err("Failed to destroy pdev; errno:%d", ret); |
| 11116 | QDF_ASSERT(0); |
| 11117 | } |
| 11118 | |
| 11119 | /* |
| 11120 | * Reset total mac phy during module stop such that during |
| 11121 | * next module start same psoc is used to populate new service |
| 11122 | * ready data |
| 11123 | */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11124 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->psoc); |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 11125 | if (tgt_hdl) |
| 11126 | target_psoc_set_total_mac_phy_cnt(tgt_hdl, 0); |
| 11127 | |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 11128 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11129 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 11130 | if (!hif_ctx) { |
| 11131 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11132 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11133 | } |
| 11134 | |
Arunk Khandavalli | 4b40433 | 2017-09-26 12:46:00 +0530 | [diff] [blame] | 11135 | if (hdd_ctx->target_hw_name) { |
| 11136 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 11137 | hdd_ctx->target_hw_name = NULL; |
| 11138 | } |
| 11139 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 11140 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11141 | |
| 11142 | ol_cds_free(); |
| 11143 | |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 11144 | if (IS_IDLE_STOP && cds_is_target_ready()) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11145 | ret = pld_power_off(qdf_ctx->dev); |
| 11146 | if (ret) |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11147 | hdd_err("Failed to power down device; errno:%d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11148 | } |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11149 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11150 | /* Free the cache channels of the command SET_DISABLE_CHANNEL_LIST */ |
| 11151 | wlan_hdd_free_cache_channels(hdd_ctx); |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 11152 | |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 11153 | hdd_check_for_leaks(hdd_ctx, is_recovery_stop); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 11154 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11155 | |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 11156 | /* Once the firmware sequence is completed reset this flag */ |
| 11157 | hdd_ctx->imps_enabled = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11158 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11159 | hdd_info("Wlan transitioned (now CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11160 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11161 | done: |
| 11162 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 11163 | cds_set_module_stop_in_progress(false); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11164 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11165 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11166 | hdd_exit(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11167 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11168 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11169 | } |
| 11170 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11171 | |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11172 | #ifdef WLAN_FEATURE_MEMDUMP_ENABLE |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11173 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11174 | * hdd_state_info_dump() - prints state information of hdd layer |
| 11175 | * @buf: buffer pointer |
| 11176 | * @size: size of buffer to be filled |
| 11177 | * |
| 11178 | * This function is used to dump state information of hdd layer |
| 11179 | * |
| 11180 | * Return: None |
| 11181 | */ |
| 11182 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 11183 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11184 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 11185 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11186 | struct hdd_adapter *adapter; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11187 | uint16_t len = 0; |
| 11188 | char *buf = *buf_ptr; |
| 11189 | |
| 11190 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11191 | if (!hdd_ctx) { |
| 11192 | hdd_err("Failed to get hdd context "); |
| 11193 | return; |
| 11194 | } |
| 11195 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11196 | hdd_debug("size of buffer: %d", *size); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11197 | |
| 11198 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 11199 | "\n is_wiphy_suspended %d", hdd_ctx->is_wiphy_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11200 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 11201 | "\n is_scheduler_suspended %d", |
| 11202 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11203 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11204 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11205 | if (adapter->dev) |
| 11206 | len += scnprintf(buf + len, *size - len, |
| 11207 | "\n device name: %s", adapter->dev->name); |
wadesong | 42968e9 | 2017-06-08 14:11:21 +0800 | [diff] [blame] | 11208 | len += scnprintf(buf + len, *size - len, |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11209 | "\n device_mode: %d", adapter->device_mode); |
| 11210 | switch (adapter->device_mode) { |
| 11211 | case QDF_STA_MODE: |
| 11212 | case QDF_P2P_CLIENT_MODE: |
| 11213 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 11214 | len += scnprintf(buf + len, *size - len, |
| 11215 | "\n connState: %d", |
| 11216 | hdd_sta_ctx->conn_info.connState); |
| 11217 | break; |
| 11218 | |
| 11219 | default: |
| 11220 | break; |
| 11221 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11222 | } |
| 11223 | |
| 11224 | *size -= len; |
| 11225 | *buf_ptr += len; |
| 11226 | } |
| 11227 | |
| 11228 | /** |
| 11229 | * hdd_register_debug_callback() - registration function for hdd layer |
| 11230 | * to print hdd state information |
| 11231 | * |
| 11232 | * Return: None |
| 11233 | */ |
| 11234 | static void hdd_register_debug_callback(void) |
| 11235 | { |
| 11236 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 11237 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11238 | #else /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Wen Gong | aa6d55d | 2018-04-26 16:33:21 +0800 | [diff] [blame] | 11239 | static void hdd_register_debug_callback(void) |
| 11240 | { |
| 11241 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11242 | #endif /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11243 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 11244 | /* |
| 11245 | * wlan_init_bug_report_lock() - Initialize bug report lock |
| 11246 | * |
| 11247 | * This function is used to create bug report lock |
| 11248 | * |
| 11249 | * Return: None |
| 11250 | */ |
| 11251 | static void wlan_init_bug_report_lock(void) |
| 11252 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 11253 | struct cds_context *p_cds_context; |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 11254 | |
| 11255 | p_cds_context = cds_get_global_context(); |
| 11256 | if (!p_cds_context) { |
| 11257 | hdd_err("cds context is NULL"); |
| 11258 | return; |
| 11259 | } |
| 11260 | |
| 11261 | qdf_spinlock_create(&p_cds_context->bug_report_lock); |
| 11262 | } |
| 11263 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11264 | #ifdef CONFIG_DP_TRACE |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11265 | void hdd_dp_trace_init(struct hdd_config *config) |
| 11266 | { |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11267 | bool live_mode = DP_TRACE_CONFIG_DEFAULT_LIVE_MODE; |
| 11268 | uint8_t thresh = DP_TRACE_CONFIG_DEFAULT_THRESH; |
| 11269 | uint16_t thresh_time_limit = DP_TRACE_CONFIG_DEFAULT_THRESH_TIME_LIMIT; |
| 11270 | uint8_t verbosity = DP_TRACE_CONFIG_DEFAULT_VERBOSTY; |
| 11271 | uint8_t proto_bitmap = DP_TRACE_CONFIG_DEFAULT_BITMAP; |
| 11272 | uint8_t config_params[DP_TRACE_CONFIG_NUM_PARAMS]; |
| 11273 | uint8_t num_entries = 0; |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11274 | uint32_t bw_compute_interval; |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11275 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11276 | if (!config->enable_dp_trace) { |
| 11277 | hdd_err("dp trace is disabled from ini"); |
| 11278 | return; |
| 11279 | } |
| 11280 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11281 | hdd_string_to_u8_array(config->dp_trace_config, config_params, |
| 11282 | &num_entries, sizeof(config_params)); |
| 11283 | |
| 11284 | /* calculating, num bw timer intervals in a second (1000ms) */ |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11285 | bw_compute_interval = GET_BW_COMPUTE_INTV(config); |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 11286 | if (bw_compute_interval <= 1000 && bw_compute_interval > 0) |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11287 | thresh_time_limit = 1000 / bw_compute_interval; |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 11288 | else if (bw_compute_interval > 1000) { |
| 11289 | hdd_err("busBandwidthComputeInterval > 1000, using 1000"); |
| 11290 | thresh_time_limit = 1; |
| 11291 | } else |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11292 | hdd_err("busBandwidthComputeInterval is 0, using defaults"); |
| 11293 | |
| 11294 | switch (num_entries) { |
| 11295 | case 4: |
| 11296 | proto_bitmap = config_params[3]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11297 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11298 | case 3: |
| 11299 | verbosity = config_params[2]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11300 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11301 | case 2: |
| 11302 | thresh = config_params[1]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11303 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11304 | case 1: |
| 11305 | live_mode = config_params[0]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11306 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11307 | default: |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 11308 | hdd_debug("live_mode %u thresh %u time_limit %u verbosity %u bitmap 0x%x", |
| 11309 | live_mode, thresh, thresh_time_limit, |
| 11310 | verbosity, proto_bitmap); |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11311 | }; |
| 11312 | |
| 11313 | qdf_dp_trace_init(live_mode, thresh, thresh_time_limit, |
| 11314 | verbosity, proto_bitmap); |
| 11315 | |
| 11316 | } |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11317 | #endif |
| 11318 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11319 | #ifdef DISABLE_CHANNEL_LIST |
| 11320 | static int wlan_hdd_cache_chann_mutex_create(struct hdd_context *hdd_ctx) |
| 11321 | { |
| 11322 | return qdf_mutex_create(&hdd_ctx->cache_channel_lock); |
| 11323 | } |
| 11324 | #else |
| 11325 | static int wlan_hdd_cache_chann_mutex_create(struct hdd_context *hdd_ctx) |
| 11326 | { |
| 11327 | return 0; |
| 11328 | } |
| 11329 | #endif |
| 11330 | |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11331 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11332 | * hdd_wlan_startup() - HDD init function |
| 11333 | * @dev: Pointer to the underlying device |
| 11334 | * |
| 11335 | * This is the driver startup code executed once a WLAN device has been detected |
| 11336 | * |
| 11337 | * Return: 0 for success, < 0 for failure |
| 11338 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11339 | int hdd_wlan_startup(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11340 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11341 | QDF_STATUS status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11342 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11343 | int ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 11344 | bool rtnl_held; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11345 | mac_handle_t mac_handle; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11346 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11347 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11348 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11349 | hdd_ctx = hdd_context_create(dev); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11350 | |
| 11351 | if (IS_ERR(hdd_ctx)) |
| 11352 | return PTR_ERR(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11353 | |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11354 | hdd_action_oui_config(hdd_ctx); |
| 11355 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 11356 | qdf_nbuf_init_replenish_timer(); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11357 | |
| 11358 | ret = wlan_hdd_cache_chann_mutex_create(hdd_ctx); |
| 11359 | if (QDF_IS_STATUS_ERROR(ret)) |
| 11360 | goto err_hdd_free_context; |
| 11361 | |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 11362 | #ifdef FEATURE_WLAN_CH_AVOID |
| 11363 | mutex_init(&hdd_ctx->avoid_freq_lock); |
| 11364 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11365 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 11366 | osif_request_manager_init(); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 11367 | qdf_atomic_init(&hdd_ctx->con_mode_flag); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11368 | hdd_driver_memdump_init(); |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 11369 | hdd_bus_bandwidth_init(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11370 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 11371 | ret = hdd_wlan_start_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11372 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11373 | hdd_err("Failed to start modules: %d", ret); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11374 | goto err_memdump_deinit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11375 | } |
| 11376 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 11377 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11378 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11379 | mac_handle = cds_get_context(QDF_MODULE_ID_SME); |
| 11380 | hdd_ctx->mac_handle = mac_handle; |
| 11381 | if (!mac_handle) { |
| 11382 | hdd_err("Mac Handle is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11383 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11384 | } |
| 11385 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 11386 | ret = hdd_wiphy_init(hdd_ctx); |
| 11387 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11388 | hdd_err("Failed to initialize wiphy: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11389 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11390 | } |
| 11391 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11392 | hdd_dp_trace_init(hdd_ctx->config); |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 11393 | |
Yuanyuan Liu | c98370e | 2016-10-13 11:22:13 -0700 | [diff] [blame] | 11394 | hdd_initialize_mac_address(hdd_ctx); |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 11395 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11396 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 11397 | if (ret) { |
| 11398 | hdd_err("register_netdevice_notifier failed: %d", ret); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 11399 | goto err_wiphy_unregister; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11400 | } |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 11401 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 11402 | ret = register_reboot_notifier(&system_reboot_notifier); |
| 11403 | if (ret) { |
| 11404 | hdd_err("Failed to register reboot notifier: %d", ret); |
| 11405 | goto err_unregister_netdev; |
| 11406 | } |
| 11407 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 11408 | rtnl_held = hdd_hold_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11409 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 11410 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 11411 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11412 | hdd_err("Failed to open interfaces: %d", ret); |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 11413 | goto err_release_rtnl_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11414 | } |
| 11415 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 11416 | hdd_release_rtnl_lock(); |
| 11417 | rtnl_held = false; |
| 11418 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 11419 | wlan_hdd_update_11n_mode(hdd_ctx->config); |
| 11420 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11421 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 11422 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 11423 | QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11424 | hdd_skip_acs_scan_timer_handler, |
| 11425 | (void *)hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11426 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 11427 | hdd_err("Failed to init ACS Skip timer"); |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 11428 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11429 | #endif |
| 11430 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 11431 | hdd_lpass_notify_wlan_version(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11432 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 11433 | if (hdd_ctx->rps) |
| 11434 | hdd_set_rps_cpu_mask(hdd_ctx); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 11435 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11436 | ret = hdd_register_notifiers(hdd_ctx); |
| 11437 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 11438 | goto err_close_adapters; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 11439 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11440 | status = wlansap_global_init(); |
| 11441 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11442 | hdd_unregister_notifiers(hdd_ctx); |
| 11443 | goto err_close_adapters; |
| 11444 | } |
| 11445 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11446 | if (hdd_ctx->config->fIsImpsEnabled) |
| 11447 | hdd_set_idle_ps_config(hdd_ctx, true); |
Kiran Kumar Lokere | b0f19c3 | 2017-10-13 12:23:26 -0700 | [diff] [blame] | 11448 | else |
| 11449 | hdd_set_idle_ps_config(hdd_ctx, false); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11450 | |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 11451 | if (QDF_GLOBAL_FTM_MODE != hdd_get_conparam()) { |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 11452 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 11453 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 11454 | hdd_prevent_suspend_timeout( |
| 11455 | hdd_ctx->config->iface_change_wait_time, |
| 11456 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
| 11457 | } |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 11458 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11459 | goto success; |
| 11460 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 11461 | err_close_adapters: |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 11462 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11463 | |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 11464 | err_release_rtnl_lock: |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 11465 | unregister_reboot_notifier(&system_reboot_notifier); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 11466 | if (rtnl_held) |
| 11467 | hdd_release_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11468 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 11469 | err_unregister_netdev: |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11470 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 11471 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11472 | err_wiphy_unregister: |
Rachit Kankane | 3080733 | 2018-06-27 18:39:36 +0530 | [diff] [blame] | 11473 | qdf_dp_trace_deinit(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11474 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11475 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11476 | err_stop_modules: |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 11477 | hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11478 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11479 | err_memdump_deinit: |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 11480 | hdd_bus_bandwidth_deinit(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11481 | hdd_driver_memdump_deinit(); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11482 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 11483 | osif_request_manager_deinit(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 11484 | hdd_exit_netlink_services(hdd_ctx); |
| 11485 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11486 | err_hdd_free_context: |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 11487 | if (cds_is_fw_down()) |
| 11488 | hdd_err("Not setting the complete event as fw is down"); |
| 11489 | else |
| 11490 | hdd_start_complete(ret); |
| 11491 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 11492 | qdf_nbuf_deinit_replenish_timer(); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 11493 | hdd_context_destroy(hdd_ctx); |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 11494 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11495 | |
| 11496 | success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11497 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11498 | return 0; |
| 11499 | } |
| 11500 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11501 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11502 | * hdd_wlan_update_target_info() - update target type info |
| 11503 | * @hdd_ctx: HDD context |
| 11504 | * @context: hif context |
| 11505 | * |
| 11506 | * Update target info received from firmware in hdd context |
| 11507 | * Return:None |
| 11508 | */ |
| 11509 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11510 | 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] | 11511 | { |
| 11512 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 11513 | |
| 11514 | if (!tgt_info) { |
| 11515 | hdd_err("Target info is Null"); |
| 11516 | return; |
| 11517 | } |
| 11518 | |
| 11519 | hdd_ctx->target_type = tgt_info->target_type; |
| 11520 | } |
| 11521 | |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11522 | 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] | 11523 | { |
| 11524 | struct hdd_context *hdd_ctx = (struct hdd_context *)data; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11525 | int status; |
| 11526 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11527 | struct osif_request *request = NULL; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11528 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11529 | hdd_enter(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11530 | |
| 11531 | if (!rsp) { |
| 11532 | hdd_err("data is null"); |
| 11533 | return; |
| 11534 | } |
| 11535 | |
| 11536 | status = wlan_hdd_validate_context(hdd_ctx); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11537 | if (status != 0) |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11538 | return; |
| 11539 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11540 | request = osif_request_get(context); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11541 | if (!request) { |
| 11542 | hdd_err("obselete request"); |
| 11543 | return; |
| 11544 | } |
| 11545 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11546 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id); |
| 11547 | if ((NULL == adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
| 11548 | hdd_err("Invalid adapter or adapter has invalid magic"); |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11549 | osif_request_put(request); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11550 | return; |
| 11551 | } |
| 11552 | |
Alok Kumar | ce2c29a | 2018-10-12 15:44:02 +0530 | [diff] [blame] | 11553 | hdd_debug("rsp->arp_req_enqueue :%x", rsp->arp_req_enqueue); |
| 11554 | hdd_debug("rsp->arp_req_tx_success :%x", rsp->arp_req_tx_success); |
| 11555 | hdd_debug("rsp->arp_req_tx_failure :%x", rsp->arp_req_tx_failure); |
| 11556 | hdd_debug("rsp->arp_rsp_recvd :%x", rsp->arp_rsp_recvd); |
| 11557 | hdd_debug("rsp->out_of_order_arp_rsp_drop_cnt :%x", |
| 11558 | rsp->out_of_order_arp_rsp_drop_cnt); |
| 11559 | hdd_debug("rsp->dad_detected :%x", rsp->dad_detected); |
| 11560 | hdd_debug("rsp->connect_status :%x", rsp->connect_status); |
| 11561 | hdd_debug("rsp->ba_session_establishment_status :%x", |
| 11562 | rsp->ba_session_establishment_status); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11563 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11564 | 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] | 11565 | adapter->dad |= rsp->dad_detected; |
| 11566 | adapter->con_status = rsp->connect_status; |
| 11567 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 11568 | /* Flag true indicates connectivity check stats present. */ |
| 11569 | if (rsp->connect_stats_present) { |
Alok Kumar | ce2c29a | 2018-10-12 15:44:02 +0530 | [diff] [blame] | 11570 | hdd_debug("rsp->tcp_ack_recvd :%x", rsp->tcp_ack_recvd); |
| 11571 | hdd_debug("rsp->icmpv4_rsp_recvd :%x", rsp->icmpv4_rsp_recvd); |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 11572 | adapter->hdd_stats.hdd_tcp_stats.rx_fw_cnt = rsp->tcp_ack_recvd; |
| 11573 | adapter->hdd_stats.hdd_icmpv4_stats.rx_fw_cnt = |
| 11574 | rsp->icmpv4_rsp_recvd; |
| 11575 | } |
| 11576 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11577 | osif_request_complete(request); |
| 11578 | osif_request_put(request); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11579 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11580 | hdd_exit(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11581 | } |
| 11582 | |
| 11583 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11584 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11585 | * @hdd_ctx: HDD context |
| 11586 | * |
| 11587 | * Register the HDD callbacks to CDS/SME. |
| 11588 | * |
| 11589 | * Return: 0 for success or Error code for failure |
| 11590 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11591 | int hdd_register_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11592 | { |
| 11593 | QDF_STATUS status; |
| 11594 | int ret = 0; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11595 | mac_handle_t mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11596 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11597 | hdd_enter(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11598 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11599 | mac_handle = hdd_ctx->mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11600 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11601 | sme_register_oem_data_rsp_callback(mac_handle, |
| 11602 | hdd_send_oem_data_rsp_msg); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11603 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11604 | sme_register_mgmt_frame_ind_callback(mac_handle, |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 11605 | hdd_indicate_mgmt_frame); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11606 | sme_set_tsfcb(mac_handle, hdd_get_tsf_cb, hdd_ctx); |
| 11607 | sme_nan_register_callback(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11608 | wlan_hdd_cfg80211_nan_callback); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11609 | sme_stats_ext_register_callback(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11610 | wlan_hdd_cfg80211_stats_ext_callback); |
| 11611 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11612 | sme_ext_scan_register_callback(mac_handle, |
| 11613 | wlan_hdd_cfg80211_extscan_callback); |
| 11614 | sme_stats_ext2_register_callback(mac_handle, |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 11615 | wlan_hdd_cfg80211_stats_ext2_callback); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11616 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11617 | sme_set_rssi_threshold_breached_cb(mac_handle, |
| 11618 | hdd_rssi_threshold_breached); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11619 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11620 | sme_set_link_layer_stats_ind_cb(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11621 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 11622 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11623 | 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] | 11624 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11625 | sme_set_link_layer_ext_cb(mac_handle, |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 11626 | wlan_hdd_cfg80211_link_layer_stats_ext_callback); |
| 11627 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11628 | status = sme_set_lost_link_info_cb(mac_handle, |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 11629 | hdd_lost_link_info_cb); |
| 11630 | /* print error and not block the startup process */ |
| 11631 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11632 | hdd_err("set lost link info callback failed"); |
| 11633 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 11634 | ret = hdd_register_data_stall_detect_cb(); |
| 11635 | if (ret) { |
| 11636 | hdd_err("Register data stall detect detect callback failed."); |
| 11637 | return ret; |
| 11638 | } |
| 11639 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11640 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 11641 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11642 | sme_register_set_connection_info_cb(mac_handle, |
| 11643 | hdd_set_connection_in_progress, |
| 11644 | hdd_is_connection_in_progress); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 11645 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11646 | status = sme_congestion_register_callback(mac_handle, |
| 11647 | hdd_update_cca_info_cb); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 11648 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11649 | hdd_err("set congestion callback failed"); |
| 11650 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11651 | status = sme_set_bt_activity_info_cb(mac_handle, |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 11652 | hdd_bt_activity_cb); |
| 11653 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11654 | hdd_err("set bt activity info callback failed"); |
| 11655 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11656 | status = sme_register_tx_queue_cb(mac_handle, |
Varun Reddy Yeturu | 076eaa8 | 2018-01-16 12:16:14 -0800 | [diff] [blame] | 11657 | hdd_tx_queue_cb); |
| 11658 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11659 | hdd_err("Register tx queue callback failed"); |
| 11660 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11661 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11662 | |
| 11663 | return ret; |
| 11664 | } |
| 11665 | |
| 11666 | /** |
| 11667 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 11668 | * @hdd_ctx: HDD context |
| 11669 | * |
| 11670 | * De-Register the HDD callbacks to CDS/SME. |
| 11671 | * |
| 11672 | * Return: void |
| 11673 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11674 | void hdd_deregister_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11675 | { |
| 11676 | QDF_STATUS status; |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 11677 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11678 | mac_handle_t mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11679 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11680 | hdd_enter(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11681 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11682 | mac_handle = hdd_ctx->mac_handle; |
| 11683 | sme_deregister_tx_queue_cb(mac_handle); |
| 11684 | status = sme_deregister_for_dcc_stats_event(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11685 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11686 | hdd_err("De-register of dcc stats callback failed: %d", |
| 11687 | status); |
| 11688 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11689 | sme_reset_link_layer_stats_ind_cb(mac_handle); |
| 11690 | sme_reset_rssi_threshold_breached_cb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11691 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11692 | sme_stats_ext_register_callback(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11693 | wlan_hdd_cfg80211_stats_ext_callback); |
| 11694 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11695 | sme_nan_deregister_callback(mac_handle); |
| 11696 | status = sme_reset_tsfcb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11697 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11698 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 11699 | status); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11700 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 11701 | ret = hdd_deregister_data_stall_detect_cb(); |
| 11702 | if (ret) |
| 11703 | hdd_err("Failed to de-register data stall detect event callback"); |
| 11704 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11705 | sme_deregister_oem_data_rsp_callback(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11706 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11707 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11708 | } |
| 11709 | |
| 11710 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11711 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
| 11712 | * @adapter: Pointer to the HDD |
| 11713 | * @enable: bool value |
| 11714 | * |
| 11715 | * This to take counter measure to handle deauth req from HDD |
| 11716 | * |
| 11717 | * Return: None |
| 11718 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11719 | QDF_STATUS hdd_softap_sta_deauth(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 11720 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11721 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11722 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11723 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11724 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11725 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11726 | /* Ignore request to deauth bcmc station */ |
| 11727 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11728 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11729 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11730 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11731 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 11732 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11733 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11734 | hdd_exit(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11735 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11736 | } |
| 11737 | |
| 11738 | /** |
| 11739 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
| 11740 | * @adapter: Pointer to the HDD |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 11741 | * @p_del_sta_params: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11742 | * |
| 11743 | * This to take counter measure to handle deauth req from HDD |
| 11744 | * |
| 11745 | * Return: None |
| 11746 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11747 | void hdd_softap_sta_disassoc(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 11748 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11749 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11750 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11751 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11752 | /* Ignore request to disassoc bcmc station */ |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 11753 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11754 | return; |
| 11755 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11756 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 11757 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11758 | } |
| 11759 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11760 | /** |
| 11761 | * hdd_issta_p2p_clientconnected() - check if sta or p2p client is connected |
| 11762 | * @hdd_ctx: HDD Context |
| 11763 | * |
| 11764 | * API to find if there is any STA or P2P-Client is connected |
| 11765 | * |
| 11766 | * Return: true if connected; false otherwise |
| 11767 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11768 | QDF_STATUS hdd_issta_p2p_clientconnected(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11769 | { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11770 | return sme_is_sta_p2p_client_connected(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11771 | } |
| 11772 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11773 | void wlan_hdd_disable_roaming(struct hdd_adapter *cur_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11774 | { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11775 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(cur_adapter); |
| 11776 | struct hdd_adapter *adapter = NULL; |
| 11777 | struct csr_roam_profile *roam_profile; |
| 11778 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11779 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11780 | if (!policy_mgr_is_sta_active_connection_exists(hdd_ctx->psoc)) { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11781 | hdd_debug("No active sta session"); |
| 11782 | return; |
| 11783 | } |
| 11784 | |
| 11785 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11786 | roam_profile = hdd_roam_profile(adapter); |
| 11787 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 11788 | |
| 11789 | if (cur_adapter->session_id != adapter->session_id && |
| 11790 | adapter->device_mode == QDF_STA_MODE && |
| 11791 | hdd_conn_is_connected(sta_ctx)) { |
| 11792 | hdd_debug("%d Disable roaming", adapter->session_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11793 | sme_stop_roaming(hdd_ctx->mac_handle, |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11794 | adapter->session_id, |
| 11795 | ecsr_driver_disabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11796 | } |
| 11797 | } |
| 11798 | } |
| 11799 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11800 | void wlan_hdd_enable_roaming(struct hdd_adapter *cur_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11801 | { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11802 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(cur_adapter); |
| 11803 | struct hdd_adapter *adapter = NULL; |
| 11804 | struct csr_roam_profile *roam_profile; |
| 11805 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11806 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11807 | if (!policy_mgr_is_sta_active_connection_exists(hdd_ctx->psoc)) { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11808 | hdd_debug("No active sta session"); |
| 11809 | return; |
| 11810 | } |
| 11811 | |
| 11812 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11813 | roam_profile = hdd_roam_profile(adapter); |
| 11814 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 11815 | |
| 11816 | if (cur_adapter->session_id != adapter->session_id && |
| 11817 | adapter->device_mode == QDF_STA_MODE && |
| 11818 | hdd_conn_is_connected(sta_ctx)) { |
| 11819 | hdd_debug("%d Enable roaming", adapter->session_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11820 | sme_start_roaming(hdd_ctx->mac_handle, |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11821 | adapter->session_id, |
| 11822 | REASON_DRIVER_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11823 | } |
| 11824 | } |
| 11825 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11826 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 11827 | /** |
| 11828 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 11829 | * @skb: sk buffer pointer |
| 11830 | * |
| 11831 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 11832 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 11833 | * |
| 11834 | * Return: None |
| 11835 | */ |
| 11836 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 11837 | { |
| 11838 | #ifdef CNSS_GENL |
| 11839 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 11840 | #else |
| 11841 | nl_srv_bcast(skb); |
| 11842 | #endif |
| 11843 | } |
| 11844 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11845 | 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] | 11846 | { |
| 11847 | struct sk_buff *skb; |
| 11848 | struct nlmsghdr *nlh; |
| 11849 | tAniMsgHdr *ani_hdr; |
| 11850 | void *nl_data = NULL; |
| 11851 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11852 | struct radio_index_tlv *radio_info; |
| 11853 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11854 | |
| 11855 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 11856 | flags = GFP_ATOMIC; |
| 11857 | |
| 11858 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 11859 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11860 | if (skb == NULL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11861 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11862 | |
| 11863 | nlh = (struct nlmsghdr *)skb->data; |
| 11864 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 11865 | nlh->nlmsg_flags = 0; |
| 11866 | nlh->nlmsg_seq = 0; |
| 11867 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 11868 | |
| 11869 | ani_hdr = NLMSG_DATA(nlh); |
| 11870 | ani_hdr->type = type; |
| 11871 | |
| 11872 | switch (type) { |
| 11873 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 11874 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11875 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11876 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 11877 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11878 | ani_hdr->length = 0; |
| 11879 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11880 | break; |
| 11881 | case WLAN_SVC_WLAN_STATUS_IND: |
| 11882 | case WLAN_SVC_WLAN_VERSION_IND: |
| 11883 | case WLAN_SVC_DFS_CAC_START_IND: |
| 11884 | case WLAN_SVC_DFS_CAC_END_IND: |
| 11885 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 11886 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 11887 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 11888 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 11889 | case WLAN_SVC_RPS_ENABLE_IND: |
Orhan K AKYILDIZ | e7445a2 | 2017-01-19 21:21:47 -0800 | [diff] [blame] | 11890 | case WLAN_SVC_CORE_MINFREQ: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11891 | ani_hdr->length = len; |
| 11892 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 11893 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 11894 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11895 | break; |
| 11896 | |
| 11897 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 11898 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11899 | type); |
| 11900 | kfree_skb(skb); |
| 11901 | return; |
| 11902 | } |
| 11903 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11904 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 11905 | * Add radio index at the end of the svc event in TLV format |
| 11906 | * to maintain the backward compatibility with userspace |
| 11907 | * applications. |
| 11908 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11909 | |
| 11910 | tlv_len = 0; |
| 11911 | |
| 11912 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 11913 | < WLAN_NL_MAX_PAYLOAD) { |
| 11914 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 11915 | sizeof(*ani_hdr) + len); |
| 11916 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 11917 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 11918 | radio_info->radio = radio; |
| 11919 | tlv_len = sizeof(*radio_info); |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 11920 | hdd_debug("Added radio index tlv - radio index %d", |
| 11921 | radio_info->radio); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11922 | } |
| 11923 | |
| 11924 | nlh->nlmsg_len += tlv_len; |
| 11925 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 11926 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 11927 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11928 | } |
| 11929 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11930 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 11931 | void wlan_hdd_auto_shutdown_cb(void) |
| 11932 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11933 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11934 | |
| 11935 | if (!hdd_ctx) |
| 11936 | return; |
| 11937 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11938 | hdd_debug("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11939 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 11940 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11941 | } |
| 11942 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11943 | 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] | 11944 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11945 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11946 | bool ap_connected = false, sta_connected = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11947 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11948 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11949 | mac_handle = hdd_ctx->mac_handle; |
| 11950 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11951 | return; |
| 11952 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 11953 | if (hdd_ctx->config->wlan_auto_shutdown == 0) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11954 | return; |
| 11955 | |
| 11956 | if (enable == false) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11957 | if (sme_set_auto_shutdown_timer(mac_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11958 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11959 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11960 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11961 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 11962 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11963 | return; |
| 11964 | } |
| 11965 | |
| 11966 | /* To enable shutdown timer check conncurrency */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11967 | if (policy_mgr_concurrent_open_sessions_running(hdd_ctx->psoc)) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11968 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11969 | if (adapter->device_mode == QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11970 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 11971 | conn_info.connState == |
| 11972 | eConnectionState_Associated) { |
| 11973 | sta_connected = true; |
| 11974 | break; |
| 11975 | } |
| 11976 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11977 | |
| 11978 | if (adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11979 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 11980 | ap_active == true) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11981 | ap_connected = true; |
| 11982 | break; |
| 11983 | } |
| 11984 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11985 | } |
| 11986 | } |
| 11987 | |
| 11988 | if (ap_connected == true || sta_connected == true) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11989 | hdd_debug("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11990 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11991 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 11992 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11993 | if (sme_set_auto_shutdown_timer(mac_handle, |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 11994 | hdd_ctx->config->wlan_auto_shutdown) |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 11995 | != QDF_STATUS_SUCCESS) |
| 11996 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 11997 | else |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 11998 | hdd_info("Auto Shutdown timer for %d seconds enabled", |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 11999 | hdd_ctx->config->wlan_auto_shutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12000 | } |
| 12001 | #endif |
| 12002 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 12003 | struct hdd_adapter * |
| 12004 | hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, |
| 12005 | bool check_start_bss) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12006 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12007 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12008 | struct hdd_adapter *adapter, *con_sap_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12009 | |
| 12010 | con_sap_adapter = NULL; |
| 12011 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12012 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 12013 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 12014 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12015 | adapter != this_sap_adapter) { |
| 12016 | if (check_start_bss) { |
| 12017 | if (test_bit(SOFTAP_BSS_STARTED, |
| 12018 | &adapter->event_flags)) { |
| 12019 | con_sap_adapter = adapter; |
| 12020 | break; |
| 12021 | } |
| 12022 | } else { |
| 12023 | con_sap_adapter = adapter; |
| 12024 | break; |
| 12025 | } |
| 12026 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12027 | } |
| 12028 | |
| 12029 | return con_sap_adapter; |
| 12030 | } |
| 12031 | |
| 12032 | #ifdef MSM_PLATFORM |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12033 | static inline bool hdd_adapter_is_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12034 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12035 | return adapter->device_mode == QDF_STA_MODE || |
| 12036 | adapter->device_mode == QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12037 | } |
| 12038 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12039 | static inline bool hdd_adapter_is_ap(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12040 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12041 | return adapter->device_mode == QDF_SAP_MODE || |
| 12042 | adapter->device_mode == QDF_P2P_GO_MODE; |
| 12043 | } |
| 12044 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12045 | static bool hdd_any_adapter_is_assoc(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12046 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12047 | struct hdd_adapter *adapter; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12048 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12049 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12050 | if (hdd_adapter_is_sta(adapter) && |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12051 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 12052 | conn_info.connState == eConnectionState_Associated) { |
| 12053 | return true; |
| 12054 | } |
| 12055 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12056 | if (hdd_adapter_is_ap(adapter) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 12057 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12058 | return true; |
| 12059 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12060 | } |
| 12061 | |
| 12062 | return false; |
| 12063 | } |
| 12064 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12065 | 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] | 12066 | { |
| 12067 | bool is_running; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12068 | |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 12069 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12070 | is_running = hdd_ctx->bus_bw_timer_running; |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 12071 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12072 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12073 | return is_running; |
| 12074 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12075 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12076 | 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] | 12077 | { |
| 12078 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 12079 | hdd_ctx->bus_bw_timer_running = true; |
| 12080 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 12081 | hdd_ctx->config->bus_bw_compute_interval); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12082 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 12083 | } |
| 12084 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12085 | void hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12086 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12087 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12088 | |
| 12089 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 12090 | hdd_debug("Bandwidth compute timer already started"); |
| 12091 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12092 | } |
| 12093 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12094 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 12095 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12096 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12097 | } |
| 12098 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12099 | 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] | 12100 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12101 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12102 | |
| 12103 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 12104 | hdd_debug("Bandwidth compute timer already started"); |
| 12105 | return; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 12106 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12107 | |
| 12108 | if (hdd_any_adapter_is_assoc(hdd_ctx)) |
| 12109 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 12110 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12111 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12112 | } |
| 12113 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12114 | 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] | 12115 | { |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 12116 | ucfg_ipa_set_perf_level(hdd_ctx->pdev, 0, 0); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12117 | |
| 12118 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12119 | hdd_ctx->bus_bw_timer_running = false; |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 12120 | qdf_timer_sync_cancel(&hdd_ctx->bus_bw_timer); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12121 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 12122 | |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 12123 | /* work callback is long running; flush outside of lock */ |
| 12124 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12125 | hdd_reset_tcp_delack(hdd_ctx); |
| 12126 | } |
| 12127 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12128 | void hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12129 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12130 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12131 | |
| 12132 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 12133 | hdd_debug("Bandwidth compute timer already stopped"); |
| 12134 | return; |
| 12135 | } |
| 12136 | |
| 12137 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 12138 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12139 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12140 | } |
| 12141 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12142 | 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] | 12143 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12144 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12145 | |
| 12146 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 12147 | hdd_debug("Bandwidth compute timer already stopped"); |
| 12148 | return; |
| 12149 | } |
| 12150 | |
| 12151 | if (!hdd_any_adapter_is_assoc(hdd_ctx)) |
| 12152 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 12153 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12154 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12155 | } |
| 12156 | #endif |
| 12157 | |
| 12158 | /** |
| 12159 | * wlan_hdd_check_custom_con_channel_rules() - This function checks the sap's |
| 12160 | * and sta's operating channel. |
| 12161 | * @sta_adapter: Describe the first argument to foobar. |
| 12162 | * @ap_adapter: Describe the second argument to foobar. |
| 12163 | * @roam_profile: Roam profile of AP to which STA wants to connect. |
| 12164 | * @concurrent_chnl_same: If both SAP and STA channels are same then |
| 12165 | * set this flag to true else false. |
| 12166 | * |
| 12167 | * This function checks the sap's operating channel and sta's operating channel. |
| 12168 | * if both are same then it will return false else it will restart the sap in |
| 12169 | * sta's channel and return true. |
| 12170 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12171 | * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12172 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 12173 | QDF_STATUS |
| 12174 | wlan_hdd_check_custom_con_channel_rules(struct hdd_adapter *sta_adapter, |
| 12175 | struct hdd_adapter *ap_adapter, |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 12176 | struct csr_roam_profile *roam_profile, |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 12177 | tScanResultHandle *scan_cache, |
| 12178 | bool *concurrent_chnl_same) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12179 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12180 | struct hdd_ap_ctx *hdd_ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12181 | uint8_t channel_id; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12182 | QDF_STATUS status; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 12183 | enum QDF_OPMODE device_mode = ap_adapter->device_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12184 | *concurrent_chnl_same = true; |
| 12185 | |
| 12186 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 12187 | status = |
Archana Ramachandran | 2eb7a61 | 2017-03-23 22:58:42 -0700 | [diff] [blame] | 12188 | sme_get_ap_channel_from_scan_cache(roam_profile, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12189 | scan_cache, |
| 12190 | &channel_id); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12191 | if (QDF_STATUS_SUCCESS == status) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 12192 | if ((QDF_SAP_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12193 | (channel_id < SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 12194 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12195 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12196 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12197 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 12198 | } else if ((QDF_P2P_GO_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12199 | (channel_id >= SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 12200 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12201 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12202 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12203 | } |
| 12204 | } |
| 12205 | } else { |
| 12206 | /* |
| 12207 | * Lets handle worst case scenario here, Scan cache lookup is |
| 12208 | * failed so we have to stop the SAP to avoid any channel |
| 12209 | * discrepancy between SAP's channel and STA's channel. |
| 12210 | * Return the status as failure so caller function could know |
| 12211 | * that scan look up is failed. |
| 12212 | */ |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12213 | hdd_err("Finding AP from scan cache failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12214 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12215 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12216 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12217 | } |
| 12218 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12219 | /** |
| 12220 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 12221 | * @ap_adapter: SAP adapter |
| 12222 | * |
| 12223 | * This function will process the stopping of sap adapter. |
| 12224 | * |
| 12225 | * Return: None |
| 12226 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12227 | void wlan_hdd_stop_sap(struct hdd_adapter *ap_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12228 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12229 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 12230 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12231 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12232 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12233 | |
| 12234 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12235 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12236 | return; |
| 12237 | } |
| 12238 | |
| 12239 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 12240 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 12241 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12242 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 12243 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12244 | mutex_lock(&hdd_ctx->sap_lock); |
| 12245 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 12246 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12247 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12248 | hdd_debug("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 12249 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12250 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 12251 | sap_context)) { |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 12252 | qdf_status = qdf_wait_for_event_completion(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 12253 | qdf_stop_bss_event, |
Vignesh Viswanathan | 865daaa | 2018-10-11 19:30:44 +0530 | [diff] [blame] | 12254 | SME_CMD_START_STOP_BSS_TIMEOUT); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12255 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12256 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12257 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12258 | return; |
| 12259 | } |
| 12260 | } |
| 12261 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12262 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12263 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12264 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 12265 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12266 | false); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12267 | hdd_debug("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12268 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12269 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12270 | } |
| 12271 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12272 | } |
| 12273 | |
| 12274 | /** |
| 12275 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 12276 | * @ap_adapter: SAP adapter |
| 12277 | * |
| 12278 | * This function will process the starting of sap adapter. |
| 12279 | * |
| 12280 | * Return: None |
| 12281 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12282 | void wlan_hdd_start_sap(struct hdd_adapter *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12283 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12284 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 12285 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12286 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12287 | struct hdd_context *hdd_ctx; |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 12288 | tsap_config_t *sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12289 | |
| 12290 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12291 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12292 | return; |
| 12293 | } |
| 12294 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 12295 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 12296 | hdd_err("SoftAp role has not been enabled"); |
| 12297 | return; |
| 12298 | } |
| 12299 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12300 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 12301 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 12302 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 12303 | sap_config = &ap_adapter->session.ap.sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12304 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12305 | mutex_lock(&hdd_ctx->sap_lock); |
| 12306 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 12307 | goto end; |
| 12308 | |
| 12309 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12310 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12311 | goto end; |
| 12312 | } |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 12313 | wlan_reg_set_channel_params(hdd_ctx->pdev, |
Abhinav Kumar | 6f69448 | 2018-09-04 16:07:39 +0530 | [diff] [blame] | 12314 | hdd_ap_ctx->sap_config.channel, 0, |
| 12315 | &hdd_ap_ctx->sap_config.ch_params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12316 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 12317 | qdf_event_reset(&hostapd_state->qdf_event); |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 12318 | 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] | 12319 | &hdd_ap_ctx->sap_config, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12320 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12321 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12322 | goto end; |
| 12323 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12324 | hdd_debug("Waiting for SAP to start"); |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 12325 | qdf_status = qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Vignesh Viswanathan | 865daaa | 2018-10-11 19:30:44 +0530 | [diff] [blame] | 12326 | SME_CMD_START_STOP_BSS_TIMEOUT); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12327 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12328 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12329 | goto end; |
| 12330 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12331 | hdd_info("SAP Start Success"); |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 12332 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12333 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12334 | if (hostapd_state->bss_state == BSS_START) { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12335 | policy_mgr_incr_active_session(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12336 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12337 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 12338 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12339 | true); |
| 12340 | } |
Sourav Mohapatra | 9bc6711 | 2017-11-08 09:36:11 +0530 | [diff] [blame] | 12341 | mutex_unlock(&hdd_ctx->sap_lock); |
| 12342 | |
| 12343 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12344 | end: |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 12345 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12346 | mutex_unlock(&hdd_ctx->sap_lock); |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 12347 | /* SAP context and beacon cleanup will happen during driver unload |
| 12348 | * in hdd_stop_adapter |
| 12349 | */ |
| 12350 | hdd_err("SAP restart after SSR failed! Reload WLAN and try SAP again"); |
| 12351 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12352 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12353 | |
| 12354 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12355 | * hdd_get_fw_version() - Get FW version |
| 12356 | * @hdd_ctx: pointer to HDD context. |
| 12357 | * @major_spid: FW version - major spid. |
| 12358 | * @minor_spid: FW version - minor spid |
| 12359 | * @ssid: FW version - ssid |
| 12360 | * @crmid: FW version - crmid |
| 12361 | * |
| 12362 | * This function is called to get the firmware build version stored |
| 12363 | * as part of the HDD context |
| 12364 | * |
| 12365 | * Return: None |
| 12366 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12367 | void hdd_get_fw_version(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12368 | uint32_t *major_spid, uint32_t *minor_spid, |
| 12369 | uint32_t *siid, uint32_t *crmid) |
| 12370 | { |
| 12371 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 12372 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 12373 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 12374 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 12375 | } |
| 12376 | |
| 12377 | #ifdef QCA_CONFIG_SMP |
| 12378 | /** |
| 12379 | * wlan_hdd_get_cpu() - get cpu_index |
| 12380 | * |
| 12381 | * Return: cpu_index |
| 12382 | */ |
| 12383 | int wlan_hdd_get_cpu(void) |
| 12384 | { |
| 12385 | int cpu_index = get_cpu(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12386 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12387 | put_cpu(); |
| 12388 | return cpu_index; |
| 12389 | } |
| 12390 | #endif |
| 12391 | |
| 12392 | /** |
| 12393 | * hdd_get_fwpath() - get framework path |
| 12394 | * |
| 12395 | * This function is used to get the string written by |
| 12396 | * userspace to start the wlan driver |
| 12397 | * |
| 12398 | * Return: string |
| 12399 | */ |
| 12400 | const char *hdd_get_fwpath(void) |
| 12401 | { |
| 12402 | return fwpath.string; |
| 12403 | } |
| 12404 | |
Dustin Brown | 94ce20f | 2018-09-04 13:11:38 -0700 | [diff] [blame] | 12405 | static inline int hdd_state_query_cb(void) |
| 12406 | { |
| 12407 | return !!wlan_hdd_validate_context(cds_get_context(QDF_MODULE_ID_HDD)); |
| 12408 | } |
| 12409 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12410 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12411 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12412 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12413 | * This function initilizes CDS global context with the help of cds_init. This |
| 12414 | * has to be the first function called after probe to get a valid global |
| 12415 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12416 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12417 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12418 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12419 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12420 | { |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 12421 | QDF_STATUS status; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12422 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12423 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 12424 | status = cds_init(); |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 12425 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12426 | hdd_err("Failed to allocate CDS context"); |
| 12427 | ret = -ENOMEM; |
| 12428 | goto err_out; |
| 12429 | } |
Dustin Brown | 94ce20f | 2018-09-04 13:11:38 -0700 | [diff] [blame] | 12430 | qdf_register_module_state_query_callback(hdd_state_query_cb); |
Hanumanth Reddy Pothula | 788a37e | 2017-08-17 18:40:11 +0530 | [diff] [blame] | 12431 | |
| 12432 | wlan_init_bug_report_lock(); |
| 12433 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12434 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12435 | wlan_logging_sock_init_svc(); |
| 12436 | #endif |
| 12437 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 12438 | qdf_timer_init(NULL, &hdd_drv_ops_inactivity_timer, |
| 12439 | (void *)hdd_drv_ops_inactivity_handler, NULL, |
| 12440 | QDF_TIMER_TYPE_SW); |
| 12441 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12442 | hdd_trace_init(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 12443 | hdd_register_debug_callback(); |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12444 | wlan_roam_debug_init(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12445 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12446 | err_out: |
| 12447 | return ret; |
| 12448 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12449 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12450 | /** |
| 12451 | * hdd_deinit() - Deinitialize Driver |
| 12452 | * |
| 12453 | * This function frees CDS global context with the help of cds_deinit. This |
| 12454 | * has to be the last function call in remove callback to free the global |
| 12455 | * context. |
| 12456 | */ |
| 12457 | void hdd_deinit(void) |
| 12458 | { |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12459 | wlan_roam_debug_deinit(); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 12460 | qdf_timer_free(&hdd_drv_ops_inactivity_timer); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12461 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12462 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12463 | wlan_logging_sock_deinit_svc(); |
| 12464 | #endif |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12465 | |
| 12466 | wlan_destroy_bug_report_lock(); |
| 12467 | cds_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12468 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12469 | |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 12470 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 12471 | #define HDD_WLAN_START_WAIT_TIME ((CDS_WMA_TIMEOUT + 5000) * 100) |
| 12472 | #else |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12473 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 12474 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12475 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12476 | static int wlan_hdd_state_ctrl_param_open(struct inode *inode, |
| 12477 | struct file *file) |
| 12478 | { |
| 12479 | return 0; |
| 12480 | } |
| 12481 | |
| 12482 | static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, |
| 12483 | const char __user *user_buf, |
| 12484 | size_t count, |
| 12485 | loff_t *f_pos) |
| 12486 | { |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12487 | char buf[3]; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12488 | static const char wlan_off_str[] = "OFF"; |
| 12489 | static const char wlan_on_str[] = "ON"; |
| 12490 | int ret; |
| 12491 | unsigned long rc; |
| 12492 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12493 | if (copy_from_user(buf, user_buf, 3)) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12494 | pr_err("Failed to read buffer\n"); |
| 12495 | return -EINVAL; |
| 12496 | } |
| 12497 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12498 | if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12499 | pr_debug("Wifi turning off from UI\n"); |
| 12500 | goto exit; |
| 12501 | } |
| 12502 | |
Srinivas Girigowda | d241288 | 2018-09-07 15:42:04 -0700 | [diff] [blame] | 12503 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) == 0) |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 12504 | pr_info("Wifi Turning On from UI\n"); |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 12505 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12506 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12507 | pr_err("Invalid value received from framework"); |
| 12508 | goto exit; |
| 12509 | } |
| 12510 | |
| 12511 | if (!cds_is_driver_loaded()) { |
Sachin Ahuja | ee62b54 | 2017-04-21 14:14:16 +0530 | [diff] [blame] | 12512 | init_completion(&wlan_start_comp); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12513 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 12514 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 12515 | if (!rc) { |
Srinivas Girigowda | 09625b0 | 2018-09-10 15:28:09 -0700 | [diff] [blame] | 12516 | hdd_alert("Timed-out!!"); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12517 | ret = -EINVAL; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12518 | return ret; |
| 12519 | } |
| 12520 | |
| 12521 | hdd_start_complete(0); |
| 12522 | } |
| 12523 | |
| 12524 | exit: |
| 12525 | return count; |
| 12526 | } |
| 12527 | |
| 12528 | |
| 12529 | const struct file_operations wlan_hdd_state_fops = { |
| 12530 | .owner = THIS_MODULE, |
| 12531 | .open = wlan_hdd_state_ctrl_param_open, |
| 12532 | .write = wlan_hdd_state_ctrl_param_write, |
| 12533 | }; |
| 12534 | |
| 12535 | static int wlan_hdd_state_ctrl_param_create(void) |
| 12536 | { |
| 12537 | unsigned int wlan_hdd_state_major = 0; |
| 12538 | int ret; |
| 12539 | struct device *dev; |
| 12540 | |
| 12541 | device = MKDEV(wlan_hdd_state_major, 0); |
| 12542 | |
| 12543 | ret = alloc_chrdev_region(&device, 0, dev_num, "qcwlanstate"); |
| 12544 | if (ret) { |
| 12545 | pr_err("Failed to register qcwlanstate"); |
| 12546 | goto dev_alloc_err; |
| 12547 | } |
| 12548 | wlan_hdd_state_major = MAJOR(device); |
| 12549 | |
| 12550 | class = class_create(THIS_MODULE, WLAN_MODULE_NAME); |
| 12551 | if (IS_ERR(class)) { |
| 12552 | pr_err("wlan_hdd_state class_create error"); |
| 12553 | goto class_err; |
| 12554 | } |
| 12555 | |
| 12556 | dev = device_create(class, NULL, device, NULL, WLAN_MODULE_NAME); |
| 12557 | if (IS_ERR(dev)) { |
| 12558 | pr_err("wlan_hdd_statedevice_create error"); |
| 12559 | goto err_class_destroy; |
| 12560 | } |
| 12561 | |
| 12562 | cdev_init(&wlan_hdd_state_cdev, &wlan_hdd_state_fops); |
| 12563 | ret = cdev_add(&wlan_hdd_state_cdev, device, dev_num); |
| 12564 | if (ret) { |
| 12565 | pr_err("Failed to add cdev error"); |
| 12566 | goto cdev_add_err; |
| 12567 | } |
| 12568 | |
| 12569 | pr_info("wlan_hdd_state %s major(%d) initialized", |
| 12570 | WLAN_MODULE_NAME, wlan_hdd_state_major); |
| 12571 | |
| 12572 | return 0; |
| 12573 | |
| 12574 | cdev_add_err: |
| 12575 | device_destroy(class, device); |
| 12576 | err_class_destroy: |
| 12577 | class_destroy(class); |
| 12578 | class_err: |
| 12579 | unregister_chrdev_region(device, dev_num); |
| 12580 | dev_alloc_err: |
| 12581 | return -ENODEV; |
| 12582 | } |
| 12583 | |
| 12584 | static void wlan_hdd_state_ctrl_param_destroy(void) |
| 12585 | { |
| 12586 | cdev_del(&wlan_hdd_state_cdev); |
| 12587 | device_destroy(class, device); |
| 12588 | class_destroy(class); |
| 12589 | unregister_chrdev_region(device, dev_num); |
| 12590 | |
| 12591 | pr_info("Device node unregistered"); |
| 12592 | } |
| 12593 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12594 | /** |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 12595 | * hdd_component_init() - Initialize all components |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12596 | * |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 12597 | * Return: QDF_STATUS |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12598 | */ |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 12599 | static QDF_STATUS hdd_component_init(void) |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12600 | { |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 12601 | QDF_STATUS status; |
| 12602 | |
| 12603 | /* initialize converged components */ |
| 12604 | status = dispatcher_init(); |
| 12605 | if (QDF_IS_STATUS_ERROR(status)) |
| 12606 | return status; |
| 12607 | |
| 12608 | /* initialize non-converged components */ |
| 12609 | status = ucfg_mlme_init(); |
| 12610 | if (QDF_IS_STATUS_ERROR(status)) |
| 12611 | goto dispatcher_deinit; |
| 12612 | |
| 12613 | status = ucfg_fwol_init(); |
| 12614 | if (QDF_IS_STATUS_ERROR(status)) |
| 12615 | goto mlme_deinit; |
| 12616 | |
| 12617 | status = disa_init(); |
| 12618 | if (QDF_IS_STATUS_ERROR(status)) |
| 12619 | goto fwol_deinit; |
| 12620 | |
| 12621 | status = pmo_init(); |
| 12622 | if (QDF_IS_STATUS_ERROR(status)) |
| 12623 | goto disa_deinit; |
| 12624 | |
| 12625 | status = ucfg_ocb_init(); |
| 12626 | if (QDF_IS_STATUS_ERROR(status)) |
| 12627 | goto pmo_deinit; |
| 12628 | |
| 12629 | status = ipa_init(); |
| 12630 | if (QDF_IS_STATUS_ERROR(status)) |
| 12631 | goto ocb_deinit; |
| 12632 | |
| 12633 | status = ucfg_action_oui_init(); |
| 12634 | if (QDF_IS_STATUS_ERROR(status)) |
| 12635 | goto ipa_deinit; |
| 12636 | |
| 12637 | return QDF_STATUS_SUCCESS; |
| 12638 | |
| 12639 | ipa_deinit: |
| 12640 | ipa_deinit(); |
| 12641 | ocb_deinit: |
| 12642 | ucfg_ocb_deinit(); |
| 12643 | pmo_deinit: |
| 12644 | pmo_deinit(); |
| 12645 | disa_deinit: |
| 12646 | disa_deinit(); |
| 12647 | fwol_deinit: |
| 12648 | ucfg_fwol_deinit(); |
| 12649 | mlme_deinit: |
| 12650 | ucfg_mlme_deinit(); |
| 12651 | dispatcher_deinit: |
| 12652 | dispatcher_deinit(); |
| 12653 | |
| 12654 | return status; |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12655 | } |
| 12656 | |
| 12657 | /** |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 12658 | * hdd_component_deinit() - Deinitialize all components |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12659 | * |
| 12660 | * Return: None |
| 12661 | */ |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 12662 | static void hdd_component_deinit(void) |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12663 | { |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 12664 | /* deinitialize non-converged components */ |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 12665 | ucfg_action_oui_deinit(); |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 12666 | ipa_deinit(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 12667 | ucfg_ocb_deinit(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12668 | pmo_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12669 | disa_deinit(); |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 12670 | ucfg_fwol_deinit(); |
Vignesh Viswanathan | a0921c4 | 2018-09-04 19:03:35 +0530 | [diff] [blame] | 12671 | ucfg_mlme_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 12672 | |
| 12673 | /* deinitialize converged components */ |
| 12674 | dispatcher_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12675 | } |
| 12676 | |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 12677 | QDF_STATUS hdd_component_psoc_open(struct wlan_objmgr_psoc *psoc) |
| 12678 | { |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 12679 | QDF_STATUS status; |
| 12680 | |
| 12681 | status = ucfg_mlme_psoc_open(psoc); |
| 12682 | if (QDF_IS_STATUS_ERROR(status)) |
| 12683 | return status; |
| 12684 | |
| 12685 | status = ucfg_fwol_psoc_open(psoc); |
| 12686 | if (QDF_IS_STATUS_ERROR(status)) |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 12687 | goto err_fwol; |
| 12688 | |
| 12689 | status = ucfg_pmo_psoc_open(psoc); |
| 12690 | if (QDF_IS_STATUS_ERROR(status)) |
| 12691 | goto err_pmo; |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 12692 | |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 12693 | status = ucfg_policy_mgr_psoc_open(psoc); |
| 12694 | if (QDF_IS_STATUS_ERROR(status)) |
| 12695 | goto err_plcy_mgr; |
| 12696 | |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 12697 | return status; |
| 12698 | |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 12699 | err_plcy_mgr: |
| 12700 | ucfg_pmo_psoc_close(psoc); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 12701 | err_pmo: |
| 12702 | ucfg_fwol_psoc_close(psoc); |
| 12703 | err_fwol: |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 12704 | ucfg_mlme_psoc_close(psoc); |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 12705 | |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 12706 | return status; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 12707 | } |
| 12708 | |
| 12709 | void hdd_component_psoc_close(struct wlan_objmgr_psoc *psoc) |
| 12710 | { |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 12711 | ucfg_policy_mgr_psoc_close(psoc); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 12712 | ucfg_pmo_psoc_close(psoc); |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 12713 | ucfg_fwol_psoc_close(psoc); |
Vignesh Viswanathan | a0921c4 | 2018-09-04 19:03:35 +0530 | [diff] [blame] | 12714 | ucfg_mlme_psoc_close(psoc); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 12715 | } |
| 12716 | |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12717 | void hdd_component_psoc_enable(struct wlan_objmgr_psoc *psoc) |
| 12718 | { |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 12719 | ocb_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12720 | disa_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12721 | } |
| 12722 | |
| 12723 | void hdd_component_psoc_disable(struct wlan_objmgr_psoc *psoc) |
| 12724 | { |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12725 | disa_psoc_disable(psoc); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 12726 | ocb_psoc_disable(psoc); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12727 | } |
| 12728 | |
Sandeep Puligilla | b7beb47 | 2018-08-13 22:54:20 -0700 | [diff] [blame] | 12729 | QDF_STATUS hdd_component_pdev_open(struct wlan_objmgr_pdev *pdev) |
| 12730 | { |
| 12731 | return ucfg_mlme_pdev_open(pdev); |
| 12732 | } |
| 12733 | |
| 12734 | void hdd_component_pdev_close(struct wlan_objmgr_pdev *pdev) |
| 12735 | { |
| 12736 | ucfg_mlme_pdev_close(pdev); |
| 12737 | } |
| 12738 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 12739 | static QDF_STATUS hdd_qdf_print_init(void) |
| 12740 | { |
| 12741 | QDF_STATUS status; |
| 12742 | int qdf_print_idx; |
| 12743 | |
| 12744 | status = qdf_print_setup(); |
| 12745 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12746 | pr_err("Failed qdf_print_setup; status:%u\n", status); |
| 12747 | return status; |
| 12748 | } |
| 12749 | |
| 12750 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, "MCL_WLAN"); |
| 12751 | if (qdf_print_idx < 0) { |
| 12752 | pr_err("Failed to register for qdf_print_ctrl\n"); |
| 12753 | return QDF_STATUS_E_FAILURE; |
| 12754 | } |
| 12755 | |
| 12756 | qdf_set_pidx(qdf_print_idx); |
| 12757 | |
| 12758 | return QDF_STATUS_SUCCESS; |
| 12759 | } |
| 12760 | |
| 12761 | static void hdd_qdf_print_deinit(void) |
| 12762 | { |
| 12763 | int qdf_pidx = qdf_get_pidx(); |
| 12764 | |
| 12765 | qdf_set_pidx(-1); |
| 12766 | qdf_print_ctrl_cleanup(qdf_pidx); |
| 12767 | |
| 12768 | /* currently, no qdf print 'un-setup'*/ |
| 12769 | } |
| 12770 | |
| 12771 | static QDF_STATUS hdd_qdf_init(void) |
| 12772 | { |
| 12773 | QDF_STATUS status; |
| 12774 | |
| 12775 | status = hdd_qdf_print_init(); |
| 12776 | if (QDF_IS_STATUS_ERROR(status)) |
| 12777 | goto exit; |
| 12778 | |
| 12779 | status = qdf_debugfs_init(); |
| 12780 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12781 | hdd_err("Failed to init debugfs; status:%u", status); |
| 12782 | goto print_deinit; |
| 12783 | } |
| 12784 | |
| 12785 | qdf_lock_stats_init(); |
| 12786 | qdf_mem_init(); |
| 12787 | qdf_mc_timer_manager_init(); |
| 12788 | qdf_event_list_init(); |
| 12789 | |
| 12790 | status = qdf_cpuhp_init(); |
| 12791 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12792 | hdd_err("Failed to init cpuhp; status:%u", status); |
| 12793 | goto event_deinit; |
| 12794 | } |
| 12795 | |
| 12796 | status = qdf_trace_spin_lock_init(); |
| 12797 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12798 | hdd_err("Failed to init spinlock; status:%u", status); |
| 12799 | goto cpuhp_deinit; |
| 12800 | } |
| 12801 | |
| 12802 | qdf_trace_init(); |
| 12803 | qdf_register_debugcb_init(); |
| 12804 | |
| 12805 | return QDF_STATUS_SUCCESS; |
| 12806 | |
| 12807 | cpuhp_deinit: |
| 12808 | qdf_cpuhp_deinit(); |
| 12809 | event_deinit: |
| 12810 | qdf_event_list_destroy(); |
| 12811 | qdf_mc_timer_manager_exit(); |
| 12812 | qdf_mem_exit(); |
| 12813 | qdf_lock_stats_deinit(); |
| 12814 | qdf_debugfs_exit(); |
| 12815 | print_deinit: |
| 12816 | hdd_qdf_print_deinit(); |
| 12817 | |
| 12818 | exit: |
| 12819 | return status; |
| 12820 | } |
| 12821 | |
| 12822 | static void hdd_qdf_deinit(void) |
| 12823 | { |
| 12824 | /* currently, no debugcb deinit */ |
| 12825 | |
| 12826 | qdf_trace_deinit(); |
| 12827 | |
| 12828 | /* currently, no trace spinlock deinit */ |
| 12829 | |
| 12830 | qdf_cpuhp_deinit(); |
| 12831 | qdf_event_list_destroy(); |
| 12832 | qdf_mc_timer_manager_exit(); |
| 12833 | qdf_mem_exit(); |
| 12834 | qdf_lock_stats_deinit(); |
| 12835 | qdf_debugfs_exit(); |
| 12836 | hdd_qdf_print_deinit(); |
| 12837 | } |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 12838 | |
| 12839 | /** |
| 12840 | * hdd_driver_load() - Perform the driver-level load operation |
| 12841 | * |
| 12842 | * Note: this is used in both static and DLKM driver builds |
| 12843 | * |
| 12844 | * Return: Errno |
| 12845 | */ |
| 12846 | static int hdd_driver_load(void) |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12847 | { |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 12848 | QDF_STATUS status; |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 12849 | int errno; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12850 | |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 12851 | pr_err("%s: Loading driver v%s\n", |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 12852 | WLAN_MODULE_NAME, |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 12853 | g_wlan_driver_version); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12854 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 12855 | status = hdd_qdf_init(); |
| 12856 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12857 | errno = qdf_status_to_os_return(status); |
| 12858 | goto exit; |
| 12859 | } |
| 12860 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 12861 | errno = hdd_init(); |
| 12862 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 12863 | hdd_err("Failed to init HDD; errno:%d", errno); |
| 12864 | goto qdf_deinit; |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12865 | } |
| 12866 | |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 12867 | status = hdd_component_init(); |
| 12868 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 12869 | hdd_err("Failed to init components; status:%u", status); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 12870 | errno = qdf_status_to_os_return(status); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 12871 | goto hdd_deinit; |
| 12872 | } |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12873 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 12874 | status = qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
| 12875 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 12876 | hdd_err("Failed to create wake lock; status:%u", status); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 12877 | errno = qdf_status_to_os_return(status); |
| 12878 | goto comp_deinit; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12879 | } |
| 12880 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 12881 | hdd_set_conparam(con_mode); |
| 12882 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 12883 | errno = wlan_hdd_state_ctrl_param_create(); |
| 12884 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 12885 | hdd_err("Failed to create ctrl param; errno:%d", errno); |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 12886 | goto wakelock_destroy; |
| 12887 | } |
| 12888 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 12889 | errno = pld_init(); |
| 12890 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 12891 | hdd_err("Failed to init PLD; errno:%d", errno); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 12892 | goto param_destroy; |
| 12893 | } |
| 12894 | |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 12895 | errno = wlan_hdd_register_driver(); |
| 12896 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 12897 | hdd_err("Failed to register driver; errno:%d", errno); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 12898 | goto pld_deinit; |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 12899 | } |
| 12900 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 12901 | hdd_debug("%s: driver loaded", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12902 | |
| 12903 | return 0; |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 12904 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 12905 | pld_deinit: |
| 12906 | pld_deinit(); |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 12907 | param_destroy: |
| 12908 | wlan_hdd_state_ctrl_param_destroy(); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 12909 | wakelock_destroy: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 12910 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 12911 | comp_deinit: |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 12912 | hdd_component_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 12913 | hdd_deinit: |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12914 | hdd_deinit(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 12915 | qdf_deinit: |
| 12916 | hdd_qdf_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 12917 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 12918 | exit: |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 12919 | return errno; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12920 | } |
| 12921 | |
| 12922 | /** |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 12923 | * hdd_driver_unload() - Performs the driver-level unload operation |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12924 | * |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 12925 | * Note: this is used in both static and DLKM driver builds |
| 12926 | * |
| 12927 | * Return: None |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12928 | */ |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 12929 | static void hdd_driver_unload(void) |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12930 | { |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 12931 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 12932 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12933 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 12934 | QWLAN_VERSIONSTR); |
| 12935 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 12936 | if (!hdd_wait_for_recovery_completion()) |
| 12937 | return; |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 12938 | |
Will Huang | ba035ec | 2018-07-05 11:13:30 +0800 | [diff] [blame] | 12939 | cds_set_driver_loaded(false); |
| 12940 | cds_set_unload_in_progress(true); |
| 12941 | |
| 12942 | if (!cds_wait_for_external_threads_completion(__func__)) |
| 12943 | hdd_warn("External threads are still active attempting " |
| 12944 | "driver unload anyway"); |
| 12945 | |
Rajeev Kumar | 3505ae5 | 2018-05-10 18:44:45 -0700 | [diff] [blame] | 12946 | if (hdd_ctx) |
| 12947 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 12948 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12949 | wlan_hdd_unregister_driver(); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 12950 | pld_deinit(); |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 12951 | wlan_hdd_state_ctrl_param_destroy(); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 12952 | hdd_set_conparam(0); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 12953 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 12954 | hdd_component_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12955 | hdd_deinit(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 12956 | hdd_qdf_deinit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12957 | } |
| 12958 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12959 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12960 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12961 | * wlan_boot_cb() - Wlan boot callback |
| 12962 | * @kobj: object whose directory we're creating the link in. |
| 12963 | * @attr: attribute the user is interacting with |
| 12964 | * @buff: the buffer containing the user data |
| 12965 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12966 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12967 | * This callback is invoked when the fs is ready to start the |
| 12968 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12969 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12970 | * 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] | 12971 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12972 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12973 | struct kobj_attribute *attr, |
| 12974 | const char *buf, |
| 12975 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12976 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12977 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12978 | if (wlan_loader->loaded_state) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 12979 | hdd_err("wlan driver already initialized"); |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12980 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12981 | } |
| 12982 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 12983 | if (hdd_driver_load()) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12984 | return -EIO; |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12985 | |
| 12986 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12987 | |
| 12988 | return count; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12989 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12990 | |
| 12991 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12992 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 12993 | * |
| 12994 | * Return: None |
| 12995 | * |
| 12996 | */ |
| 12997 | static void hdd_sysfs_cleanup(void) |
| 12998 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12999 | /* remove from group */ |
| 13000 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 13001 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 13002 | wlan_loader->attr_group); |
| 13003 | |
| 13004 | /* unlink the object from parent */ |
| 13005 | kobject_del(wlan_loader->boot_wlan_obj); |
| 13006 | |
| 13007 | /* free the object */ |
| 13008 | kobject_put(wlan_loader->boot_wlan_obj); |
| 13009 | |
| 13010 | kfree(wlan_loader->attr_group); |
| 13011 | kfree(wlan_loader); |
| 13012 | |
| 13013 | wlan_loader = NULL; |
| 13014 | } |
| 13015 | |
| 13016 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13017 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 13018 | * ready |
| 13019 | * |
| 13020 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 13021 | * when the filesystem is ready. |
| 13022 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13023 | * QDF API cannot be used here since this function is called even before |
| 13024 | * initializing WLAN driver. |
| 13025 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 13026 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13027 | */ |
| 13028 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13029 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13030 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13031 | |
| 13032 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 13033 | if (!wlan_loader) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13034 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13035 | |
| 13036 | wlan_loader->boot_wlan_obj = NULL; |
| 13037 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 13038 | GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 13039 | if (!wlan_loader->attr_group) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13040 | goto error_return; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13041 | |
| 13042 | wlan_loader->loaded_state = 0; |
| 13043 | wlan_loader->attr_group->attrs = attrs; |
| 13044 | |
Qun Zhang | 4a83a46 | 2018-09-11 16:28:51 +0800 | [diff] [blame] | 13045 | wlan_loader->boot_wlan_obj = kobject_create_and_add(WLAN_LOADER_NAME, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13046 | kernel_kobj); |
| 13047 | if (!wlan_loader->boot_wlan_obj) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13048 | hdd_err("sysfs create and add failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13049 | goto error_return; |
| 13050 | } |
| 13051 | |
| 13052 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 13053 | wlan_loader->attr_group); |
| 13054 | if (ret) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13055 | hdd_err("sysfs create group failed; errno:%d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13056 | goto error_return; |
| 13057 | } |
| 13058 | |
| 13059 | return 0; |
| 13060 | |
| 13061 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13062 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13063 | |
| 13064 | return ret; |
| 13065 | } |
| 13066 | |
| 13067 | /** |
| 13068 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 13069 | * |
| 13070 | * Return: 0 on success or errno on failure |
| 13071 | */ |
| 13072 | static int wlan_deinit_sysfs(void) |
| 13073 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13074 | if (!wlan_loader) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13075 | hdd_err("wlan_loader is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13076 | return -EINVAL; |
| 13077 | } |
| 13078 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13079 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13080 | return 0; |
| 13081 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13082 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13083 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13084 | |
| 13085 | #ifdef MODULE |
| 13086 | /** |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13087 | * hdd_module_init() - Module init helper |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13088 | * |
| 13089 | * Module init helper function used by both module and static driver. |
| 13090 | * |
| 13091 | * Return: 0 for success, errno on failure |
| 13092 | */ |
| 13093 | static int hdd_module_init(void) |
| 13094 | { |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13095 | if (hdd_driver_load()) |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 13096 | return -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13097 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 13098 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13099 | } |
| 13100 | #else |
| 13101 | static int __init hdd_module_init(void) |
| 13102 | { |
| 13103 | int ret = -EINVAL; |
| 13104 | |
| 13105 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 13106 | if (ret) |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13107 | hdd_err("Failed to create sysfs entry"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13108 | |
| 13109 | return ret; |
| 13110 | } |
| 13111 | #endif |
| 13112 | |
| 13113 | |
| 13114 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13115 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13116 | * hdd_module_exit() - Exit function |
| 13117 | * |
| 13118 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 13119 | * |
| 13120 | * Return: None |
| 13121 | */ |
| 13122 | static void __exit hdd_module_exit(void) |
| 13123 | { |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13124 | hdd_driver_unload(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13125 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13126 | #else |
| 13127 | static void __exit hdd_module_exit(void) |
| 13128 | { |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13129 | hdd_driver_unload(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13130 | wlan_deinit_sysfs(); |
| 13131 | } |
| 13132 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13133 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13134 | static int fwpath_changed_handler(const char *kmessage, |
| 13135 | const struct kernel_param *kp) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13136 | { |
| 13137 | return param_set_copystring(kmessage, kp); |
| 13138 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13139 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 13140 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
| 13141 | static bool is_monitor_mode_supported(void) |
| 13142 | { |
| 13143 | return true; |
| 13144 | } |
| 13145 | #else |
| 13146 | static bool is_monitor_mode_supported(void) |
| 13147 | { |
| 13148 | pr_err("Monitor mode not supported!"); |
| 13149 | return false; |
| 13150 | } |
| 13151 | #endif |
| 13152 | |
| 13153 | #ifdef WLAN_FEATURE_EPPING |
| 13154 | static bool is_epping_mode_supported(void) |
| 13155 | { |
| 13156 | return true; |
| 13157 | } |
| 13158 | #else |
| 13159 | static bool is_epping_mode_supported(void) |
| 13160 | { |
| 13161 | pr_err("Epping mode not supported!"); |
| 13162 | return false; |
| 13163 | } |
| 13164 | #endif |
| 13165 | |
Ryan Hsu | 6e9db0b | 2018-06-01 10:45:51 -0700 | [diff] [blame] | 13166 | #ifdef QCA_WIFI_FTM |
| 13167 | static bool is_ftm_mode_supported(void) |
| 13168 | { |
| 13169 | return true; |
| 13170 | } |
| 13171 | #else |
| 13172 | static bool is_ftm_mode_supported(void) |
| 13173 | { |
| 13174 | pr_err("FTM mode not supported!"); |
| 13175 | return false; |
| 13176 | } |
| 13177 | #endif |
| 13178 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13179 | /** |
| 13180 | * is_con_mode_valid() check con mode is valid or not |
| 13181 | * @mode: global con mode |
| 13182 | * |
| 13183 | * Return: TRUE on success FALSE on failure |
| 13184 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13185 | static bool is_con_mode_valid(enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13186 | { |
| 13187 | switch (mode) { |
| 13188 | case QDF_GLOBAL_MONITOR_MODE: |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 13189 | return is_monitor_mode_supported(); |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13190 | case QDF_GLOBAL_EPPING_MODE: |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 13191 | return is_epping_mode_supported(); |
| 13192 | case QDF_GLOBAL_FTM_MODE: |
Ryan Hsu | 6e9db0b | 2018-06-01 10:45:51 -0700 | [diff] [blame] | 13193 | return is_ftm_mode_supported(); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13194 | case QDF_GLOBAL_MISSION_MODE: |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13195 | return true; |
| 13196 | default: |
| 13197 | return false; |
| 13198 | } |
| 13199 | } |
| 13200 | |
| 13201 | /** |
| 13202 | * hdd_get_adpter_mode() - returns adapter mode based on global con mode |
| 13203 | * @mode: global con mode |
| 13204 | * |
| 13205 | * Return: adapter mode |
| 13206 | */ |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 13207 | static enum QDF_OPMODE hdd_get_adpter_mode( |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13208 | enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13209 | { |
| 13210 | |
| 13211 | switch (mode) { |
| 13212 | case QDF_GLOBAL_MISSION_MODE: |
| 13213 | return QDF_STA_MODE; |
| 13214 | case QDF_GLOBAL_MONITOR_MODE: |
| 13215 | return QDF_MONITOR_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13216 | case QDF_GLOBAL_EPPING_MODE: |
| 13217 | return QDF_EPPING_MODE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13218 | case QDF_GLOBAL_FTM_MODE: |
| 13219 | return QDF_FTM_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13220 | case QDF_GLOBAL_QVIT_MODE: |
| 13221 | return QDF_QVIT_MODE; |
| 13222 | default: |
| 13223 | return QDF_MAX_NO_OF_MODE; |
| 13224 | } |
| 13225 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13226 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13227 | static void hdd_stop_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13228 | enum QDF_GLOBAL_MODE curr_mode) |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13229 | { |
| 13230 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) |
| 13231 | return; |
| 13232 | |
| 13233 | switch (curr_mode) { |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13234 | case QDF_GLOBAL_MONITOR_MODE: |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 13235 | hdd_info("Release wakelock for monitor mode!"); |
| 13236 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 13237 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
Dundi Raviteja | 0a2a65b | 2018-04-30 12:34:11 +0530 | [diff] [blame] | 13238 | /* fallthrough */ |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 13239 | case QDF_GLOBAL_MISSION_MODE: |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13240 | case QDF_GLOBAL_FTM_MODE: |
| 13241 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 13242 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->pdev, NULL); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 13243 | hdd_stop_all_adapters(hdd_ctx); |
Ashish Kumar Dhanotiya | 6ff329e | 2018-10-05 20:38:10 +0530 | [diff] [blame] | 13244 | hdd_deinit_all_adapters(hdd_ctx, false); |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13245 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13246 | break; |
| 13247 | default: |
| 13248 | break; |
| 13249 | } |
| 13250 | } |
| 13251 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13252 | static void hdd_cleanup_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13253 | enum QDF_GLOBAL_MODE curr_mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13254 | { |
Ashish Kumar Dhanotiya | 0024313 | 2017-01-24 16:37:34 +0530 | [diff] [blame] | 13255 | int driver_status; |
| 13256 | |
| 13257 | driver_status = hdd_ctx->driver_status; |
| 13258 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13259 | switch (curr_mode) { |
| 13260 | case QDF_GLOBAL_MISSION_MODE: |
| 13261 | case QDF_GLOBAL_MONITOR_MODE: |
| 13262 | case QDF_GLOBAL_FTM_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13263 | hdd_close_all_adapters(hdd_ctx, false); |
| 13264 | break; |
| 13265 | case QDF_GLOBAL_EPPING_MODE: |
| 13266 | epping_disable(); |
| 13267 | epping_close(); |
| 13268 | break; |
| 13269 | default: |
| 13270 | return; |
| 13271 | } |
| 13272 | } |
| 13273 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13274 | static int hdd_register_req_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13275 | enum QDF_GLOBAL_MODE mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13276 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13277 | struct hdd_adapter *adapter; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13278 | int ret = 0; |
| 13279 | bool rtnl_held; |
| 13280 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 13281 | QDF_STATUS status; |
| 13282 | |
| 13283 | if (!qdf_dev) { |
| 13284 | hdd_err("qdf device context is Null return!"); |
| 13285 | return -EINVAL; |
| 13286 | } |
| 13287 | |
| 13288 | rtnl_held = hdd_hold_rtnl_lock(); |
| 13289 | switch (mode) { |
| 13290 | case QDF_GLOBAL_MISSION_MODE: |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 13291 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 13292 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13293 | hdd_err("Failed to open interfaces: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13294 | break; |
| 13295 | case QDF_GLOBAL_FTM_MODE: |
| 13296 | adapter = hdd_open_adapter(hdd_ctx, QDF_FTM_MODE, "wlan%d", |
| 13297 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 13298 | NET_NAME_UNKNOWN, rtnl_held); |
| 13299 | if (adapter == NULL) |
| 13300 | ret = -EINVAL; |
| 13301 | break; |
| 13302 | case QDF_GLOBAL_MONITOR_MODE: |
| 13303 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
| 13304 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 13305 | NET_NAME_UNKNOWN, rtnl_held); |
| 13306 | if (adapter == NULL) |
| 13307 | ret = -EINVAL; |
| 13308 | break; |
| 13309 | case QDF_GLOBAL_EPPING_MODE: |
| 13310 | status = epping_open(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 13311 | if (status != QDF_STATUS_SUCCESS) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13312 | hdd_err("Failed to open in eeping mode: %d", status); |
| 13313 | ret = -EINVAL; |
| 13314 | break; |
| 13315 | } |
| 13316 | ret = epping_enable(qdf_dev->dev); |
| 13317 | if (ret) { |
| 13318 | hdd_err("Failed to enable in epping mode : %d", ret); |
| 13319 | epping_close(); |
| 13320 | } |
| 13321 | break; |
| 13322 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13323 | hdd_err("Mode not supported"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13324 | ret = -ENOTSUPP; |
| 13325 | break; |
| 13326 | } |
| 13327 | hdd_release_rtnl_lock(); |
| 13328 | rtnl_held = false; |
| 13329 | return ret; |
| 13330 | } |
| 13331 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13332 | /** |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13333 | * __con_mode_handler() - Handles module param con_mode change |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13334 | * @kmessage: con mode name on which driver to be bring up |
| 13335 | * @kp: The associated kernel parameter |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13336 | * @hdd_ctx: Pointer to the global HDD context |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13337 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13338 | * This function is invoked when user updates con mode using sys entry, |
| 13339 | * to initialize and bring-up driver in that specific mode. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13340 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13341 | * Return - 0 on success and failure code on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13342 | */ |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13343 | static int __con_mode_handler(const char *kmessage, |
| 13344 | const struct kernel_param *kp, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13345 | struct hdd_context *hdd_ctx) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13346 | { |
| 13347 | int ret; |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13348 | enum QDF_GLOBAL_MODE curr_mode; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 13349 | enum QDF_OPMODE adapter_mode; |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 13350 | int new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13351 | |
Dustin Brown | ab6029b | 2017-05-24 13:04:19 -0700 | [diff] [blame] | 13352 | hdd_info("con_mode handler: %s", kmessage); |
| 13353 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13354 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13355 | if (ret) |
| 13356 | return ret; |
| 13357 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 13358 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 1); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13359 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 13360 | ret = kstrtoint(kmessage, 0, &new_con_mode); |
| 13361 | if (ret) { |
| 13362 | hdd_err("Failed to parse con_mode '%s'", kmessage); |
| 13363 | goto reset_flags; |
| 13364 | } |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 13365 | mutex_lock(&hdd_init_deinit_lock); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13366 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 13367 | if (!is_con_mode_valid(new_con_mode)) { |
| 13368 | hdd_err("invalid con_mode %d", new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13369 | ret = -EINVAL; |
| 13370 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13371 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13372 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13373 | curr_mode = hdd_get_conparam(); |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 13374 | if (curr_mode == new_con_mode) { |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13375 | hdd_err("curr mode: %d is same as user triggered mode %d", |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 13376 | curr_mode, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13377 | ret = 0; |
| 13378 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13379 | } |
| 13380 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13381 | /* ensure adapters are stopped */ |
| 13382 | hdd_stop_present_mode(hdd_ctx, curr_mode); |
| 13383 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 13384 | ret = hdd_wlan_stop_modules(hdd_ctx, true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13385 | if (ret) { |
| 13386 | hdd_err("Stop wlan modules failed"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13387 | goto reset_flags; |
| 13388 | } |
| 13389 | |
Dustin Brown | dd4e50f | 2018-05-24 15:43:42 -0700 | [diff] [blame] | 13390 | /* Cleanup present mode before switching to new mode */ |
| 13391 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
Ashish Kumar Dhanotiya | cda5766 | 2017-08-14 14:45:25 +0530 | [diff] [blame] | 13392 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 13393 | hdd_set_conparam(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13394 | |
| 13395 | /* Register for new con_mode & then kick_start modules again */ |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 13396 | ret = hdd_register_req_mode(hdd_ctx, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13397 | if (ret) { |
| 13398 | hdd_err("Failed to register for new mode"); |
| 13399 | goto reset_flags; |
| 13400 | } |
| 13401 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 13402 | adapter_mode = hdd_get_adpter_mode(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13403 | if (adapter_mode == QDF_MAX_NO_OF_MODE) { |
| 13404 | hdd_err("invalid adapter"); |
| 13405 | ret = -EINVAL; |
| 13406 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13407 | } |
| 13408 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 13409 | ret = hdd_wlan_start_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13410 | if (ret) { |
| 13411 | hdd_err("Start wlan modules failed: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13412 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13413 | } |
| 13414 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 13415 | if (new_con_mode == QDF_GLOBAL_MONITOR_MODE) { |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 13416 | struct hdd_adapter *adapter = |
| 13417 | hdd_get_adapter(hdd_ctx, adapter_mode); |
| 13418 | |
| 13419 | if (!adapter) { |
| 13420 | hdd_err("Failed to get adapter:%d", adapter_mode); |
| 13421 | goto reset_flags; |
| 13422 | } |
| 13423 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13424 | if (hdd_start_adapter(adapter)) { |
| 13425 | hdd_err("Failed to start %s adapter", kmessage); |
| 13426 | ret = -EINVAL; |
| 13427 | goto reset_flags; |
| 13428 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13429 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 13430 | hdd_info("Acquire wakelock for monitor mode!"); |
| 13431 | qdf_wake_lock_acquire(&hdd_ctx->monitor_mode_wakelock, |
| 13432 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 13433 | } |
| 13434 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 13435 | /* con_mode is a global module parameter */ |
| 13436 | con_mode = new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13437 | hdd_info("Mode successfully changed to %s", kmessage); |
| 13438 | ret = 0; |
| 13439 | |
| 13440 | reset_flags: |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 13441 | mutex_unlock(&hdd_init_deinit_lock); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 13442 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 0); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13443 | return ret; |
| 13444 | } |
| 13445 | |
| 13446 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13447 | 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] | 13448 | { |
| 13449 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13450 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13451 | |
| 13452 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13453 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13454 | if (ret) |
| 13455 | return ret; |
| 13456 | |
Ashish Kumar Dhanotiya | 759b327 | 2018-05-18 17:49:46 +0530 | [diff] [blame] | 13457 | if (!cds_wait_for_external_threads_completion(__func__)) { |
| 13458 | hdd_warn("External threads are still active, can not change mode"); |
| 13459 | return -EAGAIN; |
| 13460 | } |
| 13461 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13462 | cds_ssr_protect(__func__); |
| 13463 | ret = __con_mode_handler(kmessage, kp, hdd_ctx); |
| 13464 | cds_ssr_unprotect(__func__); |
| 13465 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13466 | return ret; |
| 13467 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13468 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 13469 | static int con_mode_handler_ftm(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13470 | const struct kernel_param *kp) |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 13471 | { |
| 13472 | int ret; |
| 13473 | |
| 13474 | ret = param_set_int(kmessage, kp); |
| 13475 | |
| 13476 | if (con_mode_ftm != QDF_GLOBAL_FTM_MODE) { |
| 13477 | pr_err("Only FTM mode supported!"); |
| 13478 | return -ENOTSUPP; |
| 13479 | } |
| 13480 | |
| 13481 | hdd_set_conparam(con_mode_ftm); |
| 13482 | con_mode = con_mode_ftm; |
| 13483 | |
| 13484 | return ret; |
| 13485 | } |
| 13486 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 13487 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 13488 | static int con_mode_handler_monitor(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13489 | const struct kernel_param *kp) |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 13490 | { |
| 13491 | int ret; |
| 13492 | |
| 13493 | ret = param_set_int(kmessage, kp); |
| 13494 | |
| 13495 | if (con_mode_monitor != QDF_GLOBAL_MONITOR_MODE) { |
| 13496 | pr_err("Only Monitor mode supported!"); |
| 13497 | return -ENOTSUPP; |
| 13498 | } |
| 13499 | |
| 13500 | hdd_set_conparam(con_mode_monitor); |
| 13501 | con_mode = con_mode_monitor; |
| 13502 | |
| 13503 | return ret; |
| 13504 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 13505 | #endif |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 13506 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13507 | /** |
| 13508 | * hdd_get_conparam() - driver exit point |
| 13509 | * |
| 13510 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 13511 | * |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13512 | * Return: enum QDF_GLOBAL_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13513 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13514 | enum QDF_GLOBAL_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13515 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13516 | return (enum QDF_GLOBAL_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13517 | } |
| 13518 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13519 | void hdd_set_conparam(int32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13520 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 13521 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13522 | } |
| 13523 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 13524 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 13525 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 13526 | * @hdd_ctx: HDD context |
| 13527 | * |
| 13528 | * Cleans up the pre cac interface, if it exists |
| 13529 | * |
| 13530 | * Return: None |
| 13531 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13532 | void hdd_clean_up_pre_cac_interface(struct hdd_context *hdd_ctx) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 13533 | { |
| 13534 | uint8_t session_id; |
| 13535 | QDF_STATUS status; |
Jeff Johnson | 85b5c11 | 2017-08-11 15:15:23 -0700 | [diff] [blame] | 13536 | struct hdd_adapter *precac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 13537 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13538 | 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] | 13539 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13540 | hdd_err("failed to get pre cac vdev id"); |
| 13541 | return; |
| 13542 | } |
| 13543 | |
| 13544 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, session_id); |
| 13545 | if (!precac_adapter) { |
Jeff Johnson | dd2f1fc | 2018-05-06 11:22:52 -0700 | [diff] [blame] | 13546 | hdd_err("invalid pre cac adapter"); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 13547 | return; |
| 13548 | } |
| 13549 | |
| 13550 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 13551 | wlan_hdd_sap_pre_cac_failure, |
| 13552 | (void *)precac_adapter); |
| 13553 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 13554 | |
| 13555 | } |
| 13556 | |
| 13557 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13558 | * hdd_update_ol_config - API to update ol configuration parameters |
| 13559 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 13560 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 13561 | * Return: void |
| 13562 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13563 | static void hdd_update_ol_config(struct hdd_context *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 13564 | { |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13565 | struct ol_config_info cfg; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 13566 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 13567 | bool self_recovery = false; |
| 13568 | QDF_STATUS status; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 13569 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13570 | if (!ol_ctx) |
| 13571 | return; |
| 13572 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 13573 | status = ucfg_mlme_get_self_recovery(hdd_ctx->psoc, &self_recovery); |
| 13574 | if (QDF_IS_STATUS_ERROR(status)) |
| 13575 | hdd_err("Failed to get self recovery ini config"); |
| 13576 | |
| 13577 | cfg.enable_self_recovery = self_recovery; |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13578 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 13579 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 13580 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 13581 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13582 | |
| 13583 | ol_init_ini_config(ol_ctx, &cfg); |
| 13584 | } |
| 13585 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 13586 | #ifdef FEATURE_RUNTIME_PM |
| 13587 | /** |
| 13588 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 13589 | * @hdd_ctx: hdd context |
| 13590 | * @cfg: pointer to the configuration memory being populated |
| 13591 | * |
| 13592 | * Return: void |
| 13593 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13594 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 13595 | struct hif_config_info *cfg) |
| 13596 | { |
| 13597 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13598 | cfg->runtime_pm_delay = |
| 13599 | ucfg_pmo_get_runtime_pm_delay(hdd_ctx->psoc); |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 13600 | } |
| 13601 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13602 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 13603 | struct hif_config_info *cfg) |
| 13604 | { |
| 13605 | } |
| 13606 | #endif |
| 13607 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13608 | /** |
| 13609 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 13610 | * @hdd_ctx: HDD Context |
| 13611 | * |
| 13612 | * Return: void |
| 13613 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13614 | static void hdd_update_hif_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13615 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 13616 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13617 | struct hif_config_info cfg; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 13618 | bool prevent_link_down = false; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 13619 | bool self_recovery = false; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 13620 | QDF_STATUS status; |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13621 | |
| 13622 | if (!scn) |
| 13623 | return; |
| 13624 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 13625 | status = ucfg_mlme_get_prevent_link_down(hdd_ctx->psoc, |
| 13626 | &prevent_link_down); |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 13627 | if (QDF_IS_STATUS_ERROR(status)) |
| 13628 | hdd_err("Failed to get prevent_link_down config"); |
| 13629 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 13630 | status = ucfg_mlme_get_self_recovery(hdd_ctx->psoc, &self_recovery); |
| 13631 | if (QDF_IS_STATUS_ERROR(status)) |
| 13632 | hdd_err("Failed to get self recovery ini config"); |
| 13633 | |
| 13634 | cfg.enable_self_recovery = self_recovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 13635 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13636 | hif_init_ini_config(scn, &cfg); |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 13637 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 13638 | if (prevent_link_down) |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 13639 | hif_vote_link_up(scn); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13640 | } |
| 13641 | |
| 13642 | /** |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13643 | * hdd_update_dp_config() - Propagate config parameters to Lithium |
| 13644 | * datapath |
| 13645 | * @hdd_ctx: HDD Context |
| 13646 | * |
| 13647 | * Return: 0 for success/errno for failure |
| 13648 | */ |
| 13649 | static int hdd_update_dp_config(struct hdd_context *hdd_ctx) |
| 13650 | { |
| 13651 | struct cdp_config_params params; |
| 13652 | QDF_STATUS status; |
| 13653 | |
| 13654 | params.tso_enable = hdd_ctx->config->tso_enable; |
| 13655 | params.lro_enable = hdd_ctx->config->lro_enable; |
| 13656 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 13657 | params.tx_flow_stop_queue_threshold = |
| 13658 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 13659 | params.tx_flow_start_queue_offset = |
| 13660 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 13661 | #endif |
| 13662 | params.flow_steering_enable = hdd_ctx->config->flow_steering_enable; |
| 13663 | params.napi_enable = hdd_ctx->napi_enable; |
| 13664 | params.tcp_udp_checksumoffload = |
| 13665 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
Mohit Khanna | cabf5e7 | 2018-07-24 13:28:43 -0700 | [diff] [blame] | 13666 | params.ipa_enable = ucfg_ipa_is_enabled(); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13667 | |
| 13668 | status = cdp_update_config_parameters( |
| 13669 | cds_get_context(QDF_MODULE_ID_SOC), |
| 13670 | ¶ms); |
| 13671 | if (status) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 13672 | hdd_err("Failed to attach config parameters"); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13673 | return status; |
| 13674 | } |
| 13675 | |
| 13676 | return 0; |
| 13677 | } |
| 13678 | |
| 13679 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13680 | * hdd_update_config() - Initialize driver per module ini parameters |
| 13681 | * @hdd_ctx: HDD Context |
| 13682 | * |
| 13683 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 13684 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13685 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13686 | int hdd_update_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13687 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 13688 | int ret; |
| 13689 | |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13690 | if (ucfg_pmo_is_ns_offloaded(hdd_ctx->psoc)) |
| 13691 | hdd_ctx->ns_offload_enable = true; |
| 13692 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13693 | hdd_update_ol_config(hdd_ctx); |
| 13694 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 13695 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 13696 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 13697 | else |
| 13698 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 13699 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 13700 | |
| 13701 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 13702 | } |
| 13703 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13704 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 13705 | /** |
| 13706 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 13707 | * @psoc_cfg: pmo psoc Configuration |
| 13708 | * @hdd_ctx: Pointer to hdd context |
| 13709 | * |
| 13710 | * Return: none |
| 13711 | */ |
| 13712 | static inline void hdd_ra_populate_pmo_config( |
| 13713 | struct pmo_psoc_cfg *psoc_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13714 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13715 | { |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 13716 | bool is_rate_limit_enabled; |
| 13717 | QDF_STATUS status; |
| 13718 | |
| 13719 | status = ucfg_fwol_get_is_rate_limit_enabled(hdd_ctx->psoc, |
| 13720 | &is_rate_limit_enabled); |
| 13721 | if (QDF_IS_STATUS_ERROR(status)) |
| 13722 | return; |
| 13723 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13724 | psoc_cfg->ra_ratelimit_interval = |
| 13725 | hdd_ctx->config->RArateLimitInterval; |
| 13726 | psoc_cfg->ra_ratelimit_enable = |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 13727 | is_rate_limit_enabled; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13728 | } |
| 13729 | #else |
| 13730 | static inline void hdd_ra_populate_pmo_config( |
| 13731 | struct cds_config_info *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13732 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13733 | { |
| 13734 | } |
| 13735 | #endif |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 13736 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13737 | /** |
| 13738 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 13739 | * @hdd_ctx: HDD context |
| 13740 | * |
| 13741 | * Return: void |
| 13742 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13743 | static int hdd_update_pmo_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13744 | { |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13745 | struct pmo_psoc_cfg psoc_cfg; |
| 13746 | QDF_STATUS status; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13747 | enum pmo_wow_enable_type wow_enable; |
| 13748 | |
| 13749 | ucfg_pmo_get_psoc_config(hdd_ctx->psoc, &psoc_cfg); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13750 | |
| 13751 | /* |
| 13752 | * Value of hdd_ctx->wowEnable can be, |
| 13753 | * 0 - Disable both magic pattern match and pattern byte match. |
| 13754 | * 1 - Enable magic pattern match on all interfaces. |
| 13755 | * 2 - Enable pattern byte match on all interfaces. |
| 13756 | * 3 - Enable both magic patter and pattern byte match on |
| 13757 | * all interfaces. |
| 13758 | */ |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13759 | wow_enable = ucfg_pmo_get_wow_enable(hdd_ctx->psoc); |
| 13760 | psoc_cfg.magic_ptrn_enable = (wow_enable & 0x01) ? true : false; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13761 | psoc_cfg.ptrn_match_enable_all_vdev = |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13762 | (wow_enable & 0x02) ? true : false; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 13763 | psoc_cfg.packet_filter_enabled = !hdd_ctx->config->disablePacketFilter; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13764 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 13765 | psoc_cfg.d0_wow_supported = wma_d0_wow_is_supported(); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 13766 | psoc_cfg.sta_max_li_mod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13767 | |
| 13768 | hdd_ra_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 13769 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13770 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 13771 | status = ucfg_pmo_update_psoc_config(hdd_ctx->psoc, &psoc_cfg); |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 13772 | if (QDF_IS_STATUS_ERROR(status)) |
| 13773 | hdd_err("failed pmo psoc configuration; status:%d", status); |
| 13774 | |
| 13775 | return qdf_status_to_os_return(status); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13776 | } |
| 13777 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13778 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 13779 | static inline void hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
| 13780 | struct hdd_config *cfg) |
| 13781 | { |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 13782 | struct nlo_mawc_params *mawc_cfg = &pno_cfg->mawc_params; |
| 13783 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13784 | pno_cfg->channel_prediction = cfg->pno_channel_prediction; |
| 13785 | pno_cfg->top_k_num_of_channels = cfg->top_k_num_of_channels; |
| 13786 | pno_cfg->stationary_thresh = cfg->stationary_thresh; |
| 13787 | pno_cfg->adaptive_dwell_mode = cfg->adaptive_dwell_mode_enabled; |
| 13788 | pno_cfg->channel_prediction_full_scan = |
| 13789 | cfg->channel_prediction_full_scan; |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 13790 | mawc_cfg->enable = cfg->MAWCEnabled && cfg->mawc_nlo_enabled; |
| 13791 | mawc_cfg->exp_backoff_ratio = cfg->mawc_nlo_exp_backoff_ratio; |
| 13792 | mawc_cfg->init_scan_interval = cfg->mawc_nlo_init_scan_interval; |
| 13793 | mawc_cfg->max_scan_interval = cfg->mawc_nlo_max_scan_interval; |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13794 | } |
| 13795 | #else |
| 13796 | static inline void |
| 13797 | hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
Jeff Johnson | 33a0792 | 2017-10-05 09:08:46 -0700 | [diff] [blame] | 13798 | struct hdd_config *cfg) |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13799 | { |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13800 | } |
| 13801 | #endif |
| 13802 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 13803 | 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] | 13804 | struct hdd_context *hdd_ctx) |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 13805 | { |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 13806 | struct wlan_fwol_ie_whitelist whitelist = {0}; |
| 13807 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 13808 | QDF_STATUS status; |
| 13809 | bool is_ie_whitelist_enable = false; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 13810 | uint8_t i = 0; |
| 13811 | |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 13812 | status = ucfg_fwol_get_ie_whitelist(psoc, &is_ie_whitelist_enable); |
| 13813 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13814 | hdd_err("Unable to get IE whitelist param"); |
| 13815 | return; |
| 13816 | } |
| 13817 | |
| 13818 | ie_whitelist->white_list = is_ie_whitelist_enable; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 13819 | if (!ie_whitelist->white_list) |
| 13820 | return; |
| 13821 | |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 13822 | status = ucfg_fwol_get_all_whitelist_params(psoc, &whitelist); |
| 13823 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13824 | hdd_err("Unable to get all whitelist params"); |
| 13825 | return; |
| 13826 | } |
| 13827 | |
| 13828 | ie_whitelist->ie_bitmap[0] = whitelist.ie_bitmap_0; |
| 13829 | ie_whitelist->ie_bitmap[1] = whitelist.ie_bitmap_1; |
| 13830 | ie_whitelist->ie_bitmap[2] = whitelist.ie_bitmap_2; |
| 13831 | ie_whitelist->ie_bitmap[3] = whitelist.ie_bitmap_3; |
| 13832 | ie_whitelist->ie_bitmap[4] = whitelist.ie_bitmap_4; |
| 13833 | ie_whitelist->ie_bitmap[5] = whitelist.ie_bitmap_5; |
| 13834 | ie_whitelist->ie_bitmap[6] = whitelist.ie_bitmap_6; |
| 13835 | ie_whitelist->ie_bitmap[7] = whitelist.ie_bitmap_7; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 13836 | |
Dundi Raviteja | 9ab4e7b | 2018-09-28 14:18:28 +0530 | [diff] [blame] | 13837 | ie_whitelist->num_vendor_oui = whitelist.no_of_probe_req_ouis; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 13838 | for (i = 0; i < ie_whitelist->num_vendor_oui; i++) |
Dundi Raviteja | 9ab4e7b | 2018-09-28 14:18:28 +0530 | [diff] [blame] | 13839 | ie_whitelist->voui[i] = whitelist.probe_req_voui[i]; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 13840 | } |
| 13841 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 13842 | uint32_t hdd_limit_max_per_index_score(uint32_t per_index_score) |
| 13843 | { |
| 13844 | uint8_t i, score; |
| 13845 | |
| 13846 | for (i = 0; i < MAX_INDEX_PER_INI; i++) { |
| 13847 | score = WLAN_GET_SCORE_PERCENTAGE(per_index_score, i); |
| 13848 | if (score > MAX_INDEX_SCORE) |
| 13849 | WLAN_SET_SCORE_PERCENTAGE(per_index_score, |
| 13850 | MAX_INDEX_SCORE, i); |
| 13851 | } |
| 13852 | |
| 13853 | return per_index_score; |
| 13854 | } |
| 13855 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 13856 | QDF_STATUS hdd_update_score_config( |
| 13857 | struct scoring_config *score_config, struct hdd_context *hdd_ctx) |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 13858 | { |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 13859 | struct hdd_config *cfg = hdd_ctx->config; |
gaurank kathpalia | ae52c98 | 2018-10-04 01:35:18 +0530 | [diff] [blame] | 13860 | QDF_STATUS status; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 13861 | bool bval = false; |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 13862 | |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 13863 | sme_update_score_config(hdd_ctx->mac_handle, score_config); |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 13864 | |
| 13865 | score_config->cb_mode_24G = cfg->nChannelBondingMode24GHz; |
| 13866 | score_config->cb_mode_5G = cfg->nChannelBondingMode5GHz; |
gaurank kathpalia | ae52c98 | 2018-10-04 01:35:18 +0530 | [diff] [blame] | 13867 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 13868 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
gaurank kathpalia | ae52c98 | 2018-10-04 01:35:18 +0530 | [diff] [blame] | 13869 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 13870 | hdd_err("unable to get vht_enable2x2"); |
gaurank kathpalia | ae52c98 | 2018-10-04 01:35:18 +0530 | [diff] [blame] | 13871 | score_config->vdev_nss_24g = |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 13872 | bval ? CFG_STA_NSS(cfg->vdev_type_nss_2g) : 1; |
gaurank kathpalia | ae52c98 | 2018-10-04 01:35:18 +0530 | [diff] [blame] | 13873 | score_config->vdev_nss_5g = |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 13874 | bval ? CFG_STA_NSS(cfg->vdev_type_nss_5g) : 1; |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 13875 | |
| 13876 | if (cfg->dot11Mode == eHDD_DOT11_MODE_AUTO || |
| 13877 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 13878 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) |
| 13879 | score_config->he_cap = 1; |
| 13880 | |
| 13881 | if (score_config->he_cap || |
| 13882 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 13883 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) |
| 13884 | score_config->vht_cap = 1; |
| 13885 | |
| 13886 | if (score_config->vht_cap || cfg->dot11Mode == eHDD_DOT11_MODE_11n || |
| 13887 | cfg->dot11Mode == eHDD_DOT11_MODE_11n_ONLY) |
| 13888 | score_config->ht_cap = 1; |
| 13889 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 13890 | status = ucfg_mlme_get_vht_for_24ghz(hdd_ctx->psoc, &bval); |
| 13891 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 13892 | hdd_err("Failed to get vht_for_24ghz"); |
| 13893 | if (score_config->vht_cap && bval) |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 13894 | score_config->vht_24G_cap = 1; |
| 13895 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 13896 | status = ucfg_mlme_get_vht_enable_tx_bf(hdd_ctx->psoc, |
| 13897 | &bval); |
| 13898 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 13899 | hdd_err("unable to get vht_enable_tx_bf"); |
| 13900 | |
| 13901 | if (bval) |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 13902 | score_config->beamformee_cap = 1; |
| 13903 | |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 13904 | return QDF_STATUS_SUCCESS; |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 13905 | } |
| 13906 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13907 | /** |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 13908 | * hdd_update_dfs_config() - API to update dfs configuration parameters. |
| 13909 | * @hdd_ctx: HDD context |
| 13910 | * |
| 13911 | * Return: 0 if success else err |
| 13912 | */ |
| 13913 | static int hdd_update_dfs_config(struct hdd_context *hdd_ctx) |
| 13914 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 13915 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 13916 | struct hdd_config *cfg = hdd_ctx->config; |
| 13917 | struct dfs_user_config dfs_cfg; |
| 13918 | QDF_STATUS status; |
| 13919 | |
| 13920 | dfs_cfg.dfs_is_phyerr_filter_offload = !!cfg->fDfsPhyerrFilterOffload; |
| 13921 | status = ucfg_dfs_update_config(psoc, &dfs_cfg); |
| 13922 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13923 | hdd_err("failed dfs psoc configuration"); |
| 13924 | return -EINVAL; |
| 13925 | } |
| 13926 | |
| 13927 | return 0; |
| 13928 | } |
| 13929 | |
| 13930 | /** |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13931 | * hdd_update_scan_config - API to update scan configuration parameters |
| 13932 | * @hdd_ctx: HDD context |
| 13933 | * |
| 13934 | * Return: 0 if success else err |
| 13935 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13936 | static int hdd_update_scan_config(struct hdd_context *hdd_ctx) |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13937 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 13938 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13939 | struct scan_user_cfg scan_cfg; |
| 13940 | struct hdd_config *cfg = hdd_ctx->config; |
| 13941 | QDF_STATUS status; |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 13942 | uint8_t scan_bucket_thre; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 13943 | uint8_t select_5ghz_margin; |
| 13944 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 13945 | status = ucfg_mlme_get_select_5ghz_margin(hdd_ctx->psoc, |
| 13946 | &select_5ghz_margin); |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 13947 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13948 | hdd_err("Failed to get select_5ghz_margin"); |
| 13949 | return -EIO; |
| 13950 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13951 | |
| 13952 | scan_cfg.active_dwell = cfg->nActiveMaxChnTime; |
| 13953 | scan_cfg.passive_dwell = cfg->nPassiveMaxChnTime; |
| 13954 | scan_cfg.conc_active_dwell = cfg->nActiveMaxChnTimeConc; |
| 13955 | scan_cfg.conc_passive_dwell = cfg->nPassiveMaxChnTimeConc; |
| 13956 | scan_cfg.conc_max_rest_time = cfg->nRestTimeConc; |
| 13957 | scan_cfg.conc_min_rest_time = cfg->min_rest_time_conc; |
| 13958 | scan_cfg.conc_idle_time = cfg->idle_time_conc; |
Abhishek Singh | 158fe25 | 2017-03-23 11:09:34 +0530 | [diff] [blame] | 13959 | /* convert to ms */ |
| 13960 | scan_cfg.scan_cache_aging_time = |
| 13961 | cfg->scanAgingTimeout * 1000; |
| 13962 | scan_cfg.prefer_5ghz = cfg->nRoamPrefer5GHz; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 13963 | scan_cfg.select_5ghz_margin = select_5ghz_margin; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 13964 | ucfg_mlme_get_first_scan_bucket_threshold(hdd_ctx->psoc, |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 13965 | &scan_bucket_thre); |
| 13966 | scan_cfg.scan_bucket_threshold = (int32_t)scan_bucket_thre; |
Abhishek Singh | 158fe25 | 2017-03-23 11:09:34 +0530 | [diff] [blame] | 13967 | scan_cfg.rssi_cat_gap = cfg->nRssiCatGap; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13968 | scan_cfg.scan_dwell_time_mode = cfg->scan_adaptive_dwell_mode; |
Kapil Gupta | fa9a8c6 | 2017-04-10 15:25:40 +0530 | [diff] [blame] | 13969 | scan_cfg.is_snr_monitoring_enabled = cfg->fEnableSNRMonitoring; |
Jeff Johnson | 81c00d0 | 2017-11-07 12:34:36 -0800 | [diff] [blame] | 13970 | scan_cfg.usr_cfg_probe_rpt_time = cfg->scan_probe_repeat_time; |
| 13971 | scan_cfg.usr_cfg_num_probes = cfg->scan_num_probes; |
Abhishek Singh | b58164a | 2017-07-19 18:47:23 +0530 | [diff] [blame] | 13972 | scan_cfg.is_bssid_hint_priority = cfg->is_bssid_hint_priority; |
Kiran Kumar Lokere | d547fdd | 2017-09-13 17:20:55 -0700 | [diff] [blame] | 13973 | scan_cfg.enable_mac_spoofing = cfg->enable_mac_spoofing; |
Abhishek Singh | c87bb04 | 2018-01-30 17:10:42 +0530 | [diff] [blame] | 13974 | scan_cfg.sta_miracast_mcc_rest_time = |
| 13975 | cfg->sta_miracast_mcc_rest_time_val; |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13976 | hdd_update_pno_config(&scan_cfg.pno_cfg, cfg); |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 13977 | hdd_update_ie_whitelist_attr(&scan_cfg.ie_whitelist, hdd_ctx); |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 13978 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 13979 | status = hdd_update_score_config(&scan_cfg.score_config, hdd_ctx); |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 13980 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13981 | hdd_err("Failed to update scoring config"); |
| 13982 | return -EINVAL; |
| 13983 | } |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13984 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13985 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 13986 | if (status != QDF_STATUS_SUCCESS) { |
| 13987 | hdd_err("failed pmo psoc configuration"); |
| 13988 | return -EINVAL; |
| 13989 | } |
Liangwei Dong | ac3ddde | 2018-09-10 23:25:12 -0400 | [diff] [blame] | 13990 | ucfg_scan_set_global_config( |
| 13991 | psoc, SCAN_CFG_DROP_BCN_ON_CHANNEL_MISMATCH, |
| 13992 | cfg_get(psoc, CFG_DROP_BCN_ON_CHANNEL_MISMATCH)); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13993 | |
| 13994 | return 0; |
| 13995 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13996 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13997 | int hdd_update_components_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13998 | { |
| 13999 | int ret; |
| 14000 | |
| 14001 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14002 | if (ret) |
| 14003 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14004 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14005 | ret = hdd_update_scan_config(hdd_ctx); |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 14006 | if (ret) |
| 14007 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14008 | |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 14009 | ret = hdd_update_tdls_config(hdd_ctx); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14010 | if (ret) |
| 14011 | return ret; |
| 14012 | |
| 14013 | ret = hdd_update_dp_config(hdd_ctx); |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14014 | if (ret) |
| 14015 | return ret; |
| 14016 | |
| 14017 | ret = hdd_update_dfs_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14018 | |
| 14019 | return ret; |
| 14020 | } |
| 14021 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14022 | /** |
| 14023 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 14024 | * @mode : cfg80211 DFS mode |
| 14025 | * |
| 14026 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 14027 | */ |
| 14028 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 14029 | { |
| 14030 | switch (mode) { |
| 14031 | case DFS_MODE_ENABLE: |
| 14032 | return ACS_DFS_MODE_ENABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14033 | case DFS_MODE_DISABLE: |
| 14034 | return ACS_DFS_MODE_DISABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14035 | case DFS_MODE_DEPRIORITIZE: |
| 14036 | return ACS_DFS_MODE_DEPRIORITIZE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14037 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 14038 | hdd_debug("ACS dfs mode is NONE"); |
| 14039 | return ACS_DFS_MODE_NONE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14040 | } |
| 14041 | } |
| 14042 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14043 | /** |
| 14044 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 14045 | * @hddctx: pointer to hdd context |
| 14046 | * @set_value: enable/disable |
| 14047 | * |
| 14048 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 14049 | * Host(even though it is duplicate). When Host send vendor command |
| 14050 | * disable,FW doesn't perform any action. Whenever any change in |
| 14051 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 14052 | * |
| 14053 | * return - 0 on success, appropriate error values on failure. |
| 14054 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14055 | 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] | 14056 | { |
| 14057 | QDF_STATUS status; |
| 14058 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14059 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14060 | return -EAGAIN; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14061 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14062 | status = sme_enable_disable_chanavoidind_event(hdd_ctx->mac_handle, |
| 14063 | set_value); |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14064 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 14065 | hdd_err("Failed to send chan avoid command to SME"); |
| 14066 | return -EINVAL; |
| 14067 | } |
| 14068 | return 0; |
| 14069 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14070 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14071 | /** |
| 14072 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 14073 | * @value: value to set |
| 14074 | * |
| 14075 | * This function will set the passed value to roaming in progress flag. |
| 14076 | * |
| 14077 | * Return: None |
| 14078 | */ |
| 14079 | void hdd_set_roaming_in_progress(bool value) |
| 14080 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14081 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14082 | |
| 14083 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14084 | if (!hdd_ctx) { |
| 14085 | hdd_err("HDD context is NULL"); |
| 14086 | return; |
| 14087 | } |
| 14088 | |
| 14089 | hdd_ctx->roaming_in_progress = value; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 14090 | hdd_debug("Roaming in Progress set to %d", value); |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14091 | } |
| 14092 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14093 | bool hdd_is_roaming_in_progress(struct hdd_context *hdd_ctx) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14094 | { |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14095 | if (!hdd_ctx) { |
| 14096 | hdd_err("HDD context is NULL"); |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14097 | return false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14098 | } |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 14099 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14100 | hdd_debug("roaming_in_progress = %d", hdd_ctx->roaming_in_progress); |
| 14101 | |
| 14102 | return hdd_ctx->roaming_in_progress; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14103 | } |
| 14104 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14105 | /** |
| 14106 | * hdd_is_connection_in_progress() - check if connection is in |
| 14107 | * progress |
| 14108 | * @session_id: session id |
| 14109 | * @reason: scan reject reason |
| 14110 | * |
| 14111 | * Go through each adapter and check if Connection is in progress |
| 14112 | * |
| 14113 | * Return: true if connection is in progress else false |
| 14114 | */ |
| 14115 | bool hdd_is_connection_in_progress(uint8_t *session_id, |
| 14116 | enum scan_reject_states *reason) |
| 14117 | { |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 14118 | struct hdd_station_ctx *hdd_sta_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14119 | struct hdd_adapter *adapter = NULL; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14120 | uint8_t sta_id = 0; |
| 14121 | uint8_t *sta_mac = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14122 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14123 | mac_handle_t mac_handle; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14124 | |
| 14125 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14126 | if (!hdd_ctx) { |
| 14127 | hdd_err("HDD context is NULL"); |
| 14128 | return false; |
| 14129 | } |
| 14130 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14131 | mac_handle = hdd_ctx->mac_handle; |
| 14132 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 14133 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Tushnim Bhattacharyya | 929afa4 | 2018-06-01 15:04:44 -0700 | [diff] [blame] | 14134 | hdd_debug("Adapter with device mode %s(%d) exists", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14135 | hdd_device_mode_to_string(adapter->device_mode), |
| 14136 | adapter->device_mode); |
| 14137 | if (((QDF_STA_MODE == adapter->device_mode) |
| 14138 | || (QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 14139 | || (QDF_P2P_DEVICE_MODE == adapter->device_mode)) |
| 14140 | && (eConnectionState_Connecting == |
| 14141 | (WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> |
| 14142 | conn_info.connState)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14143 | hdd_debug("%pK(%d) Connection is in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14144 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14145 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14146 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14147 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14148 | *reason = CONNECTION_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14149 | } |
| 14150 | return true; |
| 14151 | } |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 14152 | /* |
| 14153 | * sme_neighbor_middle_of_roaming is for LFR2 |
| 14154 | * hdd_is_roaming_in_progress is for LFR3 |
| 14155 | */ |
| 14156 | if (((QDF_STA_MODE == adapter->device_mode) && |
| 14157 | sme_neighbor_middle_of_roaming( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14158 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14159 | adapter->session_id)) || |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14160 | hdd_is_roaming_in_progress(hdd_ctx)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14161 | hdd_debug("%pK(%d) Reassociation in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14162 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14163 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14164 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14165 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14166 | *reason = REASSOC_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14167 | } |
| 14168 | return true; |
| 14169 | } |
| 14170 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 14171 | (QDF_P2P_CLIENT_MODE == adapter->device_mode) || |
| 14172 | (QDF_P2P_DEVICE_MODE == adapter->device_mode)) { |
| 14173 | hdd_sta_ctx = |
| 14174 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 14175 | if ((eConnectionState_Associated == |
Vignesh Viswanathan | 0a56929 | 2018-02-14 15:34:47 +0530 | [diff] [blame] | 14176 | hdd_sta_ctx->conn_info.connState) |
| 14177 | && sme_is_sta_key_exchange_in_progress( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14178 | mac_handle, adapter->session_id)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14179 | sta_mac = (uint8_t *) |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 14180 | &(adapter->mac_addr.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14181 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14182 | " is in middle of WPS/EAPOL exchange.", |
| 14183 | MAC_ADDR_ARRAY(sta_mac)); |
| 14184 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14185 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14186 | *reason = EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14187 | } |
| 14188 | return true; |
| 14189 | } |
| 14190 | } else if ((QDF_SAP_MODE == adapter->device_mode) || |
| 14191 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
| 14192 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; |
| 14193 | sta_id++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 14194 | if (!((adapter->sta_info[sta_id].in_use) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14195 | && (OL_TXRX_PEER_STATE_CONN == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 14196 | adapter->sta_info[sta_id].peer_state))) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14197 | continue; |
| 14198 | |
| 14199 | sta_mac = (uint8_t *) |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 14200 | &(adapter->sta_info[sta_id]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 14201 | sta_mac.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14202 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14203 | " of SAP/GO is in middle of WPS/EAPOL exchange", |
| 14204 | MAC_ADDR_ARRAY(sta_mac)); |
| 14205 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14206 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14207 | *reason = SAP_EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14208 | } |
| 14209 | return true; |
| 14210 | } |
| 14211 | if (hdd_ctx->connection_in_progress) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14212 | hdd_debug("AP/GO: connection is in progress"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14213 | return true; |
| 14214 | } |
| 14215 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14216 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 14217 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14218 | return false; |
| 14219 | } |
| 14220 | |
| 14221 | /** |
| 14222 | * hdd_restart_sap() - to restart SAP in driver internally |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14223 | * @ap_adapter: Pointer to SAP struct hdd_adapter structure |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14224 | * |
| 14225 | * Return: None |
| 14226 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14227 | void hdd_restart_sap(struct hdd_adapter *ap_adapter) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14228 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 14229 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 14230 | struct hdd_hostapd_state *hostapd_state; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14231 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14232 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 14233 | tsap_config_t *sap_config; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14234 | void *sap_ctx; |
| 14235 | |
| 14236 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 14237 | sap_config = &hdd_ap_ctx->sap_config; |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 14238 | sap_ctx = hdd_ap_ctx->sap_context; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14239 | |
| 14240 | mutex_lock(&hdd_ctx->sap_lock); |
| 14241 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
| 14242 | wlan_hdd_del_station(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14243 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 14244 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
| 14245 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(sap_ctx)) { |
| 14246 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 14247 | qdf_wait_for_event_completion(&hostapd_state-> |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14248 | qdf_stop_bss_event, |
Vignesh Viswanathan | 865daaa | 2018-10-11 19:30:44 +0530 | [diff] [blame] | 14249 | SME_CMD_START_STOP_BSS_TIMEOUT); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14250 | |
| 14251 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14252 | hdd_err("SAP Stop Failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14253 | goto end; |
| 14254 | } |
| 14255 | } |
| 14256 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14257 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14258 | ap_adapter->device_mode, ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 14259 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14260 | false); |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14261 | hdd_err("SAP Stop Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14262 | |
| 14263 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14264 | hdd_err("SAP Not able to set AP IEs"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14265 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14266 | eUPDATE_IE_ALL); |
| 14267 | goto end; |
| 14268 | } |
| 14269 | |
| 14270 | qdf_event_reset(&hostapd_state->qdf_event); |
| 14271 | if (wlansap_start_bss(sap_ctx, hdd_hostapd_sap_event_cb, |
| 14272 | sap_config, |
| 14273 | ap_adapter->dev) != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14274 | hdd_err("SAP Start Bss fail"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14275 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14276 | eUPDATE_IE_ALL); |
| 14277 | goto end; |
| 14278 | } |
| 14279 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14280 | hdd_info("Waiting for SAP to start"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14281 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 14282 | qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Vignesh Viswanathan | 865daaa | 2018-10-11 19:30:44 +0530 | [diff] [blame] | 14283 | SME_CMD_START_STOP_BSS_TIMEOUT); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14284 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14285 | eUPDATE_IE_ALL); |
| 14286 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14287 | hdd_err("SAP Start failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14288 | goto end; |
| 14289 | } |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14290 | hdd_err("SAP Start Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14291 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14292 | if (hostapd_state->bss_state == BSS_START) { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14293 | policy_mgr_incr_active_session(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14294 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14295 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 14296 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14297 | ap_adapter->device_mode, |
| 14298 | true); |
| 14299 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14300 | } |
| 14301 | end: |
| 14302 | mutex_unlock(&hdd_ctx->sap_lock); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14303 | } |
| 14304 | |
| 14305 | /** |
| 14306 | * hdd_check_and_restart_sap_with_non_dfs_acs() - Restart SAP |
| 14307 | * with non dfs acs |
| 14308 | * |
| 14309 | * Restarts SAP in non-DFS ACS mode when STA-AP mode DFS is not supported |
| 14310 | * |
| 14311 | * Return: None |
| 14312 | */ |
| 14313 | void hdd_check_and_restart_sap_with_non_dfs_acs(void) |
| 14314 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14315 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14316 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 14317 | struct cds_context *cds_ctx; |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14318 | uint8_t restart_chan; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14319 | |
| 14320 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14321 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14322 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14323 | return; |
| 14324 | } |
| 14325 | |
| 14326 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 14327 | if (!cds_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14328 | hdd_err("Invalid CDS Context"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14329 | return; |
| 14330 | } |
| 14331 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14332 | if (policy_mgr_get_concurrency_mode(hdd_ctx->psoc) |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14333 | != (QDF_STA_MASK | QDF_SAP_MASK)) { |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 14334 | hdd_debug("Concurrency mode is not SAP"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14335 | return; |
| 14336 | } |
| 14337 | |
| 14338 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 14339 | if (ap_adapter && |
| 14340 | test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags) && |
| 14341 | wlan_reg_is_dfs_ch(hdd_ctx->pdev, |
| 14342 | ap_adapter->session.ap.operating_channel)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14343 | |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14344 | 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] | 14345 | |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14346 | restart_chan = |
| 14347 | hdd_get_safe_channel_from_pcl_and_acs_range(ap_adapter); |
| 14348 | if (!restart_chan || |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 14349 | wlan_reg_is_dfs_ch(hdd_ctx->pdev, restart_chan)) |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14350 | restart_chan = SAP_DEFAULT_5GHZ_CHANNEL; |
| 14351 | |
| 14352 | hdd_switch_sap_channel(ap_adapter, restart_chan, true); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14353 | } |
| 14354 | } |
| 14355 | |
| 14356 | /** |
| 14357 | * hdd_set_connection_in_progress() - to set the connection in |
| 14358 | * progress flag |
| 14359 | * @value: value to set |
| 14360 | * |
| 14361 | * This function will set the passed value to connection in progress flag. |
| 14362 | * If value is previously being set to true then no need to set it again. |
| 14363 | * |
| 14364 | * Return: true if value is being set correctly and false otherwise. |
| 14365 | */ |
| 14366 | bool hdd_set_connection_in_progress(bool value) |
| 14367 | { |
| 14368 | bool status = true; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14369 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14370 | |
| 14371 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14372 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14373 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14374 | return false; |
| 14375 | } |
| 14376 | |
| 14377 | qdf_spin_lock(&hdd_ctx->connection_status_lock); |
| 14378 | /* |
| 14379 | * if the value is set to true previously and if someone is |
| 14380 | * trying to make it true again then it could be some race |
| 14381 | * condition being triggered. Avoid this situation by returning |
| 14382 | * false |
| 14383 | */ |
| 14384 | if (hdd_ctx->connection_in_progress && value) |
| 14385 | status = false; |
| 14386 | else |
| 14387 | hdd_ctx->connection_in_progress = value; |
| 14388 | qdf_spin_unlock(&hdd_ctx->connection_status_lock); |
| 14389 | return status; |
| 14390 | } |
| 14391 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14392 | 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] | 14393 | { |
| 14394 | if (!adapter) { |
| 14395 | hdd_err("Invalid adapter"); |
| 14396 | return -EINVAL; |
| 14397 | } |
| 14398 | hdd_info("Send MCC P2P QUOTA to WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14399 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 14400 | WMA_VDEV_MCC_SET_TIME_QUOTA, |
| 14401 | set_value, VDEV_CMD); |
| 14402 | return 0; |
| 14403 | |
| 14404 | } |
| 14405 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14406 | 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] | 14407 | { |
| 14408 | if (!adapter) { |
| 14409 | hdd_err("Invalid adapter"); |
| 14410 | return -EINVAL; |
| 14411 | } |
| 14412 | |
| 14413 | hdd_info("Send MCC latency WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14414 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 14415 | WMA_VDEV_MCC_SET_TIME_LATENCY, |
| 14416 | set_value, VDEV_CMD); |
| 14417 | return 0; |
| 14418 | } |
| 14419 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14420 | 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] | 14421 | *psoc, uint8_t vdev_id) |
| 14422 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14423 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14424 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 14425 | |
| 14426 | /* |
| 14427 | * Currently PSOC is not being used. But this logic will |
| 14428 | * change once we have the converged implementation of |
| 14429 | * HDD context per PSOC in place. This would break if |
| 14430 | * multiple vdev objects reuse the vdev id. |
| 14431 | */ |
| 14432 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 14433 | if (!adapter) |
| 14434 | hdd_err("Get adapter by vdev id failed"); |
| 14435 | |
| 14436 | return adapter; |
| 14437 | } |
| 14438 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14439 | 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] | 14440 | int8_t *rssi, int8_t *snr) |
| 14441 | { |
| 14442 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14443 | mac_handle_t mac_handle; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 14444 | struct csr_roam_profile *roam_profile; |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 14445 | |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 14446 | roam_profile = hdd_roam_profile(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14447 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 14448 | status = sme_get_rssi_snr_by_bssid(mac_handle, |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 14449 | roam_profile, bssid, rssi, snr); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 14450 | if (QDF_STATUS_SUCCESS != status) { |
| 14451 | hdd_warn("sme_get_rssi_snr_by_bssid failed"); |
| 14452 | return -EINVAL; |
| 14453 | } |
| 14454 | |
| 14455 | return 0; |
| 14456 | } |
| 14457 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 14458 | /** |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14459 | * hdd_reset_limit_off_chan() - reset limit off-channel command parameters |
| 14460 | * @adapter - HDD adapter |
| 14461 | * |
| 14462 | * Return: 0 on success and non zero value on failure |
| 14463 | */ |
| 14464 | int hdd_reset_limit_off_chan(struct hdd_adapter *adapter) |
| 14465 | { |
| 14466 | struct hdd_context *hdd_ctx; |
| 14467 | int ret; |
| 14468 | QDF_STATUS status; |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 14469 | uint8_t sys_pref = 0; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14470 | |
| 14471 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 14472 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 14473 | if (ret < 0) |
| 14474 | return ret; |
| 14475 | |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 14476 | ucfg_policy_mgr_get_sys_pref(hdd_ctx->psoc, |
| 14477 | &sys_pref); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14478 | /* set the system preferece to default */ |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 14479 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->psoc, sys_pref); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14480 | |
| 14481 | /* clear the bitmap */ |
| 14482 | adapter->active_ac = 0; |
| 14483 | |
| 14484 | hdd_debug("reset ac_bitmap for session %hu active_ac %0x", |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14485 | adapter->session_id, adapter->active_ac); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14486 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14487 | status = sme_send_limit_off_channel_params(hdd_ctx->mac_handle, |
| 14488 | adapter->session_id, |
| 14489 | false, 0, 0, false); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14490 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 14491 | hdd_err("failed to reset limit off chan params"); |
| 14492 | ret = -EINVAL; |
| 14493 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 14494 | |
| 14495 | return ret; |
| 14496 | } |
| 14497 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14498 | /** |
| 14499 | * hdd_start_driver_ops_timer() - Starts driver ops inactivity timer |
| 14500 | * @drv_op: Enum indicating driver op |
| 14501 | * |
| 14502 | * Return: none |
| 14503 | */ |
| 14504 | void hdd_start_driver_ops_timer(int drv_op) |
| 14505 | { |
| 14506 | memset(drv_ops_string, 0, MAX_OPS_NAME_STRING_SIZE); |
| 14507 | switch (drv_op) { |
| 14508 | case eHDD_DRV_OP_PROBE: |
| 14509 | memcpy(drv_ops_string, "probe", sizeof("probe")); |
| 14510 | break; |
| 14511 | case eHDD_DRV_OP_REMOVE: |
| 14512 | memcpy(drv_ops_string, "remove", sizeof("remove")); |
| 14513 | break; |
| 14514 | case eHDD_DRV_OP_SHUTDOWN: |
| 14515 | memcpy(drv_ops_string, "shutdown", sizeof("shutdown")); |
| 14516 | break; |
| 14517 | case eHDD_DRV_OP_REINIT: |
| 14518 | memcpy(drv_ops_string, "reinit", sizeof("reinit")); |
| 14519 | break; |
Arunk Khandavalli | e9ef42a | 2017-10-04 14:49:51 +0530 | [diff] [blame] | 14520 | case eHDD_DRV_OP_IFF_UP: |
| 14521 | memcpy(drv_ops_string, "iff_up", sizeof("iff_up")); |
| 14522 | break; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14523 | } |
| 14524 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 14525 | hdd_drv_ops_task = current; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14526 | qdf_timer_start(&hdd_drv_ops_inactivity_timer, |
Dustin Brown | cfc54fe | 2018-06-18 16:17:41 -0700 | [diff] [blame] | 14527 | HDD_OPS_INACTIVITY_TIMEOUT * qdf_timer_get_multiplier()); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14528 | } |
| 14529 | |
| 14530 | /** |
| 14531 | * hdd_stop_driver_ops_timer() - Stops driver ops inactivity timer |
| 14532 | * |
| 14533 | * Return: none |
| 14534 | */ |
| 14535 | void hdd_stop_driver_ops_timer(void) |
| 14536 | { |
| 14537 | qdf_timer_sync_cancel(&hdd_drv_ops_inactivity_timer); |
| 14538 | } |
| 14539 | |
| 14540 | /** |
| 14541 | * hdd_drv_ops_inactivity_handler() - Timeout handler for driver ops |
| 14542 | * inactivity timer |
| 14543 | * |
| 14544 | * Return: None |
| 14545 | */ |
| 14546 | void hdd_drv_ops_inactivity_handler(void) |
| 14547 | { |
Rajeev Kumar | 4471f1b | 2018-06-08 14:18:28 -0700 | [diff] [blame] | 14548 | 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] | 14549 | __func__, HDD_OPS_INACTIVITY_TIMEOUT/1000, drv_ops_string); |
| 14550 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 14551 | if (hdd_drv_ops_task) { |
| 14552 | printk("Call stack for \"%s\"\n", hdd_drv_ops_task->comm); |
| 14553 | qdf_print_thread_trace(hdd_drv_ops_task); |
| 14554 | } else { |
| 14555 | hdd_err("hdd_drv_ops_task is null"); |
| 14556 | } |
| 14557 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14558 | /* Driver shutdown is stuck, no recovery possible at this point */ |
| 14559 | if (0 == qdf_mem_cmp(&drv_ops_string[0], "shutdown", |
| 14560 | sizeof("shutdown"))) |
| 14561 | QDF_BUG(0); |
| 14562 | |
Rajeev Kumar | 1e57b9c | 2018-01-04 16:17:10 -0800 | [diff] [blame] | 14563 | if (cds_is_fw_down()) { |
| 14564 | hdd_err("FW is down"); |
| 14565 | return; |
| 14566 | } |
| 14567 | |
Dustin Brown | 83044c2 | 2018-08-13 15:00:44 -0700 | [diff] [blame] | 14568 | cds_trigger_recovery(QDF_REASON_UNSPECIFIED); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14569 | } |
| 14570 | |
Sravan Kumar Kairam | d80c766 | 2017-10-03 16:11:05 +0530 | [diff] [blame] | 14571 | void hdd_pld_ipa_uc_shutdown_pipes(void) |
| 14572 | { |
| 14573 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14574 | |
| 14575 | if (!hdd_ctx) |
| 14576 | return; |
| 14577 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 14578 | ucfg_ipa_uc_force_pipe_shutdown(hdd_ctx->pdev); |
Sravan Kumar Kairam | d80c766 | 2017-10-03 16:11:05 +0530 | [diff] [blame] | 14579 | } |
| 14580 | |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 14581 | /** |
| 14582 | * hdd_set_rx_mode_rps() - Enable/disable RPS in SAP mode |
| 14583 | * @struct hdd_context *hdd_ctx |
| 14584 | * @struct hdd_adapter *padapter |
| 14585 | * @bool enble |
| 14586 | * |
| 14587 | * Return: none |
| 14588 | */ |
| 14589 | void hdd_set_rx_mode_rps(bool enable) |
| 14590 | { |
| 14591 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 14592 | struct hdd_context *hdd_ctx; |
| 14593 | struct hdd_adapter *adapter; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 14594 | |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 14595 | if (!cds_cfg) |
| 14596 | return; |
| 14597 | |
| 14598 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14599 | if (!hdd_ctx) |
| 14600 | return; |
| 14601 | |
| 14602 | adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 14603 | if (!adapter) |
| 14604 | return; |
| 14605 | |
| 14606 | if (!hdd_ctx->rps && cds_cfg->uc_offload_enabled) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 14607 | if (enable && !cds_cfg->rps_enabled) |
| 14608 | hdd_send_rps_ind(adapter); |
| 14609 | else if (!enable && cds_cfg->rps_enabled) |
| 14610 | hdd_send_rps_disable_ind(adapter); |
| 14611 | } |
| 14612 | } |
| 14613 | |
Hanumanth Reddy Pothula | 3862ca9 | 2018-01-12 16:44:10 +0530 | [diff] [blame] | 14614 | bool hdd_is_cli_iface_up(struct hdd_context *hdd_ctx) |
| 14615 | { |
| 14616 | struct hdd_adapter *adapter = NULL; |
| 14617 | |
| 14618 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 14619 | if ((adapter->device_mode == QDF_STA_MODE || |
| 14620 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
| 14621 | qdf_atomic_test_bit(DEVICE_IFACE_OPENED, |
| 14622 | &adapter->event_flags)){ |
| 14623 | return true; |
| 14624 | } |
| 14625 | } |
| 14626 | |
| 14627 | return false; |
| 14628 | } |
| 14629 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14630 | /* Register the module init/exit functions */ |
| 14631 | module_init(hdd_module_init); |
| 14632 | module_exit(hdd_module_exit); |
| 14633 | |
| 14634 | MODULE_LICENSE("Dual BSD/GPL"); |
| 14635 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 14636 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 14637 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14638 | static const struct kernel_param_ops con_mode_ops = { |
| 14639 | .set = con_mode_handler, |
| 14640 | .get = param_get_int, |
| 14641 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14642 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14643 | static const struct kernel_param_ops con_mode_ftm_ops = { |
| 14644 | .set = con_mode_handler_ftm, |
| 14645 | .get = param_get_int, |
| 14646 | }; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 14647 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14648 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14649 | static const struct kernel_param_ops con_mode_monitor_ops = { |
| 14650 | .set = con_mode_handler_monitor, |
| 14651 | .get = param_get_int, |
| 14652 | }; |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14653 | #endif |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 14654 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14655 | static const struct kernel_param_ops fwpath_ops = { |
| 14656 | .set = fwpath_changed_handler, |
| 14657 | .get = param_get_string, |
| 14658 | }; |
| 14659 | |
| 14660 | module_param_cb(con_mode, &con_mode_ops, &con_mode, |
| 14661 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 14662 | |
| 14663 | module_param_cb(con_mode_ftm, &con_mode_ftm_ops, &con_mode_ftm, |
| 14664 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 14665 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14666 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14667 | module_param_cb(con_mode_monitor, &con_mode_monitor_ops, &con_mode_monitor, |
| 14668 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14669 | #endif |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14670 | |
| 14671 | module_param_cb(fwpath, &fwpath_ops, &fwpath, |
| 14672 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14673 | |
| 14674 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 14675 | |
| 14676 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 14677 | |
| 14678 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |