Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Jeff Johnson | 30e9bb6 | 2018-12-27 20:57:09 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2019 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4 | * Permission to use, copy, modify, and/or distribute this software for |
| 5 | * any purpose with or without fee is hereby granted, provided that the |
| 6 | * above copyright notice and this permission notice appear in all |
| 7 | * copies. |
| 8 | * |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 10 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 11 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 12 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 13 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 14 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 15 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 16 | * PERFORMANCE OF THIS SOFTWARE. |
| 17 | */ |
| 18 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19 | /** |
| 20 | * DOC: wlan_hdd_main.c |
| 21 | * |
| 22 | * WLAN Host Device Driver implementation |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | /* Include Files */ |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 27 | #include <wbuff.h> |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 28 | #include "cfg_ucfg_api.h" |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 29 | #include "wlan_dsc.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 30 | #include <wlan_hdd_includes.h> |
| 31 | #include <cds_api.h> |
| 32 | #include <cds_sched.h> |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 33 | #include <linux/cpu.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 34 | #include <linux/etherdevice.h> |
| 35 | #include <linux/firmware.h> |
| 36 | #include <wlan_hdd_tx_rx.h> |
| 37 | #include <wni_api.h> |
| 38 | #include <wlan_hdd_cfg.h> |
| 39 | #include <wlan_ptt_sock_svc.h> |
| 40 | #include <dbglog_host.h> |
| 41 | #include <wlan_logging_sock_svc.h> |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 42 | #include <wlan_roam_debug.h> |
Dustin Brown | fe50cef | 2018-12-10 10:42:37 -0800 | [diff] [blame] | 43 | #include "wlan_hdd_dsc.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 44 | #include <wlan_hdd_wowl.h> |
| 45 | #include <wlan_hdd_misc.h> |
| 46 | #include <wlan_hdd_wext.h> |
| 47 | #include "wlan_hdd_trace.h" |
| 48 | #include "wlan_hdd_ioctl.h" |
| 49 | #include "wlan_hdd_ftm.h" |
| 50 | #include "wlan_hdd_power.h" |
| 51 | #include "wlan_hdd_stats.h" |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 52 | #include "wlan_hdd_scan.h" |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 53 | #include "wlan_policy_mgr_ucfg.h" |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 54 | #include <wlan_osif_request_manager.h> |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 55 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 56 | #include "qdf_debug_domain.h" |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 57 | #endif |
Dustin Brown | d424194 | 2018-02-26 12:51:37 -0800 | [diff] [blame] | 58 | #include "qdf_str.h" |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 59 | #include "qdf_talloc.h" |
Dustin Brown | d424194 | 2018-02-26 12:51:37 -0800 | [diff] [blame] | 60 | #include "qdf_trace.h" |
| 61 | #include "qdf_types.h" |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 62 | #include <cdp_txrx_peer_ops.h> |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 63 | #include <cdp_txrx_misc.h> |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 64 | #include <cdp_txrx_stats.h> |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 65 | #include "cdp_txrx_flow_ctrl_legacy.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 66 | |
| 67 | #include <net/addrconf.h> |
| 68 | #include <linux/wireless.h> |
| 69 | #include <net/cfg80211.h> |
| 70 | #include <linux/inetdevice.h> |
| 71 | #include <net/addrconf.h> |
| 72 | #include "wlan_hdd_cfg80211.h" |
| 73 | #include "wlan_hdd_ext_scan.h" |
| 74 | #include "wlan_hdd_p2p.h" |
| 75 | #include <linux/rtnetlink.h> |
| 76 | #include "sap_api.h" |
| 77 | #include <linux/semaphore.h> |
| 78 | #include <linux/ctype.h> |
| 79 | #include <linux/compat.h> |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 80 | #include <linux/reboot.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 81 | #ifdef MSM_PLATFORM |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 82 | #include <soc/qcom/subsystem_restart.h> |
| 83 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 84 | #include <wlan_hdd_hostapd.h> |
| 85 | #include <wlan_hdd_softap_tx_rx.h> |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 86 | #include <wlan_hdd_green_ap.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 87 | #include "cfg_api.h" |
| 88 | #include "qwlan_version.h" |
| 89 | #include "wma_types.h" |
| 90 | #include "wlan_hdd_tdls.h" |
| 91 | #ifdef FEATURE_WLAN_CH_AVOID |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 92 | #include "cds_regdomain.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 93 | #endif /* FEATURE_WLAN_CH_AVOID */ |
Dustin Brown | ce46d1d | 2017-08-15 13:34:24 -0700 | [diff] [blame] | 94 | #include "cdp_txrx_flow_ctrl_v2.h" |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 95 | #include "pld_common.h" |
Tushnim Bhattacharyya | 15596cf | 2016-02-12 11:57:02 -0800 | [diff] [blame] | 96 | #include "wlan_hdd_ocb.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 97 | #include "wlan_hdd_nan.h" |
| 98 | #include "wlan_hdd_debugfs.h" |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 99 | #include "wlan_hdd_debugfs_csr.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 100 | #include "wlan_hdd_driver_ops.h" |
| 101 | #include "epping_main.h" |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 102 | #include "wlan_hdd_data_stall_detection.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 103 | |
| 104 | #include <wlan_hdd_ipa.h> |
| 105 | #include "hif.h" |
| 106 | #include "wma.h" |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 107 | #include "wlan_policy_mgr_api.h" |
Manikandan Mohan | dcc21ba | 2016-03-15 14:31:56 -0700 | [diff] [blame] | 108 | #include "wlan_hdd_tsf.h" |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 109 | #include "bmi.h" |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 110 | #include <wlan_hdd_regulatory.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 111 | #include "wlan_hdd_lpass.h" |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 112 | #include "wlan_nan_api.h" |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 113 | #include <wlan_hdd_napi.h> |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 114 | #include "wlan_hdd_disa.h" |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 115 | #include <dispatcher_init_deinit.h> |
Rajeev Kumar | 699debf | 2017-01-06 14:17:00 -0800 | [diff] [blame] | 116 | #include "wlan_hdd_object_manager.h" |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 117 | #include "cds_utils.h" |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 118 | #include <cdp_txrx_handle.h> |
Sandeep Puligilla | fdd201e | 2017-02-02 18:43:46 -0800 | [diff] [blame] | 119 | #include <qca_vendor.h> |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 120 | #include "wlan_pmo_ucfg_api.h" |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 121 | #include "sir_api.h" |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 122 | #include "os_if_wifi_pos.h" |
| 123 | #include "wifi_pos_api.h" |
| 124 | #include "wlan_hdd_oemdata.h" |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 125 | #include "wlan_hdd_he.h" |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 126 | #include "os_if_nan.h" |
| 127 | #include "nan_public_structs.h" |
Nachiket Kukade | 85aa378 | 2018-11-02 20:12:34 +0530 | [diff] [blame] | 128 | #include "nan_ucfg_api.h" |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 129 | #include "wlan_reg_ucfg_api.h" |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 130 | #include "wlan_dfs_ucfg_api.h" |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 131 | #include "wlan_hdd_rx_monitor.h" |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 132 | #include "sme_power_save_api.h" |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 133 | #include "enet.h" |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 134 | #include <cdp_txrx_cmn_struct.h> |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 135 | #include <dp_txrx.h> |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 136 | #include "wlan_hdd_sysfs.h" |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 137 | #include "wlan_disa_ucfg_api.h" |
Wu Gao | 52084c1 | 2018-05-17 20:47:11 +0800 | [diff] [blame] | 138 | #include "wlan_disa_obj_mgmt_api.h" |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 139 | #include "wlan_action_oui_ucfg_api.h" |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 140 | #include "wlan_ipa_ucfg_api.h" |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 141 | #include <target_if.h> |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 142 | #include "wlan_hdd_nud_tracking.h" |
Nachiket Kukade | d0dd62e | 2018-05-21 18:39:22 +0530 | [diff] [blame] | 143 | #include "wlan_hdd_apf.h" |
Varun Reddy Yeturu | e93d246 | 2018-05-22 13:54:52 -0700 | [diff] [blame] | 144 | #include "wlan_hdd_twt.h" |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 145 | #include "qc_sap_ioctl.h" |
Sandeep Puligilla | c5609d5 | 2018-05-17 19:23:41 -0700 | [diff] [blame] | 146 | #include "wlan_mlme_main.h" |
Wu Gao | e568979 | 2018-07-05 19:20:13 +0800 | [diff] [blame] | 147 | #include "wlan_p2p_cfg_api.h" |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 148 | #include "wlan_cfg80211_p2p.h" |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 149 | #include "wlan_tdls_cfg_api.h" |
Qiwei Cai | e689a26 | 2018-07-26 15:50:22 +0800 | [diff] [blame] | 150 | #include <wlan_hdd_rssi_monitor.h> |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 151 | #include "wlan_mlme_ucfg_api.h" |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 152 | #include "wlan_fwol_ucfg_api.h" |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 153 | #include "wlan_policy_mgr_ucfg.h" |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 154 | #ifdef CNSS_GENL |
| 155 | #include <net/cnss_nl.h> |
| 156 | #endif |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 157 | #include "wlan_reg_ucfg_api.h" |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 158 | #include "wlan_ocb_ucfg_api.h" |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 159 | #include <wlan_hdd_spectralscan.h> |
gaurank kathpalia | 4a205fc | 2018-09-15 00:59:15 +0530 | [diff] [blame] | 160 | #include "wlan_green_ap_ucfg_api.h" |
Liangwei Dong | 3abfe8f | 2018-09-20 02:25:44 -0400 | [diff] [blame] | 161 | #include <wlan_p2p_ucfg_api.h> |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 162 | #include <target_type.h> |
Liangwei Dong | 3abfe8f | 2018-09-20 02:25:44 -0400 | [diff] [blame] | 163 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 164 | #ifdef MODULE |
| 165 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 166 | #else |
| 167 | #define WLAN_MODULE_NAME "wlan" |
| 168 | #endif |
| 169 | |
| 170 | #ifdef TIMER_MANAGER |
| 171 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 172 | #else |
| 173 | #define TIMER_MANAGER_STR "" |
| 174 | #endif |
| 175 | |
| 176 | #ifdef MEMORY_DEBUG |
| 177 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 178 | #else |
| 179 | #define MEMORY_DEBUG_STR "" |
| 180 | #endif |
| 181 | |
Dustin Brown | c1034df | 2018-02-07 14:51:32 -0800 | [diff] [blame] | 182 | #ifdef PANIC_ON_BUG |
| 183 | #define PANIC_ON_BUG_STR " +PANIC_ON_BUG" |
| 184 | #else |
| 185 | #define PANIC_ON_BUG_STR "" |
| 186 | #endif |
| 187 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 188 | bool g_is_system_reboot_triggered; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 189 | int wlan_start_ret_val; |
| 190 | static DECLARE_COMPLETION(wlan_start_comp); |
| 191 | static unsigned int dev_num = 1; |
| 192 | static struct cdev wlan_hdd_state_cdev; |
| 193 | static struct class *class; |
| 194 | static dev_t device; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 195 | #ifndef MODULE |
| 196 | static struct gwlan_loader *wlan_loader; |
| 197 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 198 | struct kobj_attribute *attr, |
| 199 | const char *buf, size_t count); |
| 200 | struct gwlan_loader { |
| 201 | bool loaded_state; |
| 202 | struct kobject *boot_wlan_obj; |
| 203 | struct attribute_group *attr_group; |
| 204 | }; |
| 205 | |
| 206 | static struct kobj_attribute wlan_boot_attribute = |
| 207 | __ATTR(boot_wlan, 0220, NULL, wlan_boot_cb); |
| 208 | |
| 209 | static struct attribute *attrs[] = { |
| 210 | &wlan_boot_attribute.attr, |
| 211 | NULL, |
| 212 | }; |
| 213 | |
| 214 | #define MODULE_INITIALIZED 1 |
Qun Zhang | 4a83a46 | 2018-09-11 16:28:51 +0800 | [diff] [blame] | 215 | |
| 216 | #ifdef MULTI_IF_NAME |
| 217 | #define WLAN_LOADER_NAME "boot_" MULTI_IF_NAME |
| 218 | #else |
| 219 | #define WLAN_LOADER_NAME "boot_wlan" |
| 220 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 221 | #endif |
| 222 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 223 | #define HDD_OPS_INACTIVITY_TIMEOUT (120000) |
| 224 | #define MAX_OPS_NAME_STRING_SIZE 20 |
| 225 | |
| 226 | static qdf_timer_t hdd_drv_ops_inactivity_timer; |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 227 | static struct task_struct *hdd_drv_ops_task; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 228 | static char drv_ops_string[MAX_OPS_NAME_STRING_SIZE]; |
| 229 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 230 | /* the Android framework expects this param even though we don't use it */ |
| 231 | #define BUF_LEN 20 |
| 232 | static char fwpath_buffer[BUF_LEN]; |
| 233 | static struct kparam_string fwpath = { |
| 234 | .string = fwpath_buffer, |
| 235 | .maxlen = BUF_LEN, |
| 236 | }; |
| 237 | |
| 238 | static char *country_code; |
| 239 | static int enable_11d = -1; |
| 240 | static int enable_dfs_chan_scan = -1; |
| 241 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 242 | /* |
| 243 | * spinlock for synchronizing asynchronous request/response |
| 244 | * (full description of use in wlan_hdd_main.h) |
| 245 | */ |
| 246 | DEFINE_SPINLOCK(hdd_context_lock); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 247 | DEFINE_MUTEX(hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 248 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 249 | #define WLAN_NLINK_CESIUM 30 |
| 250 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 251 | static qdf_wake_lock_t wlan_wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 252 | |
| 253 | #define WOW_MAX_FILTER_LISTS 1 |
| 254 | #define WOW_MAX_FILTERS_PER_LIST 4 |
| 255 | #define WOW_MIN_PATTERN_SIZE 6 |
| 256 | #define WOW_MAX_PATTERN_SIZE 64 |
| 257 | |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 258 | /* max peer can be tdls peers + self peer + bss peer */ |
| 259 | #define HDD_MAX_VDEV_PEER_COUNT (HDD_MAX_NUM_TDLS_STA + 2) |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 260 | #define IS_IDLE_STOP (!cds_is_driver_unloading() && \ |
| 261 | !cds_is_driver_recovering() && !cds_is_driver_loading()) |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 262 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 263 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 264 | static const struct wiphy_wowlan_support wowlan_support_reg_init = { |
| 265 | .flags = WIPHY_WOWLAN_ANY | |
| 266 | WIPHY_WOWLAN_MAGIC_PKT | |
| 267 | WIPHY_WOWLAN_DISCONNECT | |
| 268 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 269 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 270 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 271 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 272 | WIPHY_WOWLAN_RFKILL_RELEASE, |
| 273 | .n_patterns = WOW_MAX_FILTER_LISTS * WOW_MAX_FILTERS_PER_LIST, |
| 274 | .pattern_min_len = WOW_MIN_PATTERN_SIZE, |
| 275 | .pattern_max_len = WOW_MAX_PATTERN_SIZE, |
| 276 | }; |
| 277 | #endif |
| 278 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 279 | static const struct category_info cinfo[MAX_SUPPORTED_CATEGORY] = { |
| 280 | [QDF_MODULE_ID_TLSHIM] = {QDF_TRACE_LEVEL_ALL}, |
| 281 | [QDF_MODULE_ID_WMI] = {QDF_TRACE_LEVEL_ALL}, |
| 282 | [QDF_MODULE_ID_HTT] = {QDF_TRACE_LEVEL_ALL}, |
| 283 | [QDF_MODULE_ID_HDD] = {QDF_TRACE_LEVEL_ALL}, |
| 284 | [QDF_MODULE_ID_SME] = {QDF_TRACE_LEVEL_ALL}, |
| 285 | [QDF_MODULE_ID_PE] = {QDF_TRACE_LEVEL_ALL}, |
| 286 | [QDF_MODULE_ID_WMA] = {QDF_TRACE_LEVEL_ALL}, |
| 287 | [QDF_MODULE_ID_SYS] = {QDF_TRACE_LEVEL_ALL}, |
| 288 | [QDF_MODULE_ID_QDF] = {QDF_TRACE_LEVEL_ALL}, |
| 289 | [QDF_MODULE_ID_SAP] = {QDF_TRACE_LEVEL_ALL}, |
| 290 | [QDF_MODULE_ID_HDD_SOFTAP] = {QDF_TRACE_LEVEL_ALL}, |
| 291 | [QDF_MODULE_ID_HDD_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 292 | [QDF_MODULE_ID_HDD_SAP_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 293 | [QDF_MODULE_ID_HIF] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 294 | [QDF_MODULE_ID_HTC] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 295 | [QDF_MODULE_ID_TXRX] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 296 | [QDF_MODULE_ID_QDF_DEVICE] = {QDF_TRACE_LEVEL_ALL}, |
| 297 | [QDF_MODULE_ID_CFG] = {QDF_TRACE_LEVEL_ALL}, |
| 298 | [QDF_MODULE_ID_BMI] = {QDF_TRACE_LEVEL_ALL}, |
| 299 | [QDF_MODULE_ID_EPPING] = {QDF_TRACE_LEVEL_ALL}, |
| 300 | [QDF_MODULE_ID_QVIT] = {QDF_TRACE_LEVEL_ALL}, |
| 301 | [QDF_MODULE_ID_DP] = {QDF_TRACE_LEVEL_ALL}, |
| 302 | [QDF_MODULE_ID_SOC] = {QDF_TRACE_LEVEL_ALL}, |
| 303 | [QDF_MODULE_ID_OS_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 304 | [QDF_MODULE_ID_TARGET_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 305 | [QDF_MODULE_ID_SCHEDULER] = {QDF_TRACE_LEVEL_ALL}, |
| 306 | [QDF_MODULE_ID_MGMT_TXRX] = {QDF_TRACE_LEVEL_ALL}, |
| 307 | [QDF_MODULE_ID_PMO] = {QDF_TRACE_LEVEL_ALL}, |
| 308 | [QDF_MODULE_ID_SCAN] = {QDF_TRACE_LEVEL_ALL}, |
| 309 | [QDF_MODULE_ID_POLICY_MGR] = {QDF_TRACE_LEVEL_ALL}, |
| 310 | [QDF_MODULE_ID_P2P] = {QDF_TRACE_LEVEL_ALL}, |
| 311 | [QDF_MODULE_ID_TDLS] = {QDF_TRACE_LEVEL_ALL}, |
| 312 | [QDF_MODULE_ID_REGULATORY] = {QDF_TRACE_LEVEL_ALL}, |
| 313 | [QDF_MODULE_ID_SERIALIZATION] = {QDF_TRACE_LEVEL_ALL}, |
Arif Hussain | fde76e7 | 2017-09-05 16:58:23 -0700 | [diff] [blame] | 314 | [QDF_MODULE_ID_DFS] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar | ca8ef9d | 2017-10-06 10:43:21 -0700 | [diff] [blame] | 315 | [QDF_MODULE_ID_OBJ_MGR] = {QDF_TRACE_LEVEL_ALL}, |
Deepak Dhamdhere | f918d42 | 2017-07-06 12:56:29 -0700 | [diff] [blame] | 316 | [QDF_MODULE_ID_ROAM_DEBUG] = {QDF_TRACE_LEVEL_ALL}, |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 317 | [QDF_MODULE_ID_GREEN_AP] = {QDF_TRACE_LEVEL_ALL}, |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 318 | [QDF_MODULE_ID_OCB] = {QDF_TRACE_LEVEL_ALL}, |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 319 | [QDF_MODULE_ID_IPA] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 320 | [QDF_MODULE_ID_ACTION_OUI] = {QDF_TRACE_LEVEL_ALL}, |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 321 | [QDF_MODULE_ID_CONFIG] = {QDF_TRACE_LEVEL_ALL}, |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 322 | [QDF_MODULE_ID_MLME] = {QDF_TRACE_LEVEL_ALL}, |
Ashish Kumar Dhanotiya | 8d039c8 | 2018-07-11 20:41:14 +0530 | [diff] [blame] | 323 | [QDF_MODULE_ID_TARGET] = {QDF_TRACE_LEVEL_ALL}, |
Kiran Kumar Lokere | 4ce4048 | 2018-08-30 16:31:00 -0700 | [diff] [blame] | 324 | [QDF_MODULE_ID_CRYPTO] = {QDF_TRACE_LEVEL_ALL}, |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 325 | [QDF_MODULE_ID_FWOL] = {QDF_TRACE_LEVEL_ALL}, |
Abhishek Singh | 0b0105f | 2018-09-25 10:44:16 +0530 | [diff] [blame] | 326 | [QDF_MODULE_ID_SM_ENGINE] = {QDF_TRACE_LEVEL_ALL}, |
| 327 | [QDF_MODULE_ID_CMN_MLME] = {QDF_TRACE_LEVEL_ALL}, |
Nachiket Kukade | 089b983 | 2018-12-12 16:38:17 +0530 | [diff] [blame] | 328 | [QDF_MODULE_ID_NAN] = {QDF_TRACE_LEVEL_ALL}, |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 329 | }; |
| 330 | |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 331 | struct notifier_block hdd_netdev_notifier; |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 332 | struct notifier_block system_reboot_notifier; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 333 | |
| 334 | struct sock *cesium_nl_srv_sock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 335 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 336 | static void wlan_hdd_auto_shutdown_cb(void); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 337 | #endif |
| 338 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 339 | void hdd_start_complete(int ret) |
| 340 | { |
| 341 | wlan_start_ret_val = ret; |
| 342 | |
| 343 | complete(&wlan_start_comp); |
| 344 | } |
| 345 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 346 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 347 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 348 | * @hdd_ctx: pointer to struct hdd_context |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 349 | * |
| 350 | * Return: none |
| 351 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 352 | static void hdd_set_rps_cpu_mask(struct hdd_context *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 353 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 354 | struct hdd_adapter *adapter; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 355 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 356 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 357 | hdd_send_rps_ind(adapter); |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 358 | } |
| 359 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 360 | #ifdef QCA_HL_NETDEV_FLOW_CONTROL |
| 361 | void wlan_hdd_mod_fc_timer(struct hdd_adapter *adapter, |
| 362 | enum netif_action_type action) |
| 363 | { |
| 364 | if (!adapter->tx_flow_timer_initialized) |
| 365 | return; |
| 366 | |
| 367 | if (action == WLAN_WAKE_NON_PRIORITY_QUEUE) { |
| 368 | qdf_mc_timer_stop(&adapter->tx_flow_control_timer); |
| 369 | } else if (action == WLAN_STOP_NON_PRIORITY_QUEUE) { |
| 370 | QDF_STATUS status = |
| 371 | qdf_mc_timer_start(&adapter->tx_flow_control_timer, |
| 372 | WLAN_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME); |
| 373 | |
| 374 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 375 | hdd_err("Failed to start tx_flow_control_timer"); |
| 376 | else |
| 377 | adapter-> |
| 378 | hdd_stats.tx_rx_stats.txflow_timer_cnt++; |
| 379 | |
| 380 | adapter->hdd_stats.tx_rx_stats.txflow_pause_cnt++; |
| 381 | adapter->hdd_stats.tx_rx_stats.is_txflow_paused = true; |
| 382 | } |
| 383 | } |
| 384 | #endif /* QCA_HL_NETDEV_FLOW_CONTROL */ |
| 385 | |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 386 | #ifdef MSM_PLATFORM |
| 387 | void wlan_hdd_update_tcp_rx_param(struct hdd_context *hdd_ctx, void *data) |
| 388 | { |
| 389 | if (!hdd_ctx) { |
| 390 | hdd_err("HDD context is null"); |
| 391 | return; |
| 392 | } |
| 393 | |
| 394 | if (!data) { |
| 395 | hdd_err("Data is null"); |
| 396 | return; |
| 397 | } |
| 398 | if (hdd_ctx->config->enable_tcp_param_update) |
| 399 | wlan_hdd_send_tcp_param_update_event(hdd_ctx, data, 1); |
| 400 | else |
| 401 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 402 | WLAN_SVC_WLAN_TP_IND, |
| 403 | data, |
| 404 | sizeof(struct wlan_rx_tp_data)); |
| 405 | } |
| 406 | |
| 407 | void wlan_hdd_update_tcp_tx_param(struct hdd_context *hdd_ctx, void *data) |
| 408 | { |
| 409 | enum wlan_tp_level next_tx_level; |
| 410 | struct wlan_tx_tp_data *tx_tp_data; |
| 411 | |
| 412 | if (!hdd_ctx) { |
| 413 | hdd_err("HDD context is null"); |
| 414 | return; |
| 415 | } |
| 416 | |
| 417 | if (!data) { |
| 418 | hdd_err("Data is null"); |
| 419 | return; |
| 420 | } |
| 421 | |
| 422 | tx_tp_data = (struct wlan_tx_tp_data *)data; |
| 423 | next_tx_level = tx_tp_data->level; |
| 424 | |
| 425 | if (hdd_ctx->config->enable_tcp_param_update) |
| 426 | wlan_hdd_send_tcp_param_update_event(hdd_ctx, data, 0); |
| 427 | else |
| 428 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 429 | WLAN_SVC_WLAN_TP_TX_IND, |
| 430 | &next_tx_level, |
| 431 | sizeof(next_tx_level)); |
| 432 | } |
| 433 | |
| 434 | /** |
| 435 | * wlan_hdd_send_tcp_param_update_event() - Send vendor event to update |
| 436 | * TCP parameter through Wi-Fi HAL |
| 437 | * @hdd_ctx: Pointer to HDD context |
| 438 | * @data: Parameters to update |
| 439 | * @dir: Direction(tx/rx) to update |
| 440 | * |
| 441 | * Return: None |
| 442 | */ |
| 443 | void wlan_hdd_send_tcp_param_update_event(struct hdd_context *hdd_ctx, |
| 444 | void *data, |
| 445 | uint8_t dir) |
| 446 | { |
| 447 | struct sk_buff *vendor_event; |
| 448 | uint32_t event_len; |
| 449 | bool tcp_limit_output = false; |
| 450 | bool tcp_del_ack_ind_enabled = false; |
| 451 | bool tcp_adv_win_scl_enabled = false; |
| 452 | enum wlan_tp_level next_tp_level = WLAN_SVC_TP_NONE; |
| 453 | |
| 454 | event_len = sizeof(uint8_t) + sizeof(uint8_t) + NLMSG_HDRLEN; |
| 455 | |
| 456 | if (dir == 0) /*TX Flow */ { |
| 457 | struct wlan_tx_tp_data *tx_tp_data = |
| 458 | (struct wlan_tx_tp_data *)data; |
| 459 | |
| 460 | next_tp_level = tx_tp_data->level; |
| 461 | |
| 462 | if (tx_tp_data->tcp_limit_output) { |
| 463 | /* TCP_LIMIT_OUTPUT_BYTES */ |
| 464 | event_len += sizeof(uint32_t); |
| 465 | tcp_limit_output = true; |
| 466 | } |
| 467 | } else if (dir == 1) /* RX Flow */ { |
| 468 | struct wlan_rx_tp_data *rx_tp_data = |
| 469 | (struct wlan_rx_tp_data *)data; |
| 470 | |
| 471 | next_tp_level = rx_tp_data->level; |
| 472 | |
| 473 | if (rx_tp_data->rx_tp_flags & TCP_DEL_ACK_IND_MASK) { |
| 474 | event_len += sizeof(uint32_t); /* TCP_DELACK_SEG */ |
| 475 | tcp_del_ack_ind_enabled = true; |
| 476 | } |
| 477 | if (rx_tp_data->rx_tp_flags & TCP_ADV_WIN_SCL_MASK) { |
| 478 | event_len += sizeof(uint32_t); /* TCP_ADV_WIN_SCALE */ |
| 479 | tcp_adv_win_scl_enabled = true; |
| 480 | } |
| 481 | } else { |
| 482 | hdd_err("Invalid Direction [%d]", dir); |
| 483 | return; |
| 484 | } |
| 485 | |
| 486 | vendor_event = |
| 487 | cfg80211_vendor_event_alloc( |
| 488 | hdd_ctx->wiphy, |
| 489 | NULL, event_len, |
| 490 | QCA_NL80211_VENDOR_SUBCMD_THROUGHPUT_CHANGE_EVENT_INDEX, |
| 491 | GFP_KERNEL); |
| 492 | |
| 493 | if (!vendor_event) { |
| 494 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 495 | return; |
| 496 | } |
| 497 | |
| 498 | if (nla_put_u8( |
| 499 | vendor_event, |
| 500 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_DIRECTION, |
| 501 | dir)) |
| 502 | goto tcp_param_change_nla_failed; |
| 503 | |
| 504 | if (nla_put_u8( |
| 505 | vendor_event, |
| 506 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_THROUGHPUT_LEVEL, |
| 507 | (next_tp_level == WLAN_SVC_TP_LOW ? |
| 508 | QCA_WLAN_THROUGHPUT_LEVEL_LOW : |
| 509 | QCA_WLAN_THROUGHPUT_LEVEL_HIGH))) |
| 510 | goto tcp_param_change_nla_failed; |
| 511 | |
| 512 | if (tcp_limit_output && |
| 513 | nla_put_u32( |
| 514 | vendor_event, |
| 515 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_TCP_LIMIT_OUTPUT_BYTES, |
| 516 | (next_tp_level == WLAN_SVC_TP_LOW ? |
| 517 | TCP_LIMIT_OUTPUT_BYTES_LOW : |
| 518 | TCP_LIMIT_OUTPUT_BYTES_HI))) |
| 519 | goto tcp_param_change_nla_failed; |
| 520 | |
| 521 | if (tcp_del_ack_ind_enabled && |
| 522 | (nla_put_u32( |
| 523 | vendor_event, |
| 524 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_TCP_DELACK_SEG, |
| 525 | (next_tp_level == WLAN_SVC_TP_LOW ? |
| 526 | TCP_DEL_ACK_LOW : TCP_DEL_ACK_HI)))) |
| 527 | goto tcp_param_change_nla_failed; |
| 528 | |
| 529 | if (tcp_adv_win_scl_enabled && |
| 530 | (nla_put_u32( |
| 531 | vendor_event, |
| 532 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_TCP_ADV_WIN_SCALE, |
| 533 | (next_tp_level == WLAN_SVC_TP_LOW ? |
| 534 | WIN_SCALE_LOW : WIN_SCALE_HI)))) |
| 535 | goto tcp_param_change_nla_failed; |
| 536 | |
| 537 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 538 | return; |
| 539 | |
| 540 | tcp_param_change_nla_failed: |
| 541 | hdd_err("nla_put api failed"); |
| 542 | kfree_skb(vendor_event); |
| 543 | } |
| 544 | #endif /* MSM_PLATFORM */ |
| 545 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 546 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 547 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 548 | * @vdev_id: vdev_id |
| 549 | * @action: action type |
| 550 | * @reason: reason type |
| 551 | * |
| 552 | * Return: none |
| 553 | */ |
| 554 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 555 | enum netif_action_type action, enum netif_reason_type reason) |
| 556 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 557 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 558 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 559 | |
| 560 | if (!hdd_ctx) { |
| 561 | hdd_err("hdd ctx is NULL"); |
| 562 | return; |
| 563 | } |
| 564 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 565 | wlan_hdd_mod_fc_timer(adapter, action); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 566 | wlan_hdd_netif_queue_control(adapter, action, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 567 | } |
| 568 | |
| 569 | /* |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 570 | * Store WLAN driver version and timestamp info in global variables such that |
| 571 | * crash debugger can extract them from driver debug symbol and crashdump for |
| 572 | * post processing |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 573 | */ |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 574 | #ifdef BUILD_TAG |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 575 | 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] | 576 | #else |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 577 | 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] | 578 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 579 | |
| 580 | /** |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 581 | * hdd_get_valid_chan() - return current chan list from regulatory. |
| 582 | * @hdd_ctx: HDD context |
| 583 | * @chan_list: buf hold returned chan list |
| 584 | * @chan_num: input buf size and output returned chan num |
| 585 | * |
| 586 | * This function helps get current available chan list from regulatory |
| 587 | * module. It excludes the "disabled" and "invalid" channels. |
| 588 | * |
| 589 | * Return: 0 for success. |
| 590 | */ |
| 591 | static int hdd_get_valid_chan(struct hdd_context *hdd_ctx, |
| 592 | uint8_t *chan_list, |
| 593 | uint32_t *chan_num) |
| 594 | { |
| 595 | int i = 0, j = 0; |
| 596 | struct regulatory_channel *cur_chan_list; |
| 597 | struct wlan_objmgr_pdev *pdev; |
| 598 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 599 | if (!hdd_ctx || !hdd_ctx->pdev || !chan_list || !chan_num) |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 600 | return -EINVAL; |
| 601 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 602 | pdev = hdd_ctx->pdev; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 603 | cur_chan_list = qdf_mem_malloc(NUM_CHANNELS * |
| 604 | sizeof(struct regulatory_channel)); |
| 605 | if (!cur_chan_list) |
| 606 | return -ENOMEM; |
| 607 | |
| 608 | if (wlan_reg_get_current_chan_list(pdev, cur_chan_list) != |
| 609 | QDF_STATUS_SUCCESS) { |
| 610 | qdf_mem_free(cur_chan_list); |
| 611 | return -EINVAL; |
| 612 | } |
| 613 | |
| 614 | for (i = 0; i < NUM_CHANNELS; i++) { |
| 615 | uint32_t ch = cur_chan_list[i].chan_num; |
| 616 | enum channel_state state = wlan_reg_get_channel_state(pdev, |
| 617 | ch); |
| 618 | |
| 619 | if (state != CHANNEL_STATE_DISABLE && |
| 620 | state != CHANNEL_STATE_INVALID && |
| 621 | j < *chan_num) { |
| 622 | chan_list[j] = (uint8_t)ch; |
| 623 | j++; |
| 624 | } |
| 625 | } |
| 626 | *chan_num = j; |
| 627 | qdf_mem_free(cur_chan_list); |
| 628 | return 0; |
| 629 | } |
| 630 | |
| 631 | /** |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 632 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 633 | * @adapter: HDD adapter |
| 634 | * @chan_number: Channel number |
| 635 | * @chan_bw: Bandwidth |
| 636 | * |
| 637 | * Checks if the given bandwidth is valid for the given channel number. |
| 638 | * |
| 639 | * Return: 0 for success, non-zero for failure |
| 640 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 641 | int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 642 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 643 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 644 | { |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 645 | uint8_t chan[NUM_CHANNELS]; |
| 646 | uint32_t len = NUM_CHANNELS, i; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 647 | bool found = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 648 | mac_handle_t mac_handle; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 649 | int ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 650 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 651 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 652 | if (!mac_handle) { |
| 653 | hdd_err("Invalid MAC handle"); |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 654 | return -EINVAL; |
| 655 | } |
| 656 | |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 657 | ret = hdd_get_valid_chan(adapter->hdd_ctx, chan, |
| 658 | &len); |
| 659 | if (ret) { |
| 660 | hdd_err("error %d in getting valid channel list", ret); |
| 661 | return ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 662 | } |
| 663 | |
| 664 | for (i = 0; i < len; i++) { |
| 665 | if (chan[i] == chan_number) { |
| 666 | found = true; |
| 667 | break; |
| 668 | } |
| 669 | } |
| 670 | |
| 671 | if (found == false) { |
| 672 | hdd_err("Channel not in driver's valid channel list"); |
| 673 | return -EOPNOTSUPP; |
| 674 | } |
| 675 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 676 | if ((!WLAN_REG_IS_24GHZ_CH(chan_number)) && |
| 677 | (!WLAN_REG_IS_5GHZ_CH(chan_number))) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 678 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 679 | return -EINVAL; |
| 680 | } |
| 681 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 682 | if (WLAN_REG_IS_24GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 683 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 684 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 685 | return -EINVAL; |
| 686 | } |
| 687 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 688 | (chan_bw != CH_WIDTH_MAX)) { |
| 689 | hdd_err("Only BW20 possible on channel 14"); |
| 690 | return -EINVAL; |
| 691 | } |
| 692 | } |
| 693 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 694 | if (WLAN_REG_IS_5GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 695 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 696 | (chan_bw != CH_WIDTH_MAX)) { |
| 697 | hdd_err("Only BW20 possible on channel 165"); |
| 698 | return -EINVAL; |
| 699 | } |
| 700 | } |
| 701 | |
| 702 | return 0; |
| 703 | } |
| 704 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 705 | /** |
| 706 | * hdd_wait_for_recovery_completion() - Wait for cds recovery completion |
| 707 | * |
| 708 | * Block the unloading of the driver (or) interface up until the |
| 709 | * cds recovery is completed |
| 710 | * |
| 711 | * Return: true for recovery completion else false |
| 712 | */ |
| 713 | static bool hdd_wait_for_recovery_completion(void) |
| 714 | { |
| 715 | int retry = 0; |
| 716 | |
| 717 | /* Wait for recovery to complete */ |
| 718 | while (cds_is_driver_recovering()) { |
| 719 | if (retry == HDD_MOD_EXIT_SSR_MAX_RETRIES/2) |
| 720 | hdd_err("Recovery in progress; wait here!!!"); |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 721 | |
| 722 | if (g_is_system_reboot_triggered) { |
| 723 | hdd_info("System Reboot happening ignore unload!!"); |
| 724 | return false; |
| 725 | } |
| 726 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 727 | msleep(1000); |
| 728 | if (retry++ == HDD_MOD_EXIT_SSR_MAX_RETRIES) { |
| 729 | hdd_err("SSR never completed, error"); |
| 730 | /* |
| 731 | * Trigger the bug_on in the internal builds, in the |
| 732 | * customer builds self-recovery will be enabled |
| 733 | * in those cases just return error. |
| 734 | */ |
| 735 | if (cds_is_self_recovery_enabled()) |
| 736 | return false; |
| 737 | QDF_BUG(0); |
| 738 | } |
| 739 | } |
| 740 | |
| 741 | hdd_info("Recovery completed successfully!"); |
| 742 | return true; |
| 743 | } |
| 744 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 745 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 746 | static int __hdd_netdev_notifier_call(struct notifier_block *nb, |
| 747 | unsigned long state, void *data) |
| 748 | { |
| 749 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 750 | struct netdev_notifier_info *dev_notif_info = data; |
| 751 | struct net_device *dev = dev_notif_info->dev; |
| 752 | #else |
| 753 | struct net_device *dev = data; |
| 754 | #endif |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 755 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 756 | struct hdd_context *hdd_ctx; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 757 | struct wlan_objmgr_vdev *vdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 758 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 759 | hdd_enter_dev(dev); |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 760 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 761 | if (!dev->ieee80211_ptr) { |
Dustin Brown | aeb5564 | 2018-07-30 17:20:32 -0700 | [diff] [blame] | 762 | hdd_debug("ieee80211_ptr is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 763 | return NOTIFY_DONE; |
| 764 | } |
| 765 | |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 766 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 767 | if (!hdd_ctx) { |
| 768 | hdd_err("HDD Context is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 769 | return NOTIFY_DONE; |
| 770 | } |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 771 | |
| 772 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 773 | hdd_debug("%s: Driver module is closed", __func__); |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 774 | return NOTIFY_DONE; |
| 775 | } |
| 776 | |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 777 | /* Make sure that this callback corresponds to our device. */ |
| 778 | adapter = hdd_get_adapter_by_iface_name(hdd_ctx, dev->name); |
| 779 | if (!adapter) { |
Dustin Brown | aeb5564 | 2018-07-30 17:20:32 -0700 | [diff] [blame] | 780 | hdd_debug("failed to look up adapter for '%s'", dev->name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 781 | return NOTIFY_DONE; |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 782 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 783 | |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 784 | if (adapter != WLAN_HDD_GET_PRIV_PTR(dev)) { |
| 785 | hdd_err("HDD adapter mismatch!"); |
| 786 | return NOTIFY_DONE; |
| 787 | } |
| 788 | |
Dustin Brown | aeb5564 | 2018-07-30 17:20:32 -0700 | [diff] [blame] | 789 | if (cds_is_driver_recovering()) { |
| 790 | hdd_debug("Driver is recovering"); |
| 791 | return NOTIFY_DONE; |
| 792 | } |
| 793 | |
| 794 | if (cds_is_driver_in_bad_state()) { |
| 795 | hdd_debug("Driver is in failed recovery state"); |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 796 | return NOTIFY_DONE; |
| 797 | } |
| 798 | |
| 799 | hdd_debug("%s New Net Device State = %lu", dev->name, state); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 800 | |
| 801 | switch (state) { |
| 802 | case NETDEV_REGISTER: |
| 803 | break; |
| 804 | |
| 805 | case NETDEV_UNREGISTER: |
| 806 | break; |
| 807 | |
| 808 | case NETDEV_UP: |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 809 | sme_ch_avoid_update_req(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 810 | break; |
| 811 | |
| 812 | case NETDEV_DOWN: |
| 813 | break; |
| 814 | |
| 815 | case NETDEV_CHANGE: |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 816 | if (adapter->is_link_up_service_needed) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 817 | complete(&adapter->linkup_event_var); |
| 818 | break; |
| 819 | |
| 820 | case NETDEV_GOING_DOWN: |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 821 | vdev = hdd_objmgr_get_vdev(adapter); |
| 822 | if (!vdev) |
| 823 | break; |
| 824 | if (ucfg_scan_get_vdev_status(vdev) != |
Sandeep Puligilla | 5f86d99 | 2017-10-29 14:58:53 -0700 | [diff] [blame] | 825 | SCAN_NOT_IN_PROGRESS) { |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 826 | wlan_abort_scan(hdd_ctx->pdev, INVAL_PDEV_ID, |
| 827 | adapter->session_id, INVALID_SCAN_ID, |
| 828 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 829 | } |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 830 | hdd_objmgr_put_vdev(adapter); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 831 | cds_flush_work(&adapter->scan_block_work); |
| 832 | /* Need to clean up blocked scan request */ |
| 833 | wlan_hdd_cfg80211_scan_block_cb(&adapter->scan_block_work); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 834 | hdd_debug("Scan is not Pending from user"); |
Arunk Khandavalli | f0c0d76 | 2017-12-07 10:18:50 +0530 | [diff] [blame] | 835 | /* |
| 836 | * After NETDEV_GOING_DOWN, kernel calls hdd_stop.Irrespective |
| 837 | * of return status of hdd_stop call, kernel resets the IFF_UP |
| 838 | * flag after which driver does not send the cfg80211_scan_done. |
| 839 | * Ensure to cleanup the scan queue in NETDEV_GOING_DOWN |
| 840 | */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 841 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->pdev, dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 842 | break; |
| 843 | |
| 844 | default: |
| 845 | break; |
| 846 | } |
| 847 | |
| 848 | return NOTIFY_DONE; |
| 849 | } |
| 850 | |
| 851 | /** |
| 852 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 853 | * @nb: pointer to notifier block |
| 854 | * @state: state |
| 855 | * @ndev: ndev pointer |
| 856 | * |
| 857 | * Return: 0 on success, error number otherwise. |
| 858 | */ |
| 859 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 860 | unsigned long state, |
| 861 | void *ndev) |
| 862 | { |
| 863 | int ret; |
| 864 | |
| 865 | cds_ssr_protect(__func__); |
| 866 | ret = __hdd_netdev_notifier_call(nb, state, ndev); |
| 867 | cds_ssr_unprotect(__func__); |
| 868 | |
| 869 | return ret; |
| 870 | } |
| 871 | |
| 872 | struct notifier_block hdd_netdev_notifier = { |
| 873 | .notifier_call = hdd_netdev_notifier_call, |
| 874 | }; |
| 875 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 876 | static int system_reboot_notifier_call(struct notifier_block *nb, |
| 877 | unsigned long msg_type, void *_unused) |
| 878 | { |
| 879 | switch (msg_type) { |
| 880 | case SYS_DOWN: |
| 881 | case SYS_HALT: |
| 882 | case SYS_POWER_OFF: |
| 883 | g_is_system_reboot_triggered = true; |
| 884 | hdd_info("reboot, reason: %ld", msg_type); |
| 885 | break; |
| 886 | default: |
| 887 | break; |
| 888 | } |
| 889 | |
| 890 | return NOTIFY_OK; |
| 891 | } |
| 892 | |
| 893 | struct notifier_block system_reboot_notifier = { |
| 894 | .notifier_call = system_reboot_notifier_call, |
| 895 | }; |
| 896 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 897 | /* variable to hold the insmod parameters */ |
| 898 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 899 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 900 | static int con_mode_ftm; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 901 | int con_mode_monitor; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 902 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 903 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 904 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 905 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 906 | /** |
| 907 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 908 | * @ch_width: NL channel width |
| 909 | * |
| 910 | * Converts the NL channel width to the driver's internal representation |
| 911 | * |
| 912 | * Return: Converted channel width. In case of non matching NL channel width, |
| 913 | * CH_WIDTH_MAX will be returned. |
| 914 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 915 | 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] | 916 | { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 917 | uint8_t fw_ch_bw; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 918 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 919 | fw_ch_bw = wma_get_vht_ch_width(); |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 920 | switch (ch_width) { |
| 921 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 922 | case NL80211_CHAN_WIDTH_20: |
| 923 | return CH_WIDTH_20MHZ; |
| 924 | case NL80211_CHAN_WIDTH_40: |
| 925 | return CH_WIDTH_40MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 926 | case NL80211_CHAN_WIDTH_80: |
| 927 | return CH_WIDTH_80MHZ; |
| 928 | case NL80211_CHAN_WIDTH_80P80: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 929 | if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ) |
| 930 | return CH_WIDTH_80P80MHZ; |
| 931 | else if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 932 | return CH_WIDTH_160MHZ; |
| 933 | else |
| 934 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 935 | case NL80211_CHAN_WIDTH_160: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 936 | if (fw_ch_bw >= WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 937 | return CH_WIDTH_160MHZ; |
| 938 | else |
| 939 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 940 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 941 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 942 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 943 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 944 | default: |
| 945 | hdd_err("Invalid channel width %d, setting to default", |
| 946 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 947 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 948 | } |
| 949 | } |
| 950 | |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 951 | QDF_STATUS hdd_nl_to_qdf_iface_type(enum nl80211_iftype nl_type, |
| 952 | enum QDF_OPMODE *out_qdf_type) |
| 953 | { |
| 954 | switch (nl_type) { |
| 955 | case NL80211_IFTYPE_ADHOC: |
| 956 | *out_qdf_type = QDF_IBSS_MODE; |
| 957 | break; |
| 958 | case NL80211_IFTYPE_AP: |
| 959 | *out_qdf_type = QDF_SAP_MODE; |
| 960 | break; |
| 961 | case NL80211_IFTYPE_MONITOR: |
| 962 | *out_qdf_type = QDF_MONITOR_MODE; |
| 963 | break; |
| 964 | case NL80211_IFTYPE_OCB: |
| 965 | *out_qdf_type = QDF_OCB_MODE; |
| 966 | break; |
| 967 | case NL80211_IFTYPE_P2P_CLIENT: |
| 968 | *out_qdf_type = QDF_P2P_CLIENT_MODE; |
| 969 | break; |
| 970 | case NL80211_IFTYPE_P2P_DEVICE: |
| 971 | *out_qdf_type = QDF_P2P_DEVICE_MODE; |
| 972 | break; |
| 973 | case NL80211_IFTYPE_P2P_GO: |
| 974 | *out_qdf_type = QDF_P2P_GO_MODE; |
| 975 | break; |
| 976 | case NL80211_IFTYPE_STATION: |
| 977 | *out_qdf_type = QDF_STA_MODE; |
| 978 | break; |
| 979 | case NL80211_IFTYPE_WDS: |
| 980 | *out_qdf_type = QDF_WDS_MODE; |
| 981 | break; |
| 982 | default: |
| 983 | hdd_err("Invalid nl80211 interface type %d", nl_type); |
| 984 | return QDF_STATUS_E_INVAL; |
| 985 | } |
| 986 | |
| 987 | return QDF_STATUS_SUCCESS; |
| 988 | } |
| 989 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 990 | uint8_t wlan_hdd_find_opclass(mac_handle_t mac_handle, uint8_t channel, |
| 991 | uint8_t bw_offset) |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 992 | { |
| 993 | uint8_t opclass = 0; |
| 994 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 995 | sme_get_opclass(mac_handle, channel, bw_offset, &opclass); |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 996 | return opclass; |
| 997 | } |
| 998 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 999 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 1000 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 1001 | * @module_id: Module whose trace level is being configured |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1002 | * @bitmask: Bitmask of log levels to be enabled |
| 1003 | * |
| 1004 | * Called immediately after the cfg.ini is read in order to configure |
| 1005 | * the desired trace levels. |
| 1006 | * |
| 1007 | * Return: None |
| 1008 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 1009 | 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] | 1010 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1011 | QDF_TRACE_LEVEL level; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 1012 | int qdf_print_idx = -1; |
| 1013 | int status = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1014 | /* |
| 1015 | * if the bitmask is the default value, then a bitmask was not |
| 1016 | * specified in cfg.ini, so leave the logging level alone (it |
| 1017 | * will remain at the "compiled in" default value) |
| 1018 | */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1019 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 1020 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1021 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 1022 | qdf_print_idx = qdf_get_pidx(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1023 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 1024 | /* a mask was specified. start by disabling all logging */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 1025 | status = qdf_print_set_category_verbose(qdf_print_idx, module_id, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 1026 | QDF_TRACE_LEVEL_NONE, 0); |
| 1027 | |
| 1028 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 1029 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1030 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Ashish Kumar Dhanotiya | 83f286b | 2017-09-15 19:52:58 +0530 | [diff] [blame] | 1031 | level = QDF_TRACE_LEVEL_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1032 | while (0 != bitmask) { |
| 1033 | if (bitmask & 1) { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 1034 | status = qdf_print_set_category_verbose(qdf_print_idx, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 1035 | module_id, level, 1); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 1036 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 1037 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1038 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1039 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1040 | level++; |
| 1041 | bitmask >>= 1; |
| 1042 | } |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 1043 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1044 | } |
| 1045 | |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1046 | 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] | 1047 | { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1048 | if (!hdd_ctx) { |
| 1049 | hdd_err("HDD context is null (via %s)", func); |
| 1050 | return -ENODEV; |
| 1051 | } |
| 1052 | |
| 1053 | if (!hdd_ctx->config) { |
| 1054 | hdd_err("HDD config is null (via %s)", func); |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 1055 | return -ENODEV; |
| 1056 | } |
| 1057 | |
| 1058 | if (cds_is_driver_recovering()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1059 | hdd_debug("Recovery in progress (via %s); state:0x%x", |
| 1060 | func, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1061 | return -EAGAIN; |
| 1062 | } |
| 1063 | |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 1064 | if (cds_is_load_or_unload_in_progress()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1065 | hdd_debug("Load/unload in progress (via %s); state:0x%x", |
| 1066 | func, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1067 | return -EAGAIN; |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 1068 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 1069 | |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1070 | if (hdd_ctx->start_modules_in_progress) { |
| 1071 | hdd_debug("Start modules in progress (via %s)", func); |
| 1072 | return -EAGAIN; |
| 1073 | } |
| 1074 | |
| 1075 | if (hdd_ctx->stop_modules_in_progress) { |
| 1076 | hdd_debug("Stop modules in progress (via %s)", func); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 1077 | return -EAGAIN; |
| 1078 | } |
| 1079 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1080 | if (cds_is_driver_in_bad_state()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1081 | hdd_debug("Driver in bad state (via %s); state:0x%x", |
| 1082 | func, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 1083 | return -EAGAIN; |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1084 | } |
| 1085 | |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 1086 | if (cds_is_fw_down()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1087 | hdd_debug("FW is down (via %s); state:0x%x", |
| 1088 | func, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 1089 | return -EAGAIN; |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 1090 | } |
| 1091 | |
Liangwei Dong | 858feb1 | 2018-05-21 01:52:46 -0400 | [diff] [blame] | 1092 | if (qdf_atomic_read(&hdd_ctx->con_mode_flag)) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1093 | hdd_debug("Driver mode change in progress (via %s)", func); |
Liangwei Dong | 858feb1 | 2018-05-21 01:52:46 -0400 | [diff] [blame] | 1094 | return -EAGAIN; |
| 1095 | } |
| 1096 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1097 | return 0; |
| 1098 | } |
| 1099 | |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1100 | int __hdd_validate_adapter(struct hdd_adapter *adapter, const char *func) |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1101 | { |
| 1102 | if (!adapter) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1103 | hdd_err("adapter is null (via %s)", func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1104 | return -EINVAL; |
| 1105 | } |
| 1106 | |
| 1107 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1108 | hdd_err("bad adapter magic (via %s)", func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1109 | return -EINVAL; |
| 1110 | } |
| 1111 | |
| 1112 | if (!adapter->dev) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1113 | hdd_err("adapter net_device is null (via %s)", func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1114 | return -EINVAL; |
| 1115 | } |
| 1116 | |
| 1117 | if (!(adapter->dev->flags & IFF_UP)) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1118 | hdd_debug_rl("adapter '%s' is not up (via %s)", |
| 1119 | adapter->dev->name, func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1120 | return -EAGAIN; |
| 1121 | } |
| 1122 | |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1123 | return __wlan_hdd_validate_session_id(adapter->session_id, func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1124 | } |
| 1125 | |
Dustin Brown | 6350061 | 2018-08-07 11:36:09 -0700 | [diff] [blame] | 1126 | int __wlan_hdd_validate_session_id(uint8_t session_id, const char *func) |
| 1127 | { |
| 1128 | if (session_id == CSR_SESSION_ID_INVALID) { |
| 1129 | hdd_debug_rl("adapter is not up (via %s)", func); |
| 1130 | return -EINVAL; |
| 1131 | } |
| 1132 | |
| 1133 | if (session_id >= CSR_ROAM_SESSION_MAX) { |
| 1134 | hdd_err("bad session Id:%u (via %s)", session_id, func); |
| 1135 | return -EINVAL; |
| 1136 | } |
| 1137 | |
| 1138 | return 0; |
| 1139 | } |
| 1140 | |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 1141 | QDF_STATUS __wlan_hdd_validate_mac_address(struct qdf_mac_addr *mac_addr, |
| 1142 | const char *func) |
| 1143 | { |
| 1144 | if (!mac_addr) { |
| 1145 | hdd_err("Received NULL mac address (via %s)", func); |
| 1146 | return QDF_STATUS_E_INVAL; |
| 1147 | } |
| 1148 | |
| 1149 | if (qdf_is_macaddr_zero(mac_addr)) { |
| 1150 | hdd_err("MAC is all zero (via %s)", func); |
| 1151 | return QDF_STATUS_E_INVAL; |
| 1152 | } |
| 1153 | |
| 1154 | if (qdf_is_macaddr_broadcast(mac_addr)) { |
| 1155 | hdd_err("MAC is Broadcast (via %s)", func); |
| 1156 | return QDF_STATUS_E_INVAL; |
| 1157 | } |
| 1158 | |
| 1159 | if (QDF_NET_IS_MAC_MULTICAST(mac_addr->bytes)) { |
| 1160 | hdd_err("MAC is Multicast (via %s)", func); |
| 1161 | return QDF_STATUS_E_INVAL; |
| 1162 | } |
| 1163 | |
| 1164 | return QDF_STATUS_SUCCESS; |
| 1165 | } |
| 1166 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1167 | /** |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1168 | * wlan_hdd_validate_modules_state() - Check modules status |
| 1169 | * @hdd_ctx: HDD context pointer |
| 1170 | * |
| 1171 | * Check's the driver module's state and returns true if the |
| 1172 | * modules are enabled returns false if modules are closed. |
| 1173 | * |
| 1174 | * Return: True if modules are enabled or false. |
| 1175 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1176 | bool wlan_hdd_validate_modules_state(struct hdd_context *hdd_ctx) |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1177 | { |
| 1178 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 1179 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 1180 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 1181 | hdd_info("Modules not enabled, Present status: %d", |
| 1182 | hdd_ctx->driver_status); |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1183 | return false; |
| 1184 | } |
| 1185 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 1186 | return true; |
| 1187 | } |
| 1188 | |
| 1189 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1190 | * 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] | 1191 | * @struct hdd_adapter Hdd adapter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1192 | * |
| 1193 | * This function sets the IBSS power save config parameters to WMA |
| 1194 | * which will send it to firmware if FW supports IBSS power save |
| 1195 | * before vdev start. |
| 1196 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1197 | * 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] | 1198 | * on failure. |
| 1199 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 1200 | QDF_STATUS hdd_set_ibss_power_save_params(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1201 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1202 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1203 | |
| 1204 | if (hdd_ctx == NULL) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1205 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1206 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1207 | } |
| 1208 | |
Manikandan Mohan | 2bd0977 | 2018-11-28 18:27:32 -0800 | [diff] [blame] | 1209 | return ucfg_mlme_ibss_power_save_setup(hdd_ctx->psoc, |
| 1210 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1211 | } |
| 1212 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1213 | #ifdef FEATURE_RUNTIME_PM |
| 1214 | /** |
| 1215 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 1216 | * @hdd_ctx: HDD context |
| 1217 | * |
| 1218 | * Return: None |
| 1219 | */ |
| 1220 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) |
| 1221 | { |
| 1222 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1223 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1224 | qdf_runtime_lock_init(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1225 | qdf_runtime_lock_init(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1226 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1227 | wlan_scan_runtime_pm_init(hdd_ctx->pdev); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1228 | } |
| 1229 | |
| 1230 | /** |
| 1231 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 1232 | * @hdd_ctx: HDD Context |
| 1233 | * |
| 1234 | * Return: None |
| 1235 | */ |
| 1236 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) |
| 1237 | { |
| 1238 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1239 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1240 | qdf_runtime_lock_deinit(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1241 | qdf_runtime_lock_deinit(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1242 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1243 | wlan_scan_runtime_pm_deinit(hdd_ctx->pdev); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1244 | } |
| 1245 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1246 | #else /* FEATURE_RUNTIME_PM */ |
| 1247 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) {} |
| 1248 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) {} |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1249 | #endif /* FEATURE_RUNTIME_PM */ |
| 1250 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1251 | #define INTF_MACADDR_MASK 0x7 |
| 1252 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1253 | void hdd_update_macaddr(struct hdd_context *hdd_ctx, |
| 1254 | struct qdf_mac_addr hw_macaddr, bool generate_mac_auto) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1255 | { |
| 1256 | int8_t i; |
| 1257 | uint8_t macaddr_b3, tmp_br3; |
| 1258 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1259 | /* |
| 1260 | * If "generate_mac_auto" is true, it indicates that all the |
| 1261 | * addresses are derived addresses, else the first addresses |
| 1262 | * is not derived address (It is provided by fw). |
| 1263 | */ |
| 1264 | if (!generate_mac_auto) { |
| 1265 | qdf_mem_copy(hdd_ctx->provisioned_mac_addr[0].bytes, |
| 1266 | hw_macaddr.bytes, QDF_MAC_ADDR_SIZE); |
| 1267 | hdd_ctx->num_provisioned_addr++; |
| 1268 | hdd_info("hdd_ctx->provisioned_mac_addr[0]: " |
| 1269 | MAC_ADDRESS_STR, |
| 1270 | MAC_ADDR_ARRAY(hdd_ctx-> |
| 1271 | provisioned_mac_addr[0].bytes)); |
| 1272 | } else { |
| 1273 | qdf_mem_copy(hdd_ctx->derived_mac_addr[0].bytes, |
| 1274 | hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1275 | QDF_MAC_ADDR_SIZE); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1276 | hdd_ctx->num_derived_addr++; |
| 1277 | hdd_info("hdd_ctx->derived_mac_addr[0]: " |
| 1278 | MAC_ADDRESS_STR, |
| 1279 | MAC_ADDR_ARRAY(hdd_ctx->derived_mac_addr[0].bytes)); |
| 1280 | } |
| 1281 | for (i = hdd_ctx->num_derived_addr; i < (QDF_MAX_CONCURRENCY_PERSONA - |
| 1282 | hdd_ctx->num_provisioned_addr); |
| 1283 | i++) { |
| 1284 | qdf_mem_copy(hdd_ctx->derived_mac_addr[i].bytes, |
| 1285 | hw_macaddr.bytes, |
| 1286 | QDF_MAC_ADDR_SIZE); |
| 1287 | macaddr_b3 = hdd_ctx->derived_mac_addr[i].bytes[3]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1288 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 1289 | INTF_MACADDR_MASK; |
| 1290 | macaddr_b3 += tmp_br3; |
| 1291 | |
| 1292 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 1293 | * mac address range before collision |
| 1294 | */ |
| 1295 | macaddr_b3 ^= (1 << 7); |
| 1296 | |
| 1297 | /* Set locally administered bit */ |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1298 | hdd_ctx->derived_mac_addr[i].bytes[0] |= 0x02; |
| 1299 | hdd_ctx->derived_mac_addr[i].bytes[3] = macaddr_b3; |
| 1300 | hdd_info("hdd_ctx->derived_mac_addr[%d]: " |
| 1301 | MAC_ADDRESS_STR, i, |
| 1302 | MAC_ADDR_ARRAY(hdd_ctx->derived_mac_addr[i].bytes)); |
| 1303 | hdd_ctx->num_derived_addr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1304 | } |
| 1305 | } |
| 1306 | |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1307 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
| 1308 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1309 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1310 | struct tdls_start_params tdls_cfg; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1311 | QDF_STATUS status; |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1312 | struct wlan_mlme_nss_chains vdev_ini_cfg; |
| 1313 | |
| 1314 | /* Populate the nss chain params from ini for this vdev type */ |
| 1315 | sme_populate_nss_chain_params(hdd_ctx->mac_handle, &vdev_ini_cfg, |
| 1316 | QDF_TDLS_MODE, |
| 1317 | hdd_ctx->num_rf_chains); |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1318 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1319 | cfg_tdls_set_vdev_nss_2g(hdd_ctx->psoc, |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1320 | vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_2GHZ]); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1321 | cfg_tdls_set_vdev_nss_5g(hdd_ctx->psoc, |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1322 | vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_5GHZ]); |
jiad | 7b8a5e0 | 2018-11-26 16:37:57 +0800 | [diff] [blame] | 1323 | hdd_init_tdls_config(&tdls_cfg); |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1324 | tdls_cfg.tdls_del_all_peers = eWNI_SME_DEL_ALL_TDLS_PEERS; |
| 1325 | tdls_cfg.tdls_update_dp_vdev_flags = CDP_UPDATE_TDLS_FLAGS; |
| 1326 | tdls_cfg.tdls_event_cb = wlan_cfg80211_tdls_event_callback; |
| 1327 | tdls_cfg.tdls_evt_cb_data = psoc; |
Jeff Johnson | 1d40f5b | 2018-03-02 08:35:53 -0800 | [diff] [blame] | 1328 | tdls_cfg.tdls_peer_context = hdd_ctx; |
| 1329 | tdls_cfg.tdls_reg_peer = hdd_tdls_register_peer; |
| 1330 | tdls_cfg.tdls_dereg_peer = hdd_tdls_deregister_peer; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1331 | tdls_cfg.tdls_wmm_cb = hdd_wmm_is_acm_allowed; |
| 1332 | tdls_cfg.tdls_wmm_cb_data = psoc; |
| 1333 | tdls_cfg.tdls_rx_cb = wlan_cfg80211_tdls_rx_callback; |
| 1334 | tdls_cfg.tdls_rx_cb_data = psoc; |
| 1335 | tdls_cfg.tdls_dp_vdev_update = hdd_update_dp_vdev_flags; |
| 1336 | |
| 1337 | status = ucfg_tdls_update_config(psoc, &tdls_cfg); |
| 1338 | if (status != QDF_STATUS_SUCCESS) { |
| 1339 | hdd_err("failed pmo psoc configuration"); |
| 1340 | return -EINVAL; |
| 1341 | } |
| 1342 | |
| 1343 | hdd_ctx->tdls_umac_comp_active = true; |
| 1344 | /* enable napier specific tdls data path */ |
| 1345 | hdd_ctx->tdls_nap_active = true; |
| 1346 | |
| 1347 | return 0; |
| 1348 | } |
| 1349 | |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 1350 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1351 | static void hdd_update_roam_offload(struct hdd_context *hdd_ctx, |
| 1352 | struct wma_tgt_services *cfg) |
| 1353 | { |
| 1354 | bool roam_offload_enable; |
| 1355 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1356 | ucfg_mlme_get_roaming_offload(hdd_ctx->psoc, &roam_offload_enable); |
| 1357 | ucfg_mlme_set_roaming_offload(hdd_ctx->psoc, |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 1358 | roam_offload_enable & |
| 1359 | cfg->en_roam_offload); |
| 1360 | } |
| 1361 | #else |
| 1362 | static inline void hdd_update_roam_offload(struct hdd_context *hdd_ctx, |
| 1363 | struct wma_tgt_services *cfg) |
| 1364 | { |
| 1365 | } |
| 1366 | #endif |
| 1367 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1368 | static void hdd_update_tgt_services(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1369 | struct wma_tgt_services *cfg) |
| 1370 | { |
| 1371 | struct hdd_config *config = hdd_ctx->config; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 1372 | bool arp_offload_enable; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 1373 | bool mawc_enabled; |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1374 | #ifdef FEATURE_WLAN_TDLS |
| 1375 | bool tdls_support; |
| 1376 | bool tdls_off_channel; |
| 1377 | bool tdls_buffer_sta; |
| 1378 | uint32_t tdls_uapsd_mask; |
| 1379 | #endif |
jiad | 7b8a5e0 | 2018-11-26 16:37:57 +0800 | [diff] [blame] | 1380 | bool value; |
| 1381 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1382 | /* Set up UAPSD */ |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 1383 | ucfg_mlme_set_sap_uapsd_flag(hdd_ctx->psoc, cfg->uapsd); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1384 | |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 1385 | /* 11AX mode support */ |
| 1386 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 1387 | config->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) && !cfg->en_11ax) |
| 1388 | config->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 1389 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1390 | /* 11AC mode support */ |
| 1391 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 1392 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 1393 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1394 | |
| 1395 | /* ARP offload: override user setting if invalid */ |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 1396 | arp_offload_enable = |
| 1397 | ucfg_pmo_is_arp_offload_enabled(hdd_ctx->psoc); |
| 1398 | ucfg_pmo_set_arp_offload_enabled(hdd_ctx->psoc, |
| 1399 | arp_offload_enable & cfg->arp_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1400 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 1401 | /* PNO offload */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1402 | hdd_debug("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1403 | if (cfg->pno_offload) |
| 1404 | config->PnoOffload = true; |
| 1405 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1406 | #ifdef FEATURE_WLAN_TDLS |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1407 | cfg_tdls_get_support_enable(hdd_ctx->psoc, &tdls_support); |
| 1408 | cfg_tdls_set_support_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1409 | tdls_support & cfg->en_tdls); |
| 1410 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1411 | cfg_tdls_get_off_channel_enable(hdd_ctx->psoc, &tdls_off_channel); |
| 1412 | cfg_tdls_set_off_channel_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1413 | tdls_off_channel && |
| 1414 | cfg->en_tdls_offchan); |
| 1415 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1416 | cfg_tdls_get_buffer_sta_enable(hdd_ctx->psoc, &tdls_buffer_sta); |
| 1417 | cfg_tdls_set_buffer_sta_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1418 | tdls_buffer_sta && |
| 1419 | cfg->en_tdls_uapsd_buf_sta); |
| 1420 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1421 | cfg_tdls_get_uapsd_mask(hdd_ctx->psoc, &tdls_uapsd_mask); |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1422 | if (tdls_uapsd_mask && cfg->en_tdls_uapsd_sleep_sta) |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1423 | cfg_tdls_set_sleep_sta_enable(hdd_ctx->psoc, true); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1424 | else |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1425 | cfg_tdls_set_sleep_sta_enable(hdd_ctx->psoc, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1426 | #endif |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 1427 | hdd_update_roam_offload(hdd_ctx, cfg); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 1428 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 1429 | if (ucfg_mlme_get_sap_get_peer_info(hdd_ctx->psoc, &value) == |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 1430 | QDF_STATUS_SUCCESS) |
| 1431 | value &= cfg->get_peer_info_enabled; |
| 1432 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 1433 | ucfg_mlme_is_mawc_enabled(hdd_ctx->psoc, &mawc_enabled); |
| 1434 | ucfg_mlme_set_mawc_enabled(hdd_ctx->psoc, |
| 1435 | mawc_enabled & cfg->is_fw_mawc_capable); |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1436 | hdd_update_tdls_config(hdd_ctx); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1437 | sme_update_tgt_services(hdd_ctx->mac_handle, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1438 | } |
| 1439 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1440 | /** |
| 1441 | * hdd_update_vdev_nss() - sets the vdev nss |
| 1442 | * @hdd_ctx: HDD context |
| 1443 | * |
| 1444 | * Sets the Nss per vdev type based on INI |
| 1445 | * |
| 1446 | * Return: None |
| 1447 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1448 | static void hdd_update_vdev_nss(struct hdd_context *hdd_ctx) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1449 | { |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1450 | uint8_t max_supp_nss = 1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1451 | mac_handle_t mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1452 | QDF_STATUS status; |
| 1453 | bool bval; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1454 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1455 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 1456 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1457 | hdd_err("unable to get vht_enable2x2"); |
| 1458 | |
| 1459 | if (bval && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1460 | max_supp_nss = 2; |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1461 | |
| 1462 | hdd_debug("max nss %d", max_supp_nss); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1463 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1464 | mac_handle = hdd_ctx->mac_handle; |
| 1465 | sme_update_vdev_type_nss(mac_handle, max_supp_nss, |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1466 | NSS_CHAINS_BAND_2GHZ); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1467 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1468 | sme_update_vdev_type_nss(mac_handle, max_supp_nss, |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1469 | NSS_CHAINS_BAND_5GHZ); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1470 | } |
| 1471 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1472 | /** |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1473 | * hdd_update_wiphy_vhtcap() - Updates wiphy vhtcap fields |
| 1474 | * @hdd_ctx: HDD context |
| 1475 | * |
| 1476 | * Updates wiphy vhtcap fields |
| 1477 | * |
| 1478 | * Return: None |
| 1479 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1480 | static void hdd_update_wiphy_vhtcap(struct hdd_context *hdd_ctx) |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1481 | { |
| 1482 | struct ieee80211_supported_band *band_5g = |
| 1483 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1484 | QDF_STATUS status; |
| 1485 | uint8_t value = 0, value1 = 0; |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1486 | |
| 1487 | if (!band_5g) { |
| 1488 | hdd_debug("5GHz band disabled, skipping capability population"); |
| 1489 | return; |
| 1490 | } |
| 1491 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1492 | status = ucfg_mlme_cfg_get_vht_tx_bfee_ant_supp(hdd_ctx->psoc, |
| 1493 | &value); |
| 1494 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1495 | hdd_err("unable to get tx_bfee_ant_supp"); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1496 | |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1497 | band_5g->vht_cap.cap |= |
| 1498 | (value << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1499 | |
| 1500 | value1 = NUM_OF_SOUNDING_DIMENSIONS; |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1501 | band_5g->vht_cap.cap |= |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1502 | (value1 << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1503 | |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 1504 | hdd_debug("Updated wiphy vhtcap:0x%x, CSNAntSupp:%d, NumSoundDim:%d", |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1505 | band_5g->vht_cap.cap, value, value1); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1506 | } |
| 1507 | |
| 1508 | /** |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1509 | * hdd_update_hw_dbs_capable() - sets the dbs capability of the device |
| 1510 | * @hdd_ctx: HDD context |
| 1511 | * |
| 1512 | * Sets the DBS capability as per INI and firmware capability |
| 1513 | * |
| 1514 | * Return: None |
| 1515 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1516 | static void hdd_update_hw_dbs_capable(struct hdd_context *hdd_ctx) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1517 | { |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1518 | uint8_t hw_dbs_capable = 0; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 1519 | uint8_t dual_mac_feature = DISABLE_DBS_CXN_AND_SCAN; |
| 1520 | QDF_STATUS status; |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1521 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 1522 | status = ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 1523 | &dual_mac_feature); |
| 1524 | if (status != QDF_STATUS_SUCCESS) |
| 1525 | hdd_err("can't get dual_mac_feature value"); |
| 1526 | if (policy_mgr_is_hw_dbs_capable(hdd_ctx->psoc)) { |
| 1527 | switch (dual_mac_feature) { |
| 1528 | case ENABLE_DBS_CXN_AND_SCAN: |
| 1529 | case ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF: |
| 1530 | case ENABLE_DBS_CXN_AND_DISABLE_SIMULTANEOUS_SCAN: |
| 1531 | hw_dbs_capable = 1; |
| 1532 | break; |
| 1533 | default: |
| 1534 | hw_dbs_capable = 0; |
| 1535 | break; |
| 1536 | } |
| 1537 | } |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1538 | sme_update_hw_dbs_capable(hdd_ctx->mac_handle, hw_dbs_capable); |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1539 | } |
| 1540 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1541 | static void hdd_update_tgt_ht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1542 | struct wma_tgt_ht_cap *cfg) |
| 1543 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1544 | QDF_STATUS status; |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 1545 | qdf_size_t value_len; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1546 | uint32_t value; |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 1547 | uint8_t mpdu_density; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1548 | struct mlme_ht_capabilities_info ht_cap_info; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1549 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1550 | bool b_enable1x1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1551 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1552 | /* get the MPDU density */ |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 1553 | status = ucfg_mlme_get_ht_mpdu_density(hdd_ctx->psoc, &mpdu_density); |
| 1554 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1555 | hdd_err("could not get HT MPDU Density"); |
| 1556 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1557 | } |
| 1558 | |
| 1559 | /* |
| 1560 | * MPDU density: |
| 1561 | * override user's setting if value is larger |
| 1562 | * than the one supported by target |
| 1563 | */ |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 1564 | if (mpdu_density > cfg->mpdu_density) { |
| 1565 | status = ucfg_mlme_set_ht_mpdu_density(hdd_ctx->psoc, |
| 1566 | cfg->mpdu_density); |
| 1567 | if (QDF_IS_STATUS_ERROR(status)) |
| 1568 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1569 | } |
| 1570 | |
| 1571 | /* get the HT capability info */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1572 | 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] | 1573 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1574 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1575 | return; |
| 1576 | } |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1577 | |
| 1578 | /* check and update RX STBC */ |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1579 | if (ht_cap_info.rx_stbc && !cfg->ht_rx_stbc) |
| 1580 | ht_cap_info.rx_stbc = cfg->ht_rx_stbc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1581 | |
| 1582 | /* Set the LDPC capability */ |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1583 | ht_cap_info.adv_coding_cap = cfg->ht_rx_ldpc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1584 | |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1585 | if (ht_cap_info.short_gi_20_mhz && !cfg->ht_sgi_20) |
| 1586 | ht_cap_info.short_gi_20_mhz = cfg->ht_sgi_20; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1587 | |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1588 | if (ht_cap_info.short_gi_40_mhz && !cfg->ht_sgi_40) |
| 1589 | ht_cap_info.short_gi_40_mhz = cfg->ht_sgi_40; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1590 | |
| 1591 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 1592 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 1593 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1594 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &b_enable1x1); |
| 1595 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1596 | hdd_err("unable to get vht_enable2x2"); |
| 1597 | |
| 1598 | b_enable1x1 = b_enable1x1 && (cfg->num_rf_chains == 2); |
| 1599 | |
| 1600 | status = ucfg_mlme_set_vht_enable2x2(hdd_ctx->psoc, b_enable1x1); |
| 1601 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1602 | hdd_err("unable to set vht_enable2x2"); |
| 1603 | |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1604 | if (!b_enable1x1) { |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1605 | ht_cap_info.tx_stbc = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1606 | |
| 1607 | /* 1x1 */ |
| 1608 | /* Update Rx Highest Long GI data Rate */ |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1609 | status = ucfg_mlme_cfg_set_vht_rx_supp_data_rate( |
| 1610 | hdd_ctx->psoc, |
| 1611 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1); |
| 1612 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1613 | hdd_err("Failed to set rx_supp_data_rate"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1614 | /* Update Tx Highest Long GI data Rate */ |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1615 | status = ucfg_mlme_cfg_set_vht_tx_supp_data_rate( |
| 1616 | hdd_ctx->psoc, |
| 1617 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1); |
| 1618 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1619 | hdd_err("Failed to set tx_supp_data_rate"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1620 | } |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1621 | if (!(cfg->ht_tx_stbc && b_enable1x1)) |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1622 | ht_cap_info.tx_stbc = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1623 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1624 | 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] | 1625 | if (status != QDF_STATUS_SUCCESS) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1626 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1627 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 1628 | value_len = SIZE_OF_SUPPORTED_MCS_SET; |
| 1629 | if (ucfg_mlme_get_supported_mcs_set( |
| 1630 | hdd_ctx->psoc, mcs_set, |
| 1631 | &value_len) == QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1632 | hdd_debug("Read MCS rate set"); |
gaurank kathpalia | 18b4936 | 2018-04-15 23:12:03 +0530 | [diff] [blame] | 1633 | if (cfg->num_rf_chains > SIZE_OF_SUPPORTED_MCS_SET) |
| 1634 | cfg->num_rf_chains = SIZE_OF_SUPPORTED_MCS_SET; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1635 | |
| 1636 | if (b_enable1x1) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1637 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 1638 | mcs_set[value] = |
| 1639 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 1640 | |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 1641 | status = ucfg_mlme_set_supported_mcs_set( |
| 1642 | hdd_ctx->psoc, |
| 1643 | mcs_set, |
| 1644 | (qdf_size_t)SIZE_OF_SUPPORTED_MCS_SET); |
| 1645 | if (QDF_IS_STATUS_ERROR(status)) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1646 | hdd_err("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1647 | } |
| 1648 | } |
| 1649 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 1650 | } |
| 1651 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1652 | static void hdd_update_tgt_vht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1653 | struct wma_tgt_vht_cap *cfg) |
| 1654 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1655 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1656 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 1657 | struct ieee80211_supported_band *band_5g = |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 1658 | wiphy->bands[HDD_NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1659 | uint32_t ch_width = eHT_CHANNEL_WIDTH_80MHZ; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1660 | struct wma_caps_per_phy caps_per_phy; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1661 | uint8_t val = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1662 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1663 | if (!band_5g) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1664 | hdd_debug("5GHz band disabled, skipping capability population"); |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1665 | return; |
| 1666 | } |
| 1667 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1668 | status = ucfg_mlme_update_vht_cap(hdd_ctx->psoc, cfg); |
| 1669 | if (QDF_IS_STATUS_ERROR(status)) |
| 1670 | hdd_err("could not update vht capabilities"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1671 | |
| 1672 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1673 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1674 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1675 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1676 | else |
| 1677 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1678 | |
| 1679 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1680 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) { |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1681 | status = ucfg_mlme_set_vht_ch_width(hdd_ctx->psoc, |
| 1682 | VHT_CAP_160_AND_80P80_SUPP); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1683 | if (QDF_IS_STATUS_ERROR(status)) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1684 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1685 | band_5g->vht_cap.cap |= |
| 1686 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1687 | ch_width = eHT_CHANNEL_WIDTH_80P80MHZ; |
| 1688 | } else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) { |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1689 | status = ucfg_mlme_set_vht_ch_width(hdd_ctx->psoc, |
| 1690 | VHT_CAP_160_SUPP); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1691 | if (QDF_IS_STATUS_ERROR(status)) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1692 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1693 | band_5g->vht_cap.cap |= |
| 1694 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1695 | ch_width = eHT_CHANNEL_WIDTH_160MHZ; |
| 1696 | } |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1697 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1698 | status = |
| 1699 | ucfg_mlme_cfg_get_vht_chan_width(hdd_ctx->psoc, &val); |
| 1700 | if (QDF_IS_STATUS_ERROR(status)) |
| 1701 | hdd_err("could not get channel_width"); |
| 1702 | |
| 1703 | val = QDF_MIN(val, ch_width); |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1704 | status = ucfg_mlme_set_vht_ch_width(hdd_ctx->psoc, val); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1705 | if (QDF_IS_STATUS_ERROR(status)) |
| 1706 | hdd_err("could not set the channel width"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1707 | |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1708 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1709 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1710 | hdd_debug("VHT RxLDPC capability is set"); |
| 1711 | } else { |
| 1712 | /* |
| 1713 | * Get the RX LDPC capability for the NON DBS |
| 1714 | * hardware mode for 5G band |
| 1715 | */ |
| 1716 | status = wma_get_caps_for_phyidx_hwmode(&caps_per_phy, |
| 1717 | HW_MODE_DBS_NONE, CDS_BAND_5GHZ); |
| 1718 | if ((QDF_IS_STATUS_SUCCESS(status)) && |
| 1719 | (caps_per_phy.vht_5g & WMI_VHT_CAP_RX_LDPC)) { |
| 1720 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1721 | hdd_debug("VHT RX LDPC capability is set"); |
| 1722 | } |
| 1723 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1724 | |
| 1725 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1726 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1727 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1728 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1729 | |
| 1730 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1731 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1732 | |
| 1733 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1734 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1735 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1736 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1737 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1738 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1739 | |
| 1740 | band_5g->vht_cap.cap |= |
| 1741 | (cfg->vht_max_ampdu_len_exp << |
| 1742 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1743 | |
| 1744 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1745 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1746 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1747 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1748 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1749 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1750 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1751 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1752 | |
| 1753 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1754 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1755 | |
| 1756 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1757 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1758 | /** |
| 1759 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1760 | * @hdd_ctx: Pointer to the HDD context |
| 1761 | * |
| 1762 | * Auto-generate mac address using device serial number. |
| 1763 | * Keep the first 3 bytes of OUI as before and replace |
| 1764 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1765 | * |
| 1766 | * Return: 0 for success |
| 1767 | * Non zero failure code for errors |
| 1768 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1769 | static int hdd_generate_macaddr_auto(struct hdd_context *hdd_ctx) |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1770 | { |
| 1771 | unsigned int serialno = 0; |
| 1772 | struct qdf_mac_addr mac_addr = { |
| 1773 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1774 | }; |
| 1775 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1776 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1777 | if (serialno == 0) |
| 1778 | return -EINVAL; |
| 1779 | |
| 1780 | serialno &= 0x00ffffff; |
| 1781 | |
| 1782 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1783 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1784 | mac_addr.bytes[5] = serialno & 0xff; |
| 1785 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1786 | hdd_update_macaddr(hdd_ctx, mac_addr, true); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1787 | return 0; |
| 1788 | } |
| 1789 | |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1790 | /** |
| 1791 | * hdd_update_ra_rate_limit() - Update RA rate limit from target |
| 1792 | * configuration to cfg_ini in HDD |
| 1793 | * @hdd_ctx: Pointer to hdd_ctx |
| 1794 | * @cfg: target configuration |
| 1795 | * |
| 1796 | * Return: None |
| 1797 | */ |
| 1798 | #ifdef FEATURE_WLAN_RA_FILTERING |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1799 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1800 | struct wma_tgt_cfg *cfg) |
| 1801 | { |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 1802 | ucfg_fwol_set_is_rate_limit_enabled(hdd_ctx->psoc, |
| 1803 | cfg->is_ra_rate_limit_enabled); |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1804 | } |
| 1805 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1806 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1807 | struct wma_tgt_cfg *cfg) |
| 1808 | { |
| 1809 | } |
| 1810 | #endif |
| 1811 | |
Jeff Johnson | f917638 | 2018-07-17 19:15:58 -0700 | [diff] [blame] | 1812 | static void hdd_sar_target_config(struct hdd_context *hdd_ctx, |
| 1813 | struct wma_tgt_cfg *cfg) |
| 1814 | { |
| 1815 | hdd_ctx->sar_version = cfg->sar_version; |
| 1816 | } |
| 1817 | |
Jeff Johnson | 8abc593 | 2018-06-02 22:51:37 -0700 | [diff] [blame] | 1818 | 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] | 1819 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1820 | int ret; |
Jeff Johnson | ea70b94 | 2018-07-02 09:42:31 -0700 | [diff] [blame] | 1821 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1822 | uint8_t temp_band_cap, band_capability; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1823 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1824 | uint8_t antenna_mode; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1825 | uint8_t sub_20_chan_width; |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1826 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1827 | mac_handle_t mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1828 | bool bval = false; |
| 1829 | uint8_t value = 0; |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 1830 | uint32_t fine_time_meas_cap = 0; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1831 | |
gaurank kathpalia | 843f7c3 | 2018-07-02 18:04:14 +0530 | [diff] [blame] | 1832 | if (!hdd_ctx) { |
| 1833 | hdd_err("HDD context is NULL"); |
| 1834 | return; |
| 1835 | } |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1836 | ret = hdd_objmgr_create_and_store_pdev(hdd_ctx); |
| 1837 | if (ret) { |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1838 | QDF_DEBUG_PANIC("Failed to create pdev; errno:%d", ret); |
| 1839 | return; |
| 1840 | } |
| 1841 | |
| 1842 | hdd_debug("New pdev has been created with pdev_id = %u", |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1843 | hdd_ctx->pdev->pdev_objmgr.wlan_pdev_id); |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1844 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1845 | status = dispatcher_pdev_open(hdd_ctx->pdev); |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1846 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1847 | QDF_DEBUG_PANIC("dispatcher pdev open failed; status:%d", |
| 1848 | status); |
| 1849 | return; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1850 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1851 | |
Sandeep Puligilla | b7beb47 | 2018-08-13 22:54:20 -0700 | [diff] [blame] | 1852 | status = hdd_component_pdev_open(hdd_ctx->pdev); |
| 1853 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1854 | QDF_DEBUG_PANIC("hdd component pdev open failed; status:%d", |
| 1855 | status); |
| 1856 | return; |
| 1857 | } |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1858 | cdp_pdev_set_ctrl_pdev(cds_get_context(QDF_MODULE_ID_SOC), |
| 1859 | cds_get_context(QDF_MODULE_ID_TXRX), |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1860 | (struct cdp_ctrl_objmgr_pdev *)hdd_ctx->pdev); |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1861 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1862 | wlan_pdev_set_dp_handle(hdd_ctx->pdev, |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1863 | cds_get_context(QDF_MODULE_ID_TXRX)); |
| 1864 | |
Will Huang | 0724417 | 2018-05-14 14:23:30 +0800 | [diff] [blame] | 1865 | hdd_objmgr_update_tgt_max_vdev_psoc(hdd_ctx, cfg->max_intf_count); |
| 1866 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1867 | ucfg_ipa_set_dp_handle(hdd_ctx->psoc, |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1868 | cds_get_context(QDF_MODULE_ID_SOC)); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1869 | ucfg_ipa_set_txrx_handle(hdd_ctx->psoc, |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1870 | cds_get_context(QDF_MODULE_ID_TXRX)); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1871 | ucfg_ipa_reg_sap_xmit_cb(hdd_ctx->pdev, |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 1872 | hdd_softap_hard_start_xmit); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1873 | ucfg_ipa_reg_send_to_nw_cb(hdd_ctx->pdev, |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 1874 | hdd_ipa_send_skb_to_network); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1875 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1876 | status = ucfg_mlme_get_sub_20_chan_width(hdd_ctx->psoc, |
| 1877 | &sub_20_chan_width); |
| 1878 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1879 | hdd_err("Failed to get sub_20_chan_width config"); |
| 1880 | return; |
| 1881 | } |
| 1882 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1883 | if (cds_cfg) { |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1884 | if (sub_20_chan_width != |
| 1885 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1886 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1887 | cds_cfg->sub_20_channel_width = |
| 1888 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1889 | } else { |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1890 | cds_cfg->sub_20_channel_width = sub_20_chan_width; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1891 | } |
| 1892 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1893 | |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1894 | status = ucfg_mlme_get_band_capability(hdd_ctx->psoc, &band_capability); |
| 1895 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1896 | hdd_err("Failed to get MLME band capability"); |
| 1897 | return; |
| 1898 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1899 | |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1900 | /* first store the INI band capability */ |
| 1901 | temp_band_cap = band_capability; |
| 1902 | |
| 1903 | band_capability = cfg->band_cap; |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 1904 | hdd_ctx->is_fils_roaming_supported = |
| 1905 | cfg->services.is_fils_roaming_supported; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1906 | |
Vignesh Viswanathan | 694e28e | 2018-01-18 20:53:57 +0530 | [diff] [blame] | 1907 | hdd_ctx->config->is_11k_offload_supported = |
| 1908 | cfg->services.is_11k_offload_supported; |
| 1909 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 1910 | /* |
| 1911 | * now overwrite the target band capability with INI |
| 1912 | * setting if INI setting is a subset |
| 1913 | */ |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1914 | if ((band_capability == BAND_ALL) && |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1915 | (temp_band_cap != BAND_ALL)) |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1916 | band_capability = temp_band_cap; |
| 1917 | else if ((band_capability != BAND_ALL) && |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1918 | (temp_band_cap != BAND_ALL) && |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1919 | (band_capability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1920 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1921 | } |
| 1922 | |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1923 | status = ucfg_mlme_set_band_capability(hdd_ctx->psoc, band_capability); |
| 1924 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1925 | hdd_err("Failed to set MLME Band Capability"); |
| 1926 | return; |
| 1927 | } |
| 1928 | |
| 1929 | hdd_ctx->curr_band = band_capability; |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 1930 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1931 | if (!cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1932 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 1933 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 1934 | } |
| 1935 | |
| 1936 | /* This can be extended to other configurations like ht, vht cap... */ |
| 1937 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1938 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) |
| 1939 | qdf_mem_copy(&hdd_ctx->hw_macaddr, &cfg->hw_macaddr, |
| 1940 | QDF_MAC_ADDR_SIZE); |
| 1941 | else |
| 1942 | hdd_info("hw_mac is zero"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1943 | |
| 1944 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 1945 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1946 | |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 1947 | hdd_ctx->hw_bd_id = cfg->hw_bd_id; |
| 1948 | qdf_mem_copy(&hdd_ctx->hw_bd_info, &cfg->hw_bd_info, |
| 1949 | sizeof(cfg->hw_bd_info)); |
| 1950 | |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 1951 | if (cfg->max_intf_count > CSR_ROAM_SESSION_MAX) { |
| 1952 | hdd_err("fw max vdevs (%u) > host max vdevs (%u); using %u", |
| 1953 | cfg->max_intf_count, CSR_ROAM_SESSION_MAX, |
| 1954 | CSR_ROAM_SESSION_MAX); |
| 1955 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 1956 | } else { |
| 1957 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 1958 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1959 | |
Jeff Johnson | f917638 | 2018-07-17 19:15:58 -0700 | [diff] [blame] | 1960 | hdd_sar_target_config(hdd_ctx, cfg); |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 1961 | hdd_lpass_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1962 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1963 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 1964 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 1965 | |
| 1966 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 1967 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1968 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame] | 1969 | if (cfg->services.en_11ax) { |
| 1970 | hdd_info("11AX: 11ax is enabled - update HDD config"); |
| 1971 | hdd_update_tgt_he_cap(hdd_ctx, cfg); |
| 1972 | } |
Varun Reddy Yeturu | e93d246 | 2018-05-22 13:54:52 -0700 | [diff] [blame] | 1973 | hdd_update_tgt_twt_cap(hdd_ctx, cfg); |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1974 | |
| 1975 | hdd_update_vdev_nss(hdd_ctx); |
| 1976 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1977 | hdd_update_hw_dbs_capable(hdd_ctx); |
gaurank kathpalia | 5fcefa9 | 2018-10-24 15:03:15 +0530 | [diff] [blame] | 1978 | hdd_ctx->dynamic_nss_chains_support = |
| 1979 | cfg->dynamic_nss_chains_support; |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 1980 | ucfg_mlme_get_fine_time_meas_cap(hdd_ctx->psoc, &fine_time_meas_cap); |
| 1981 | fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
| 1982 | status = ucfg_mlme_set_fine_time_meas_cap(hdd_ctx->psoc, |
| 1983 | fine_time_meas_cap); |
| 1984 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1985 | hdd_err("failed to set fine_time_meas_cap, 0x%x, ox%x", |
| 1986 | fine_time_meas_cap, cfg->fine_time_measurement_cap); |
| 1987 | ucfg_mlme_get_fine_time_meas_cap(hdd_ctx->psoc, |
| 1988 | &fine_time_meas_cap); |
| 1989 | } |
| 1990 | |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 1991 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 1992 | hdd_debug("fine_time_meas_cap: 0x%x", fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1993 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1994 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 1995 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1996 | hdd_err("unable to get vht_enable2x2"); |
| 1997 | |
| 1998 | antenna_mode = (bval == 0x01) ? |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1999 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 2000 | hdd_update_smps_antenna_mode(hdd_ctx, antenna_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2001 | hdd_debug("Init current antenna mode: %d", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2002 | hdd_ctx->current_antenna_mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 2003 | |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 2004 | hdd_ctx->rcpi_enabled = cfg->rcpi_enabled; |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 2005 | hdd_update_ra_rate_limit(hdd_ctx, cfg); |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 2006 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 2007 | status = ucfg_mlme_cfg_get_vht_tx_bfee_ant_supp(hdd_ctx->psoc, |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 2008 | &value); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 2009 | if (QDF_IS_STATUS_ERROR(status)) { |
| 2010 | status = false; |
| 2011 | hdd_err("set tx_bfee_ant_supp failed"); |
| 2012 | } |
| 2013 | |
| 2014 | if ((value > |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2015 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF) && |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 2016 | !cfg->tx_bfee_8ss_enabled) { |
| 2017 | status = |
| 2018 | ucfg_mlme_cfg_set_vht_tx_bfee_ant_supp(hdd_ctx->psoc, |
| 2019 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF); |
| 2020 | if (QDF_IS_STATUS_ERROR(status)) { |
| 2021 | status = false; |
| 2022 | hdd_err("set tx_bfee_ant_supp failed"); |
| 2023 | } |
| 2024 | } |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2025 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 2026 | mac_handle = hdd_ctx->mac_handle; |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2027 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 2028 | hdd_debug("txBFCsnValue %d", value); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 2029 | |
| 2030 | /* |
| 2031 | * Update txBFCsnValue and NumSoundingDim values to vhtcap in wiphy |
| 2032 | */ |
| 2033 | hdd_update_wiphy_vhtcap(hdd_ctx); |
Manjeet Singh | 70d3d93 | 2016-12-20 20:41:10 +0530 | [diff] [blame] | 2034 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 2035 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 2036 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 2037 | /* |
| 2038 | * This needs to be done after HDD pdev is created and stored since |
| 2039 | * it will access the HDD pdev object lock. |
| 2040 | */ |
| 2041 | hdd_runtime_suspend_context_init(hdd_ctx); |
| 2042 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 2043 | /* Configure NAN datapath features */ |
| 2044 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Nachiket Kukade | 85aa378 | 2018-11-02 20:12:34 +0530 | [diff] [blame] | 2045 | ucfg_nan_set_tgt_caps(hdd_ctx->psoc, &cfg->nan_caps); |
Arif Hussain | 759a023 | 2017-03-20 13:17:18 -0700 | [diff] [blame] | 2046 | hdd_ctx->dfs_cac_offload = cfg->dfs_cac_offload; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 2047 | hdd_ctx->lte_coex_ant_share = cfg->services.lte_coex_ant_share; |
Liangwei Dong | 0da1426 | 2018-07-03 03:30:23 -0400 | [diff] [blame] | 2048 | hdd_ctx->obss_scan_offload = cfg->services.obss_scan_offload; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 2049 | status = sme_cfg_set_int(mac_handle, WNI_CFG_OBSS_DETECTION_OFFLOAD, |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2050 | cfg->obss_detection_offloaded); |
| 2051 | if (QDF_IS_STATUS_ERROR(status)) |
| 2052 | hdd_err("Couldn't pass WNI_CFG_OBSS_DETECTION_OFFLOAD to CFG"); |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2053 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 2054 | status = sme_cfg_set_int(mac_handle, |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2055 | WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD, |
| 2056 | cfg->obss_color_collision_offloaded); |
| 2057 | if (QDF_IS_STATUS_ERROR(status)) |
| 2058 | hdd_err("Failed to set WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2059 | } |
| 2060 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2061 | bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2062 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2063 | struct hdd_adapter *adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 2064 | struct hdd_ap_ctx *ap_ctx; |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 2065 | bool dfs_disable_channel_switch = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2066 | |
Jiachao Wu | f610d91 | 2018-01-23 17:47:32 +0800 | [diff] [blame] | 2067 | if (!hdd_ctx) { |
| 2068 | hdd_info("Couldn't get hdd_ctx"); |
| 2069 | return true; |
| 2070 | } |
| 2071 | |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 2072 | ucfg_mlme_get_dfs_disable_channel_switch(hdd_ctx->psoc, |
| 2073 | &dfs_disable_channel_switch); |
| 2074 | if (dfs_disable_channel_switch) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 2075 | hdd_info("skip tx block hdd_ctx=%pK, disableDFSChSwitch=%d", |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 2076 | hdd_ctx, dfs_disable_channel_switch); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2077 | return true; |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2078 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2079 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 2080 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2081 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 2082 | |
| 2083 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 2084 | QDF_P2P_GO_MODE == adapter->device_mode) && |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 2085 | (wlan_reg_is_passive_or_disable_ch(hdd_ctx->pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 2086 | ap_ctx->operating_channel))) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2087 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->dfs_cac_block_tx = |
| 2088 | true; |
| 2089 | hdd_info("tx blocked for session: %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2090 | adapter->session_id); |
bings | 6fb9bf6 | 2018-07-05 14:01:53 +0800 | [diff] [blame] | 2091 | if (adapter->txrx_vdev) |
| 2092 | cdp_fc_vdev_flush( |
| 2093 | cds_get_context(QDF_MODULE_ID_SOC), |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 2094 | adapter->txrx_vdev); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2095 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2096 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2097 | |
| 2098 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2099 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2100 | |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2101 | bool hdd_is_valid_mac_address(const uint8_t *mac_addr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2102 | { |
| 2103 | int xdigit = 0; |
| 2104 | int separator = 0; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2105 | |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2106 | while (*mac_addr) { |
| 2107 | if (isxdigit(*mac_addr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2108 | xdigit++; |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2109 | } else if (':' == *mac_addr) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2110 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 2111 | break; |
| 2112 | |
| 2113 | ++separator; |
| 2114 | } else { |
| 2115 | /* Invalid MAC found */ |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2116 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2117 | } |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2118 | ++mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2119 | } |
| 2120 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 2121 | } |
| 2122 | |
| 2123 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2124 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 2125 | * @dev: Handle to struct net_device to be updated. |
| 2126 | * |
| 2127 | * Return: None |
| 2128 | */ |
| 2129 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 2130 | { |
| 2131 | dev->header_ops = NULL; |
| 2132 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 2133 | dev->hard_header_len = ETH_HLEN; |
| 2134 | dev->mtu = ETH_DATA_LEN; |
| 2135 | dev->addr_len = ETH_ALEN; |
| 2136 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 2137 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 2138 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 2139 | |
| 2140 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 2141 | } |
| 2142 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 2143 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2144 | /** |
chenguo | 7130396 | 2018-10-24 19:44:34 +0800 | [diff] [blame] | 2145 | * hdd_mon_turn_off_ps_and_wow() - Update monitor mode struct net_device. |
| 2146 | * @hdd_ctx: Pointer to HDD context. |
| 2147 | * |
| 2148 | * Return: None |
| 2149 | */ |
| 2150 | static void hdd_mon_turn_off_ps_and_wow(struct hdd_context *hdd_ctx) |
| 2151 | { |
| 2152 | ucfg_pmo_set_power_save_mode(hdd_ctx->psoc, PS_NOT_SUPPORTED); |
| 2153 | ucfg_pmo_set_wow_enable(hdd_ctx->psoc, PMO_WOW_DISABLE_BOTH); |
| 2154 | } |
| 2155 | |
| 2156 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2157 | * __hdd__mon_open() - HDD Open function |
| 2158 | * @dev: Pointer to net_device structure |
| 2159 | * |
| 2160 | * This is called in response to ifconfig up |
| 2161 | * |
| 2162 | * Return: 0 for success; non-zero for failure |
| 2163 | */ |
| 2164 | static int __hdd_mon_open(struct net_device *dev) |
| 2165 | { |
| 2166 | int ret; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2167 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2168 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2169 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2170 | hdd_enter_dev(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2171 | |
| 2172 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2173 | if (ret) |
| 2174 | return ret; |
| 2175 | |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2176 | hdd_mon_mode_ether_setup(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2177 | |
| 2178 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 2179 | ret = hdd_psoc_idle_restart(hdd_ctx); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2180 | if (ret) { |
| 2181 | hdd_err("Failed to start WLAN modules return"); |
| 2182 | return ret; |
| 2183 | } |
| 2184 | hdd_err("hdd_wlan_start_modules() successful !"); |
| 2185 | |
| 2186 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2187 | ret = hdd_start_adapter(adapter); |
| 2188 | if (ret) { |
| 2189 | hdd_err("Failed to start adapter :%d", |
| 2190 | adapter->device_mode); |
| 2191 | return ret; |
| 2192 | } |
| 2193 | hdd_err("hdd_start_adapters() successful !"); |
| 2194 | } |
chenguo | 7130396 | 2018-10-24 19:44:34 +0800 | [diff] [blame] | 2195 | hdd_mon_turn_off_ps_and_wow(hdd_ctx); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2196 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2197 | } |
| 2198 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2199 | ret = hdd_set_mon_rx_cb(dev); |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 2200 | |
| 2201 | if (!ret) |
| 2202 | ret = hdd_enable_monitor_mode(dev); |
| 2203 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2204 | return ret; |
| 2205 | } |
| 2206 | |
| 2207 | /** |
| 2208 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 2209 | * @dev: Pointer to net_device structure |
| 2210 | * |
| 2211 | * This is called in response to ifconfig up |
| 2212 | * |
| 2213 | * Return: 0 for success; non-zero for failure |
| 2214 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2215 | static int hdd_mon_open(struct net_device *dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2216 | { |
| 2217 | int ret; |
| 2218 | |
| 2219 | cds_ssr_protect(__func__); |
| 2220 | ret = __hdd_mon_open(dev); |
| 2221 | cds_ssr_unprotect(__func__); |
| 2222 | |
| 2223 | return ret; |
| 2224 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 2225 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2226 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2227 | static QDF_STATUS |
| 2228 | wlan_hdd_update_dbs_scan_and_fw_mode_config(void) |
| 2229 | { |
| 2230 | struct policy_mgr_dual_mac_config cfg = {0}; |
| 2231 | QDF_STATUS status; |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 2232 | uint32_t chnl_sel_logic_conc = 0; |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2233 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2234 | uint8_t dual_mac_feature = DISABLE_DBS_CXN_AND_SCAN; |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2235 | |
| 2236 | if (!hdd_ctx) { |
| 2237 | hdd_err("HDD context is NULL"); |
| 2238 | return QDF_STATUS_E_FAILURE; |
| 2239 | } |
| 2240 | |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 2241 | /* |
| 2242 | * ROME platform doesn't support any DBS related commands in FW, |
| 2243 | * so if driver sends wmi command with dual_mac_config with all set to |
| 2244 | * 0 then FW wouldn't respond back and driver would timeout on waiting |
| 2245 | * for response. Check if FW supports DBS to eliminate ROME vs |
| 2246 | * NON-ROME platform. |
| 2247 | */ |
| 2248 | if (!policy_mgr_find_if_fw_supports_dbs(hdd_ctx->psoc)) |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2249 | return QDF_STATUS_SUCCESS; |
| 2250 | |
| 2251 | cfg.scan_config = 0; |
| 2252 | cfg.fw_mode_config = 0; |
| 2253 | cfg.set_dual_mac_cb = policy_mgr_soc_set_dual_mac_cfg_cb; |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 2254 | if (policy_mgr_is_hw_dbs_capable(hdd_ctx->psoc)) { |
| 2255 | status = |
| 2256 | ucfg_policy_mgr_get_chnl_select_plcy(hdd_ctx->psoc, |
| 2257 | &chnl_sel_logic_conc); |
| 2258 | if (status != QDF_STATUS_SUCCESS) { |
| 2259 | hdd_err("can't get chnl sel policy, use def"); |
| 2260 | return status; |
| 2261 | } |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2262 | } |
| 2263 | status = |
| 2264 | ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 2265 | &dual_mac_feature); |
| 2266 | if (status != QDF_STATUS_SUCCESS) { |
| 2267 | hdd_err("ucfg_policy_mgr_get_dual_mac_feature failed, use def"); |
| 2268 | return status; |
| 2269 | } |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2270 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2271 | if (dual_mac_feature != DISABLE_DBS_CXN_AND_SCAN) { |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2272 | status = policy_mgr_get_updated_scan_and_fw_mode_config( |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2273 | hdd_ctx->psoc, &cfg.scan_config, |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2274 | &cfg.fw_mode_config, |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2275 | dual_mac_feature, |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 2276 | chnl_sel_logic_conc); |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2277 | |
| 2278 | if (status != QDF_STATUS_SUCCESS) { |
| 2279 | hdd_err("wma_get_updated_scan_and_fw_mode_config failed %d", |
| 2280 | status); |
| 2281 | return status; |
| 2282 | } |
| 2283 | } |
| 2284 | |
| 2285 | hdd_debug("send scan_cfg: 0x%x fw_mode_cfg: 0x%x to fw", |
| 2286 | cfg.scan_config, cfg.fw_mode_config); |
| 2287 | |
| 2288 | status = sme_soc_set_dual_mac_config(cfg); |
| 2289 | if (status != QDF_STATUS_SUCCESS) { |
| 2290 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 2291 | return status; |
| 2292 | } |
| 2293 | |
| 2294 | return QDF_STATUS_SUCCESS; |
| 2295 | } |
| 2296 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2297 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2298 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 2299 | * @adapter: pointer to HDD adapter |
| 2300 | * |
| 2301 | * This function is called to start the device specific adapter for |
| 2302 | * the mode passed in the adapter's device_mode. |
| 2303 | * |
| 2304 | * Return: 0 for success; non-zero for failure |
| 2305 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2306 | int hdd_start_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2307 | { |
| 2308 | |
| 2309 | int ret; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 2310 | enum QDF_OPMODE device_mode = adapter->device_mode; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2311 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2312 | hdd_enter_dev(adapter->dev); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2313 | hdd_debug("Start_adapter for mode : %d", adapter->device_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2314 | |
| 2315 | switch (device_mode) { |
| 2316 | case QDF_P2P_CLIENT_MODE: |
| 2317 | case QDF_P2P_DEVICE_MODE: |
| 2318 | case QDF_OCB_MODE: |
| 2319 | case QDF_STA_MODE: |
| 2320 | case QDF_MONITOR_MODE: |
| 2321 | ret = hdd_start_station_adapter(adapter); |
| 2322 | if (ret) |
| 2323 | goto err_start_adapter; |
Alok Kumar | 81e1d73 | 2018-09-04 11:10:36 +0530 | [diff] [blame] | 2324 | |
| 2325 | hdd_nud_ignore_tracking(adapter, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2326 | break; |
| 2327 | case QDF_P2P_GO_MODE: |
| 2328 | case QDF_SAP_MODE: |
| 2329 | ret = hdd_start_ap_adapter(adapter); |
| 2330 | if (ret) |
| 2331 | goto err_start_adapter; |
| 2332 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 2333 | case QDF_IBSS_MODE: |
| 2334 | /* |
| 2335 | * For IBSS interface is initialized as part of |
| 2336 | * hdd_init_station_mode() |
| 2337 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2338 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2339 | case QDF_FTM_MODE: |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2340 | /* vdevs are dynamically managed by firmware in FTM */ |
| 2341 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2342 | default: |
| 2343 | hdd_err("Invalid session type %d", device_mode); |
| 2344 | QDF_ASSERT(0); |
| 2345 | goto err_start_adapter; |
| 2346 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2347 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2348 | if (hdd_set_fw_params(adapter)) |
| 2349 | hdd_err("Failed to set the FW params for the adapter!"); |
| 2350 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2351 | if (adapter->session_id != HDD_SESSION_ID_INVALID) { |
| 2352 | ret = wlan_hdd_cfg80211_register_frames(adapter); |
| 2353 | if (ret < 0) { |
| 2354 | hdd_err("Failed to register frames - ret %d", ret); |
| 2355 | goto err_start_adapter; |
| 2356 | } |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2357 | } |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2358 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2359 | wlan_hdd_update_dbs_scan_and_fw_mode_config(); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2360 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2361 | exit_with_success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2362 | hdd_exit(); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2363 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2364 | return 0; |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2365 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2366 | err_start_adapter: |
| 2367 | return -EINVAL; |
| 2368 | } |
| 2369 | |
| 2370 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2371 | * hdd_enable_power_management() - API to Enable Power Management |
| 2372 | * |
| 2373 | * API invokes Bus Interface Layer power management functionality |
| 2374 | * |
| 2375 | * Return: None |
| 2376 | */ |
| 2377 | static void hdd_enable_power_management(void) |
| 2378 | { |
| 2379 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2380 | |
| 2381 | if (!hif_ctx) { |
| 2382 | hdd_err("Bus Interface Context is Invalid"); |
| 2383 | return; |
| 2384 | } |
| 2385 | |
| 2386 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 2387 | } |
| 2388 | |
| 2389 | /** |
| 2390 | * hdd_disable_power_management() - API to disable Power Management |
| 2391 | * |
| 2392 | * API disable Bus Interface Layer Power management functionality |
| 2393 | * |
| 2394 | * Return: None |
| 2395 | */ |
| 2396 | static void hdd_disable_power_management(void) |
| 2397 | { |
| 2398 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2399 | |
| 2400 | if (!hif_ctx) { |
| 2401 | hdd_err("Bus Interface Context is Invalid"); |
| 2402 | return; |
| 2403 | } |
| 2404 | |
| 2405 | hif_disable_power_management(hif_ctx); |
| 2406 | } |
| 2407 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2408 | void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2409 | { |
| 2410 | void *hif_sc; |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2411 | size_t target_hw_name_len; |
| 2412 | const char *target_hw_name; |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2413 | uint8_t *buf; |
| 2414 | uint32_t buf_len; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2415 | |
| 2416 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
| 2417 | if (!hif_sc) { |
| 2418 | hdd_err("HIF context is NULL"); |
| 2419 | return; |
| 2420 | } |
| 2421 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2422 | hif_get_hw_info(hif_sc, &hdd_ctx->target_hw_version, |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2423 | &hdd_ctx->target_hw_revision, |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2424 | &target_hw_name); |
| 2425 | |
| 2426 | if (hdd_ctx->target_hw_name) |
| 2427 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2428 | |
| 2429 | target_hw_name_len = strlen(target_hw_name) + 1; |
| 2430 | hdd_ctx->target_hw_name = qdf_mem_malloc(target_hw_name_len); |
| 2431 | if (hdd_ctx->target_hw_name) |
| 2432 | qdf_mem_copy(hdd_ctx->target_hw_name, target_hw_name, |
| 2433 | target_hw_name_len); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2434 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2435 | buf = qdf_mem_malloc(WE_MAX_STR_LEN); |
| 2436 | if (buf) { |
| 2437 | buf_len = hdd_wlan_get_version(hdd_ctx, WE_MAX_STR_LEN, buf); |
| 2438 | hdd_info("%s", buf); |
| 2439 | qdf_mem_free(buf); |
| 2440 | } |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2441 | } |
| 2442 | |
| 2443 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2444 | * hdd_update_cds_ac_specs_params() - update cds ac_specs params |
| 2445 | * @hdd_ctx: Pointer to hdd context |
| 2446 | * |
| 2447 | * Return: none |
| 2448 | */ |
| 2449 | static void |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2450 | hdd_update_cds_ac_specs_params(struct hdd_context *hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2451 | { |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2452 | uint8_t tx_sched_wrr_param[TX_SCHED_WRR_PARAMS_NUM] = {0}; |
| 2453 | qdf_size_t out_size = 0; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2454 | int i; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2455 | struct cds_context *cds_ctx; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2456 | |
| 2457 | if (NULL == hdd_ctx) |
| 2458 | return; |
| 2459 | |
| 2460 | if (NULL == hdd_ctx->config) { |
| 2461 | /* Do nothing if hdd_ctx is invalid */ |
| 2462 | hdd_err("%s: Warning: hdd_ctx->cfg_ini is NULL", __func__); |
| 2463 | return; |
| 2464 | } |
| 2465 | |
| 2466 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2467 | |
| 2468 | if (!cds_ctx) { |
| 2469 | hdd_err("Invalid CDS Context"); |
| 2470 | return; |
| 2471 | } |
| 2472 | |
| 2473 | for (i = 0; i < OL_TX_NUM_WMM_AC; i++) { |
| 2474 | switch (i) { |
| 2475 | case OL_TX_WMM_AC_BE: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2476 | qdf_uint8_array_parse( |
| 2477 | cfg_get(hdd_ctx->psoc, |
| 2478 | CFG_DP_ENABLE_TX_SCHED_WRR_BE), |
| 2479 | tx_sched_wrr_param, |
| 2480 | sizeof(tx_sched_wrr_param), |
| 2481 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2482 | break; |
| 2483 | case OL_TX_WMM_AC_BK: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2484 | qdf_uint8_array_parse( |
| 2485 | cfg_get(hdd_ctx->psoc, |
| 2486 | CFG_DP_ENABLE_TX_SCHED_WRR_BK), |
| 2487 | tx_sched_wrr_param, |
| 2488 | sizeof(tx_sched_wrr_param), |
| 2489 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2490 | break; |
| 2491 | case OL_TX_WMM_AC_VI: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2492 | qdf_uint8_array_parse( |
| 2493 | cfg_get(hdd_ctx->psoc, |
| 2494 | CFG_DP_ENABLE_TX_SCHED_WRR_VI), |
| 2495 | tx_sched_wrr_param, |
| 2496 | sizeof(tx_sched_wrr_param), |
| 2497 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2498 | break; |
| 2499 | case OL_TX_WMM_AC_VO: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2500 | qdf_uint8_array_parse( |
| 2501 | cfg_get(hdd_ctx->psoc, |
| 2502 | CFG_DP_ENABLE_TX_SCHED_WRR_VO), |
| 2503 | tx_sched_wrr_param, |
| 2504 | sizeof(tx_sched_wrr_param), |
| 2505 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2506 | break; |
| 2507 | default: |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2508 | break; |
| 2509 | } |
| 2510 | |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2511 | if (out_size == TX_SCHED_WRR_PARAMS_NUM) { |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2512 | cds_ctx->ac_specs[i].wrr_skip_weight = |
| 2513 | tx_sched_wrr_param[0]; |
| 2514 | cds_ctx->ac_specs[i].credit_threshold = |
| 2515 | tx_sched_wrr_param[1]; |
| 2516 | cds_ctx->ac_specs[i].send_limit = |
| 2517 | tx_sched_wrr_param[2]; |
| 2518 | cds_ctx->ac_specs[i].credit_reserve = |
| 2519 | tx_sched_wrr_param[3]; |
| 2520 | cds_ctx->ac_specs[i].discard_weight = |
| 2521 | tx_sched_wrr_param[4]; |
| 2522 | } |
| 2523 | |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2524 | out_size = 0; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2525 | } |
| 2526 | } |
| 2527 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2528 | uint32_t hdd_wlan_get_version(struct hdd_context *hdd_ctx, |
| 2529 | const size_t version_len, uint8_t *version) |
| 2530 | { |
| 2531 | uint32_t size; |
| 2532 | uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0; |
| 2533 | |
| 2534 | if (!hdd_ctx) { |
| 2535 | hdd_err("Invalid context, HDD context is null"); |
| 2536 | return 0; |
| 2537 | } |
| 2538 | |
Ashish Kumar Dhanotiya | 7353f88 | 2018-05-15 12:50:19 +0530 | [diff] [blame] | 2539 | if (!version || version_len == 0) { |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2540 | hdd_err("Invalid buffer pointr or buffer len\n"); |
| 2541 | return 0; |
| 2542 | } |
| 2543 | |
| 2544 | msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 2545 | mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 2546 | siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 2547 | crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 2548 | sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28; |
| 2549 | |
| 2550 | size = scnprintf(version, version_len, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2551 | "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] | 2552 | QWLAN_VERSIONSTR, |
| 2553 | msp_id, mspid, siid, crmid, sub_id, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2554 | hdd_ctx->target_hw_name, |
| 2555 | hdd_ctx->hw_bd_info.bdf_version, |
| 2556 | hdd_ctx->hw_bd_info.ref_design_id, |
| 2557 | hdd_ctx->hw_bd_info.customer_id, |
| 2558 | hdd_ctx->hw_bd_info.project_id, |
| 2559 | hdd_ctx->hw_bd_info.board_data_rev); |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2560 | |
| 2561 | return size; |
| 2562 | } |
| 2563 | |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 2564 | int hdd_set_11ax_rate(struct hdd_adapter *adapter, int set_value, |
| 2565 | struct sap_config *sap_config) |
| 2566 | { |
| 2567 | uint8_t preamble = 0, nss = 0, rix = 0; |
| 2568 | int ret; |
| 2569 | mac_handle_t mac_handle = adapter->hdd_ctx->mac_handle; |
| 2570 | |
| 2571 | if (!sap_config) { |
| 2572 | if (!sme_is_feature_supported_by_fw(DOT11AX)) { |
| 2573 | hdd_err("Target does not support 11ax"); |
| 2574 | return -EIO; |
| 2575 | } |
| 2576 | } else if (sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax && |
| 2577 | sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax_ONLY) { |
| 2578 | hdd_err("Invalid hw mode, SAP hw_mode= 0x%x, ch = %d", |
| 2579 | sap_config->SapHw_mode, sap_config->channel); |
| 2580 | return -EIO; |
| 2581 | } |
| 2582 | |
| 2583 | if (set_value != 0xff) { |
| 2584 | rix = RC_2_RATE_IDX_11AX(set_value); |
| 2585 | preamble = WMI_RATE_PREAMBLE_HE; |
| 2586 | nss = HT_RC_2_STREAMS_11AX(set_value); |
| 2587 | |
| 2588 | set_value = hdd_assemble_rate_code(preamble, nss, rix); |
| 2589 | } else { |
| 2590 | ret = sme_set_auto_rate_he_ltf(mac_handle, adapter->session_id, |
| 2591 | QCA_WLAN_HE_LTF_AUTO); |
| 2592 | } |
| 2593 | |
| 2594 | hdd_info("SET_11AX_RATE val %d rix %d preamble %x nss %d", |
| 2595 | set_value, rix, preamble, nss); |
| 2596 | |
| 2597 | ret = wma_cli_set_command(adapter->session_id, |
| 2598 | WMI_VDEV_PARAM_FIXED_RATE, |
| 2599 | set_value, VDEV_CMD); |
| 2600 | |
| 2601 | return ret; |
| 2602 | } |
| 2603 | |
| 2604 | int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate) |
| 2605 | { |
| 2606 | int set_value; |
| 2607 | |
| 2608 | if (sme_is_feature_supported_by_fw(DOT11AX)) |
| 2609 | set_value = WMI_ASSEMBLE_RATECODE_V1(rate, nss, preamble); |
| 2610 | else |
| 2611 | set_value = (preamble << 6) | (nss << 4) | rate; |
| 2612 | |
| 2613 | return set_value; |
| 2614 | } |
| 2615 | |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2616 | #ifdef FEATURE_WLAN_WAPI |
| 2617 | /** |
| 2618 | * hdd_wapi_security_sta_exist() - return wapi security sta exist or not |
| 2619 | * |
| 2620 | * This API returns the wapi security station exist or not |
| 2621 | * |
| 2622 | * Return: true - wapi security station exist |
| 2623 | */ |
| 2624 | static bool hdd_wapi_security_sta_exist(void) |
| 2625 | { |
| 2626 | struct hdd_adapter *adapter = NULL; |
| 2627 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 2628 | |
| 2629 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 2630 | if ((adapter->device_mode == QDF_STA_MODE) && |
| 2631 | adapter->wapi_info.wapi_mode && |
| 2632 | (adapter->wapi_info.wapi_auth_mode != WAPI_AUTH_MODE_OPEN)) |
| 2633 | return true; |
| 2634 | } |
| 2635 | return false; |
| 2636 | } |
| 2637 | #else |
| 2638 | static bool hdd_wapi_security_sta_exist(void) |
| 2639 | { |
| 2640 | return false; |
| 2641 | } |
| 2642 | #endif |
| 2643 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2644 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2645 | static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev( |
| 2646 | struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) |
| 2647 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2648 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2649 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2650 | |
| 2651 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 2652 | if (!adapter) { |
| 2653 | hdd_err("Adapter is NULL"); |
| 2654 | return PM_MAX_NUM_OF_MODE; |
| 2655 | } |
| 2656 | |
| 2657 | return policy_mgr_convert_device_mode_to_qdf_type( |
| 2658 | adapter->device_mode); |
| 2659 | } |
| 2660 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2661 | static void hdd_register_policy_manager_callback( |
| 2662 | struct wlan_objmgr_psoc *psoc) |
| 2663 | { |
| 2664 | struct policy_mgr_hdd_cbacks hdd_cbacks; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 2665 | |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2666 | qdf_mem_zero(&hdd_cbacks, sizeof(hdd_cbacks)); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2667 | hdd_cbacks.sap_restart_chan_switch_cb = |
Jeff Johnson | 2381294 | 2017-10-06 11:33:55 -0700 | [diff] [blame] | 2668 | hdd_sap_restart_chan_switch_cb; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2669 | hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = |
| 2670 | wlan_hdd_get_channel_for_sap_restart; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2671 | hdd_cbacks.get_mode_for_non_connected_vdev = |
| 2672 | wlan_hdd_get_mode_for_non_connected_vdev; |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 2673 | hdd_cbacks.hdd_get_device_mode = hdd_get_device_mode; |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2674 | hdd_cbacks.hdd_wapi_security_sta_exist = |
| 2675 | hdd_wapi_security_sta_exist; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2676 | if (QDF_STATUS_SUCCESS != |
| 2677 | policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { |
| 2678 | hdd_err("HDD callback registration with policy manager failed"); |
| 2679 | } |
| 2680 | } |
| 2681 | #else |
| 2682 | static void hdd_register_policy_manager_callback( |
| 2683 | struct wlan_objmgr_psoc *psoc) |
| 2684 | { |
| 2685 | } |
| 2686 | #endif |
| 2687 | |
jiad | ff1ac13 | 2018-11-26 16:27:48 +0800 | [diff] [blame] | 2688 | #ifdef WLAN_FEATURE_NAN_DATAPATH |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2689 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2690 | { |
| 2691 | struct nan_callbacks cb_obj = {0}; |
| 2692 | |
| 2693 | cb_obj.ndi_open = hdd_ndi_open; |
| 2694 | cb_obj.ndi_close = hdd_ndi_close; |
| 2695 | cb_obj.ndi_start = hdd_ndi_start; |
| 2696 | cb_obj.ndi_delete = hdd_ndi_delete; |
| 2697 | cb_obj.drv_ndi_create_rsp_handler = hdd_ndi_drv_ndi_create_rsp_handler; |
| 2698 | cb_obj.drv_ndi_delete_rsp_handler = hdd_ndi_drv_ndi_delete_rsp_handler; |
| 2699 | |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2700 | cb_obj.new_peer_ind = hdd_ndp_new_peer_handler; |
| 2701 | cb_obj.get_peer_idx = hdd_ndp_get_peer_idx; |
Naveen Rawat | b3143ea | 2017-03-26 22:25:46 -0700 | [diff] [blame] | 2702 | cb_obj.peer_departed_ind = hdd_ndp_peer_departed_handler; |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2703 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2704 | os_if_nan_register_hdd_callbacks(hdd_ctx->psoc, &cb_obj); |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2705 | } |
jiad | ff1ac13 | 2018-11-26 16:27:48 +0800 | [diff] [blame] | 2706 | #else |
| 2707 | static inline void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
| 2708 | { |
| 2709 | } |
| 2710 | #endif |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2711 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2712 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2713 | /** |
| 2714 | * hdd_check_for_leaks() - Perform runtime memory leak checks |
Dustin Brown | a6246dd | 2018-05-24 14:35:58 -0700 | [diff] [blame] | 2715 | * @hdd_ctx: the global HDD context |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2716 | * @is_ssr: true if SSR is in progress |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2717 | * |
| 2718 | * This API triggers runtime memory leak detection. This feature enforces the |
| 2719 | * policy that any memory allocated at runtime must also be released at runtime. |
| 2720 | * |
| 2721 | * Allocating memory at runtime and releasing it at unload is effectively a |
| 2722 | * memory leak for configurations which never unload (e.g. LONU, statically |
| 2723 | * compiled driver). Such memory leaks are NOT false positives, and must be |
| 2724 | * fixed. |
| 2725 | * |
| 2726 | * Return: None |
| 2727 | */ |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2728 | 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] | 2729 | { |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2730 | /* DO NOT REMOVE these checks; for false positives, read above first */ |
| 2731 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2732 | wlan_objmgr_psoc_check_for_peer_leaks(hdd_ctx->psoc); |
| 2733 | wlan_objmgr_psoc_check_for_vdev_leaks(hdd_ctx->psoc); |
| 2734 | wlan_objmgr_psoc_check_for_pdev_leaks(hdd_ctx->psoc); |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2735 | |
| 2736 | /* many adapter resources are not freed by design during SSR */ |
| 2737 | if (is_ssr) |
| 2738 | return; |
| 2739 | |
Dustin Brown | 677e086 | 2017-10-10 16:30:09 -0700 | [diff] [blame] | 2740 | qdf_mc_timer_check_for_leaks(); |
Dustin Brown | 8e71150 | 2017-12-07 16:49:11 -0800 | [diff] [blame] | 2741 | qdf_nbuf_map_check_for_leaks(); |
Dustin Brown | e6b9d5a | 2017-12-14 15:18:49 -0800 | [diff] [blame] | 2742 | qdf_mem_check_for_leaks(); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2743 | } |
| 2744 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2745 | #define hdd_debug_domain_set(domain) qdf_debug_domain_set(domain) |
| 2746 | #else |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2747 | static inline void hdd_check_for_leaks(struct hdd_context *hdd_ctx, bool is_ssr) |
| 2748 | { } |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2749 | |
| 2750 | #define hdd_debug_domain_set(domain) |
| 2751 | #endif /* CONFIG_LEAK_DETECTION */ |
| 2752 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2753 | /** |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2754 | * hdd_update_country_code - Update country code |
| 2755 | * @hdd_ctx: HDD context |
| 2756 | * |
| 2757 | * Update country code based on module parameter country_code |
| 2758 | * |
| 2759 | * Return: 0 on success and errno on failure |
| 2760 | */ |
| 2761 | static int hdd_update_country_code(struct hdd_context *hdd_ctx) |
| 2762 | { |
| 2763 | if (!country_code) |
| 2764 | return 0; |
| 2765 | |
| 2766 | return hdd_reg_set_country(hdd_ctx, country_code); |
| 2767 | } |
| 2768 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2769 | int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, bool reinit) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2770 | { |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2771 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2772 | qdf_device_t qdf_dev; |
| 2773 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2774 | bool unint = false; |
| 2775 | void *hif_ctx; |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2776 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2777 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2778 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2779 | if (!qdf_dev) { |
| 2780 | hdd_err("QDF Device Context is Invalid return"); |
| 2781 | return -EINVAL; |
| 2782 | } |
| 2783 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 2784 | hdd_psoc_idle_timer_stop(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2785 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2786 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2787 | if (hdd_ctx->driver_status == DRIVER_MODULES_ENABLED) { |
| 2788 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2789 | hdd_debug("Driver modules already Enabled"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2790 | hdd_exit(); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2791 | return 0; |
| 2792 | } |
| 2793 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2794 | hdd_ctx->start_modules_in_progress = true; |
| 2795 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2796 | switch (hdd_ctx->driver_status) { |
| 2797 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2798 | hdd_info("Wlan transitioning (UNINITIALIZED -> CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2799 | unint = true; |
| 2800 | /* Fall through dont add break here */ |
| 2801 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 2802 | hdd_info("Wlan transitioning (CLOSED -> ENABLED)"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2803 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2804 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2805 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2806 | if (!reinit && !unint) { |
| 2807 | ret = pld_power_on(qdf_dev->dev); |
| 2808 | if (ret) { |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2809 | hdd_err("Failed to power up device; errno:%d", |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2810 | ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2811 | goto release_lock; |
| 2812 | } |
| 2813 | } |
Yuanyuan Liu | f8fe4bc | 2017-06-07 16:55:58 -0700 | [diff] [blame] | 2814 | |
| 2815 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 2816 | hdd_ctx->config->enable_fw_log); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2817 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 2818 | qdf_dev->bus_type, |
| 2819 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 2820 | HIF_ENABLE_TYPE_PROBE); |
| 2821 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2822 | hdd_err("Failed to open hif; errno: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2823 | goto power_down; |
| 2824 | } |
| 2825 | |
| 2826 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2827 | if (!hif_ctx) { |
| 2828 | hdd_err("hif context is null!!"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2829 | ret = -EINVAL; |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2830 | goto power_down; |
| 2831 | } |
| 2832 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2833 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 2834 | if (status != QDF_STATUS_SUCCESS) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2835 | hdd_err("No Memory to Create BMI Context; status: %d", |
| 2836 | status); |
| 2837 | ret = qdf_status_to_os_return(status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2838 | goto hif_close; |
| 2839 | } |
| 2840 | |
jitiphil | 4c256a3 | 2018-09-07 08:51:52 +0530 | [diff] [blame] | 2841 | ucfg_ipa_component_config_update(hdd_ctx->psoc); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2842 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2843 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 2844 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2845 | status = hdd_component_psoc_open(hdd_ctx->psoc); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 2846 | if (QDF_IS_STATUS_ERROR(status)) { |
| 2847 | hdd_err("Failed to Open legacy components; status: %d", |
| 2848 | status); |
| 2849 | ret = qdf_status_to_os_return(status); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 2850 | goto cds_free; |
| 2851 | } |
| 2852 | |
| 2853 | ret = hdd_update_config(hdd_ctx); |
| 2854 | if (ret) { |
| 2855 | hdd_err("Failed to update configuration; errno: %d", |
| 2856 | ret); |
| 2857 | goto cds_free; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 2858 | } |
| 2859 | |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 2860 | status = wbuff_module_init(); |
| 2861 | if (QDF_IS_STATUS_ERROR(status)) |
| 2862 | hdd_err("WBUFF init unsuccessful; status: %d", status); |
| 2863 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2864 | status = cds_open(hdd_ctx->psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2865 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2866 | hdd_err("Failed to Open CDS; status: %d", status); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2867 | ret = qdf_status_to_os_return(status); |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 2868 | goto psoc_close; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2869 | } |
| 2870 | |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 2871 | hdd_ctx->mac_handle = cds_get_context(QDF_MODULE_ID_SME); |
| 2872 | |
Manjunathappa Prakash | b6b4ff1 | 2018-06-04 12:32:33 -0700 | [diff] [blame] | 2873 | if (hdd_ctx->config->rx_thread_affinity_mask) |
| 2874 | cds_set_rx_thread_cpu_mask( |
| 2875 | hdd_ctx->config->rx_thread_affinity_mask); |
| 2876 | |
| 2877 | /* initialize components configurations after psoc open */ |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2878 | ret = hdd_update_components_config(hdd_ctx); |
| 2879 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2880 | hdd_err("Failed to update component configs; errno: %d", |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2881 | ret); |
| 2882 | goto close; |
| 2883 | } |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 2884 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2885 | status = cds_dp_open(hdd_ctx->psoc); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2886 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2887 | hdd_err("Failed to Open cds post open; status: %d", |
| 2888 | status); |
| 2889 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2890 | goto close; |
| 2891 | } |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2892 | |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 2893 | ret = hdd_register_cb(hdd_ctx); |
| 2894 | if (ret) { |
| 2895 | hdd_err("Failed to register HDD callbacks!"); |
| 2896 | goto cds_txrx_free; |
| 2897 | } |
| 2898 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2899 | /* |
| 2900 | * NAN compoenet requires certian operations like, open adapter, |
| 2901 | * close adapter, etc. to be initiated by HDD, for those |
| 2902 | * register HDD callbacks with UMAC's NAN componenet. |
| 2903 | */ |
| 2904 | hdd_nan_register_callbacks(hdd_ctx); |
| 2905 | |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 2906 | status = cds_pre_enable(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2907 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2908 | hdd_err("Failed to pre-enable CDS; status: %d", status); |
| 2909 | ret = qdf_status_to_os_return(status); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 2910 | goto deregister_cb; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2911 | } |
| 2912 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2913 | hdd_register_policy_manager_callback( |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2914 | hdd_ctx->psoc); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2915 | |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 2916 | hdd_sysfs_create_driver_root_obj(); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2917 | hdd_sysfs_create_version_interface(hdd_ctx->psoc); |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 2918 | hdd_sysfs_create_powerstats_interface(); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2919 | hdd_update_hw_sw_info(hdd_ctx); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2920 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2921 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2922 | hdd_err("in ftm mode, no need to configure cds modules"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2923 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2924 | break; |
| 2925 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2926 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2927 | ret = hdd_configure_cds(hdd_ctx); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2928 | if (ret) { |
| 2929 | hdd_err("Failed to Enable cds modules; errno: %d", ret); |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 2930 | goto destroy_driver_sysfs; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2931 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2932 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2933 | hdd_enable_power_management(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2934 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2935 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2936 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2937 | default: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2938 | QDF_DEBUG_PANIC("Unknown driver state:%d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2939 | hdd_ctx->driver_status); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2940 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2941 | goto release_lock; |
| 2942 | } |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2943 | |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 2944 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
| 2945 | hdd_info("Wlan transitioned (now ENABLED)"); |
| 2946 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2947 | hdd_ctx->start_modules_in_progress = false; |
Dustin Brown | ad698ae | 2018-09-05 17:19:30 -0700 | [diff] [blame] | 2948 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2949 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2950 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2951 | hdd_exit(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2952 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2953 | return 0; |
| 2954 | |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 2955 | destroy_driver_sysfs: |
| 2956 | hdd_sysfs_destroy_powerstats_interface(); |
| 2957 | hdd_sysfs_destroy_version_interface(); |
| 2958 | hdd_sysfs_destroy_driver_root_obj(); |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 2959 | cds_post_disable(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2960 | |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 2961 | deregister_cb: |
| 2962 | hdd_deregister_cb(hdd_ctx); |
| 2963 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2964 | cds_txrx_free: |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2965 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->psoc); |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2966 | |
| 2967 | if (tgt_hdl && target_psoc_get_wmi_ready(tgt_hdl)) { |
| 2968 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 2969 | dispatcher_pdev_close(hdd_ctx->pdev); |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2970 | hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 2971 | } |
| 2972 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2973 | cds_dp_close(hdd_ctx->psoc); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2974 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2975 | close: |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2976 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2977 | hdd_info("Wlan transition aborted (now CLOSED)"); |
| 2978 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2979 | cds_close(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2980 | |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 2981 | psoc_close: |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2982 | hdd_component_psoc_close(hdd_ctx->psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2983 | cds_deinit_ini_config(); |
| 2984 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2985 | cds_free: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2986 | ol_cds_free(); |
| 2987 | |
| 2988 | hif_close: |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2989 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2990 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2991 | power_down: |
| 2992 | if (!reinit && !unint) |
| 2993 | pld_power_off(qdf_dev->dev); |
| 2994 | release_lock: |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2995 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2996 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Abhinav Kumar | 7ae9b7b | 2017-12-19 15:11:54 +0530 | [diff] [blame] | 2997 | if (hdd_ctx->target_hw_name) { |
| 2998 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2999 | hdd_ctx->target_hw_name = NULL; |
| 3000 | } |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 3001 | |
| 3002 | hdd_check_for_leaks(hdd_ctx, reinit); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 3003 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 3004 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3005 | hdd_exit(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 3006 | |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 3007 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3008 | } |
| 3009 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3010 | #ifdef WIFI_POS_CONVERGED |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3011 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3012 | { |
| 3013 | int ret = os_if_wifi_pos_register_nl(); |
| 3014 | |
| 3015 | if (ret) |
| 3016 | hdd_err("os_if_wifi_pos_register_nl failed"); |
| 3017 | |
| 3018 | return ret; |
| 3019 | } |
| 3020 | |
| 3021 | static int hdd_deactivate_wifi_pos(void) |
| 3022 | { |
| 3023 | int ret = os_if_wifi_pos_deregister_nl(); |
| 3024 | |
| 3025 | if (ret) |
| 3026 | hdd_err("os_if_wifi_pos_deregister_nl failed"); |
| 3027 | |
| 3028 | return ret; |
| 3029 | } |
| 3030 | |
| 3031 | /** |
| 3032 | * hdd_populate_wifi_pos_cfg - populates wifi_pos parameters |
| 3033 | * @hdd_ctx: hdd context |
| 3034 | * |
| 3035 | * Return: status of operation |
| 3036 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3037 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3038 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3039 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3040 | uint16_t neighbor_scan_max_chan_time; |
| 3041 | uint16_t neighbor_scan_min_chan_time; |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3042 | |
| 3043 | wifi_pos_set_oem_target_type(psoc, hdd_ctx->target_type); |
| 3044 | wifi_pos_set_oem_fw_version(psoc, hdd_ctx->target_fw_version); |
| 3045 | wifi_pos_set_drv_ver_major(psoc, QWLAN_VERSION_MAJOR); |
| 3046 | wifi_pos_set_drv_ver_minor(psoc, QWLAN_VERSION_MINOR); |
| 3047 | wifi_pos_set_drv_ver_patch(psoc, QWLAN_VERSION_PATCH); |
| 3048 | wifi_pos_set_drv_ver_build(psoc, QWLAN_VERSION_BUILD); |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3049 | ucfg_mlme_get_neighbor_scan_max_chan_time(psoc, |
| 3050 | &neighbor_scan_max_chan_time); |
| 3051 | ucfg_mlme_get_neighbor_scan_min_chan_time(psoc, |
| 3052 | &neighbor_scan_min_chan_time); |
| 3053 | wifi_pos_set_dwell_time_min(psoc, neighbor_scan_min_chan_time); |
| 3054 | wifi_pos_set_dwell_time_max(psoc, neighbor_scan_max_chan_time); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3055 | } |
| 3056 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3057 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3058 | { |
| 3059 | return oem_activate_service(hdd_ctx); |
| 3060 | } |
| 3061 | |
| 3062 | static int hdd_deactivate_wifi_pos(void) |
| 3063 | { |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 3064 | return oem_deactivate_service(); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3065 | } |
| 3066 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3067 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3068 | { |
| 3069 | } |
| 3070 | #endif |
| 3071 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3072 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3073 | * __hdd_open() - HDD Open function |
| 3074 | * @dev: Pointer to net_device structure |
| 3075 | * |
| 3076 | * This is called in response to ifconfig up |
| 3077 | * |
| 3078 | * Return: 0 for success; non-zero for failure |
| 3079 | */ |
| 3080 | static int __hdd_open(struct net_device *dev) |
| 3081 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3082 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3083 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3084 | int ret; |
| 3085 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3086 | hdd_enter_dev(dev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3087 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3088 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3089 | |
Ashish Kumar Dhanotiya | 15a7db5 | 2017-08-03 10:27:34 +0530 | [diff] [blame] | 3090 | /* Nothing to be done if device is unloading */ |
| 3091 | if (cds_is_driver_unloading()) { |
| 3092 | hdd_err("Driver is unloading can not open the hdd"); |
| 3093 | return -EBUSY; |
| 3094 | } |
| 3095 | |
Dustin Brown | 0184775 | 2017-10-25 13:56:27 -0700 | [diff] [blame] | 3096 | if (cds_is_driver_recovering()) { |
| 3097 | hdd_err("WLAN is currently recovering; Please try again."); |
| 3098 | return -EBUSY; |
| 3099 | } |
| 3100 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 3101 | if (qdf_atomic_read(&hdd_ctx->con_mode_flag)) { |
| 3102 | hdd_err("con_mode_handler is in progress; Please try again."); |
| 3103 | return -EBUSY; |
| 3104 | } |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3105 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 3106 | mutex_lock(&hdd_init_deinit_lock); |
Jeff Johnson | 5794d4f | 2018-12-04 11:57:09 -0800 | [diff] [blame] | 3107 | hdd_start_driver_ops_timer(HDD_DRV_OP_IFF_UP); |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 3108 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3109 | /* |
| 3110 | * This scenario can be hit in cases where in the wlan driver after |
| 3111 | * registering the netdevices and there is a failure in driver |
| 3112 | * initialization. So return error gracefully because the netdevices |
| 3113 | * will be de-registered as part of the load failure. |
| 3114 | */ |
| 3115 | |
| 3116 | if (!cds_is_driver_loaded()) { |
| 3117 | hdd_err("Failed to start the wlan driver!!"); |
| 3118 | ret = -EIO; |
| 3119 | goto err_hdd_hdd_init_deinit_lock; |
| 3120 | } |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 3121 | |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 3122 | ret = hdd_psoc_idle_restart(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3123 | if (ret) { |
| 3124 | hdd_err("Failed to start WLAN modules return"); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3125 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3126 | } |
| 3127 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3128 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 3129 | ret = hdd_start_adapter(adapter); |
| 3130 | if (ret) { |
| 3131 | hdd_err("Failed to start adapter :%d", |
| 3132 | adapter->device_mode); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3133 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3134 | } |
| 3135 | } |
| 3136 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3137 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 3138 | 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] | 3139 | hdd_debug("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3140 | /* Enable TX queues only when we are connected */ |
| 3141 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3142 | WLAN_START_ALL_NETIF_QUEUE, |
| 3143 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3144 | } |
| 3145 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3146 | /* Enable carrier and transmit queues for NDI */ |
| 3147 | if (WLAN_HDD_IS_NDI(adapter)) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 3148 | hdd_debug("Enabling Tx Queues"); |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3149 | wlan_hdd_netif_queue_control(adapter, |
| 3150 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 3151 | WLAN_CONTROL_PATH); |
| 3152 | } |
| 3153 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3154 | hdd_populate_wifi_pos_cfg(hdd_ctx); |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 3155 | hdd_lpass_notify_start(hdd_ctx, adapter); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3156 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3157 | err_hdd_hdd_init_deinit_lock: |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 3158 | hdd_stop_driver_ops_timer(); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3159 | mutex_unlock(&hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3160 | return ret; |
| 3161 | } |
| 3162 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3163 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3164 | /** |
| 3165 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 3166 | * @dev: Pointer to net_device structure |
| 3167 | * |
| 3168 | * This is called in response to ifconfig up |
| 3169 | * |
| 3170 | * Return: 0 for success; non-zero for failure |
| 3171 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3172 | static int hdd_open(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3173 | { |
| 3174 | int ret; |
| 3175 | |
| 3176 | cds_ssr_protect(__func__); |
| 3177 | ret = __hdd_open(dev); |
| 3178 | cds_ssr_unprotect(__func__); |
| 3179 | |
| 3180 | return ret; |
| 3181 | } |
| 3182 | |
| 3183 | /** |
| 3184 | * __hdd_stop() - HDD stop function |
| 3185 | * @dev: Pointer to net_device structure |
| 3186 | * |
| 3187 | * This is called in response to ifconfig down |
| 3188 | * |
| 3189 | * Return: 0 for success; non-zero for failure |
| 3190 | */ |
| 3191 | static int __hdd_stop(struct net_device *dev) |
| 3192 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3193 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3194 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3195 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3196 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3197 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3198 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3199 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3200 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3201 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3202 | |
| 3203 | ret = wlan_hdd_validate_context(hdd_ctx); |
Arunk Khandavalli | 987c8d5 | 2018-06-21 17:40:31 +0530 | [diff] [blame] | 3204 | if (ret) { |
| 3205 | set_bit(DOWN_DURING_SSR, &adapter->event_flags); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3206 | return ret; |
Arunk Khandavalli | 987c8d5 | 2018-06-21 17:40:31 +0530 | [diff] [blame] | 3207 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3208 | |
| 3209 | /* Nothing to be done if the interface is not opened */ |
| 3210 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3211 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3212 | return -ENODEV; |
| 3213 | } |
| 3214 | |
| 3215 | /* Make sure the interface is marked as closed */ |
| 3216 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3217 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3218 | mac_handle = hdd_ctx->mac_handle; |
| 3219 | |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3220 | hdd_debug("Disabling Auto Power save timer"); |
| 3221 | sme_ps_disable_auto_ps_timer( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3222 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3223 | adapter->session_id); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3224 | |
| 3225 | /* |
| 3226 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 3227 | * be called on that interface |
| 3228 | */ |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 3229 | hdd_debug("Disabling queues, adapter device mode: %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 3230 | qdf_opmode_str(adapter->device_mode), adapter->device_mode); |
Kabilan Kannan | 8dac350 | 2017-10-30 12:40:27 -0700 | [diff] [blame] | 3231 | |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 3232 | wlan_hdd_netif_queue_control(adapter, |
| 3233 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 3234 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3235 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 3236 | if (adapter->device_mode == QDF_STA_MODE) |
| 3237 | hdd_lpass_notify_stop(hdd_ctx); |
| 3238 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3239 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3240 | * NAN data interface is different in some sense. The traffic on NDI is |
| 3241 | * bursty in nature and depends on the need to transfer. The service |
| 3242 | * layer may down the interface after the usage and up again when |
| 3243 | * required. In some sense, the NDI is expected to be available |
| 3244 | * (like SAP) iface until NDI delete request is issued by the service |
| 3245 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 3246 | * interface (NDI). |
| 3247 | */ |
| 3248 | if (WLAN_HDD_IS_NDI(adapter)) |
| 3249 | return 0; |
| 3250 | |
| 3251 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3252 | * The interface is marked as down for outside world (aka kernel) |
| 3253 | * But the driver is pretty much alive inside. The driver needs to |
| 3254 | * tear down the existing connection on the netdev (session) |
| 3255 | * cleanup the data pipes and wait until the control plane is stabilized |
| 3256 | * for this interface. The call also needs to wait until the above |
| 3257 | * mentioned actions are completed before returning to the caller. |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3258 | * Notice that hdd_stop_adapter is requested not to close the session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3259 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 3260 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 3261 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3262 | |
| 3263 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 3264 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 3265 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 3266 | if (!hdd_is_any_interface_open(hdd_ctx)) |
| 3267 | hdd_psoc_idle_timer_start(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3268 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3269 | hdd_exit(); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 3270 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3271 | return 0; |
| 3272 | } |
| 3273 | |
| 3274 | /** |
| 3275 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 3276 | * @dev: pointer to net_device structure |
| 3277 | * |
| 3278 | * This is called in response to ifconfig down |
| 3279 | * |
| 3280 | * Return: 0 for success and error number for failure |
| 3281 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3282 | static int hdd_stop(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3283 | { |
| 3284 | int ret; |
| 3285 | |
| 3286 | cds_ssr_protect(__func__); |
| 3287 | ret = __hdd_stop(dev); |
| 3288 | cds_ssr_unprotect(__func__); |
| 3289 | |
| 3290 | return ret; |
| 3291 | } |
| 3292 | |
| 3293 | /** |
| 3294 | * __hdd_uninit() - HDD uninit function |
| 3295 | * @dev: Pointer to net_device structure |
| 3296 | * |
| 3297 | * This is called during the netdev unregister to uninitialize all data |
| 3298 | * associated with the device |
| 3299 | * |
| 3300 | * Return: None |
| 3301 | */ |
| 3302 | static void __hdd_uninit(struct net_device *dev) |
| 3303 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3304 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3305 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3306 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3307 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3308 | |
| 3309 | do { |
| 3310 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3311 | hdd_err("Invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3312 | break; |
| 3313 | } |
| 3314 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3315 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3316 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3317 | hdd_err("NULL hdd_ctx"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3318 | break; |
| 3319 | } |
| 3320 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3321 | if (dev != adapter->dev) |
| 3322 | hdd_err("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3323 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3324 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3325 | |
| 3326 | /* after uninit our adapter structure will no longer be valid */ |
| 3327 | adapter->dev = NULL; |
| 3328 | adapter->magic = 0; |
| 3329 | } while (0); |
| 3330 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3331 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3332 | } |
| 3333 | |
| 3334 | /** |
| 3335 | * hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 3336 | * @dev: pointer to net_device structure |
| 3337 | * |
| 3338 | * This is called during the netdev unregister to uninitialize all data |
| 3339 | * associated with the device |
| 3340 | * |
| 3341 | * Return: none |
| 3342 | */ |
| 3343 | static void hdd_uninit(struct net_device *dev) |
| 3344 | { |
| 3345 | cds_ssr_protect(__func__); |
| 3346 | __hdd_uninit(dev); |
| 3347 | cds_ssr_unprotect(__func__); |
| 3348 | } |
| 3349 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3350 | static int hdd_open_cesium_nl_sock(void) |
| 3351 | { |
| 3352 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3353 | struct netlink_kernel_cfg cfg = { |
| 3354 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 3355 | .input = NULL |
| 3356 | }; |
| 3357 | #endif |
| 3358 | int ret = 0; |
| 3359 | |
| 3360 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3361 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3362 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 3363 | THIS_MODULE, |
| 3364 | #endif |
| 3365 | &cfg); |
| 3366 | #else |
| 3367 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3368 | WLAN_NLINK_MCAST_GRP_ID, |
| 3369 | NULL, NULL, THIS_MODULE); |
| 3370 | #endif |
| 3371 | |
| 3372 | if (cesium_nl_srv_sock == NULL) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3373 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3374 | ret = -ECONNREFUSED; |
| 3375 | } |
| 3376 | |
| 3377 | return ret; |
| 3378 | } |
| 3379 | |
| 3380 | static void hdd_close_cesium_nl_sock(void) |
| 3381 | { |
| 3382 | if (NULL != cesium_nl_srv_sock) { |
| 3383 | netlink_kernel_release(cesium_nl_srv_sock); |
| 3384 | cesium_nl_srv_sock = NULL; |
| 3385 | } |
| 3386 | } |
| 3387 | |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3388 | void hdd_update_dynamic_mac(struct hdd_context *hdd_ctx, |
| 3389 | struct qdf_mac_addr *curr_mac_addr, |
| 3390 | struct qdf_mac_addr *new_mac_addr) |
| 3391 | { |
| 3392 | uint8_t i; |
| 3393 | |
| 3394 | hdd_enter(); |
| 3395 | |
| 3396 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3397 | if (!qdf_mem_cmp( |
| 3398 | curr_mac_addr->bytes, |
| 3399 | &hdd_ctx->dynamic_mac_list[i].dynamic_mac.bytes[0], |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3400 | sizeof(struct qdf_mac_addr))) { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3401 | qdf_mem_copy(&hdd_ctx->dynamic_mac_list[i].dynamic_mac, |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3402 | new_mac_addr->bytes, |
| 3403 | sizeof(struct qdf_mac_addr)); |
| 3404 | break; |
| 3405 | } |
| 3406 | } |
| 3407 | |
| 3408 | hdd_exit(); |
| 3409 | } |
| 3410 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3411 | /** |
| 3412 | * __hdd_set_mac_address() - set the user specified mac address |
| 3413 | * @dev: Pointer to the net device. |
| 3414 | * @addr: Pointer to the sockaddr. |
| 3415 | * |
| 3416 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3417 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3418 | * |
| 3419 | * Return: 0 for success, non zero for failure |
| 3420 | */ |
| 3421 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3422 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3423 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Ashish Kumar Dhanotiya | e533f6c | 2018-06-19 21:16:07 +0530 | [diff] [blame] | 3424 | struct hdd_adapter *adapter_temp; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3425 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3426 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3427 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3428 | int ret; |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3429 | struct qdf_mac_addr mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3430 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3431 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3432 | |
Hanumanth Reddy Pothula | 5c7a781 | 2018-03-09 12:55:32 +0530 | [diff] [blame] | 3433 | if (netif_running(dev)) { |
| 3434 | hdd_err("On iface up, set mac address change isn't supported"); |
| 3435 | return -EBUSY; |
| 3436 | } |
| 3437 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3438 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3439 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 3440 | if (0 != ret) |
| 3441 | return ret; |
| 3442 | |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3443 | 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] | 3444 | adapter_temp = hdd_get_adapter_by_macaddr(hdd_ctx, mac_addr.bytes); |
| 3445 | if (adapter_temp) { |
| 3446 | if (!qdf_str_cmp(adapter_temp->dev->name, dev->name)) |
| 3447 | return 0; |
| 3448 | hdd_err("%s adapter exist with same address " MAC_ADDRESS_STR, |
| 3449 | adapter_temp->dev->name, |
Ashish Kumar Dhanotiya | f974f33 | 2018-04-19 16:03:15 +0530 | [diff] [blame] | 3450 | MAC_ADDR_ARRAY(mac_addr.bytes)); |
| 3451 | return -EINVAL; |
| 3452 | } |
| 3453 | |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 3454 | qdf_ret_status = wlan_hdd_validate_mac_address(&mac_addr); |
| 3455 | if (QDF_IS_STATUS_ERROR(qdf_ret_status)) |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3456 | return -EINVAL; |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3457 | |
Ashish Kumar Dhanotiya | 8bfef12 | 2018-04-18 16:48:27 +0530 | [diff] [blame] | 3458 | hdd_info("Changing MAC to " MAC_ADDRESS_STR " of the interface %s ", |
| 3459 | MAC_ADDR_ARRAY(mac_addr.bytes), dev->name); |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3460 | |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3461 | hdd_update_dynamic_mac(hdd_ctx, &adapter->mac_addr, &mac_addr); |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3462 | memcpy(&adapter->mac_addr, psta_mac_addr->sa_data, ETH_ALEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3463 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 3464 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3465 | hdd_exit(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3466 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3467 | } |
| 3468 | |
| 3469 | /** |
| 3470 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
| 3471 | * function from SSR |
| 3472 | * @dev: pointer to net_device structure |
| 3473 | * @addr: Pointer to the sockaddr |
| 3474 | * |
| 3475 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3476 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3477 | * |
| 3478 | * Return: 0 for success. |
| 3479 | */ |
| 3480 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3481 | { |
| 3482 | int ret; |
| 3483 | |
| 3484 | cds_ssr_protect(__func__); |
| 3485 | ret = __hdd_set_mac_address(dev, addr); |
| 3486 | cds_ssr_unprotect(__func__); |
| 3487 | |
| 3488 | return ret; |
| 3489 | } |
| 3490 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3491 | static uint8_t *wlan_hdd_get_derived_intf_addr(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3492 | { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3493 | int i, j; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3494 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3495 | i = qdf_ffz(hdd_ctx->derived_intf_addr_mask); |
| 3496 | if (i < 0 || i >= hdd_ctx->num_derived_addr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3497 | return NULL; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3498 | qdf_atomic_set_bit(i, &hdd_ctx->derived_intf_addr_mask); |
| 3499 | hdd_info("Assigning MAC from derived list" MAC_ADDRESS_STR, |
| 3500 | MAC_ADDR_ARRAY(hdd_ctx->derived_mac_addr[i].bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3501 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3502 | /* Copy the mac in dynamic mac list at first free position */ |
| 3503 | for (j = 0; j < QDF_MAX_CONCURRENCY_PERSONA; j++) { |
| 3504 | if (qdf_is_macaddr_zero(&hdd_ctx-> |
| 3505 | dynamic_mac_list[j].dynamic_mac)) |
| 3506 | break; |
| 3507 | } |
| 3508 | if (j == QDF_MAX_CONCURRENCY_PERSONA) { |
| 3509 | hdd_err("Max interfaces are up"); |
| 3510 | return NULL; |
| 3511 | } |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 3512 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3513 | qdf_mem_copy(&hdd_ctx->dynamic_mac_list[j].dynamic_mac.bytes, |
| 3514 | &hdd_ctx->derived_mac_addr[i].bytes, |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3515 | sizeof(struct qdf_mac_addr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3516 | hdd_ctx->dynamic_mac_list[j].is_provisioned_mac = false; |
| 3517 | hdd_ctx->dynamic_mac_list[j].bit_position = i; |
| 3518 | |
| 3519 | return hdd_ctx->derived_mac_addr[i].bytes; |
| 3520 | } |
| 3521 | |
| 3522 | static uint8_t *wlan_hdd_get_provisioned_intf_addr(struct hdd_context *hdd_ctx) |
| 3523 | { |
| 3524 | int i, j; |
| 3525 | |
| 3526 | i = qdf_ffz(hdd_ctx->provisioned_intf_addr_mask); |
| 3527 | if (i < 0 || i >= hdd_ctx->num_provisioned_addr) |
| 3528 | return NULL; |
| 3529 | qdf_atomic_set_bit(i, &hdd_ctx->provisioned_intf_addr_mask); |
| 3530 | hdd_info("Assigning MAC from provisioned list" MAC_ADDRESS_STR, |
| 3531 | MAC_ADDR_ARRAY(hdd_ctx->provisioned_mac_addr[i].bytes)); |
| 3532 | |
| 3533 | /* Copy the mac in dynamic mac list at first free position */ |
| 3534 | for (j = 0; j < QDF_MAX_CONCURRENCY_PERSONA; j++) { |
| 3535 | if (qdf_is_macaddr_zero(&hdd_ctx-> |
| 3536 | dynamic_mac_list[j].dynamic_mac)) |
| 3537 | break; |
| 3538 | } |
| 3539 | if (j == QDF_MAX_CONCURRENCY_PERSONA) { |
| 3540 | hdd_err("Max interfaces are up"); |
| 3541 | return NULL; |
| 3542 | } |
| 3543 | |
| 3544 | qdf_mem_copy(&hdd_ctx->dynamic_mac_list[j].dynamic_mac.bytes, |
| 3545 | &hdd_ctx->provisioned_mac_addr[i].bytes, |
| 3546 | sizeof(struct qdf_mac_addr)); |
| 3547 | hdd_ctx->dynamic_mac_list[j].is_provisioned_mac = true; |
| 3548 | hdd_ctx->dynamic_mac_list[j].bit_position = i; |
| 3549 | return hdd_ctx->provisioned_mac_addr[i].bytes; |
| 3550 | } |
| 3551 | |
| 3552 | uint8_t *wlan_hdd_get_intf_addr(struct hdd_context *hdd_ctx, |
| 3553 | enum QDF_OPMODE interface_type) |
| 3554 | { |
| 3555 | uint8_t *mac_addr = NULL; |
| 3556 | |
| 3557 | if (qdf_atomic_test_bit(interface_type, |
| 3558 | (unsigned long *) |
| 3559 | (&hdd_ctx->config->provisioned_intf_pool))) |
| 3560 | mac_addr = wlan_hdd_get_provisioned_intf_addr(hdd_ctx); |
| 3561 | |
| 3562 | if ((!mac_addr) && |
| 3563 | (qdf_atomic_test_bit(interface_type, |
| 3564 | (unsigned long *) |
| 3565 | (&hdd_ctx->config->derived_intf_pool)))) |
| 3566 | mac_addr = wlan_hdd_get_derived_intf_addr(hdd_ctx); |
| 3567 | |
| 3568 | if (!mac_addr) |
| 3569 | hdd_err("MAC is not available in both the lists"); |
| 3570 | return mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3571 | } |
| 3572 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 3573 | void wlan_hdd_release_intf_addr(struct hdd_context *hdd_ctx, |
| 3574 | uint8_t *releaseAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3575 | { |
| 3576 | int i; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3577 | int mac_pos_in_mask; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3578 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3579 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3580 | if (!memcmp(releaseAddr, |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3581 | hdd_ctx->dynamic_mac_list[i].dynamic_mac.bytes, |
| 3582 | QDF_MAC_ADDR_SIZE)) { |
| 3583 | mac_pos_in_mask = |
| 3584 | hdd_ctx->dynamic_mac_list[i].bit_position; |
| 3585 | if (hdd_ctx->dynamic_mac_list[i].is_provisioned_mac) { |
| 3586 | qdf_atomic_clear_bit( |
| 3587 | mac_pos_in_mask, |
| 3588 | &hdd_ctx-> |
| 3589 | provisioned_intf_addr_mask); |
| 3590 | hdd_info("Releasing MAC from provisioned list"); |
| 3591 | hdd_info( |
| 3592 | MAC_ADDRESS_STR, |
| 3593 | MAC_ADDR_ARRAY(releaseAddr)); |
| 3594 | } else { |
| 3595 | qdf_atomic_clear_bit( |
| 3596 | mac_pos_in_mask, &hdd_ctx-> |
| 3597 | derived_intf_addr_mask); |
| 3598 | hdd_info("Releasing MAC from derived list"); |
| 3599 | hdd_info(MAC_ADDRESS_STR, |
| 3600 | MAC_ADDR_ARRAY(releaseAddr)); |
| 3601 | } |
| 3602 | qdf_zero_macaddr(&hdd_ctx-> |
| 3603 | dynamic_mac_list[i].dynamic_mac); |
| 3604 | hdd_ctx->dynamic_mac_list[i].is_provisioned_mac = |
| 3605 | false; |
| 3606 | hdd_ctx->dynamic_mac_list[i].bit_position = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3607 | break; |
| 3608 | } |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3609 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3610 | } |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3611 | if (i == QDF_MAX_CONCURRENCY_PERSONA) |
| 3612 | hdd_err("Releasing non existing MAC" MAC_ADDRESS_STR, |
| 3613 | MAC_ADDR_ARRAY(releaseAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3614 | } |
| 3615 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3616 | /** |
| 3617 | * __hdd_set_multicast_list() - set the multicast address list |
| 3618 | * @dev: Pointer to the WLAN device. |
| 3619 | * @skb: Pointer to OS packet (sk_buff). |
| 3620 | * |
| 3621 | * This funciton sets the multicast address list. |
| 3622 | * |
| 3623 | * Return: None |
| 3624 | */ |
| 3625 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 3626 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3627 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3628 | int i = 0, errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3629 | struct netdev_hw_addr *ha; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3630 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3631 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3632 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3633 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3634 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3635 | hdd_enter_dev(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3636 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3637 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 3638 | |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3639 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 3640 | if (errno) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3641 | goto out; |
| 3642 | |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3643 | errno = hdd_validate_adapter(adapter); |
| 3644 | if (errno) |
Dustin Brown | c788acb | 2017-08-01 17:43:51 -0700 | [diff] [blame] | 3645 | goto out; |
| 3646 | |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3647 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 3648 | hdd_err("%s: Driver module is closed", __func__); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3649 | goto out; |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3650 | } |
| 3651 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3652 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 3653 | if (!mc_list_request) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3654 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3655 | |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3656 | /* Delete already configured multicast address list */ |
| 3657 | if (adapter->mc_addr_list.mc_cnt > 0) { |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3658 | hdd_debug("clear previously configured MC address list"); |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3659 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3660 | pmo_mc_list_change_notify); |
| 3661 | } |
| 3662 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3663 | if (dev->flags & IFF_ALLMULTI) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3664 | hdd_debug("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3665 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3666 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3667 | } else { |
| 3668 | mc_count = netdev_mc_count(dev); |
Wu Gao | d7dd6e4 | 2018-10-16 17:22:56 +0800 | [diff] [blame] | 3669 | if (mc_count > ucfg_pmo_max_mc_addr_supported(psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3670 | hdd_debug("Exceeded max MC filter addresses (%d). Allowing all MC frames by disabling MC address filtering", |
Wu Gao | d7dd6e4 | 2018-10-16 17:22:56 +0800 | [diff] [blame] | 3671 | ucfg_pmo_max_mc_addr_supported(psoc)); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3672 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3673 | pmo_mc_list_change_notify); |
stonez | df2bdfd | 2018-11-20 14:45:06 +0800 | [diff] [blame] | 3674 | adapter->mc_addr_list.mc_cnt = 0; |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3675 | goto free_req; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3676 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3677 | netdev_for_each_mc_addr(ha, dev) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3678 | hdd_debug("ha_addr[%d] "MAC_ADDRESS_STR, |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 3679 | i, MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3680 | if (i == mc_count) |
| 3681 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3682 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 3683 | 0, ETH_ALEN); |
| 3684 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 3685 | ha->addr, ETH_ALEN); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3686 | hdd_debug("mlist[%d] = %pM", i, |
| 3687 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3688 | i++; |
| 3689 | } |
| 3690 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3691 | |
stonez | df2bdfd | 2018-11-20 14:45:06 +0800 | [diff] [blame] | 3692 | adapter->mc_addr_list.mc_cnt = mc_count; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3693 | mc_list_request->psoc = psoc; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3694 | mc_list_request->vdev_id = adapter->session_id; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3695 | mc_list_request->count = mc_count; |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3696 | |
| 3697 | errno = hdd_cache_mc_addr_list(mc_list_request); |
| 3698 | if (errno) { |
| 3699 | hdd_err("Failed to cache MC address list for vdev %u; errno:%d", |
| 3700 | adapter->session_id, errno); |
| 3701 | goto free_req; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3702 | } |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3703 | |
| 3704 | hdd_enable_mc_addr_filtering(adapter, pmo_mc_list_change_notify); |
| 3705 | |
| 3706 | free_req: |
| 3707 | qdf_mem_free(mc_list_request); |
| 3708 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3709 | out: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3710 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3711 | } |
| 3712 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3713 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3714 | /** |
| 3715 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
| 3716 | * @dev: pointer to net_device |
| 3717 | * |
| 3718 | * Return: none |
| 3719 | */ |
| 3720 | static void hdd_set_multicast_list(struct net_device *dev) |
| 3721 | { |
| 3722 | cds_ssr_protect(__func__); |
| 3723 | __hdd_set_multicast_list(dev); |
| 3724 | cds_ssr_unprotect(__func__); |
| 3725 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3726 | |
| 3727 | /** |
| 3728 | * hdd_select_queue() - used by Linux OS to decide which queue to use first |
| 3729 | * @dev: Pointer to the WLAN device. |
| 3730 | * @skb: Pointer to OS packet (sk_buff). |
| 3731 | * |
| 3732 | * This function is registered with the Linux OS for network |
| 3733 | * core to decide which queue to use first. |
| 3734 | * |
| 3735 | * Return: ac, Queue Index/access category corresponding to UP in IP header |
| 3736 | */ |
| 3737 | static uint16_t hdd_select_queue(struct net_device *dev, struct sk_buff *skb |
| 3738 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) |
| 3739 | , void *accel_priv |
| 3740 | #endif |
| 3741 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 3742 | , select_queue_fallback_t fallback |
| 3743 | #endif |
| 3744 | ) |
| 3745 | { |
| 3746 | return hdd_wmm_select_queue(dev, skb); |
| 3747 | } |
| 3748 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3749 | static const struct net_device_ops wlan_drv_ops = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3750 | .ndo_open = hdd_open, |
| 3751 | .ndo_stop = hdd_stop, |
| 3752 | .ndo_uninit = hdd_uninit, |
| 3753 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 3754 | .ndo_tx_timeout = hdd_tx_timeout, |
| 3755 | .ndo_get_stats = hdd_get_stats, |
| 3756 | .ndo_do_ioctl = hdd_ioctl, |
| 3757 | .ndo_set_mac_address = hdd_set_mac_address, |
| 3758 | .ndo_select_queue = hdd_select_queue, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3759 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3760 | }; |
| 3761 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 3762 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3763 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3764 | static const struct net_device_ops wlan_mon_drv_ops = { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3765 | .ndo_open = hdd_mon_open, |
| 3766 | .ndo_stop = hdd_stop, |
| 3767 | .ndo_get_stats = hdd_get_stats, |
| 3768 | }; |
| 3769 | |
| 3770 | /** |
| 3771 | * hdd_set_station_ops() - update net_device ops for monitor mode |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3772 | * @dev: Handle to struct net_device to be updated. |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3773 | * Return: None |
| 3774 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3775 | void hdd_set_station_ops(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3776 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3777 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3778 | dev->netdev_ops = &wlan_mon_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3779 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3780 | dev->netdev_ops = &wlan_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3781 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 3782 | #else |
| 3783 | void hdd_set_station_ops(struct net_device *dev) |
| 3784 | { |
| 3785 | dev->netdev_ops = &wlan_drv_ops; |
| 3786 | } |
| 3787 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3788 | |
| 3789 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3790 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 3791 | * @hdd_ctx: global hdd context |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3792 | * @mac_addr: mac address to assign to the interface |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3793 | * @name: User-visible name of the interface |
| 3794 | * |
| 3795 | * hdd adapter pointer would point to the netdev->priv space, this function |
Jeff Johnson | 6201829 | 2018-05-06 16:18:35 -0700 | [diff] [blame] | 3796 | * would retrieve the pointer, and setup the hdd adapter configuration. |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3797 | * |
| 3798 | * Return: the pointer to hdd adapter, otherwise NULL |
| 3799 | */ |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3800 | static struct hdd_adapter * |
| 3801 | hdd_alloc_station_adapter(struct hdd_context *hdd_ctx, tSirMacAddr mac_addr, |
| 3802 | unsigned char name_assign_type, const char *name) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3803 | { |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3804 | struct net_device *dev; |
| 3805 | struct hdd_adapter *adapter; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 3806 | struct hdd_station_ctx *sta_ctx; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3807 | QDF_STATUS qdf_status; |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 3808 | void *soc; |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3809 | |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 3810 | soc = cds_get_context(QDF_MODULE_ID_SOC); |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3811 | /* cfg80211 initialization and registration */ |
| 3812 | dev = alloc_netdev_mq(sizeof(*adapter), name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3813 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3814 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3815 | #endif |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3816 | (cds_get_conparam() == QDF_GLOBAL_MONITOR_MODE ? |
| 3817 | hdd_mon_mode_ether_setup : ether_setup), |
| 3818 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3819 | |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3820 | if (!dev) { |
| 3821 | hdd_err("Failed to allocate new net_device '%s'", name); |
| 3822 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3823 | } |
| 3824 | |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3825 | adapter = netdev_priv(dev); |
| 3826 | |
| 3827 | qdf_mem_zero(adapter, sizeof(*adapter)); |
| 3828 | sta_ctx = &adapter->session.station; |
| 3829 | qdf_mem_set(sta_ctx->conn_info.staId, sizeof(sta_ctx->conn_info.staId), |
| 3830 | HDD_WLAN_INVALID_STA_ID); |
| 3831 | adapter->dev = dev; |
| 3832 | adapter->hdd_ctx = hdd_ctx; |
| 3833 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
| 3834 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3835 | |
| 3836 | qdf_status = qdf_event_create(&adapter->qdf_session_open_event); |
| 3837 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 3838 | goto free_net_dev; |
| 3839 | |
| 3840 | qdf_status = qdf_event_create(&adapter->qdf_session_close_event); |
| 3841 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 3842 | goto free_net_dev; |
| 3843 | |
| 3844 | adapter->offloads_configured = false; |
| 3845 | adapter->is_link_up_service_needed = false; |
| 3846 | adapter->disconnection_in_progress = false; |
| 3847 | adapter->send_mode_change = true; |
| 3848 | |
| 3849 | /* Init the net_device structure */ |
| 3850 | strlcpy(dev->name, name, IFNAMSIZ); |
| 3851 | |
| 3852 | qdf_mem_copy(dev->dev_addr, mac_addr, sizeof(tSirMacAddr)); |
| 3853 | qdf_mem_copy(adapter->mac_addr.bytes, mac_addr, sizeof(tSirMacAddr)); |
| 3854 | dev->watchdog_timeo = HDD_TX_TIMEOUT; |
| 3855 | |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 3856 | if (cdp_cfg_get(soc, |
| 3857 | cfg_dp_enable_ip_tcp_udp_checksum_offload)) |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3858 | dev->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
| 3859 | dev->features |= NETIF_F_RXCSUM; |
| 3860 | |
| 3861 | hdd_set_tso_flags(hdd_ctx, dev); |
| 3862 | hdd_set_station_ops(adapter->dev); |
| 3863 | |
| 3864 | hdd_dev_setup_destructor(dev); |
| 3865 | dev->ieee80211_ptr = &adapter->wdev; |
| 3866 | dev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
| 3867 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
| 3868 | adapter->wdev.netdev = dev; |
| 3869 | |
| 3870 | /* set dev's parent to underlying device */ |
| 3871 | SET_NETDEV_DEV(dev, hdd_ctx->parent_dev); |
| 3872 | hdd_wmm_init(adapter); |
| 3873 | spin_lock_init(&adapter->pause_map_lock); |
| 3874 | adapter->start_time = qdf_system_ticks(); |
| 3875 | adapter->last_time = adapter->start_time; |
| 3876 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3877 | return adapter; |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3878 | |
| 3879 | free_net_dev: |
| 3880 | free_netdev(adapter->dev); |
| 3881 | |
| 3882 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3883 | } |
| 3884 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3885 | 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] | 3886 | { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3887 | struct net_device *dev = adapter->dev; |
| 3888 | int ret; |
| 3889 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 3890 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3891 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3892 | if (rtnl_held) { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3893 | if (strnchr(dev->name, IFNAMSIZ - 1, '%')) { |
| 3894 | |
| 3895 | ret = dev_alloc_name(dev, dev->name); |
| 3896 | if (ret < 0) { |
| 3897 | hdd_err( |
| 3898 | "unable to get dev name: %s, err = 0x%x", |
| 3899 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3900 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3901 | } |
| 3902 | } |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3903 | |
| 3904 | ret = register_netdevice(dev); |
| 3905 | if (ret) { |
| 3906 | hdd_err("register_netdevice(%s) failed, err = 0x%x", |
| 3907 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3908 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3909 | } |
| 3910 | } else { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3911 | ret = register_netdev(dev); |
| 3912 | if (ret) { |
| 3913 | hdd_err("register_netdev(%s) failed, err = 0x%x", |
| 3914 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3915 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3916 | } |
| 3917 | } |
| 3918 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 3919 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3920 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3921 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3922 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3923 | } |
| 3924 | |
Pragaspathi Thilagaraj | 3551caa | 2018-09-26 15:52:56 +0530 | [diff] [blame] | 3925 | QDF_STATUS hdd_sme_open_session_callback(uint8_t session_id, |
| 3926 | QDF_STATUS qdf_status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3927 | { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3928 | struct hdd_adapter *adapter; |
| 3929 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3930 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3931 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3932 | if (!hdd_ctx) { |
| 3933 | hdd_err("Invalid HDD_CTX"); |
| 3934 | return QDF_STATUS_E_FAILURE; |
| 3935 | } |
| 3936 | |
| 3937 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 3938 | if (NULL == adapter) { |
Naveen Rawat | 23a3b91 | 2018-05-30 17:45:52 -0700 | [diff] [blame] | 3939 | hdd_err("NULL adapter for %d", session_id); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3940 | return QDF_STATUS_E_INVAL; |
| 3941 | } |
Pragaspathi Thilagaraj | 3551caa | 2018-09-26 15:52:56 +0530 | [diff] [blame] | 3942 | |
| 3943 | if (qdf_status == QDF_STATUS_SUCCESS) |
| 3944 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3945 | |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3946 | qdf_event_set(&adapter->qdf_session_open_event); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3947 | hdd_debug("session %d opened", adapter->session_id); |
| 3948 | |
| 3949 | return QDF_STATUS_SUCCESS; |
| 3950 | } |
| 3951 | |
| 3952 | QDF_STATUS hdd_sme_close_session_callback(uint8_t session_id) |
| 3953 | { |
| 3954 | struct hdd_adapter *adapter; |
| 3955 | struct hdd_context *hdd_ctx; |
| 3956 | |
| 3957 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3958 | if (!hdd_ctx) { |
| 3959 | hdd_err("Invalid HDD_CTX"); |
| 3960 | return QDF_STATUS_E_FAILURE; |
| 3961 | } |
| 3962 | |
| 3963 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3964 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3965 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3966 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3967 | } |
| 3968 | |
| 3969 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3970 | hdd_err("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3971 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3972 | } |
| 3973 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3974 | /* |
| 3975 | * For NAN Data interface, the close session results in the final |
| 3976 | * indication to the userspace |
| 3977 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 3978 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3979 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3980 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3981 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3982 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3983 | /* |
| 3984 | * We can be blocked while waiting for scheduled work to be |
| 3985 | * flushed, and the adapter structure can potentially be freed, in |
| 3986 | * which case the magic will have been reset. So make sure the |
| 3987 | * magic is still good, and hence the adapter structure is still |
| 3988 | * valid, before signaling completion |
| 3989 | */ |
| 3990 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3991 | qdf_event_set(&adapter->qdf_session_close_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3992 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3993 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3994 | } |
| 3995 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3996 | int hdd_vdev_ready(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3997 | { |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 3998 | struct wlan_objmgr_vdev *vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3999 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4000 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4001 | vdev = hdd_objmgr_get_vdev(adapter); |
| 4002 | if (!vdev) |
| 4003 | return -EINVAL; |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 4004 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4005 | status = pmo_vdev_ready(vdev); |
| 4006 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4007 | hdd_objmgr_put_vdev(adapter); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 4008 | return qdf_status_to_os_return(status); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4009 | } |
| 4010 | |
| 4011 | status = ucfg_reg_11d_vdev_created_update(vdev); |
| 4012 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4013 | hdd_objmgr_put_vdev(adapter); |
| 4014 | return qdf_status_to_os_return(status); |
| 4015 | } |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 4016 | |
| 4017 | if (wma_capability_enhanced_mcast_filter()) |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4018 | status = ucfg_pmo_enhanced_mc_filter_enable(vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 4019 | else |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4020 | status = ucfg_pmo_enhanced_mc_filter_disable(vdev); |
| 4021 | |
| 4022 | hdd_objmgr_put_vdev(adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4023 | |
| 4024 | return qdf_status_to_os_return(status); |
| 4025 | } |
| 4026 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4027 | int hdd_vdev_destroy(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4028 | { |
| 4029 | QDF_STATUS status; |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4030 | int errno; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4031 | struct hdd_context *hdd_ctx; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4032 | uint8_t vdev_id; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4033 | struct wlan_objmgr_vdev *vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4034 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4035 | vdev_id = adapter->session_id; |
| 4036 | hdd_info("destroying vdev %d", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4037 | |
| 4038 | /* vdev created sanity check */ |
| 4039 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4040 | hdd_err("vdev %u does not exist", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4041 | return -EINVAL; |
| 4042 | } |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4043 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4044 | vdev = hdd_objmgr_get_vdev(adapter); |
| 4045 | if (!vdev) |
| 4046 | return -EINVAL; |
Ashish Kumar Dhanotiya | 68ee2e4 | 2018-11-19 21:15:14 +0530 | [diff] [blame] | 4047 | |
| 4048 | ucfg_pmo_del_wow_pattern(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4049 | status = ucfg_reg_11d_vdev_delete_update(vdev); |
Abhishek Singh | 935e477 | 2018-11-21 14:14:10 +0530 | [diff] [blame] | 4050 | ucfg_scan_vdev_set_disable(vdev, REASON_VDEV_DOWN); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4051 | hdd_objmgr_put_vdev(adapter); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 4052 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4053 | /* close sme session (destroy vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4054 | qdf_event_reset(&adapter->qdf_session_close_event); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4055 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4056 | status = sme_close_session(hdd_ctx->mac_handle, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4057 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4058 | hdd_err("failed to close sme session; status:%d", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 4059 | goto release_vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4060 | } |
| 4061 | |
| 4062 | /* block on a completion variable until sme session is closed */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4063 | status = qdf_wait_for_event_completion( |
| 4064 | &adapter->qdf_session_close_event, |
Abhishek Singh | 13bf0ce | 2018-10-24 14:26:14 +0530 | [diff] [blame] | 4065 | SME_CMD_VDEV_CREATE_DELETE_TIMEOUT); |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4066 | |
| 4067 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4068 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 4069 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4070 | if (adapter->device_mode == QDF_NDI_MODE) |
| 4071 | hdd_ndp_session_end_handler(adapter); |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4072 | |
| 4073 | if (status == QDF_STATUS_E_TIMEOUT) |
| 4074 | hdd_err("timed out waiting for sme close session"); |
| 4075 | else if (adapter->qdf_session_close_event.force_set) |
| 4076 | hdd_info("SSR occurred during sme close session"); |
| 4077 | else |
| 4078 | hdd_err("failed to wait for sme close session; status:%u", |
| 4079 | status); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4080 | } |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 4081 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 4082 | release_vdev: |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 4083 | |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4084 | /* do vdev logical destroy via objmgr */ |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 4085 | errno = hdd_objmgr_release_and_destroy_vdev(adapter); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4086 | if (errno) { |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 4087 | hdd_err("failed to destroy objmgr vdev; errno:%d", errno); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4088 | return errno; |
| 4089 | } |
| 4090 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4091 | hdd_info("vdev %d destroyed successfully", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4092 | |
| 4093 | return 0; |
| 4094 | } |
| 4095 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4096 | static int hdd_set_sme_session_param(struct hdd_adapter *adapter, |
| 4097 | struct sme_session_params *session_param, |
Jeff Johnson | 6a18c96 | 2018-07-01 09:09:37 -0700 | [diff] [blame] | 4098 | csr_roam_complete_cb callback, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4099 | void *callback_ctx) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4100 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4101 | uint32_t type; |
| 4102 | uint32_t sub_type; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4103 | QDF_STATUS status; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4104 | |
| 4105 | /* determine vdev (sub)type */ |
| 4106 | status = cds_get_vdev_types(adapter->device_mode, &type, &sub_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4107 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4108 | hdd_err("failed to get vdev type: %d", status); |
| 4109 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4110 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4111 | session_param->sme_session_id = adapter->session_id; |
| 4112 | session_param->self_mac_addr = (uint8_t *)&adapter->mac_addr; |
| 4113 | session_param->type_of_persona = type; |
| 4114 | session_param->subtype_of_persona = sub_type; |
| 4115 | session_param->session_open_cb = hdd_sme_open_session_callback; |
| 4116 | session_param->session_close_cb = hdd_sme_close_session_callback; |
| 4117 | session_param->callback = callback; |
| 4118 | session_param->callback_ctx = callback_ctx; |
| 4119 | |
| 4120 | return 0; |
| 4121 | } |
| 4122 | |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4123 | static void |
| 4124 | hdd_store_nss_chains_cfg_in_vdev(struct hdd_adapter *adapter) |
| 4125 | { |
| 4126 | struct wlan_mlme_nss_chains vdev_ini_cfg; |
| 4127 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 4128 | |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 4129 | /* Populate the nss chain params from ini for this vdev type */ |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4130 | sme_populate_nss_chain_params(hdd_ctx->mac_handle, &vdev_ini_cfg, |
| 4131 | adapter->device_mode, |
| 4132 | hdd_ctx->num_rf_chains); |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 4133 | |
| 4134 | /* Store the nss chain config into the vdev */ |
| 4135 | sme_store_nss_chains_cfg_in_vdev(adapter->vdev, &vdev_ini_cfg); |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4136 | } |
gaurank kathpalia | 6982d47 | 2018-10-31 21:54:15 +0530 | [diff] [blame] | 4137 | |
| 4138 | bool hdd_is_vdev_in_conn_state(struct hdd_adapter *adapter) |
| 4139 | { |
| 4140 | switch (adapter->device_mode) { |
| 4141 | case QDF_STA_MODE: |
| 4142 | case QDF_P2P_CLIENT_MODE: |
| 4143 | case QDF_P2P_DEVICE_MODE: |
| 4144 | return hdd_conn_is_connected( |
| 4145 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)); |
| 4146 | case QDF_SAP_MODE: |
| 4147 | case QDF_P2P_GO_MODE: |
| 4148 | return (test_bit(SOFTAP_BSS_STARTED, |
| 4149 | &adapter->event_flags)); |
| 4150 | default: |
| 4151 | hdd_err("Device mode %d invalid", adapter->device_mode); |
| 4152 | return 0; |
| 4153 | } |
| 4154 | |
| 4155 | return 0; |
| 4156 | } |
| 4157 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4158 | int hdd_vdev_create(struct hdd_adapter *adapter, |
Jeff Johnson | 6a18c96 | 2018-07-01 09:09:37 -0700 | [diff] [blame] | 4159 | csr_roam_complete_cb callback, void *ctx) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4160 | { |
| 4161 | QDF_STATUS status; |
| 4162 | int errno; |
Karthik Kantamneni | 9180c75 | 2018-11-14 12:14:17 +0530 | [diff] [blame] | 4163 | bool bval; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4164 | struct hdd_context *hdd_ctx; |
| 4165 | struct sme_session_params sme_session_params = {0}; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4166 | struct wlan_objmgr_vdev *vdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4167 | |
| 4168 | hdd_info("creating new vdev"); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4169 | |
| 4170 | /* do vdev create via objmgr */ |
| 4171 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 4172 | errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->pdev, adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4173 | if (errno) { |
| 4174 | hdd_err("failed to create objmgr vdev: %d", errno); |
| 4175 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4176 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4177 | |
| 4178 | /* Open a SME session (prepare vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4179 | status = qdf_event_reset(&adapter->qdf_session_open_event); |
| 4180 | if (QDF_STATUS_SUCCESS != status) { |
| 4181 | hdd_err("failed to reinit session open event"); |
| 4182 | return -EINVAL; |
| 4183 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4184 | errno = hdd_set_sme_session_param(adapter, &sme_session_params, |
| 4185 | callback, ctx); |
| 4186 | if (errno) { |
| 4187 | hdd_err("failed to populating SME params"); |
| 4188 | goto objmgr_vdev_destroy_procedure; |
| 4189 | } |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4190 | status = sme_open_session(hdd_ctx->mac_handle, &sme_session_params); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4191 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4192 | hdd_err("failed to open sme session: %d", status); |
| 4193 | errno = qdf_status_to_os_return(status); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4194 | goto objmgr_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4195 | } |
| 4196 | |
| 4197 | /* block on a completion variable until sme session is opened */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4198 | status = qdf_wait_for_event_completion(&adapter->qdf_session_open_event, |
Abhishek Singh | 13bf0ce | 2018-10-24 14:26:14 +0530 | [diff] [blame] | 4199 | SME_CMD_VDEV_CREATE_DELETE_TIMEOUT); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4200 | if (QDF_STATUS_SUCCESS != status) { |
| 4201 | if (adapter->qdf_session_open_event.force_set) { |
| 4202 | /* |
| 4203 | * SSR/PDR has caused shutdown, which has forcefully |
| 4204 | * set the event. Return without the closing session. |
| 4205 | */ |
| 4206 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 4207 | hdd_err("Session open event forcefully set"); |
| 4208 | return -EINVAL; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4209 | } |
Jeff Johnson | c66d310 | 2018-02-28 11:58:26 -0800 | [diff] [blame] | 4210 | |
| 4211 | if (QDF_STATUS_E_TIMEOUT == status) |
| 4212 | hdd_err("Session failed to open within timeout period"); |
| 4213 | else |
| 4214 | hdd_err("Failed to wait for session open event(status-%d)", |
| 4215 | status); |
| 4216 | errno = -ETIMEDOUT; |
| 4217 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 4218 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4219 | } |
| 4220 | |
Pragaspathi Thilagaraj | 3551caa | 2018-09-26 15:52:56 +0530 | [diff] [blame] | 4221 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 4222 | hdd_err("Session failed to open due to vdev create failure"); |
| 4223 | errno = -EINVAL; |
| 4224 | goto objmgr_vdev_destroy_procedure; |
| 4225 | } |
| 4226 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4227 | /* firmware ready for component communication, raise vdev_ready event */ |
| 4228 | errno = hdd_vdev_ready(adapter); |
| 4229 | if (errno) { |
| 4230 | hdd_err("failed to dispatch vdev ready event: %d", errno); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4231 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4232 | } |
| 4233 | |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 4234 | if (adapter->device_mode == QDF_STA_MODE) { |
Karthik Kantamneni | 9180c75 | 2018-11-14 12:14:17 +0530 | [diff] [blame] | 4235 | bval = false; |
| 4236 | status = ucfg_mlme_get_rtt_mac_randomization(hdd_ctx->psoc, |
| 4237 | &bval); |
| 4238 | if (QDF_IS_STATUS_ERROR(status)) |
| 4239 | hdd_err("unable to get RTT MAC randomization value"); |
| 4240 | |
| 4241 | hdd_debug("setting RTT mac randomization param: %d", bval); |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 4242 | errno = sme_cli_set_command(adapter->session_id, |
| 4243 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_INITIATOR_RANDOM_MAC, |
Karthik Kantamneni | 9180c75 | 2018-11-14 12:14:17 +0530 | [diff] [blame] | 4244 | bval, |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 4245 | VDEV_CMD); |
| 4246 | if (0 != errno) |
| 4247 | hdd_err("RTT mac randomization param set failed %d", |
| 4248 | errno); |
| 4249 | } |
| 4250 | |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 4251 | if (adapter->device_mode == QDF_STA_MODE || |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4252 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
| 4253 | vdev = hdd_objmgr_get_vdev(adapter); |
| 4254 | if (!vdev) |
| 4255 | goto hdd_vdev_destroy_procedure; |
| 4256 | wlan_vdev_set_max_peer_count(vdev, HDD_MAX_VDEV_PEER_COUNT); |
| 4257 | hdd_objmgr_put_vdev(adapter); |
| 4258 | } |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 4259 | |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4260 | hdd_store_nss_chains_cfg_in_vdev(adapter); |
| 4261 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4262 | hdd_info("vdev %d created successfully", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4263 | |
| 4264 | return 0; |
| 4265 | |
| 4266 | /* |
| 4267 | * Due to legacy constraints, we need to destroy in the same order as |
| 4268 | * create. So, split error handling into 2 cases to accommodate. |
| 4269 | */ |
| 4270 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4271 | objmgr_vdev_destroy_procedure: |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 4272 | QDF_BUG(!hdd_objmgr_release_and_destroy_vdev(adapter)); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4273 | |
| 4274 | return errno; |
| 4275 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4276 | hdd_vdev_destroy_procedure: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4277 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
| 4278 | |
| 4279 | return errno; |
| 4280 | } |
| 4281 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4282 | QDF_STATUS hdd_init_station_mode(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4283 | { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 4284 | struct hdd_station_ctx *sta_ctx = &adapter->session.station; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4285 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4286 | QDF_STATUS status; |
| 4287 | int ret_val; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4288 | mac_handle_t mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4289 | bool bval = false; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4290 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4291 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4292 | mac_handle = hdd_ctx->mac_handle; |
| 4293 | sme_set_curr_device_mode(mac_handle, adapter->device_mode); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4294 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 4295 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 4296 | hdd_err("unable to get vht_enable2x2"); |
| 4297 | sme_set_pdev_ht_vht_ies(mac_handle, bval); |
| 4298 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4299 | sme_set_vdev_ies_per_band(mac_handle, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4300 | |
Jeff Johnson | 7f2c591 | 2018-03-23 11:42:28 -0700 | [diff] [blame] | 4301 | hdd_roam_profile_init(adapter); |
| 4302 | hdd_register_wext(adapter->dev); |
| 4303 | |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 4304 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4305 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4306 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 4307 | sizeof(sta_ctx->conn_info.staId), HDD_WLAN_INVALID_STA_ID); |
Hanumanth Reddy Pothula | b2d729c | 2017-05-30 11:49:53 +0530 | [diff] [blame] | 4308 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 4309 | /* set fast roaming capability in sme session */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4310 | status = sme_config_fast_roaming(mac_handle, adapter->session_id, |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 4311 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4312 | /* Set the default operation channel */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4313 | sta_ctx->conn_info.operationChannel = |
Vignesh Viswanathan | a0358ff | 2018-11-27 09:53:07 +0530 | [diff] [blame] | 4314 | hdd_ctx->config->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4315 | |
| 4316 | /* Make the default Auth Type as OPEN */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4317 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4318 | |
| 4319 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4320 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4321 | hdd_err("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4322 | status, status); |
| 4323 | goto error_init_txrx; |
| 4324 | } |
| 4325 | |
| 4326 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4327 | |
| 4328 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4329 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4330 | hdd_err("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4331 | status, status); |
| 4332 | goto error_wmm_init; |
| 4333 | } |
| 4334 | |
| 4335 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4336 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4337 | ret_val = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4338 | WMI_PDEV_PARAM_BURST_ENABLE, |
Dundi Raviteja | 3aa01be | 2018-05-21 18:58:59 +0530 | [diff] [blame] | 4339 | HDD_ENABLE_SIFS_BURST_DEFAULT, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4340 | PDEV_CMD); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4341 | if (ret_val) |
| 4342 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", ret_val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4343 | |
Poddar, Siddarth | 4b3f731 | 2017-11-02 17:00:20 +0530 | [diff] [blame] | 4344 | /* |
| 4345 | * In case of USB tethering, LRO is disabled. If SSR happened |
| 4346 | * during that time, then as part of SSR init, do not enable |
| 4347 | * the LRO again. Keep the LRO state same as before SSR. |
| 4348 | */ |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 4349 | if (cdp_cfg_get(cds_get_context(QDF_MODULE_ID_SOC), |
| 4350 | cfg_dp_lro_enable) && |
| 4351 | !(qdf_atomic_read(&hdd_ctx->vendor_disable_lro_flag))) |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 4352 | adapter->dev->features |= NETIF_F_LRO; |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 4353 | |
| 4354 | /* rcpi info initialization */ |
| 4355 | qdf_mem_zero(&adapter->rcpi, sizeof(adapter->rcpi)); |
| 4356 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4357 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4358 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4359 | error_wmm_init: |
| 4360 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4361 | hdd_deinit_tx_rx(adapter); |
| 4362 | error_init_txrx: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4363 | hdd_unregister_wext(adapter->dev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4364 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4365 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4366 | return status; |
| 4367 | } |
| 4368 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4369 | /** |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4370 | * hdd_deinit_station_mode() - De-initialize the station adapter |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4371 | * @hdd_ctx: global hdd context |
| 4372 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4373 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 4374 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4375 | * |
| 4376 | * This function De-initializes the STA/P2P/OCB adapter. |
| 4377 | * |
| 4378 | * Return: None. |
| 4379 | */ |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4380 | static void hdd_deinit_station_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4381 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4382 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4383 | { |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4384 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4385 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 4386 | if (adapter->dev) { |
| 4387 | if (rtnl_held) |
| 4388 | adapter->dev->wireless_handlers = NULL; |
| 4389 | else { |
| 4390 | rtnl_lock(); |
| 4391 | adapter->dev->wireless_handlers = NULL; |
| 4392 | rtnl_unlock(); |
| 4393 | } |
| 4394 | } |
| 4395 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4396 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 4397 | hdd_deinit_tx_rx(adapter); |
| 4398 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4399 | } |
| 4400 | |
| 4401 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 4402 | hdd_wmm_adapter_close(adapter); |
| 4403 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4404 | } |
| 4405 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4406 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4407 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4408 | } |
| 4409 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4410 | void hdd_deinit_adapter(struct hdd_context *hdd_ctx, |
| 4411 | struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4412 | bool rtnl_held) |
| 4413 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4414 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4415 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4416 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4417 | case QDF_STA_MODE: |
| 4418 | case QDF_P2P_CLIENT_MODE: |
| 4419 | case QDF_P2P_DEVICE_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4420 | case QDF_IBSS_MODE: |
| 4421 | case QDF_NDI_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4422 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4423 | hdd_deinit_station_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4424 | break; |
| 4425 | } |
| 4426 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4427 | case QDF_SAP_MODE: |
| 4428 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4429 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4430 | hdd_deinit_ap_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4431 | break; |
| 4432 | } |
| 4433 | |
| 4434 | default: |
| 4435 | break; |
| 4436 | } |
| 4437 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4438 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4439 | } |
| 4440 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4441 | static void hdd_cleanup_adapter(struct hdd_context *hdd_ctx, |
| 4442 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4443 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4444 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4445 | struct net_device *dev = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4446 | |
| 4447 | if (adapter) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4448 | dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4449 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4450 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4451 | return; |
| 4452 | } |
| 4453 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4454 | hdd_nud_deinit_tracking(adapter); |
| 4455 | qdf_mutex_destroy(&adapter->disconnection_status_lock); |
Nachiket Kukade | 5f0ce4f | 2018-06-15 19:47:37 +0530 | [diff] [blame] | 4456 | hdd_apf_context_destroy(adapter); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4457 | qdf_spinlock_destroy(&adapter->vdev_lock); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4458 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 4459 | wlan_hdd_debugfs_csr_deinit(adapter); |
Arunk Khandavalli | ca56d4b | 2018-11-29 15:46:00 +0530 | [diff] [blame] | 4460 | if (adapter->device_mode == QDF_STA_MODE) |
| 4461 | hdd_sysfs_destroy_adapter_root_obj(adapter); |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 4462 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4463 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 4464 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4465 | /* |
| 4466 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 4467 | * the driver is almost closed and cannot handle either control |
| 4468 | * messages or data. However, unregister_netdevice() call above will |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4469 | * eventually invoke hdd_stop(ndo_close) driver callback, which attempts |
| 4470 | * to close the active connections(basically excites control path) which |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4471 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 4472 | * the interface is closed and restricts any operations on that |
| 4473 | */ |
| 4474 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 4475 | |
| 4476 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4477 | if (rtnl_held) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4478 | unregister_netdevice(dev); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4479 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4480 | unregister_netdev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4481 | /* |
| 4482 | * Note that the adapter is no longer valid at this point |
| 4483 | * since the memory has been reclaimed |
| 4484 | */ |
| 4485 | } |
| 4486 | } |
| 4487 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4488 | 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] | 4489 | tSirMacAddr macAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4490 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4491 | struct hdd_adapter *adapter; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4492 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4493 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 4494 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 4495 | macAddr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4496 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4497 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4498 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4499 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4500 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4501 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4502 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4503 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 4504 | /** |
| 4505 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 4506 | * @hdd_ctx: HDD Context |
| 4507 | * @adapter: HDD Adapter |
| 4508 | * |
| 4509 | * This function set the FW Debug log level based on the INI. |
| 4510 | * |
| 4511 | * Return: None |
| 4512 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4513 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4514 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4515 | { |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4516 | QDF_STATUS status; |
| 4517 | uint16_t enable_fw_log_level, enable_fw_log_type; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4518 | int ret; |
| 4519 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4520 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 4521 | (!hdd_ctx->config->enable_fw_log)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4522 | 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] | 4523 | return; |
| 4524 | } |
| 4525 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4526 | /* Enable FW logs based on INI configuration */ |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4527 | status = ucfg_fwol_get_enable_fw_log_type(hdd_ctx->psoc, |
| 4528 | &enable_fw_log_type); |
| 4529 | if (QDF_IS_STATUS_ERROR(status)) |
| 4530 | return; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4531 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4532 | WMI_DBGLOG_TYPE, |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4533 | enable_fw_log_type, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4534 | DBG_CMD); |
| 4535 | if (ret != 0) |
| 4536 | hdd_err("Failed to enable FW log type ret %d", |
| 4537 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4538 | |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4539 | status = ucfg_fwol_get_enable_fw_log_level(hdd_ctx->psoc, |
| 4540 | &enable_fw_log_level); |
| 4541 | if (QDF_IS_STATUS_ERROR(status)) |
| 4542 | return; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4543 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4544 | WMI_DBGLOG_LOG_LEVEL, |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4545 | enable_fw_log_level, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4546 | DBG_CMD); |
| 4547 | if (ret != 0) |
| 4548 | hdd_err("Failed to enable FW log level ret %d", |
| 4549 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4550 | |
lifeng | faa83cb | 2018-11-24 01:53:56 +0800 | [diff] [blame] | 4551 | sme_enable_fw_module_log_level(hdd_ctx->mac_handle, |
| 4552 | adapter->session_id); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4553 | } |
| 4554 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4555 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4556 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4557 | { |
| 4558 | } |
| 4559 | |
| 4560 | #endif |
| 4561 | |
| 4562 | /** |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4563 | * hdd_configure_chain_mask() - programs chain mask to firmware |
| 4564 | * @adapter: HDD adapter |
| 4565 | * |
| 4566 | * Return: 0 on success or errno on failure |
| 4567 | */ |
| 4568 | static int hdd_configure_chain_mask(struct hdd_adapter *adapter) |
| 4569 | { |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4570 | QDF_STATUS status; |
| 4571 | struct wma_caps_per_phy non_dbs_phy_cap; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4572 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4573 | bool enable2x2 = false, enable_bt_chain_sep = false; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4574 | uint8_t dual_mac_feature = DISABLE_DBS_CXN_AND_SCAN; |
| 4575 | |
| 4576 | status = ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 4577 | &dual_mac_feature); |
| 4578 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 4579 | hdd_err("unable to get dual mac feature"); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4580 | |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4581 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &enable2x2); |
| 4582 | if (QDF_IS_STATUS_ERROR(status)) |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4583 | hdd_err("unable to get vht_enable2x2"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4584 | |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4585 | status = ucfg_mlme_get_bt_chain_separation_flag(hdd_ctx->psoc, |
| 4586 | &enable_bt_chain_sep); |
| 4587 | if (QDF_IS_STATUS_ERROR(status)) |
| 4588 | hdd_debug("unable to get BT chain separation. using default"); |
| 4589 | |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 4590 | hdd_debug("enable2x2: %d, lte_coex: %d, disable_DBS: %d", |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4591 | enable2x2, hdd_ctx->lte_coex_ant_share, |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4592 | dual_mac_feature); |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4593 | hdd_debug("enable_bt_chain_separation %d", enable_bt_chain_sep); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4594 | |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4595 | status = wma_get_caps_for_phyidx_hwmode(&non_dbs_phy_cap, |
| 4596 | HW_MODE_DBS_NONE, |
| 4597 | CDS_BAND_ALL); |
| 4598 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4599 | hdd_err("couldn't get phy caps. skip chain mask programming"); |
| 4600 | return qdf_status_to_os_return(status); |
| 4601 | } |
| 4602 | |
| 4603 | if (non_dbs_phy_cap.tx_chain_mask_2G < 3 || |
| 4604 | non_dbs_phy_cap.rx_chain_mask_2G < 3 || |
| 4605 | non_dbs_phy_cap.tx_chain_mask_5G < 3 || |
| 4606 | non_dbs_phy_cap.rx_chain_mask_5G < 3) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4607 | hdd_debug("firmware not capable. skip chain mask programming"); |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4608 | return 0; |
| 4609 | } |
| 4610 | |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4611 | if (enable2x2 && !enable_bt_chain_sep) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4612 | hdd_debug("2x2 enabled. skip chain mask programming"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4613 | return 0; |
| 4614 | } |
| 4615 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4616 | if (dual_mac_feature != DISABLE_DBS_CXN_AND_SCAN) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4617 | hdd_debug("DBS enabled(%d). skip chain mask programming", |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4618 | dual_mac_feature); |
Naveen Rawat | b54c72b | 2018-02-05 10:39:06 -0800 | [diff] [blame] | 4619 | return 0; |
| 4620 | } |
| 4621 | |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4622 | if (hdd_ctx->lte_coex_ant_share) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4623 | hdd_debug("lte ant sharing enabled. skip chainmask programming"); |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4624 | return 0; |
| 4625 | } |
| 4626 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 4627 | status = ucfg_mlme_configure_chain_mask(hdd_ctx->psoc, |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 4628 | adapter->session_id); |
| 4629 | if (status != QDF_STATUS_SUCCESS) |
| 4630 | goto error; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4631 | |
| 4632 | return 0; |
| 4633 | |
| 4634 | error: |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 4635 | hdd_err("WMI PDEV set param failed"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4636 | return -EINVAL; |
| 4637 | } |
| 4638 | |
| 4639 | /** |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4640 | * hdd_send_coex_config_params() - Send coex config params to FW |
| 4641 | * @hdd_ctx: HDD context |
| 4642 | * @adapter: Primary adapter context |
| 4643 | * |
| 4644 | * This function is used to send all coex config related params to FW |
| 4645 | * |
| 4646 | * Return: 0 on success and -EINVAL on failure |
| 4647 | */ |
| 4648 | static int hdd_send_coex_config_params(struct hdd_context *hdd_ctx, |
| 4649 | struct hdd_adapter *adapter) |
| 4650 | { |
| 4651 | struct coex_config_params coex_cfg_params = {0}; |
| 4652 | struct wlan_fwol_coex_config config = {0}; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 4653 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4654 | QDF_STATUS status; |
| 4655 | |
| 4656 | if (!hdd_ctx) { |
| 4657 | hdd_err("hdd_ctx is invalid"); |
| 4658 | goto err; |
| 4659 | } |
| 4660 | |
| 4661 | if (!adapter) { |
| 4662 | hdd_err("adapter is invalid"); |
| 4663 | goto err; |
| 4664 | } |
| 4665 | |
| 4666 | if (!psoc) { |
| 4667 | hdd_err("HDD psoc is invalid"); |
| 4668 | goto err; |
| 4669 | } |
| 4670 | |
| 4671 | status = ucfg_fwol_get_coex_config_params(psoc, &config); |
| 4672 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4673 | hdd_err("Unable to get coex config params"); |
| 4674 | goto err; |
| 4675 | } |
| 4676 | |
| 4677 | coex_cfg_params.vdev_id = adapter->session_id; |
| 4678 | coex_cfg_params.config_type = WMI_COEX_CONFIG_TX_POWER; |
| 4679 | coex_cfg_params.config_arg1 = config.max_tx_power_for_btc; |
| 4680 | |
| 4681 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4682 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4683 | hdd_err("Failed to send coex Tx power"); |
| 4684 | goto err; |
| 4685 | } |
| 4686 | |
| 4687 | coex_cfg_params.config_type = WMI_COEX_CONFIG_HANDOVER_RSSI; |
| 4688 | coex_cfg_params.config_arg1 = config.wlan_low_rssi_threshold; |
| 4689 | |
| 4690 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4691 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4692 | hdd_err("Failed to send coex handover RSSI"); |
| 4693 | goto err; |
| 4694 | } |
| 4695 | |
| 4696 | coex_cfg_params.config_type = WMI_COEX_CONFIG_BTC_MODE; |
| 4697 | coex_cfg_params.config_arg1 = config.btc_mode; |
| 4698 | |
| 4699 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4700 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4701 | hdd_err("Failed to send coex BTC mode"); |
| 4702 | goto err; |
| 4703 | } |
| 4704 | |
| 4705 | coex_cfg_params.config_type = WMI_COEX_CONFIG_ANTENNA_ISOLATION; |
| 4706 | coex_cfg_params.config_arg1 = config.antenna_isolation; |
| 4707 | |
| 4708 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4709 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4710 | hdd_err("Failed to send coex antenna isolation"); |
| 4711 | goto err; |
| 4712 | } |
| 4713 | |
| 4714 | coex_cfg_params.config_type = WMI_COEX_CONFIG_BT_LOW_RSSI_THRESHOLD; |
| 4715 | coex_cfg_params.config_arg1 = config.bt_low_rssi_threshold; |
| 4716 | |
| 4717 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4718 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4719 | hdd_err("Failed to send coex BT low RSSI threshold"); |
| 4720 | goto err; |
| 4721 | } |
| 4722 | |
| 4723 | coex_cfg_params.config_type = WMI_COEX_CONFIG_BT_INTERFERENCE_LEVEL; |
| 4724 | coex_cfg_params.config_arg1 = config.bt_interference_low_ll; |
| 4725 | coex_cfg_params.config_arg2 = config.bt_interference_low_ul; |
| 4726 | coex_cfg_params.config_arg3 = config.bt_interference_medium_ll; |
| 4727 | coex_cfg_params.config_arg4 = config.bt_interference_medium_ul; |
| 4728 | coex_cfg_params.config_arg5 = config.bt_interference_high_ll; |
| 4729 | coex_cfg_params.config_arg6 = config.bt_interference_high_ul; |
| 4730 | |
| 4731 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4732 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4733 | hdd_err("Failed to send coex BT interference level"); |
| 4734 | goto err; |
| 4735 | } |
| 4736 | return 0; |
| 4737 | err: |
| 4738 | return -EINVAL; |
| 4739 | } |
| 4740 | |
| 4741 | /** |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4742 | * hdd_set_fw_params() - Set parameters to firmware |
| 4743 | * @adapter: HDD adapter |
| 4744 | * |
| 4745 | * This function Sets various parameters to fw once the |
| 4746 | * adapter is started. |
| 4747 | * |
| 4748 | * Return: 0 on success or errno on failure |
| 4749 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4750 | int hdd_set_fw_params(struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4751 | { |
| 4752 | int ret; |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4753 | uint16_t upper_brssi_thresh, lower_brssi_thresh, rts_profile; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4754 | bool enable_dtim_1chrx; |
| 4755 | QDF_STATUS status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4756 | struct hdd_context *hdd_ctx; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4757 | bool bval = false; |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4758 | uint8_t max_amsdu_len, enable_tx_sch_delay; |
| 4759 | uint32_t dtim_sel_diversity, enable_secondary_rate; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4760 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4761 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4762 | |
| 4763 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 4764 | if (!hdd_ctx) |
| 4765 | return -EINVAL; |
| 4766 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4767 | if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 4768 | hdd_debug("FTM Mode is active; nothing to do"); |
| 4769 | return 0; |
| 4770 | } |
| 4771 | |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4772 | ret = -1; |
| 4773 | if (QDF_IS_STATUS_SUCCESS(ucfg_fwol_get_lprx_enable(hdd_ctx->psoc, |
| 4774 | &bval))) { |
| 4775 | ret = sme_cli_set_command(adapter->session_id, |
| 4776 | WMI_PDEV_PARAM_DTIM_SYNTH, |
| 4777 | bval, PDEV_CMD); |
| 4778 | } |
Ashish Kumar Dhanotiya | b8630ab | 2017-07-21 14:18:14 +0530 | [diff] [blame] | 4779 | if (ret) { |
| 4780 | hdd_err("Failed to set LPRx"); |
| 4781 | goto error; |
| 4782 | } |
| 4783 | |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 4784 | ucfg_mlme_get_dtim_selection_diversity(hdd_ctx->psoc, |
| 4785 | &dtim_sel_diversity); |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4786 | |
| 4787 | ret = sme_cli_set_command( |
| 4788 | adapter->session_id, |
| 4789 | WMI_PDEV_PARAM_1CH_DTIM_OPTIMIZED_CHAIN_SELECTION, |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 4790 | dtim_sel_diversity, PDEV_CMD); |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4791 | if (ret) { |
| 4792 | hdd_err("Failed to set DTIM_OPTIMIZED_CHAIN_SELECTION"); |
| 4793 | goto error; |
| 4794 | } |
| 4795 | |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4796 | ret = -1; |
| 4797 | if (QDF_IS_STATUS_SUCCESS(ucfg_fwol_get_enable_tx_sch_delay( |
| 4798 | hdd_ctx->psoc, &enable_tx_sch_delay))) { |
| 4799 | ret = sme_cli_set_command(adapter->session_id, |
| 4800 | WMI_PDEV_PARAM_TX_SCH_DELAY, |
| 4801 | enable_tx_sch_delay, PDEV_CMD); |
| 4802 | } |
Ashish Kumar Dhanotiya | 48dac7d | 2018-03-28 14:59:50 +0530 | [diff] [blame] | 4803 | if (ret) { |
| 4804 | hdd_err("Failed to set WMI_PDEV_PARAM_TX_SCH_DELAY"); |
| 4805 | goto error; |
| 4806 | } |
| 4807 | |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4808 | ret = -1; |
| 4809 | if (QDF_IS_STATUS_SUCCESS(ucfg_fwol_get_enable_secondary_rate( |
| 4810 | hdd_ctx->psoc, &enable_secondary_rate))) { |
| 4811 | ret = sme_cli_set_command(adapter->session_id, |
| 4812 | WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE, |
| 4813 | enable_secondary_rate, PDEV_CMD); |
| 4814 | } |
Ashish Kumar Dhanotiya | 959b38c | 2018-04-06 21:07:57 +0530 | [diff] [blame] | 4815 | if (ret) { |
| 4816 | hdd_err("Failed to set WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE"); |
| 4817 | goto error; |
| 4818 | } |
| 4819 | |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4820 | if (adapter->device_mode == QDF_STA_MODE) { |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4821 | status = ucfg_get_upper_brssi_thresh(hdd_ctx->psoc, |
| 4822 | &upper_brssi_thresh); |
| 4823 | if (QDF_IS_STATUS_ERROR(status)) |
| 4824 | return -EINVAL; |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4825 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4826 | sme_set_smps_cfg(adapter->session_id, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4827 | HDD_STA_SMPS_PARAM_UPPER_BRSSI_THRESH, |
| 4828 | upper_brssi_thresh); |
| 4829 | |
| 4830 | status = ucfg_get_lower_brssi_thresh(hdd_ctx->psoc, |
| 4831 | &lower_brssi_thresh); |
| 4832 | if (QDF_IS_STATUS_ERROR(status)) |
| 4833 | return -EINVAL; |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4834 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4835 | sme_set_smps_cfg(adapter->session_id, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4836 | HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH, |
| 4837 | lower_brssi_thresh); |
| 4838 | |
| 4839 | status = ucfg_get_enable_dtim_1chrx(hdd_ctx->psoc, |
| 4840 | &enable_dtim_1chrx); |
| 4841 | if (QDF_IS_STATUS_ERROR(status)) |
| 4842 | return -EINVAL; |
| 4843 | |
| 4844 | sme_set_smps_cfg(adapter->session_id, |
| 4845 | HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE, |
| 4846 | enable_dtim_1chrx); |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4847 | } |
| 4848 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4849 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 4850 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 4851 | hdd_err("unable to get vht_enable2x2"); |
| 4852 | |
| 4853 | if (bval) { |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4854 | hdd_debug("configuring 2x2 mode fw params"); |
| 4855 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 4856 | ret = sme_set_cck_tx_fir_override(hdd_ctx->mac_handle, |
| 4857 | adapter->session_id); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4858 | if (ret) { |
| 4859 | hdd_err("WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE set failed %d", |
| 4860 | ret); |
| 4861 | goto error; |
| 4862 | } |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4863 | |
| 4864 | if (hdd_configure_chain_mask(adapter)) |
| 4865 | goto error; |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4866 | } else { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4867 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 4868 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4869 | hdd_debug("configuring 1x1 mode fw params"); |
| 4870 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4871 | /* |
| 4872 | * Disable DTIM 1 chain Rx when in 1x1, |
| 4873 | * we are passing two value |
| 4874 | * as param_id << 29 | param_value. |
| 4875 | * Below param_value = 0(disable) |
| 4876 | */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4877 | ret = sme_cli_set_command(adapter->session_id, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4878 | WMI_STA_SMPS_PARAM_CMDID, |
| 4879 | HDD_DTIM_1CHAIN_RX_ID << |
| 4880 | HDD_SMPS_PARAM_VALUE_S, |
| 4881 | VDEV_CMD); |
| 4882 | if (ret) { |
| 4883 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 4884 | goto error; |
| 4885 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4886 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4887 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 4888 | #undef HDD_SMPS_PARAM_VALUE_S |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4889 | |
| 4890 | if (hdd_configure_chain_mask(adapter)) |
| 4891 | goto error; |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4892 | } |
| 4893 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 4894 | ret = sme_set_enable_mem_deep_sleep(hdd_ctx->mac_handle, |
| 4895 | adapter->session_id); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4896 | if (ret) { |
| 4897 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", ret); |
| 4898 | goto error; |
| 4899 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4900 | |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4901 | status = ucfg_fwol_get_rts_profile(hdd_ctx->psoc, &rts_profile); |
| 4902 | if (QDF_IS_STATUS_ERROR(status)) |
| 4903 | return -EINVAL; |
| 4904 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4905 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4906 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4907 | rts_profile, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4908 | VDEV_CMD); |
| 4909 | if (ret) { |
| 4910 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 4911 | goto error; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4912 | } |
| 4913 | |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 4914 | status = ucfg_mlme_get_max_amsdu_num(hdd_ctx->psoc, &max_amsdu_len); |
| 4915 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4916 | hdd_err("Failed to get Max AMSDU Num"); |
| 4917 | goto error; |
| 4918 | } |
| 4919 | |
| 4920 | hdd_debug("SET AMSDU num %d", max_amsdu_len); |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4921 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4922 | ret = wma_cli_set_command(adapter->session_id, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4923 | GEN_VDEV_PARAM_AMSDU, |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 4924 | max_amsdu_len, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4925 | GEN_CMD); |
| 4926 | if (ret != 0) { |
| 4927 | hdd_err("GEN_VDEV_PARAM_AMSDU set failed %d", ret); |
| 4928 | goto error; |
| 4929 | } |
| 4930 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4931 | hdd_set_fw_log_params(hdd_ctx, adapter); |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4932 | |
| 4933 | ret = hdd_send_coex_config_params(hdd_ctx, adapter); |
| 4934 | if (ret) { |
| 4935 | hdd_warn("Error initializing coex config params"); |
| 4936 | goto error; |
| 4937 | } |
| 4938 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4939 | hdd_exit(); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4940 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4941 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4942 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4943 | error: |
| 4944 | return -EINVAL; |
| 4945 | } |
| 4946 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4947 | /** |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 4948 | * hdd_init_completion() - Initialize Completion Variables |
| 4949 | * @adapter: HDD adapter |
| 4950 | * |
| 4951 | * This function Initialize the completion variables for |
| 4952 | * a particular adapter |
| 4953 | * |
| 4954 | * Return: None |
| 4955 | */ |
| 4956 | static void hdd_init_completion(struct hdd_adapter *adapter) |
| 4957 | { |
| 4958 | init_completion(&adapter->disconnect_comp_var); |
| 4959 | init_completion(&adapter->roaming_comp_var); |
| 4960 | init_completion(&adapter->linkup_event_var); |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 4961 | init_completion(&adapter->sta_authorized_event); |
| 4962 | init_completion(&adapter->offchannel_tx_event); |
| 4963 | init_completion(&adapter->tx_action_cnf_event); |
| 4964 | init_completion(&adapter->ibss_peer_info_comp); |
| 4965 | init_completion(&adapter->lfr_fw_status.disable_lfr_event); |
| 4966 | } |
| 4967 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 4968 | static void hdd_reset_locally_admin_bit(struct hdd_context *hdd_ctx, |
| 4969 | tSirMacAddr macAddr) |
| 4970 | { |
| 4971 | int i; |
| 4972 | /* |
| 4973 | * Reset locally administered bit for dynamic_mac_list |
| 4974 | * also as while releasing the MAC address for any |
| 4975 | * interface mac will be compared with dynamic mac list |
| 4976 | */ |
| 4977 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
| 4978 | if (!qdf_mem_cmp( |
| 4979 | macAddr, |
| 4980 | &hdd_ctx-> |
| 4981 | dynamic_mac_list[i].dynamic_mac.bytes[0], |
| 4982 | sizeof(struct qdf_mac_addr))) { |
| 4983 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT( |
| 4984 | hdd_ctx-> |
| 4985 | dynamic_mac_list[i].dynamic_mac.bytes); |
| 4986 | break; |
| 4987 | } |
| 4988 | } |
| 4989 | /* |
| 4990 | * Reset locally administered bit if the device mode is |
| 4991 | * STA |
| 4992 | */ |
| 4993 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr); |
| 4994 | hdd_debug("locally administered bit reset in sta mode: " |
| 4995 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
| 4996 | } |
| 4997 | |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 4998 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4999 | * hdd_open_adapter() - open and setup the hdd adatper |
| 5000 | * @hdd_ctx: global hdd context |
| 5001 | * @session_type: type of the interface to be created |
| 5002 | * @iface_name: User-visible name of the interface |
| 5003 | * @macAddr: MAC address to assign to the interface |
| 5004 | * @name_assign_type: the name of assign type of the netdev |
| 5005 | * @rtnl_held: the rtnl lock hold flag |
| 5006 | * |
| 5007 | * This function open and setup the hdd adpater according to the device |
| 5008 | * type request, assign the name, the mac address assigned, and then prepared |
| 5009 | * the hdd related parameters, queue, lock and ready to start. |
| 5010 | * |
| 5011 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 5012 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5013 | 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] | 5014 | const char *iface_name, tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5015 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 5016 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5017 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5018 | struct hdd_adapter *adapter = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5019 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5020 | |
| 5021 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 5022 | /* |
| 5023 | * Max limit reached on the number of vdevs configured by the |
| 5024 | * host. Return error |
| 5025 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5026 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 5027 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5028 | return NULL; |
| 5029 | } |
| 5030 | |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 5031 | status = wlan_hdd_validate_mac_address((struct qdf_mac_addr *)macAddr); |
| 5032 | if (QDF_IS_STATUS_ERROR(status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5033 | /* Not received valid macAddr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5034 | 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] | 5035 | return NULL; |
| 5036 | } |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 5037 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5038 | status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5039 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5040 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 5041 | " already exists", |
| 5042 | MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5043 | return NULL; |
| 5044 | } |
| 5045 | |
| 5046 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5047 | case QDF_STA_MODE: |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 5048 | if (!hdd_ctx->config->mac_provision) |
| 5049 | hdd_reset_locally_admin_bit(hdd_ctx, macAddr); |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 5050 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5051 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5052 | case QDF_P2P_CLIENT_MODE: |
| 5053 | case QDF_P2P_DEVICE_MODE: |
| 5054 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 5055 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5056 | case QDF_MONITOR_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5057 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 5058 | name_assign_type, |
| 5059 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5060 | |
| 5061 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5062 | hdd_err("failed to allocate adapter for session %d", |
| 5063 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5064 | return NULL; |
| 5065 | } |
| 5066 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5067 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5068 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5069 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5070 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5071 | else if (QDF_MONITOR_MODE == session_type) |
| 5072 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5073 | else |
| 5074 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 5075 | |
| 5076 | adapter->device_mode = session_type; |
| 5077 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5078 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5079 | /* |
| 5080 | * Workqueue which gets scheduled in IPv4 notification |
| 5081 | * callback |
| 5082 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5083 | INIT_WORK(&adapter->ipv4_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5084 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5085 | |
| 5086 | #ifdef WLAN_NS_OFFLOAD |
| 5087 | /* |
| 5088 | * Workqueue which gets scheduled in IPv6 |
| 5089 | * notification callback. |
| 5090 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5091 | INIT_WORK(&adapter->ipv6_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5092 | hdd_ipv6_notifier_work_queue); |
| 5093 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5094 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5095 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5096 | goto err_free_netdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5097 | |
| 5098 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5099 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5100 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5101 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5102 | WLAN_CONTROL_PATH); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5103 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5104 | hdd_nud_init_tracking(adapter); |
Arunk Khandavalli | ca56d4b | 2018-11-29 15:46:00 +0530 | [diff] [blame] | 5105 | if (adapter->device_mode == QDF_STA_MODE || |
| 5106 | adapter->device_mode == QDF_P2P_DEVICE_MODE) |
| 5107 | hdd_sysfs_create_adapter_root_obj(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5108 | qdf_mutex_create(&adapter->disconnection_status_lock); |
| 5109 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 5110 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5111 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5112 | case QDF_P2P_GO_MODE: |
| 5113 | case QDF_SAP_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5114 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr, |
| 5115 | name_assign_type, |
| 5116 | (uint8_t *) iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5117 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5118 | hdd_err("failed to allocate adapter for session %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5119 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5120 | return NULL; |
| 5121 | } |
| 5122 | |
| 5123 | adapter->wdev.iftype = |
| 5124 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5125 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5126 | NL80211_IFTYPE_P2P_GO; |
| 5127 | adapter->device_mode = session_type; |
| 5128 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 5129 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5130 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5131 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5132 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5133 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5134 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5135 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5136 | WLAN_CONTROL_PATH); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5137 | |
| 5138 | /* |
| 5139 | * Workqueue which gets scheduled in IPv4 notification |
| 5140 | * callback |
| 5141 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5142 | INIT_WORK(&adapter->ipv4_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5143 | hdd_ipv4_notifier_work_queue); |
| 5144 | |
| 5145 | #ifdef WLAN_NS_OFFLOAD |
| 5146 | /* |
| 5147 | * Workqueue which gets scheduled in IPv6 |
| 5148 | * notification callback. |
| 5149 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5150 | INIT_WORK(&adapter->ipv6_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5151 | hdd_ipv6_notifier_work_queue); |
| 5152 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5153 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5154 | case QDF_FTM_MODE: |
| 5155 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 5156 | name_assign_type, |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 5157 | iface_name); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5158 | if (NULL == adapter) { |
| 5159 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 5160 | return NULL; |
| 5161 | } |
| 5162 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 5163 | adapter->device_mode = session_type; |
| 5164 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5165 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5166 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5167 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5168 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5169 | hdd_debug("Disabling queues"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5170 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5171 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5172 | WLAN_CONTROL_PATH); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5173 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5174 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5175 | hdd_err("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 5176 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5177 | return NULL; |
| 5178 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5179 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5180 | qdf_spinlock_create(&adapter->vdev_lock); |
| 5181 | |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 5182 | hdd_init_completion(adapter); |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 5183 | INIT_WORK(&adapter->scan_block_work, wlan_hdd_cfg80211_scan_block_cb); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 5184 | qdf_list_create(&adapter->blocked_scan_request_q, WLAN_MAX_SCAN_COUNT); |
| 5185 | qdf_mutex_create(&adapter->blocked_scan_request_q_lock); |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 5186 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5187 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5188 | /* Add it to the hdd's session list. */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5189 | status = hdd_add_adapter_back(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5190 | } |
| 5191 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5192 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5193 | if (NULL != adapter) { |
| 5194 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 5195 | adapter = NULL; |
| 5196 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5197 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5198 | return NULL; |
| 5199 | } |
Nachiket Kukade | 5f0ce4f | 2018-06-15 19:47:37 +0530 | [diff] [blame] | 5200 | hdd_apf_context_init(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5201 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5202 | if (QDF_STATUS_SUCCESS == status) { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5203 | policy_mgr_set_concurrency_mode(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5204 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5205 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5206 | /* Adapter successfully added. Increment the vdev count */ |
| 5207 | hdd_ctx->current_intf_count++; |
| 5208 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5209 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5210 | hdd_ctx->current_intf_count); |
| 5211 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 5212 | hdd_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5213 | } |
| 5214 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 5215 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 5216 | hdd_err("Interface %s wow debug_fs init failed", |
| 5217 | netdev_name(adapter->dev)); |
| 5218 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 5219 | hdd_register_hl_netdev_fc_timer(adapter, |
| 5220 | hdd_tx_resume_timer_expired_handler); |
| 5221 | |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 5222 | hdd_info("%s interface created. iftype: %d", netdev_name(adapter->dev), |
| 5223 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5224 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 5225 | if (adapter->device_mode == QDF_STA_MODE) |
| 5226 | wlan_hdd_debugfs_csr_init(adapter); |
| 5227 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5228 | return adapter; |
| 5229 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5230 | err_free_netdev: |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5231 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 5232 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5233 | |
| 5234 | return NULL; |
| 5235 | } |
| 5236 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5237 | static void __hdd_close_adapter(struct hdd_context *hdd_ctx, |
| 5238 | struct hdd_adapter *adapter, |
| 5239 | bool rtnl_held) |
| 5240 | { |
| 5241 | qdf_list_destroy(&adapter->blocked_scan_request_q); |
| 5242 | qdf_mutex_destroy(&adapter->blocked_scan_request_q_lock); |
| 5243 | policy_mgr_clear_concurrency_mode(hdd_ctx->psoc, adapter->device_mode); |
| 5244 | |
| 5245 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 5246 | |
| 5247 | if (hdd_ctx->current_intf_count != 0) |
| 5248 | hdd_ctx->current_intf_count--; |
| 5249 | } |
| 5250 | |
| 5251 | void hdd_close_adapter(struct hdd_context *hdd_ctx, |
| 5252 | struct hdd_adapter *adapter, |
| 5253 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5254 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5255 | /* |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5256 | * Stop the global bus bandwidth timer while touching the adapter list |
| 5257 | * to avoid bad memory access by the timer handler. |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5258 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5259 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5260 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5261 | hdd_remove_adapter(hdd_ctx, adapter); |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5262 | __hdd_close_adapter(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5263 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5264 | /* conditionally restart the bw timer */ |
| 5265 | hdd_bus_bw_compute_timer_try_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5266 | } |
| 5267 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5268 | 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] | 5269 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5270 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5271 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5272 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5273 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5274 | while (QDF_IS_STATUS_SUCCESS(hdd_remove_front_adapter(hdd_ctx, |
| 5275 | &adapter))) { |
| 5276 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
| 5277 | __hdd_close_adapter(hdd_ctx, adapter, rtnl_held); |
| 5278 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5279 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5280 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5281 | } |
| 5282 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5283 | void wlan_hdd_reset_prob_rspies(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5284 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5285 | struct qdf_mac_addr *bssid = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5286 | tSirUpdateIE updateIE; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5287 | mac_handle_t mac_handle; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5288 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5289 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5290 | case QDF_STA_MODE: |
| 5291 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5292 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5293 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5294 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5295 | bssid = &sta_ctx->conn_info.bssId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5296 | break; |
| 5297 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5298 | case QDF_SAP_MODE: |
| 5299 | case QDF_P2P_GO_MODE: |
| 5300 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5301 | { |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5302 | bssid = &adapter->mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5303 | break; |
| 5304 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5305 | case QDF_FTM_MODE: |
| 5306 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5307 | default: |
| 5308 | /* |
| 5309 | * wlan_hdd_reset_prob_rspies should not have been called |
| 5310 | * for these kind of devices |
| 5311 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5312 | hdd_err("Unexpected request for the current device type %d", |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5313 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5314 | return; |
| 5315 | } |
| 5316 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 5317 | qdf_copy_macaddr(&updateIE.bssid, bssid); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5318 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5319 | updateIE.ieBufferlength = 0; |
| 5320 | updateIE.pAdditionIEBuffer = NULL; |
| 5321 | updateIE.append = true; |
| 5322 | updateIE.notify = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5323 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 5324 | if (sme_update_add_ie(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5325 | &updateIE, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5326 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5327 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5328 | } |
| 5329 | } |
| 5330 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5331 | QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx, |
| 5332 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5333 | { |
Liangwei Dong | ad89c76 | 2018-06-01 01:56:23 -0400 | [diff] [blame] | 5334 | return hdd_stop_adapter_ext(hdd_ctx, adapter, 0); |
| 5335 | } |
| 5336 | |
| 5337 | QDF_STATUS hdd_stop_adapter_ext(struct hdd_context *hdd_ctx, |
| 5338 | struct hdd_adapter *adapter, |
| 5339 | enum hdd_adapter_stop_flag_t flag) |
| 5340 | { |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5341 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 5342 | struct hdd_station_ctx *sta_ctx; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5343 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5344 | union iwreq_data wrqu; |
| 5345 | tSirUpdateIE updateIE; |
| 5346 | unsigned long rc; |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 5347 | tsap_config_t *sap_config; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5348 | mac_handle_t mac_handle; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5349 | struct wlan_objmgr_vdev *vdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5350 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5351 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5352 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 5353 | if (adapter->session_id != HDD_SESSION_ID_INVALID) |
| 5354 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 5355 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5356 | hdd_nud_ignore_tracking(adapter, true); |
| 5357 | hdd_nud_reset_tracking(adapter); |
Alok Kumar | 016a1ac | 2018-09-16 09:55:50 +0530 | [diff] [blame] | 5358 | hdd_nud_flush_work(adapter); |
hangtian | 9c47aaf | 2018-11-26 17:59:39 +0800 | [diff] [blame] | 5359 | hdd_stop_tsf_sync(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5360 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5361 | hdd_debug("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5362 | wlan_hdd_netif_queue_control(adapter, |
| 5363 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5364 | WLAN_CONTROL_PATH); |
Tushnim Bhattacharyya | 9bd058f | 2017-12-27 14:01:31 -0800 | [diff] [blame] | 5365 | /* |
| 5366 | * if this is the last active connection check & stop the |
| 5367 | * opportunistic timer first |
| 5368 | */ |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5369 | if ((policy_mgr_get_connection_count(hdd_ctx->psoc) == 1 && |
| 5370 | policy_mgr_mode_specific_connection_count(hdd_ctx->psoc, |
| 5371 | policy_mgr_convert_device_mode_to_qdf_type( |
| 5372 | adapter->device_mode), NULL) == 1) || |
| 5373 | !policy_mgr_get_connection_count(hdd_ctx->psoc)) |
Tushnim Bhattacharyya | 9bd058f | 2017-12-27 14:01:31 -0800 | [diff] [blame] | 5374 | policy_mgr_check_and_stop_opportunistic_timer( |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5375 | hdd_ctx->psoc, adapter->session_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5376 | |
| 5377 | mac_handle = hdd_ctx->mac_handle; |
| 5378 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5379 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5380 | case QDF_STA_MODE: |
| 5381 | case QDF_P2P_CLIENT_MODE: |
| 5382 | case QDF_IBSS_MODE: |
| 5383 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5384 | case QDF_NDI_MODE: |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5385 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 5386 | |
| 5387 | if (adapter->device_mode == QDF_NDI_MODE || |
| 5388 | hdd_conn_is_connected(sta_ctx) || |
| 5389 | hdd_is_connecting(sta_ctx)) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5390 | INIT_COMPLETION(adapter->disconnect_comp_var); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5391 | |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5392 | roam_profile = hdd_roam_profile(adapter); |
| 5393 | /* For NDI do not use roam_profile */ |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5394 | if (adapter->device_mode == QDF_NDI_MODE) |
| 5395 | status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5396 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5397 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5398 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5399 | else if (roam_profile->BSSType == |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5400 | eCSR_BSS_TYPE_START_IBSS) |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5401 | status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5402 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5403 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5404 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Abhinav Kumar | 19a7a40 | 2018-07-12 17:36:57 +0530 | [diff] [blame] | 5405 | else if (adapter->device_mode == QDF_STA_MODE) |
| 5406 | wlan_hdd_disconnect(adapter, |
| 5407 | eCSR_DISCONNECT_REASON_DEAUTH); |
| 5408 | else |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5409 | status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5410 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5411 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5412 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5413 | /* success implies disconnect is queued */ |
| 5414 | if (QDF_IS_STATUS_SUCCESS(status) && |
| 5415 | adapter->device_mode != QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5416 | rc = wait_for_completion_timeout( |
| 5417 | &adapter->disconnect_comp_var, |
| 5418 | msecs_to_jiffies |
| 5419 | (WLAN_WAIT_TIME_DISCONNECT)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5420 | if (!rc) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5421 | hdd_warn("disconn_comp_var wait fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5422 | } |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5423 | if (QDF_IS_STATUS_ERROR(status)) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5424 | hdd_warn("failed to post disconnect"); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5425 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5426 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5427 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5428 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5429 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 5430 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 5431 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5432 | |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5433 | wlan_hdd_scan_abort(adapter); |
Wu Gao | 4a1ec8c | 2018-07-23 19:18:40 +0800 | [diff] [blame] | 5434 | wlan_hdd_cleanup_actionframe(adapter); |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 5435 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 5436 | hdd_clear_fils_connection_info(adapter); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5437 | hdd_deregister_tx_flow_control(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5438 | |
| 5439 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5440 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5441 | #ifdef WLAN_NS_OFFLOAD |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5442 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5443 | #endif |
| 5444 | #endif |
| 5445 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5446 | if (adapter->device_mode == QDF_STA_MODE) { |
| 5447 | struct wlan_objmgr_vdev *vdev; |
| 5448 | |
| 5449 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5450 | if (vdev) { |
| 5451 | wlan_cfg80211_sched_scan_stop(vdev); |
| 5452 | hdd_objmgr_put_vdev(adapter); |
| 5453 | } |
| 5454 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5455 | |
Pragaspathi Thilagaraj | e6f37e0 | 2019-01-04 12:24:33 +0530 | [diff] [blame] | 5456 | /* |
| 5457 | * During vdev destroy, if any STA is in connecting state the |
| 5458 | * roam command will be in active queue and thus vdev destroy is |
| 5459 | * queued in pending queue. In case STA tries to connect to |
| 5460 | * multiple BSSID and fails to connect, due to auth/assoc |
| 5461 | * timeouts it may take more than vdev destroy time to get |
| 5462 | * completed. On vdev destroy timeout vdev is moved to logically |
| 5463 | * deleted state. Once connection is completed, vdev destroy is |
| 5464 | * activated and to release the self-peer ref count it try to |
| 5465 | * get the ref of the vdev, which fails as vdev is logically |
| 5466 | * deleted and this leads to peer ref leak. So before vdev |
| 5467 | * destroy is queued abort any STA ongoing connection to avoid |
| 5468 | * vdev destroy timeout. |
| 5469 | */ |
| 5470 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) |
| 5471 | hdd_abort_ongoing_sta_connection(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5472 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 5473 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5474 | break; |
| 5475 | |
Rajeev Kumar | 3b90620 | 2018-02-01 10:55:14 -0800 | [diff] [blame] | 5476 | case QDF_MONITOR_MODE: |
| 5477 | wlan_hdd_scan_abort(adapter); |
| 5478 | hdd_deregister_tx_flow_control(adapter); |
| 5479 | hdd_vdev_destroy(adapter); |
| 5480 | break; |
| 5481 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5482 | case QDF_SAP_MODE: |
Will Huang | 7049bae | 2018-08-13 17:25:02 +0800 | [diff] [blame] | 5483 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 5484 | cds_flush_delayed_work(&adapter->acs_pending_work); |
| 5485 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 5486 | } |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5487 | |
wadesong | f9b15ed | 2017-12-14 14:12:32 +0800 | [diff] [blame] | 5488 | wlan_hdd_scan_abort(adapter); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5489 | |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 5490 | sap_config = &adapter->session.ap.sap_config; |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5491 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
| 5492 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 5493 | ucfg_ipa_flush(hdd_ctx->pdev); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5494 | |
Liangwei Dong | ad89c76 | 2018-06-01 01:56:23 -0400 | [diff] [blame] | 5495 | if (!(flag & HDD_IN_CAC_WORK_TH_CONTEXT)) |
| 5496 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
Jeff Johnson | 46807cd | 2018-04-29 21:32:22 -0700 | [diff] [blame] | 5497 | /* fallthrough */ |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5498 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5499 | case QDF_P2P_GO_MODE: |
Krunal Soni | 2220839 | 2017-09-29 18:10:34 -0700 | [diff] [blame] | 5500 | cds_flush_work(&adapter->sap_stop_bss_work); |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5501 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5502 | wlan_hdd_undo_acs(adapter); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5503 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5504 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5505 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5506 | |
| 5507 | hdd_deregister_tx_flow_control(adapter); |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 5508 | hdd_destroy_acs_timer(adapter); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5509 | |
Pragaspathi Thilagaraj | e6f37e0 | 2019-01-04 12:24:33 +0530 | [diff] [blame] | 5510 | /** |
| 5511 | * During vdev destroy, If any STA is in connecting state the |
| 5512 | * roam command will be in active queue and thus vdev destroy is |
| 5513 | * queued in pending queue. In case STA is tries to connected to |
| 5514 | * multiple BSSID and fails to connect, due to auth/assoc |
| 5515 | * timeouts it may take more than vdev destroy time to get |
| 5516 | * completes. If vdev destroy timeout vdev is moved to logically |
| 5517 | * deleted state. Once connection is completed, vdev destroy is |
| 5518 | * activated and to release the self-peer ref count it try to |
| 5519 | * get the ref of the vdev, which fails as vdev is logically |
| 5520 | * deleted and this leads to peer ref leak. So before vdev |
| 5521 | * destroy is queued abort any STA ongoing connection to avoid |
| 5522 | * vdev destroy timeout. |
| 5523 | */ |
| 5524 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) |
| 5525 | hdd_abort_ongoing_sta_connection(hdd_ctx); |
| 5526 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5527 | mutex_lock(&hdd_ctx->sap_lock); |
| 5528 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5529 | status = wlansap_stop_bss( |
| 5530 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5531 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5532 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 5533 | struct hdd_hostapd_state *hostapd_state = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5534 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5535 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5536 | qdf_stop_bss_event); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5537 | status = qdf_wait_for_event_completion( |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 5538 | &hostapd_state->qdf_stop_bss_event, |
Vignesh Viswanathan | 865daaa | 2018-10-11 19:30:44 +0530 | [diff] [blame] | 5539 | SME_CMD_START_STOP_BSS_TIMEOUT); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5540 | if (QDF_IS_STATUS_ERROR(status)) |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5541 | hdd_err("failure waiting for wlansap_stop_bss %d", |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5542 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5543 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5544 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5545 | } |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5546 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5547 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5548 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5549 | adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5550 | adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5551 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5552 | adapter->device_mode, |
| 5553 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5554 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 5555 | qdf_copy_macaddr(&updateIE.bssid, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5556 | &adapter->mac_addr); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5557 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5558 | updateIE.ieBufferlength = 0; |
| 5559 | updateIE.pAdditionIEBuffer = NULL; |
| 5560 | updateIE.append = false; |
| 5561 | updateIE.notify = false; |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5562 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5563 | /* Probe bcn reset */ |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5564 | status = sme_update_add_ie(mac_handle, &updateIE, |
| 5565 | eUPDATE_IE_PROBE_BCN); |
| 5566 | if (status == QDF_STATUS_E_FAILURE) |
| 5567 | hdd_err("Could not pass PROBE_RSP_BCN to PE"); |
| 5568 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5569 | /* Assoc resp reset */ |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5570 | status = sme_update_add_ie(mac_handle, &updateIE, |
| 5571 | eUPDATE_IE_ASSOC_RESP); |
| 5572 | if (status == QDF_STATUS_E_FAILURE) |
| 5573 | hdd_err("Could not pass ASSOC_RSP to PE"); |
| 5574 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5575 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 5576 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5577 | } |
Jiachao Wu | b1e1ddd | 2018-05-21 12:04:15 +0800 | [diff] [blame] | 5578 | clear_bit(SOFTAP_INIT_DONE, &adapter->event_flags); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5579 | qdf_mem_free(adapter->session.ap.beacon); |
| 5580 | adapter->session.ap.beacon = NULL; |
Jiachao Wu | b1e1ddd | 2018-05-21 12:04:15 +0800 | [diff] [blame] | 5581 | |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5582 | /* |
| 5583 | * If Do_Not_Break_Stream was enabled clear avoid channel list. |
| 5584 | */ |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5585 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5586 | if (vdev) { |
| 5587 | if (policy_mgr_is_dnsc_set(vdev)) |
| 5588 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0); |
| 5589 | hdd_objmgr_put_vdev(adapter); |
| 5590 | } |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5591 | |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5592 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5593 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5594 | #ifdef WLAN_NS_OFFLOAD |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5595 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5596 | #endif |
| 5597 | #endif |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5598 | |
| 5599 | hdd_vdev_destroy(adapter); |
| 5600 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5601 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5602 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5603 | case QDF_OCB_MODE: |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5604 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 5605 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5606 | cds_get_context(QDF_MODULE_ID_TXRX), |
| 5607 | sta_ctx->conn_info.staId[0]); |
Zhang Qian | 79d0d13 | 2018-02-05 13:40:16 +0800 | [diff] [blame] | 5608 | hdd_deregister_tx_flow_control(adapter); |
| 5609 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5610 | break; |
| 5611 | default: |
| 5612 | break; |
| 5613 | } |
| 5614 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 5615 | hdd_deregister_hl_netdev_fc_timer(adapter); |
| 5616 | |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5617 | if (adapter->scan_info.default_scan_ies) { |
| 5618 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 5619 | adapter->scan_info.default_scan_ies = NULL; |
| 5620 | } |
| 5621 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5622 | hdd_exit(); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5623 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5624 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5625 | } |
| 5626 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5627 | /** |
| 5628 | * hdd_deinit_all_adapters - deinit all adapters |
| 5629 | * @hdd_ctx: HDD context |
| 5630 | * @rtnl_held: True if RTNL lock held |
| 5631 | * |
| 5632 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5633 | 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] | 5634 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5635 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5636 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5637 | hdd_enter(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5638 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5639 | hdd_for_each_adapter(hdd_ctx, adapter) |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5640 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5641 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5642 | hdd_exit(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5643 | } |
| 5644 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5645 | QDF_STATUS hdd_stop_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5646 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5647 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5648 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5649 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5650 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5651 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5652 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5653 | hdd_for_each_adapter(hdd_ctx, adapter) |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5654 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5655 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5656 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5657 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5658 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5659 | } |
| 5660 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5661 | static void hdd_reset_scan_operation(struct hdd_context *hdd_ctx, |
| 5662 | struct hdd_adapter *adapter) |
| 5663 | { |
| 5664 | switch (adapter->device_mode) { |
| 5665 | case QDF_STA_MODE: |
| 5666 | case QDF_P2P_CLIENT_MODE: |
| 5667 | case QDF_IBSS_MODE: |
| 5668 | case QDF_P2P_DEVICE_MODE: |
| 5669 | case QDF_NDI_MODE: |
| 5670 | wlan_hdd_scan_abort(adapter); |
| 5671 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5672 | if (adapter->device_mode == QDF_STA_MODE) { |
| 5673 | struct wlan_objmgr_vdev *vdev; |
| 5674 | |
| 5675 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5676 | if (vdev) { |
| 5677 | wlan_cfg80211_sched_scan_stop(vdev); |
| 5678 | hdd_objmgr_put_vdev(adapter); |
| 5679 | } |
| 5680 | } |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5681 | break; |
| 5682 | case QDF_P2P_GO_MODE: |
| 5683 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5684 | break; |
| 5685 | case QDF_SAP_MODE: |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5686 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5687 | wlan_hdd_undo_acs(adapter); |
| 5688 | break; |
| 5689 | default: |
| 5690 | break; |
| 5691 | } |
| 5692 | } |
| 5693 | |
Ke Huang | c067b8d | 2018-05-21 15:50:13 +0800 | [diff] [blame] | 5694 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 5695 | /** |
| 5696 | * hdd_adapter_abort_tx_flow() - Abort the tx flow control |
| 5697 | * @pAdapter: pointer to hdd_adapter_t |
| 5698 | * |
| 5699 | * Resume tx and stop the tx flow control timer if the tx is paused |
| 5700 | * and the flow control timer is running. This function is called by |
| 5701 | * SSR to avoid the inconsistency of tx status before and after SSR. |
| 5702 | * |
| 5703 | * Return: void |
| 5704 | */ |
| 5705 | static void hdd_adapter_abort_tx_flow(struct hdd_adapter *adapter) |
| 5706 | { |
| 5707 | if (adapter->hdd_stats.tx_rx_stats.is_txflow_paused && |
| 5708 | QDF_TIMER_STATE_RUNNING == |
| 5709 | qdf_mc_timer_get_current_state( |
| 5710 | &adapter->tx_flow_control_timer)) { |
| 5711 | hdd_tx_resume_timer_expired_handler(adapter); |
| 5712 | qdf_mc_timer_stop(&adapter->tx_flow_control_timer); |
| 5713 | } |
| 5714 | } |
| 5715 | #endif |
| 5716 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5717 | QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5718 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5719 | struct hdd_adapter *adapter; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5720 | struct hdd_station_ctx *sta_ctx; |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5721 | struct qdf_mac_addr peerMacAddr; |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5722 | int sta_id; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 5723 | bool value; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5724 | struct wlan_objmgr_vdev *vdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5725 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5726 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5727 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5728 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5729 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5730 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 5731 | hdd_info("[SSR] reset adapter with device mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 5732 | qdf_opmode_str(adapter->device_mode), |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 5733 | adapter->device_mode); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5734 | |
Ke Huang | c067b8d | 2018-05-21 15:50:13 +0800 | [diff] [blame] | 5735 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 5736 | hdd_adapter_abort_tx_flow(adapter); |
| 5737 | #endif |
| 5738 | |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5739 | if ((adapter->device_mode == QDF_STA_MODE) || |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5740 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5741 | /* Stop tdls timers */ |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5742 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5743 | if (vdev) { |
| 5744 | hdd_notify_tdls_reset_adapter(vdev); |
| 5745 | hdd_objmgr_put_vdev(adapter); |
| 5746 | } |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5747 | adapter->session.station.hdd_reassoc_scenario = false; |
| 5748 | } |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 5749 | ucfg_mlme_get_sap_internal_restart(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 5750 | if (value && |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5751 | adapter->device_mode == QDF_SAP_MODE) { |
| 5752 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5753 | WLAN_STOP_ALL_NETIF_QUEUE, |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5754 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5755 | if (test_bit(SOFTAP_BSS_STARTED, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5756 | &adapter->event_flags)) |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5757 | hdd_sap_indicate_disconnect_for_sta(adapter); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5758 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
| 5759 | } else { |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5760 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5761 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5762 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5763 | } |
Nijun Gong | 104ccc7 | 2018-08-07 10:43:56 +0800 | [diff] [blame] | 5764 | /* |
| 5765 | * Clear fc flag if it was set before SSR to avoid TX queues |
| 5766 | * permanently stopped after SSR. |
| 5767 | * Here WLAN_START_ALL_NETIF_QUEUE will actually not start any |
| 5768 | * queue since it's blocked by reason WLAN_CONTROL_PATH. |
| 5769 | */ |
| 5770 | if (adapter->pause_map & (1 << WLAN_DATA_FLOW_CONTROL)) |
| 5771 | wlan_hdd_netif_queue_control(adapter, |
| 5772 | WLAN_START_ALL_NETIF_QUEUE, |
| 5773 | WLAN_DATA_FLOW_CONTROL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5774 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5775 | hdd_reset_scan_operation(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5776 | |
| 5777 | hdd_deinit_tx_rx(adapter); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5778 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5779 | adapter->device_mode, adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5780 | hdd_green_ap_start_state_mc(hdd_ctx, adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5781 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5782 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 5783 | hdd_wmm_adapter_close(adapter); |
| 5784 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 5785 | } |
| 5786 | |
Vignesh Viswanathan | 2eb1874 | 2017-09-08 11:18:59 +0530 | [diff] [blame] | 5787 | if (adapter->device_mode == QDF_STA_MODE) |
| 5788 | hdd_clear_fils_connection_info(adapter); |
| 5789 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5790 | if (adapter->device_mode == QDF_SAP_MODE) { |
Jingxiang Ge | ec11359 | 2018-08-09 15:40:39 +0800 | [diff] [blame] | 5791 | wlansap_cleanup_cac_timer( |
| 5792 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5793 | /* |
| 5794 | * If adapter is SAP, set session ID to invalid |
| 5795 | * since SAP session will be cleanup during SSR. |
| 5796 | */ |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 5797 | wlansap_set_invalid_session( |
| 5798 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5799 | } |
| 5800 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5801 | /* Delete connection peers if any to avoid peer object leaks */ |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5802 | if (adapter->device_mode == QDF_STA_MODE || |
| 5803 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5804 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5805 | qdf_copy_macaddr(&peerMacAddr, |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5806 | &sta_ctx->conn_info.bssId); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5807 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5808 | } else if (adapter->device_mode == QDF_P2P_GO_MODE) { |
Wu Gao | 6b81fc5 | 2018-05-24 19:27:27 +0800 | [diff] [blame] | 5809 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5810 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) { |
| 5811 | if (adapter->sta_info[sta_id].in_use) { |
| 5812 | hdd_debug("[SSR] deregister STA with ID %d", |
| 5813 | sta_id); |
| 5814 | hdd_softap_deregister_sta(adapter, |
| 5815 | sta_id); |
| 5816 | adapter->sta_info[sta_id].in_use = 0; |
| 5817 | } |
| 5818 | } |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5819 | } |
| 5820 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5821 | hdd_nud_ignore_tracking(adapter, true); |
Alok Kumar | 016a1ac | 2018-09-16 09:55:50 +0530 | [diff] [blame] | 5822 | hdd_nud_reset_tracking(adapter); |
| 5823 | hdd_nud_flush_work(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5824 | hdd_set_disconnect_status(adapter, false); |
hangtian | 9c47aaf | 2018-11-26 17:59:39 +0800 | [diff] [blame] | 5825 | hdd_stop_tsf_sync(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5826 | |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5827 | hdd_softap_deinit_tx_rx(adapter); |
Tiger Yu | 8c38770 | 2018-07-06 16:56:42 +0800 | [diff] [blame] | 5828 | hdd_deregister_tx_flow_control(adapter); |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5829 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 5830 | /* Destroy vdev which will be recreated during reinit. */ |
| 5831 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5832 | } |
| 5833 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5834 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5835 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5836 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5837 | } |
| 5838 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5839 | bool hdd_is_any_interface_open(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5840 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5841 | struct hdd_adapter *adapter; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5842 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5843 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5844 | hdd_info("FTM mode, don't close the module"); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5845 | return true; |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5846 | } |
| 5847 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5848 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5849 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags) || |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5850 | test_bit(SME_SESSION_OPENED, &adapter->event_flags)) |
| 5851 | return true; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5852 | } |
| 5853 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5854 | return false; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5855 | } |
| 5856 | |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 5857 | bool hdd_is_interface_up(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5858 | { |
| 5859 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 5860 | return true; |
| 5861 | else |
| 5862 | return false; |
| 5863 | } |
| 5864 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5865 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
bings | bdcd4a2 | 2017-06-20 09:27:00 +0800 | [diff] [blame] | 5866 | && !defined(WITH_BACKPORTS) && !defined(IEEE80211_PRIVACY) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5867 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5868 | struct ieee80211_channel *channel, |
| 5869 | const u8 *bssid, const u8 *ssid, |
| 5870 | size_t ssid_len) |
| 5871 | { |
| 5872 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5873 | ssid, ssid_len, |
| 5874 | WLAN_CAPABILITY_ESS, |
| 5875 | WLAN_CAPABILITY_ESS); |
| 5876 | } |
| 5877 | #else |
| 5878 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5879 | struct ieee80211_channel *channel, |
| 5880 | const u8 *bssid, const u8 *ssid, |
| 5881 | size_t ssid_len) |
| 5882 | { |
| 5883 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5884 | ssid, ssid_len, |
| 5885 | IEEE80211_BSS_TYPE_ESS, |
| 5886 | IEEE80211_PRIVACY_ANY); |
| 5887 | } |
| 5888 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5889 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5890 | #if defined CFG80211_CONNECT_BSS || \ |
| 5891 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5892 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5893 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5894 | /** |
| 5895 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 5896 | * @timeout_reason: reason for connect timeout |
| 5897 | * |
| 5898 | * This function is used to convert host timeout |
| 5899 | * reason enum to kernel specific enum. |
| 5900 | * |
| 5901 | * Return: nl timeout enum |
| 5902 | */ |
| 5903 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 5904 | tSirResultCodes timeout_reason) |
| 5905 | { |
| 5906 | switch (timeout_reason) { |
| 5907 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 5908 | return NL80211_TIMEOUT_SCAN; |
| 5909 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 5910 | return NL80211_TIMEOUT_AUTH; |
| 5911 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 5912 | return NL80211_TIMEOUT_ASSOC; |
| 5913 | default: |
| 5914 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 5915 | } |
| 5916 | } |
| 5917 | |
| 5918 | /** |
| 5919 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 5920 | * @dev: network device |
| 5921 | * @bssid: bssid to which we want to associate |
| 5922 | * @timeout_reason: reason for connect timeout |
| 5923 | * |
| 5924 | * This API is used to send connection timeout reason to supplicant |
| 5925 | * |
| 5926 | * Return: void |
| 5927 | */ |
| 5928 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5929 | const u8 *bssid, |
| 5930 | tSirResultCodes timeout_reason) |
| 5931 | { |
| 5932 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5933 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5934 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5935 | |
| 5936 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 5937 | nl_timeout_reason); |
| 5938 | } |
| 5939 | |
| 5940 | /** |
| 5941 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 5942 | * @dev: network device |
| 5943 | * @bssid: bssid to which we want to associate |
| 5944 | * @req_ie: Request Information Element |
| 5945 | * @req_ie_len: len of the req IE |
| 5946 | * @resp_ie: Response IE |
| 5947 | * @resp_ie_len: len of ht response IE |
| 5948 | * @status: status |
| 5949 | * @gfp: Kernel Flag |
| 5950 | * @timeout_reason: reason for connect timeout |
| 5951 | * |
| 5952 | * Return: void |
| 5953 | */ |
| 5954 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5955 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5956 | size_t req_ie_len, const u8 *resp_ie, |
| 5957 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5958 | tSirResultCodes timeout_reason) |
| 5959 | { |
| 5960 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5961 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5962 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5963 | |
| 5964 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5965 | resp_ie, resp_ie_len, status, gfp, |
| 5966 | nl_timeout_reason); |
| 5967 | } |
| 5968 | #else |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5969 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5970 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5971 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5972 | const u8 *bssid, |
| 5973 | tSirResultCodes timeout_reason) |
| 5974 | { |
| 5975 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 5976 | } |
| 5977 | #endif |
| 5978 | |
| 5979 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5980 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5981 | size_t req_ie_len, const u8 *resp_ie, |
| 5982 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5983 | tSirResultCodes timeout_reason) |
| 5984 | { |
| 5985 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5986 | resp_ie, resp_ie_len, status, gfp); |
| 5987 | } |
| 5988 | #endif |
| 5989 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5990 | /** |
| 5991 | * hdd_connect_bss() - API to send connection status to supplicant |
| 5992 | * @dev: network device |
| 5993 | * @bssid: bssid to which we want to associate |
| 5994 | * @req_ie: Request Information Element |
| 5995 | * @req_ie_len: len of the req IE |
| 5996 | * @resp_ie: Response IE |
| 5997 | * @resp_ie_len: len of ht response IE |
| 5998 | * @status: status |
| 5999 | * @gfp: Kernel Flag |
| 6000 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6001 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6002 | * |
| 6003 | * The API is a wrapper to send connection status to supplicant |
| 6004 | * |
| 6005 | * Return: Void |
| 6006 | */ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6007 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 6008 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6009 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 6010 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 6011 | size_t req_ie_len, const u8 *resp_ie, |
| 6012 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6013 | bool connect_timeout, |
| 6014 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6015 | { |
| 6016 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6017 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6018 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6019 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 6020 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6021 | } |
| 6022 | #else |
| 6023 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 6024 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 6025 | size_t req_ie_len, const u8 *resp_ie, |
| 6026 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6027 | bool connect_timeout, |
| 6028 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6029 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6030 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 6031 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6032 | } |
| 6033 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6034 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6035 | #if defined(WLAN_FEATURE_FILS_SK) |
| 6036 | #if defined(CFG80211_CONNECT_DONE) || \ |
| 6037 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
| 6038 | #if defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 6039 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6040 | /** |
| 6041 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 6042 | * @fils_params: connect response to supplicant |
| 6043 | * @fils_kek: FILS kek |
| 6044 | * @fils_kek_len: FILS kek length |
| 6045 | * @pmk: FILS PMK |
| 6046 | * @pmk_len: FILS PMK length |
| 6047 | * @pmkid: PMKID |
| 6048 | * @fils_seq_num: FILS Seq number |
| 6049 | * |
| 6050 | * Return: None |
| 6051 | */ |
| 6052 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 6053 | *fils_params, const uint8_t *fils_kek, |
| 6054 | size_t fils_kek_len, const uint8_t *pmk, |
| 6055 | size_t pmk_len, const uint8_t *pmkid, |
| 6056 | uint16_t fils_seq_num) |
| 6057 | { |
| 6058 | /* Increament seq number to be used for next FILS */ |
| 6059 | fils_params->fils_erp_next_seq_num = fils_seq_num + 1; |
| 6060 | fils_params->update_erp_next_seq_num = true; |
| 6061 | fils_params->fils_kek = fils_kek; |
| 6062 | fils_params->fils_kek_len = fils_kek_len; |
| 6063 | fils_params->pmk = pmk; |
| 6064 | fils_params->pmk_len = pmk_len; |
| 6065 | fils_params->pmkid = pmkid; |
| 6066 | } |
| 6067 | #else |
| 6068 | static inline void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 6069 | *fils_params, const uint8_t |
| 6070 | *fils_kek, size_t fils_kek_len, |
| 6071 | const uint8_t *pmk, size_t pmk_len, |
| 6072 | const uint8_t *pmkid, |
| 6073 | uint16_t fils_seq_num) |
| 6074 | { } |
| 6075 | #endif |
| 6076 | |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6077 | void hdd_update_hlp_info(struct net_device *dev, |
| 6078 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6079 | { |
| 6080 | struct sk_buff *skb; |
| 6081 | uint16_t skb_len; |
| 6082 | struct llc_snap_hdr_t *llc_hdr; |
| 6083 | QDF_STATUS status; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6084 | uint8_t *hlp_data; |
| 6085 | uint16_t hlp_data_len; |
| 6086 | struct fils_join_rsp_params *roam_fils_params |
| 6087 | = roam_info->fils_join_rsp; |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6088 | struct hdd_adapter *padapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6089 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6090 | if (!roam_fils_params) { |
| 6091 | hdd_err("FILS Roam Param NULL"); |
| 6092 | return; |
| 6093 | } |
| 6094 | |
Srinivas Girigowda | 3cc8e91 | 2017-11-28 18:11:57 -0800 | [diff] [blame] | 6095 | if (!roam_fils_params->hlp_data_len) { |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6096 | hdd_err("FILS HLP Data NULL, len %d", |
| 6097 | roam_fils_params->hlp_data_len); |
| 6098 | return; |
| 6099 | } |
| 6100 | |
| 6101 | hlp_data = roam_fils_params->hlp_data; |
| 6102 | hlp_data_len = roam_fils_params->hlp_data_len; |
| 6103 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6104 | /* Calculate skb length */ |
| 6105 | skb_len = (2 * ETH_ALEN) + hlp_data_len; |
| 6106 | skb = qdf_nbuf_alloc(NULL, skb_len, 0, 4, false); |
| 6107 | if (skb == NULL) { |
| 6108 | hdd_err("HLP packet nbuf alloc fails"); |
| 6109 | return; |
| 6110 | } |
| 6111 | |
| 6112 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->dst_mac.bytes, |
| 6113 | QDF_MAC_ADDR_SIZE); |
| 6114 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->src_mac.bytes, |
| 6115 | QDF_MAC_ADDR_SIZE); |
| 6116 | |
| 6117 | llc_hdr = (struct llc_snap_hdr_t *) hlp_data; |
| 6118 | if (IS_SNAP(llc_hdr)) { |
| 6119 | hlp_data += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 6120 | hlp_data_len += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 6121 | } |
| 6122 | |
| 6123 | qdf_mem_copy(skb_put(skb, hlp_data_len), hlp_data, hlp_data_len); |
| 6124 | |
| 6125 | /* |
| 6126 | * This HLP packet is formed from HLP info encapsulated |
| 6127 | * in assoc response frame which is AEAD encrypted. |
| 6128 | * Hence, this checksum validation can be set unnecessary. |
| 6129 | * i.e. network layer need not worry about checksum. |
| 6130 | */ |
| 6131 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 6132 | |
| 6133 | status = hdd_rx_packet_cbk(padapter, skb); |
| 6134 | if (QDF_IS_STATUS_ERROR(status)) { |
| 6135 | hdd_err("Sending HLP packet fails"); |
| 6136 | return; |
| 6137 | } |
| 6138 | hdd_debug("send HLP packet to netif successfully"); |
| 6139 | } |
| 6140 | |
| 6141 | /** |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6142 | * hdd_connect_done() - Wrapper API to call cfg80211_connect_done |
| 6143 | * @dev: network device |
| 6144 | * @bssid: bssid to which we want to associate |
| 6145 | * @bss: cfg80211 bss info |
| 6146 | * @roam_info: information about connected bss |
| 6147 | * @req_ie: Request Information Element |
| 6148 | * @req_ie_len: len of the req IE |
| 6149 | * @resp_ie: Response IE |
| 6150 | * @resp_ie_len: len of ht response IE |
| 6151 | * @status: status |
| 6152 | * @gfp: allocation flags |
| 6153 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 6154 | * @timeout_reason: reason for connect timeout |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6155 | * |
| 6156 | * This API is used as wrapper to send FILS key/sequence number |
| 6157 | * params etc. to supplicant in case of FILS connection |
| 6158 | * |
| 6159 | * Return: None |
| 6160 | */ |
| 6161 | static void hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6162 | struct cfg80211_bss *bss, |
| 6163 | struct csr_roam_info *roam_info, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6164 | const u8 *req_ie, size_t req_ie_len, |
| 6165 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6166 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6167 | tSirResultCodes timeout_reason) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6168 | { |
| 6169 | struct cfg80211_connect_resp_params fils_params; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6170 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6171 | struct fils_join_rsp_params *roam_fils_params = |
| 6172 | roam_info->fils_join_rsp; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6173 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6174 | qdf_mem_zero(&fils_params, sizeof(fils_params)); |
| 6175 | |
| 6176 | if (!roam_fils_params) { |
| 6177 | fils_params.status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 6178 | } else { |
| 6179 | fils_params.status = status; |
| 6180 | fils_params.bssid = bssid; |
Srinivas Girigowda | e975f53 | 2018-01-05 14:03:05 -0800 | [diff] [blame] | 6181 | fils_params.timeout_reason = |
| 6182 | hdd_convert_timeout_reason(timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6183 | fils_params.req_ie = req_ie; |
| 6184 | fils_params.req_ie_len = req_ie_len; |
| 6185 | fils_params.resp_ie = resp_ie; |
| 6186 | fils_params.resp_ie_len = resp_ie_len; |
| 6187 | fils_params.bss = bss; |
| 6188 | hdd_populate_fils_params(&fils_params, roam_fils_params->kek, |
| 6189 | roam_fils_params->kek_len, |
| 6190 | roam_fils_params->fils_pmk, |
| 6191 | roam_fils_params->fils_pmk_len, |
| 6192 | roam_fils_params->fils_pmkid, |
| 6193 | roam_info->fils_seq_num); |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 6194 | hdd_save_gtk_params(adapter, roam_info, false); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6195 | } |
| 6196 | hdd_debug("FILS indicate connect status %d seq no %d", |
| 6197 | fils_params.status, |
| 6198 | fils_params.fils_erp_next_seq_num); |
| 6199 | |
| 6200 | cfg80211_connect_done(dev, &fils_params, gfp); |
| 6201 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6202 | if (roam_fils_params && roam_fils_params->hlp_data_len) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6203 | hdd_update_hlp_info(dev, roam_info); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6204 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6205 | /* Clear all the FILS key info */ |
| 6206 | if (roam_fils_params && roam_fils_params->fils_pmk) |
| 6207 | qdf_mem_free(roam_fils_params->fils_pmk); |
| 6208 | if (roam_fils_params) |
| 6209 | qdf_mem_free(roam_fils_params); |
| 6210 | roam_info->fils_join_rsp = NULL; |
| 6211 | } |
| 6212 | #else |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6213 | static inline void |
| 6214 | hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6215 | struct cfg80211_bss *bss, struct csr_roam_info *roam_info, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6216 | const u8 *req_ie, size_t req_ie_len, |
| 6217 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
| 6218 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6219 | tSirResultCodes timeout_reason) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6220 | { } |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6221 | #endif |
| 6222 | #endif |
| 6223 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6224 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 6225 | (defined(CFG80211_CONNECT_DONE) || \ |
| 6226 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6227 | /** |
| 6228 | * hdd_fils_update_connect_results() - API to send fils connection status to |
| 6229 | * supplicant. |
| 6230 | * @dev: network device |
| 6231 | * @bssid: bssid to which we want to associate |
| 6232 | * @bss: cfg80211 bss info |
| 6233 | * @roam_info: information about connected bss |
| 6234 | * @req_ie: Request Information Element |
| 6235 | * @req_ie_len: len of the req IE |
| 6236 | * @resp_ie: Response IE |
| 6237 | * @resp_ie_len: len of ht response IE |
| 6238 | * @status: status |
| 6239 | * @gfp: allocation flags |
| 6240 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 6241 | * @timeout_reason: reason for connect timeout |
| 6242 | * |
| 6243 | * The API is a wrapper to send connection status to supplicant |
| 6244 | * |
| 6245 | * Return: 0 if success else failure |
| 6246 | */ |
| 6247 | static int hdd_fils_update_connect_results(struct net_device *dev, |
| 6248 | const u8 *bssid, |
| 6249 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6250 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6251 | size_t req_ie_len, const u8 *resp_ie, |
| 6252 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 6253 | bool connect_timeout, |
| 6254 | tSirResultCodes timeout_reason) |
| 6255 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6256 | hdd_enter(); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6257 | if (!roam_info || !roam_info->is_fils_connection) |
| 6258 | return -EINVAL; |
| 6259 | |
| 6260 | hdd_connect_done(dev, bssid, bss, roam_info, req_ie, req_ie_len, |
| 6261 | resp_ie, resp_ie_len, status, gfp, connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6262 | timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6263 | return 0; |
| 6264 | } |
| 6265 | #else |
| 6266 | static inline int hdd_fils_update_connect_results(struct net_device *dev, |
| 6267 | const u8 *bssid, |
| 6268 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6269 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6270 | size_t req_ie_len, const u8 *resp_ie, |
| 6271 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 6272 | bool connect_timeout, |
| 6273 | tSirResultCodes timeout_reason) |
| 6274 | { |
| 6275 | return -EINVAL; |
| 6276 | } |
| 6277 | #endif |
| 6278 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6279 | /** |
| 6280 | * hdd_connect_result() - API to send connection status to supplicant |
| 6281 | * @dev: network device |
| 6282 | * @bssid: bssid to which we want to associate |
| 6283 | * @roam_info: information about connected bss |
| 6284 | * @req_ie: Request Information Element |
| 6285 | * @req_ie_len: len of the req IE |
| 6286 | * @resp_ie: Response IE |
| 6287 | * @resp_ie_len: len of ht response IE |
| 6288 | * @status: status |
| 6289 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6290 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6291 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6292 | * |
| 6293 | * The API is a wrapper to send connection status to supplicant |
| 6294 | * and allow runtime suspend |
| 6295 | * |
| 6296 | * Return: Void |
| 6297 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6298 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6299 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6300 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6301 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6302 | bool connect_timeout, |
| 6303 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6304 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6305 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6306 | struct cfg80211_bss *bss = NULL; |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 6307 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6308 | |
| 6309 | if (WLAN_STATUS_SUCCESS == status) { |
| 6310 | struct ieee80211_channel *chan; |
| 6311 | int freq; |
| 6312 | int chan_no = roam_info->pBssDesc->channelId; |
| 6313 | |
| 6314 | if (chan_no <= 14) |
| 6315 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 6316 | HDD_NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6317 | else |
| 6318 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 6319 | HDD_NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6320 | |
| 6321 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
| 6322 | bss = hdd_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
| 6323 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 6324 | roam_info->u.pConnectedProfile->SSID.length); |
| 6325 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6326 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6327 | if (hdd_fils_update_connect_results(dev, bssid, bss, |
| 6328 | roam_info, req_ie, req_ie_len, resp_ie, |
| 6329 | resp_ie_len, status, gfp, connect_timeout, |
| 6330 | timeout_reason) != 0) { |
| 6331 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 6332 | req_ie_len, resp_ie, resp_ie_len, |
| 6333 | status, gfp, connect_timeout, timeout_reason); |
| 6334 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6335 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 6336 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 6337 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6338 | } |
| 6339 | #else |
| 6340 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6341 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6342 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6343 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6344 | bool connect_timeout, |
| 6345 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6346 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6347 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 6348 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6349 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6350 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 6351 | resp_ie, resp_ie_len, status, gfp); |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 6352 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 6353 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 6354 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6355 | } |
| 6356 | #endif |
| 6357 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 6358 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6359 | int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan, |
| 6360 | uint32_t bandwidth) |
| 6361 | { |
| 6362 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6363 | struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 6364 | struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info; |
| 6365 | QDF_STATUS status; |
Jeff Johnson | 43837af | 2018-10-17 12:44:05 -0700 | [diff] [blame] | 6366 | mac_handle_t mac_handle = hdd_ctx->mac_handle; |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6367 | struct qdf_mac_addr bssid; |
| 6368 | struct csr_roam_profile roam_profile; |
| 6369 | struct ch_params ch_params; |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6370 | eConnectionState connstate; |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6371 | |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6372 | if (hdd_get_conparam() != QDF_GLOBAL_MONITOR_MODE && |
| 6373 | adapter->device_mode != QDF_STA_MODE) { |
| 6374 | 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] | 6375 | return -EINVAL; |
| 6376 | } |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6377 | if (adapter->device_mode == QDF_STA_MODE && |
| 6378 | hdd_ctx->config->enable_change_channel_bandwidth) { |
| 6379 | connstate = sta_ctx->conn_info.connState; |
| 6380 | if (eConnectionState_Associated == connstate || |
| 6381 | eConnectionState_Connecting == connstate) { |
| 6382 | return -EINVAL; |
| 6383 | } |
| 6384 | } |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6385 | |
Visweswara Tanuku | 006313a | 2018-04-12 12:26:34 +0530 | [diff] [blame] | 6386 | /* Validate Channel */ |
| 6387 | if (!WLAN_REG_IS_24GHZ_CH(chan) && !WLAN_REG_IS_5GHZ_CH(chan)) { |
| 6388 | hdd_err("Channel %d Not supported", chan); |
| 6389 | return -EINVAL; |
| 6390 | } |
| 6391 | |
| 6392 | if (WLAN_REG_IS_24GHZ_CH(chan)) { |
| 6393 | if (bandwidth == CH_WIDTH_80MHZ) { |
| 6394 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 6395 | return -EINVAL; |
| 6396 | } |
| 6397 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 14) && |
| 6398 | (bandwidth != CH_WIDTH_MAX)) { |
| 6399 | hdd_err("Only BW20 possible on channel 14"); |
| 6400 | return -EINVAL; |
| 6401 | } |
| 6402 | } |
| 6403 | |
| 6404 | if (WLAN_REG_IS_5GHZ_CH(chan)) { |
| 6405 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 165) && |
| 6406 | (bandwidth != CH_WIDTH_MAX)) { |
| 6407 | hdd_err("Only BW20 possible on channel 165"); |
| 6408 | return -EINVAL; |
| 6409 | } |
| 6410 | } |
| 6411 | |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6412 | hdd_debug("Set monitor mode Channel %d", chan); |
| 6413 | qdf_mem_zero(&roam_profile, sizeof(roam_profile)); |
| 6414 | roam_profile.ChannelInfo.ChannelList = &ch_info->channel; |
| 6415 | roam_profile.ChannelInfo.numOfChannels = 1; |
| 6416 | roam_profile.phyMode = ch_info->phy_mode; |
| 6417 | roam_profile.ch_params.ch_width = bandwidth; |
| 6418 | hdd_select_cbmode(adapter, chan, &roam_profile.ch_params); |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6419 | if (hdd_ctx->config->enable_change_channel_bandwidth && |
Jeff Johnson | 43837af | 2018-10-17 12:44:05 -0700 | [diff] [blame] | 6420 | (!sme_find_session_by_bssid(mac_handle, adapter->mac_addr.bytes))) { |
| 6421 | status = sme_create_mon_session(mac_handle, |
Rajeev Kumar Sirasanagandla | e3b5991 | 2018-08-24 15:53:31 +0530 | [diff] [blame] | 6422 | adapter->mac_addr.bytes, |
| 6423 | adapter->session_id); |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6424 | if (status != QDF_STATUS_SUCCESS) { |
| 6425 | hdd_err("Status: %d Failed to create session.", |
| 6426 | status); |
| 6427 | return qdf_status_to_os_return(status); |
| 6428 | } |
| 6429 | } |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6430 | qdf_mem_copy(bssid.bytes, adapter->mac_addr.bytes, |
| 6431 | QDF_MAC_ADDR_SIZE); |
| 6432 | |
| 6433 | ch_params.ch_width = bandwidth; |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 6434 | wlan_reg_set_channel_params(hdd_ctx->pdev, chan, 0, &ch_params); |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6435 | if (ch_params.ch_width == CH_WIDTH_INVALID) { |
| 6436 | hdd_err("Invalid capture channel or bandwidth for a country"); |
| 6437 | return -EINVAL; |
| 6438 | } |
| 6439 | if (wlan_hdd_change_hw_mode_for_given_chnl(adapter, chan, |
| 6440 | POLICY_MGR_UPDATE_REASON_SET_OPER_CHAN)) { |
| 6441 | hdd_err("Failed to change hw mode"); |
| 6442 | return -EINVAL; |
| 6443 | } |
| 6444 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 6445 | status = sme_roam_channel_change_req(hdd_ctx->mac_handle, |
| 6446 | bssid, &ch_params, |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6447 | &roam_profile); |
| 6448 | if (status) { |
| 6449 | hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode", |
| 6450 | status); |
| 6451 | } |
| 6452 | |
| 6453 | adapter->mon_chan = chan; |
| 6454 | adapter->mon_bandwidth = bandwidth; |
| 6455 | return qdf_status_to_os_return(status); |
| 6456 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 6457 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6458 | |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6459 | #ifdef MSM_PLATFORM |
| 6460 | /** |
| 6461 | * hdd_stop_p2p_go() - call cfg80211 API to stop P2P GO |
| 6462 | * @adapter: pointer to adapter |
| 6463 | * |
| 6464 | * This function calls cfg80211 API to stop P2P GO |
| 6465 | * |
| 6466 | * Return: None |
| 6467 | */ |
| 6468 | static void hdd_stop_p2p_go(struct hdd_adapter *adapter) |
| 6469 | { |
| 6470 | hdd_debug("[SSR] send stop ap to supplicant"); |
| 6471 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 6472 | } |
| 6473 | |
| 6474 | static inline void hdd_delete_sta(struct hdd_adapter *adapter) |
| 6475 | { |
| 6476 | } |
| 6477 | #else |
| 6478 | static inline void hdd_stop_p2p_go(struct hdd_adapter *adapter) |
| 6479 | { |
| 6480 | } |
| 6481 | |
| 6482 | /** |
| 6483 | * hdd_delete_sta() - call cfg80211 API to delete STA |
| 6484 | * @adapter: pointer to adapter |
| 6485 | * |
| 6486 | * This function calls cfg80211 API to delete STA |
| 6487 | * |
| 6488 | * Return: None |
| 6489 | */ |
| 6490 | static void hdd_delete_sta(struct hdd_adapter *adapter) |
| 6491 | { |
| 6492 | struct qdf_mac_addr bcast_mac = QDF_MAC_ADDR_BCAST_INIT; |
| 6493 | |
| 6494 | hdd_debug("[SSR] send restart supplicant"); |
| 6495 | /* event supplicant to restart */ |
| 6496 | cfg80211_del_sta(adapter->dev, |
| 6497 | (const u8 *)&bcast_mac.bytes[0], |
| 6498 | GFP_KERNEL); |
| 6499 | } |
| 6500 | #endif |
| 6501 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6502 | QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6503 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6504 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6505 | eConnectionState connState; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 6506 | bool value; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6507 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6508 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6509 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6510 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6511 | if (!hdd_is_interface_up(adapter)) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6512 | continue; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6513 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 6514 | hdd_debug("[SSR] start adapter with device mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 6515 | qdf_opmode_str(adapter->device_mode), |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 6516 | adapter->device_mode); |
| 6517 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6518 | hdd_wmm_init(adapter); |
| 6519 | |
| 6520 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6521 | case QDF_STA_MODE: |
| 6522 | case QDF_P2P_CLIENT_MODE: |
| 6523 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6524 | |
| 6525 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 6526 | ->conn_info.connState; |
| 6527 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6528 | hdd_start_station_adapter(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6529 | /* Open the gates for HDD to receive Wext commands */ |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 6530 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6531 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6532 | /* Indicate disconnect event to supplicant |
| 6533 | * if associated previously |
| 6534 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6535 | if (eConnectionState_Associated == connState || |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 6536 | eConnectionState_IbssConnected == connState || |
| 6537 | eConnectionState_NotConnected == connState || |
| 6538 | eConnectionState_IbssDisconnected == connState || |
| 6539 | eConnectionState_Disconnecting == connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6540 | union iwreq_data wrqu; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6541 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6542 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 6543 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 6544 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 6545 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 6546 | &wrqu, NULL); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 6547 | adapter->session.station. |
Jeff Johnson | 690fe95 | 2017-10-25 11:48:39 -0700 | [diff] [blame] | 6548 | hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6549 | |
| 6550 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 6551 | wlan_hdd_cfg80211_indicate_disconnect( |
| 6552 | adapter->dev, false, |
| 6553 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6554 | } else if (eConnectionState_Connecting == connState) { |
| 6555 | /* |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6556 | * Indicate connect failure to supplicant if we |
| 6557 | * were in the process of connecting |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6558 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6559 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6560 | NULL, 0, NULL, 0, |
| 6561 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6562 | GFP_KERNEL, false, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6563 | } |
| 6564 | |
| 6565 | hdd_register_tx_flow_control(adapter, |
| 6566 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 6567 | hdd_tx_resume_cb, |
| 6568 | hdd_tx_flow_control_is_pause); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6569 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 6570 | hdd_lpass_notify_start(hdd_ctx, adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6571 | hdd_nud_ignore_tracking(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6572 | break; |
| 6573 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6574 | case QDF_SAP_MODE: |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 6575 | ucfg_mlme_get_sap_internal_restart(hdd_ctx->psoc, |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 6576 | &value); |
| 6577 | if (value) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6578 | hdd_start_ap_adapter(adapter); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 6579 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6580 | break; |
| 6581 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6582 | case QDF_P2P_GO_MODE: |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6583 | hdd_delete_sta(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6584 | break; |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6585 | case QDF_MONITOR_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6586 | hdd_start_station_adapter(adapter); |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6587 | hdd_set_mon_rx_cb(adapter->dev); |
| 6588 | wlan_hdd_set_mon_chan(adapter, adapter->mon_chan, |
| 6589 | adapter->mon_bandwidth); |
| 6590 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6591 | default: |
| 6592 | break; |
| 6593 | } |
Krunal Soni | 9c2ee03 | 2017-07-18 13:49:54 -0700 | [diff] [blame] | 6594 | /* |
| 6595 | * Action frame registered in one adapter which will |
| 6596 | * applicable to all interfaces |
| 6597 | */ |
| 6598 | wlan_hdd_cfg80211_register_frames(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6599 | } |
| 6600 | |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6601 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6602 | if (!hdd_is_interface_up(adapter)) |
| 6603 | continue; |
| 6604 | |
| 6605 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
| 6606 | hdd_stop_p2p_go(adapter); |
| 6607 | } |
| 6608 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6609 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6610 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6611 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6612 | } |
| 6613 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6614 | QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6615 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6616 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6617 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6618 | qdf_list_node_t *node; |
| 6619 | |
| 6620 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6621 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6622 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6623 | status = qdf_list_peek_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6624 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6625 | |
| 6626 | if (QDF_IS_STATUS_ERROR(status)) |
| 6627 | return status; |
| 6628 | |
| 6629 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6630 | |
| 6631 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6632 | } |
| 6633 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6634 | QDF_STATUS hdd_get_next_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6635 | struct hdd_adapter *current_adapter, |
| 6636 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6637 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6638 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6639 | qdf_list_node_t *node; |
| 6640 | |
| 6641 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6642 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6643 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6644 | status = qdf_list_peek_next(&hdd_ctx->hdd_adapters, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6645 | ¤t_adapter->node, |
| 6646 | &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6647 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6648 | |
| 6649 | if (QDF_IS_STATUS_ERROR(status)) |
| 6650 | return status; |
| 6651 | |
| 6652 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6653 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6654 | return status; |
| 6655 | } |
| 6656 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6657 | QDF_STATUS hdd_remove_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6658 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6659 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6660 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6661 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6662 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6663 | status = qdf_list_remove_node(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6664 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6665 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6666 | return status; |
| 6667 | } |
| 6668 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6669 | QDF_STATUS hdd_remove_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6670 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6671 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6672 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6673 | qdf_list_node_t *node; |
| 6674 | |
| 6675 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6676 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6677 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6678 | status = qdf_list_remove_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6679 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6680 | |
| 6681 | if (QDF_IS_STATUS_ERROR(status)) |
| 6682 | return status; |
| 6683 | |
| 6684 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6685 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6686 | return status; |
| 6687 | } |
| 6688 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6689 | QDF_STATUS hdd_add_adapter_back(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6690 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6691 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6692 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6693 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6694 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6695 | status = qdf_list_insert_back(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6696 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6697 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6698 | return status; |
| 6699 | } |
| 6700 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6701 | QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6702 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6703 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6704 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6705 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6706 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6707 | status = qdf_list_insert_front(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6708 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6709 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6710 | return status; |
| 6711 | } |
| 6712 | |
Liangwei Dong | 3abfe8f | 2018-09-20 02:25:44 -0400 | [diff] [blame] | 6713 | struct hdd_adapter *hdd_get_adapter_by_rand_macaddr( |
| 6714 | struct hdd_context *hdd_ctx, tSirMacAddr mac_addr) |
| 6715 | { |
| 6716 | struct hdd_adapter *adapter; |
| 6717 | |
| 6718 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6719 | if ((adapter->device_mode == QDF_STA_MODE || |
| 6720 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6721 | adapter->device_mode == QDF_P2P_DEVICE_MODE) && |
| 6722 | ucfg_p2p_check_random_mac(hdd_ctx->psoc, |
| 6723 | adapter->session_id, mac_addr)) |
| 6724 | return adapter; |
| 6725 | } |
| 6726 | |
| 6727 | return NULL; |
| 6728 | } |
| 6729 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6730 | 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] | 6731 | tSirMacAddr macAddr) |
| 6732 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6733 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6734 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6735 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6736 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 6737 | macAddr, sizeof(tSirMacAddr))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6738 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6739 | } |
| 6740 | |
| 6741 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6742 | } |
| 6743 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6744 | 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] | 6745 | uint32_t vdev_id) |
| 6746 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6747 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6748 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6749 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6750 | if (adapter->session_id == vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6751 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6752 | } |
| 6753 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6754 | return NULL; |
| 6755 | } |
| 6756 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6757 | /** |
| 6758 | * hdd_get_adapter_by_sme_session_id() - Return adapter with |
| 6759 | * the sessionid |
| 6760 | * @hdd_ctx: hdd context. |
| 6761 | * @sme_session_id: sme session is for the adapter to get. |
| 6762 | * |
| 6763 | * This function is used to get the adapter with provided session id |
| 6764 | * |
| 6765 | * Return: adapter pointer if found |
| 6766 | * |
| 6767 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 6768 | struct hdd_adapter * |
| 6769 | hdd_get_adapter_by_sme_session_id(struct hdd_context *hdd_ctx, |
| 6770 | uint32_t sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6771 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6772 | struct hdd_adapter *adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6773 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6774 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6775 | if (adapter->session_id == sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6776 | return adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6777 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6778 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6779 | return NULL; |
| 6780 | } |
| 6781 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6782 | 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] | 6783 | const char *iface_name) |
| 6784 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6785 | struct hdd_adapter *adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6786 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6787 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6788 | if (!qdf_str_cmp(adapter->dev->name, iface_name)) |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6789 | return adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6790 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6791 | |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6792 | return NULL; |
| 6793 | } |
| 6794 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6795 | /** |
| 6796 | * hdd_get_adapter() - to get adapter matching the mode |
| 6797 | * @hdd_ctx: hdd context |
| 6798 | * @mode: adapter mode |
| 6799 | * |
| 6800 | * This routine will return the pointer to adapter matching |
| 6801 | * with the passed mode. |
| 6802 | * |
| 6803 | * Return: pointer to adapter or null |
| 6804 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6805 | struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6806 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6807 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6808 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6809 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6810 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6811 | if (adapter->device_mode == mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6812 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6813 | } |
| 6814 | |
| 6815 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6816 | } |
| 6817 | |
Jeff Johnson | 36a0abf | 2018-05-20 11:24:25 -0700 | [diff] [blame] | 6818 | enum QDF_OPMODE hdd_get_device_mode(uint32_t session_id) |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 6819 | { |
| 6820 | struct hdd_context *hdd_ctx; |
| 6821 | struct hdd_adapter *adapter; |
| 6822 | |
| 6823 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 6824 | if (!hdd_ctx) { |
| 6825 | hdd_err("Invalid HDD context"); |
| 6826 | return QDF_MAX_NO_OF_MODE; |
| 6827 | } |
| 6828 | |
| 6829 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 6830 | if (!adapter) { |
| 6831 | hdd_err("Invalid HDD adapter"); |
| 6832 | return QDF_MAX_NO_OF_MODE; |
| 6833 | } |
| 6834 | |
| 6835 | return adapter->device_mode; |
| 6836 | } |
| 6837 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6838 | /** |
| 6839 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 6840 | * @hdd_ctx: Pointer to the HDD context. |
| 6841 | * @mode: Device mode for which operating channel is required. |
Jeff Johnson | 77f89bb | 2018-05-06 16:21:36 -0700 | [diff] [blame] | 6842 | * Supported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6843 | * QDF_STA_MODE, |
| 6844 | * QDF_P2P_CLIENT_MODE, |
| 6845 | * QDF_SAP_MODE, |
| 6846 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6847 | * |
| 6848 | * This API returns the operating channel of the requested device mode |
| 6849 | * |
| 6850 | * Return: channel number. "0" id the requested device is not found OR it is |
| 6851 | * not connected. |
| 6852 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6853 | uint8_t hdd_get_operating_channel(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6854 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6855 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6856 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6857 | uint8_t operatingChannel = 0; |
| 6858 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6859 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6860 | if (mode == adapter->device_mode) { |
| 6861 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6862 | case QDF_STA_MODE: |
| 6863 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6864 | if (hdd_conn_is_connected |
| 6865 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6866 | (adapter))) { |
| 6867 | operatingChannel = |
| 6868 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6869 | (adapter))->conn_info. |
| 6870 | operationChannel; |
| 6871 | } |
| 6872 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6873 | case QDF_SAP_MODE: |
| 6874 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6875 | /* softap connection info */ |
| 6876 | if (test_bit |
| 6877 | (SOFTAP_BSS_STARTED, |
| 6878 | &adapter->event_flags)) |
| 6879 | operatingChannel = |
| 6880 | (WLAN_HDD_GET_AP_CTX_PTR |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 6881 | (adapter))->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6882 | break; |
| 6883 | default: |
| 6884 | break; |
| 6885 | } |
| 6886 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6887 | /* Found the device of interest. break the loop */ |
| 6888 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6889 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6890 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6891 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6892 | return operatingChannel; |
| 6893 | } |
| 6894 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6895 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6896 | hdd_ctx) |
| 6897 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6898 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6899 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6900 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6901 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6902 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6903 | if (adapter->device_mode == QDF_STA_MODE || |
| 6904 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6905 | adapter->device_mode == QDF_IBSS_MODE || |
| 6906 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6907 | adapter->device_mode == QDF_SAP_MODE || |
| 6908 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6909 | hdd_unregister_wext(adapter->dev); |
| 6910 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6911 | } |
| 6912 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6913 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6914 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6915 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6916 | } |
| 6917 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6918 | 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] | 6919 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6920 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6921 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6922 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6923 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6924 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6925 | if (adapter->device_mode == QDF_STA_MODE || |
| 6926 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6927 | adapter->device_mode == QDF_IBSS_MODE || |
| 6928 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6929 | adapter->device_mode == QDF_SAP_MODE || |
| 6930 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 6931 | wlan_abort_scan(hdd_ctx->pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6932 | adapter->session_id, INVALID_SCAN_ID, |
Vignesh Viswanathan | 19611c8 | 2018-01-16 16:20:40 +0530 | [diff] [blame] | 6933 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6934 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6935 | } |
| 6936 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6937 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6938 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6939 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6940 | } |
| 6941 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6942 | /** |
| 6943 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 6944 | * adapters |
| 6945 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 6946 | * |
| 6947 | * return: QDF_STATUS_SUCCESS |
| 6948 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6949 | 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] | 6950 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6951 | struct hdd_adapter *adapter; |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6952 | int err; |
| 6953 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6954 | hdd_enter(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6955 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6956 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6957 | if (adapter->device_mode == QDF_STA_MODE || |
| 6958 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6959 | adapter->device_mode == QDF_IBSS_MODE || |
| 6960 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6961 | adapter->device_mode == QDF_SAP_MODE || |
| 6962 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6963 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 6964 | if (err) |
| 6965 | hdd_err("Unable to stop scheduled scan"); |
| 6966 | } |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6967 | } |
| 6968 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6969 | hdd_exit(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6970 | |
| 6971 | return QDF_STATUS_SUCCESS; |
| 6972 | } |
| 6973 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6974 | #ifdef WLAN_NS_OFFLOAD |
| 6975 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6976 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6977 | * @hdd_ctx: Pointer to hdd context |
| 6978 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6979 | * Unregister for IPv6 address change notifications. |
| 6980 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6981 | * Return: None |
| 6982 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6983 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6984 | { |
| 6985 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6986 | } |
| 6987 | |
| 6988 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6989 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6990 | * @hdd_ctx: Pointer to hdd context |
| 6991 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6992 | * Register for IPv6 address change notifications. |
| 6993 | * |
| 6994 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6995 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6996 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6997 | { |
| 6998 | int ret; |
| 6999 | |
| 7000 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 7001 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7002 | if (ret) { |
| 7003 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 7004 | goto out; |
| 7005 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7006 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7007 | hdd_debug("Registered IPv6 notifier"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7008 | out: |
| 7009 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7010 | } |
| 7011 | #else |
| 7012 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7013 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7014 | * @hdd_ctx: Pointer to hdd context |
| 7015 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7016 | * Unregister for IPv6 address change notifications. |
| 7017 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7018 | * Return: None |
| 7019 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7020 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7021 | { |
| 7022 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7023 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7024 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7025 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7026 | * @hdd_ctx: Pointer to hdd context |
| 7027 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7028 | * Register for IPv6 address change notifications. |
| 7029 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7030 | * Return: None |
| 7031 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7032 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7033 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7034 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7035 | } |
| 7036 | #endif |
| 7037 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7038 | void hdd_set_disconnect_status(struct hdd_adapter *adapter, bool status) |
| 7039 | { |
| 7040 | qdf_mutex_acquire(&adapter->disconnection_status_lock); |
| 7041 | adapter->disconnection_in_progress = status; |
| 7042 | qdf_mutex_release(&adapter->disconnection_status_lock); |
| 7043 | hdd_debug("setting disconnection status: %d", status); |
| 7044 | } |
| 7045 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7046 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7047 | * hdd_register_notifiers - Register netdev notifiers. |
| 7048 | * @hdd_ctx: HDD context |
| 7049 | * |
| 7050 | * Register netdev notifiers like IPv4 and IPv6. |
| 7051 | * |
| 7052 | * Return: 0 on success and errno on failure |
| 7053 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7054 | static int hdd_register_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7055 | { |
| 7056 | int ret; |
| 7057 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7058 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 7059 | if (ret) |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 7060 | goto out; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7061 | |
| 7062 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 7063 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 7064 | if (ret) { |
| 7065 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 7066 | goto unregister_ip6_notifier; |
| 7067 | } |
| 7068 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7069 | ret = hdd_nud_register_netevent_notifier(hdd_ctx); |
| 7070 | if (ret) { |
| 7071 | hdd_err("Failed to register netevent notifier: %d", |
| 7072 | ret); |
| 7073 | goto unregister_inetaddr_notifier; |
| 7074 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7075 | return 0; |
| 7076 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7077 | unregister_inetaddr_notifier: |
| 7078 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7079 | unregister_ip6_notifier: |
| 7080 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7081 | out: |
| 7082 | return ret; |
| 7083 | |
| 7084 | } |
| 7085 | |
| 7086 | /** |
| 7087 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 7088 | * @hdd_ctx: HDD context |
| 7089 | * |
| 7090 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 7091 | * |
| 7092 | * Return: None. |
| 7093 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7094 | void hdd_unregister_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7095 | { |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7096 | hdd_nud_unregister_netevent_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7097 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 7098 | |
| 7099 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7100 | } |
| 7101 | |
| 7102 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7103 | * hdd_exit_netlink_services - Exit netlink services |
| 7104 | * @hdd_ctx: HDD context |
| 7105 | * |
| 7106 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 7107 | * nl service. |
| 7108 | * |
| 7109 | * Return: None. |
| 7110 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7111 | static void hdd_exit_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7112 | { |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7113 | spectral_scan_deactivate_service(); |
| 7114 | cnss_diag_deactivate_service(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7115 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7116 | ptt_sock_deactivate_svc(); |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7117 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7118 | |
| 7119 | nl_srv_exit(); |
| 7120 | } |
| 7121 | |
| 7122 | /** |
| 7123 | * hdd_init_netlink_services- Init netlink services |
| 7124 | * @hdd_ctx: HDD context |
| 7125 | * |
| 7126 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 7127 | * nl service. |
| 7128 | * |
| 7129 | * Return: 0 on success and errno on failure. |
| 7130 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7131 | static int hdd_init_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7132 | { |
| 7133 | int ret; |
| 7134 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 7135 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7136 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7137 | hdd_err("nl_srv_init failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7138 | goto out; |
| 7139 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 7140 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7141 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 7142 | ret = hdd_activate_wifi_pos(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7143 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7144 | hdd_err("hdd_activate_wifi_pos failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7145 | goto err_nl_srv; |
| 7146 | } |
| 7147 | |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7148 | ptt_sock_activate_svc(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7149 | |
| 7150 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 7151 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7152 | hdd_err("hdd_open_cesium_nl_sock failed ret: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7153 | |
| 7154 | ret = cnss_diag_activate_service(); |
| 7155 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7156 | hdd_err("cnss_diag_activate_service failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7157 | goto err_close_cesium; |
| 7158 | } |
| 7159 | |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7160 | spectral_scan_activate_service(); |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 7161 | |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7162 | return 0; |
| 7163 | |
| 7164 | err_close_cesium: |
| 7165 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7166 | ptt_sock_deactivate_svc(); |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7167 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7168 | err_nl_srv: |
| 7169 | nl_srv_exit(); |
| 7170 | out: |
| 7171 | return ret; |
| 7172 | } |
| 7173 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7174 | /** |
| 7175 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 7176 | * @hdd_ctx: HDD context. |
| 7177 | * |
| 7178 | * Destroy RX wakelock. |
| 7179 | * |
| 7180 | * Return: None. |
| 7181 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7182 | static void hdd_rx_wake_lock_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7183 | { |
| 7184 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 7185 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7186 | |
| 7187 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7188 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 7189 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7190 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7191 | * Create RX wakelock. |
| 7192 | * |
| 7193 | * Return: None. |
| 7194 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7195 | static void hdd_rx_wake_lock_create(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7196 | { |
| 7197 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 7198 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7199 | |
| 7200 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7201 | * hdd_context_deinit() - Deinitialize HDD context |
| 7202 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7203 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7204 | * Deinitialize HDD context along with all the feature specific contexts but |
| 7205 | * do not free hdd context itself. Caller of this API is supposed to free |
| 7206 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7207 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7208 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7209 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7210 | static int hdd_context_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7211 | { |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 7212 | qdf_wake_lock_destroy(&hdd_ctx->monitor_mode_wakelock); |
| 7213 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7214 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7215 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7216 | hdd_sap_context_destroy(hdd_ctx); |
| 7217 | |
| 7218 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 7219 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7220 | hdd_scan_context_destroy(hdd_ctx); |
| 7221 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 7222 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7223 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7224 | return 0; |
| 7225 | } |
| 7226 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 7227 | void hdd_context_destroy(struct hdd_context *hdd_ctx) |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7228 | { |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 7229 | cds_set_context(QDF_MODULE_ID_HDD, NULL); |
Arunk Khandavalli | 3d267b4 | 2017-05-02 18:58:59 +0530 | [diff] [blame] | 7230 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 7231 | hdd_exit_netlink_services(hdd_ctx); |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 7232 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 7233 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7234 | hdd_context_deinit(hdd_ctx); |
| 7235 | |
Dustin Brown | db2df2e | 2018-10-31 15:29:24 -0700 | [diff] [blame] | 7236 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 7237 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7238 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7239 | hdd_ctx->config = NULL; |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 7240 | cfg_release(); |
| 7241 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7242 | wiphy_free(hdd_ctx->wiphy); |
| 7243 | } |
| 7244 | |
| 7245 | /** |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 7246 | * wlan_destroy_bug_report_lock() - Destroy bug report lock |
| 7247 | * |
| 7248 | * This function is used to destroy bug report lock |
| 7249 | * |
| 7250 | * Return: None |
| 7251 | */ |
| 7252 | static void wlan_destroy_bug_report_lock(void) |
| 7253 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 7254 | struct cds_context *p_cds_context; |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 7255 | |
| 7256 | p_cds_context = cds_get_global_context(); |
| 7257 | if (!p_cds_context) { |
| 7258 | hdd_err("cds context is NULL"); |
| 7259 | return; |
| 7260 | } |
| 7261 | |
| 7262 | qdf_spinlock_destroy(&p_cds_context->bug_report_lock); |
| 7263 | } |
| 7264 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7265 | #ifdef DISABLE_CHANNEL_LIST |
| 7266 | static void wlan_hdd_cache_chann_mutex_destroy(struct hdd_context *hdd_ctx) |
| 7267 | { |
| 7268 | qdf_mutex_destroy(&hdd_ctx->cache_channel_lock); |
| 7269 | } |
| 7270 | #else |
| 7271 | static void wlan_hdd_cache_chann_mutex_destroy(struct hdd_context *hdd_ctx) |
| 7272 | { |
| 7273 | } |
| 7274 | #endif |
| 7275 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 7276 | void hdd_wlan_exit(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7277 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7278 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7279 | int driver_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7280 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7281 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7282 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 7283 | hdd_psoc_idle_timer_stop(hdd_ctx); |
Dustin Brown | 6470aba | 2018-09-05 09:49:58 -0700 | [diff] [blame] | 7284 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7285 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7286 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7287 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 7288 | if (QDF_TIMER_STATE_RUNNING == |
| 7289 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 7290 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7291 | } |
| 7292 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7293 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 7294 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 7295 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7296 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7297 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 7298 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 7299 | hdd_ctx->last_acs_channel_list = NULL; |
| 7300 | hdd_ctx->num_of_channels = 0; |
| 7301 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7302 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7303 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7304 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 7305 | driver_status = hdd_ctx->driver_status; |
| 7306 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 7307 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7308 | /* |
| 7309 | * Powersave Offload Case |
| 7310 | * Disable Idle Power Save Mode |
| 7311 | */ |
| 7312 | hdd_set_idle_ps_config(hdd_ctx, false); |
Sandeep Puligilla | 8fa28fd | 2017-11-02 12:19:33 -0700 | [diff] [blame] | 7313 | /* clear the scan queue in all the scenarios */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 7314 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->pdev, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7315 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7316 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 7317 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 7318 | /* |
| 7319 | * Cancel any outstanding scan requests. We are about to close |
| 7320 | * all of our adapters, but an adapter structure is what SME |
| 7321 | * passes back to our callback function. Hence if there |
| 7322 | * are any outstanding scan requests then there is a |
| 7323 | * race condition between when the adapter is closed and |
| 7324 | * when the callback is invoked. We try to resolve that |
| 7325 | * race condition here by canceling any outstanding scans |
| 7326 | * before we close the adapters. |
| 7327 | * Note that the scans may be cancelled in an asynchronous |
| 7328 | * manner, so ideally there needs to be some kind of |
| 7329 | * synchronization. Rather than introduce a new |
| 7330 | * synchronization here, we will utilize the fact that we are |
| 7331 | * about to Request Full Power, and since that is synchronized, |
| 7332 | * the expectation is that by the time Request Full Power has |
| 7333 | * completed, all scans will be cancelled |
| 7334 | */ |
| 7335 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7336 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 7337 | hdd_stop_all_adapters(hdd_ctx); |
bings | 29c9986 | 2017-11-01 13:54:13 +0800 | [diff] [blame] | 7338 | hdd_deinit_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7339 | } |
| 7340 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 7341 | unregister_reboot_notifier(&system_reboot_notifier); |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 7342 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 7343 | |
Rachit Kankane | 3080733 | 2018-06-27 18:39:36 +0530 | [diff] [blame] | 7344 | qdf_dp_trace_deinit(); |
| 7345 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 7346 | hdd_wlan_stop_modules(hdd_ctx, false); |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 7347 | |
Visweswara Tanuku | c029a20 | 2018-11-27 10:42:10 +0530 | [diff] [blame] | 7348 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 7349 | hdd_bus_bandwidth_deinit(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 7350 | hdd_driver_memdump_deinit(); |
| 7351 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 7352 | qdf_nbuf_deinit_replenish_timer(); |
| 7353 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 7354 | if (QDF_GLOBAL_MONITOR_MODE == hdd_get_conparam()) { |
| 7355 | hdd_info("Release wakelock for monitor mode!"); |
| 7356 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 7357 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 7358 | } |
| 7359 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7360 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7361 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7362 | wlan_hdd_cache_chann_mutex_destroy(hdd_ctx); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7363 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 7364 | osif_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7365 | |
Dustin Brown | d005ad8 | 2018-01-19 10:32:13 -0800 | [diff] [blame] | 7366 | hdd_close_all_adapters(hdd_ctx, false); |
| 7367 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 7368 | wlansap_global_deinit(); |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7369 | /* |
| 7370 | * If there is re_init failure wiphy would have already de-registered |
| 7371 | * check the wiphy status before un-registering again |
| 7372 | */ |
Ashish Kumar Dhanotiya | e16feb7 | 2017-03-31 19:39:37 +0530 | [diff] [blame] | 7373 | if (wiphy && wiphy->registered) { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7374 | wiphy_unregister(wiphy); |
| 7375 | wlan_hdd_cfg80211_deinit(wiphy); |
| 7376 | hdd_lpass_notify_stop(hdd_ctx); |
| 7377 | } |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 7378 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7379 | hdd_exit_netlink_services(hdd_ctx); |
| 7380 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 7381 | #ifdef FEATURE_WLAN_CH_AVOID |
| 7382 | mutex_destroy(&hdd_ctx->avoid_freq_lock); |
| 7383 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7384 | } |
| 7385 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7386 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7387 | /** |
| 7388 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7389 | * @data: pointer to struct hdd_context |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7390 | * |
| 7391 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 7392 | * Then new ACS request will do a fresh scan without reusing the cached |
| 7393 | * scan information. |
| 7394 | * |
| 7395 | * Return: void |
| 7396 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 7397 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7398 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7399 | struct hdd_context *hdd_ctx = (struct hdd_context *) data; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7400 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7401 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7402 | hdd_debug("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7403 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7404 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 7405 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 7406 | hdd_ctx->last_acs_channel_list = NULL; |
| 7407 | hdd_ctx->num_of_channels = 0; |
| 7408 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7409 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7410 | mac_handle = hdd_ctx->mac_handle; |
| 7411 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7412 | return; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7413 | sme_scan_flush_result(mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7414 | } |
| 7415 | #endif |
| 7416 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7417 | /** |
| 7418 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 7419 | * @state: state |
| 7420 | * |
| 7421 | * This function notifies FW with modem power status |
| 7422 | * |
| 7423 | * Return: 0 if successful, error number otherwise |
| 7424 | */ |
| 7425 | int hdd_wlan_notify_modem_power_state(int state) |
| 7426 | { |
| 7427 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7428 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7429 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7430 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7431 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7432 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7433 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7434 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7435 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7436 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7437 | mac_handle = hdd_ctx->mac_handle; |
| 7438 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7439 | return -EINVAL; |
| 7440 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7441 | qdf_status = sme_notify_modem_power_state(mac_handle, state); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7442 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7443 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7444 | state); |
| 7445 | return -EINVAL; |
| 7446 | } |
| 7447 | return 0; |
| 7448 | } |
| 7449 | |
| 7450 | /** |
| 7451 | * |
| 7452 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 7453 | * @adapter - Pointer to the HDD |
| 7454 | * |
| 7455 | * Return: None |
| 7456 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7457 | QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7458 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7459 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7460 | |
| 7461 | /* |
| 7462 | * Send ready indication to the HDD. This will kick off the MAC |
| 7463 | * into a 'running' state and should kick off an initial scan. |
| 7464 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7465 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->mac_handle); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7466 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7467 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 7468 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7469 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7470 | } |
| 7471 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7472 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7473 | } |
| 7474 | |
Sourav Mohapatra | 92ea8d6 | 2018-02-05 10:03:10 +0530 | [diff] [blame] | 7475 | struct hdd_adapter *hdd_get_first_valid_adapter(struct hdd_context *hdd_ctx) |
| 7476 | { |
| 7477 | struct hdd_adapter *adapter; |
| 7478 | |
| 7479 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 7480 | if (adapter && adapter->magic == WLAN_HDD_ADAPTER_MAGIC) |
| 7481 | return adapter; |
| 7482 | } |
| 7483 | |
| 7484 | return NULL; |
| 7485 | } |
| 7486 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7487 | /* wake lock APIs for HDD */ |
| 7488 | void hdd_prevent_suspend(uint32_t reason) |
| 7489 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 7490 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7491 | } |
| 7492 | |
| 7493 | void hdd_allow_suspend(uint32_t reason) |
| 7494 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 7495 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7496 | } |
| 7497 | |
| 7498 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 7499 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 7500 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 7501 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7502 | } |
| 7503 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7504 | /* Initialize channel list in sme based on the country code */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7505 | QDF_STATUS hdd_set_sme_chan_list(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7506 | { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7507 | return sme_init_chan_list(hdd_ctx->mac_handle, |
Amar Singhal | 6f8592b | 2017-04-26 14:31:58 -0700 | [diff] [blame] | 7508 | hdd_ctx->reg.alpha2, |
| 7509 | hdd_ctx->reg.cc_src); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7510 | } |
| 7511 | |
| 7512 | /** |
| 7513 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 7514 | * @hdd_ctx: Pointer to the hdd context |
| 7515 | * |
| 7516 | * HDD function to know if hardware supports 5GHz |
| 7517 | * |
| 7518 | * Return: true if hardware supports 5GHz |
| 7519 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7520 | bool hdd_is_5g_supported(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7521 | { |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 7522 | if (!hdd_ctx) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7523 | return true; |
| 7524 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 7525 | if (hdd_ctx->curr_band != BAND_2G) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7526 | return true; |
| 7527 | else |
| 7528 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7529 | } |
| 7530 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7531 | static int hdd_wiphy_init(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7532 | { |
| 7533 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7534 | int ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7535 | |
| 7536 | wiphy = hdd_ctx->wiphy; |
| 7537 | |
| 7538 | /* |
| 7539 | * The channel information in |
| 7540 | * wiphy needs to be initialized before wiphy registration |
| 7541 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7542 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 7543 | if (ret_val) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7544 | hdd_err("regulatory init failed"); |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7545 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7546 | } |
| 7547 | |
| 7548 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 7549 | wiphy->wowlan = &wowlan_support_reg_init; |
| 7550 | #else |
| 7551 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 7552 | WIPHY_WOWLAN_MAGIC_PKT | |
| 7553 | WIPHY_WOWLAN_DISCONNECT | |
| 7554 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 7555 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 7556 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 7557 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 7558 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 7559 | |
| 7560 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 7561 | WOW_MAX_FILTERS_PER_LIST); |
| 7562 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 7563 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 7564 | #endif |
Liangwei Dong | 0da1426 | 2018-07-03 03:30:23 -0400 | [diff] [blame] | 7565 | if (hdd_ctx->obss_scan_offload) { |
| 7566 | hdd_debug("wmi_service_obss_scan supported"); |
| 7567 | } else if (hdd_ctx->config->nChannelBondingMode24GHz) { |
| 7568 | hdd_debug("enable wpa_supp obss_scan"); |
| 7569 | wiphy->features |= NL80211_FEATURE_NEED_OBSS_SCAN; |
| 7570 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7571 | |
| 7572 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7573 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7574 | if (0 > ret_val) { |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7575 | hdd_err("wiphy registration failed"); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7576 | return ret_val; |
| 7577 | } |
Amar Singhal | ac26de2 | 2018-06-22 12:53:06 -0700 | [diff] [blame] | 7578 | |
Kiran Kumar Lokere | 0508af9 | 2018-04-23 18:38:32 -0700 | [diff] [blame] | 7579 | /* Check the kernel version for upstream commit aced43ce780dc5 that |
| 7580 | * has support for processing user cell_base hints when wiphy is |
| 7581 | * self managed or check the backport flag for the same. |
| 7582 | */ |
Amar Singhal | ac26de2 | 2018-06-22 12:53:06 -0700 | [diff] [blame] | 7583 | #if defined CFG80211_USER_HINT_CELL_BASE_SELF_MANAGED || \ |
| 7584 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)) |
Kiran Kumar Lokere | 0508af9 | 2018-04-23 18:38:32 -0700 | [diff] [blame] | 7585 | hdd_send_wiphy_regd_sync_event(hdd_ctx); |
| 7586 | #endif |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7587 | |
Amar Singhal | 2d81201 | 2018-02-03 15:06:47 +0800 | [diff] [blame] | 7588 | pld_increment_driver_load_cnt(hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7589 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7590 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7591 | } |
| 7592 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7593 | #ifdef MSM_PLATFORM |
| 7594 | /** |
| 7595 | * hdd_display_periodic_stats() - Function to display periodic stats |
| 7596 | * @hdd_ctx - handle to hdd context |
| 7597 | * @bool data_in_interval - true, if data detected in bw time interval |
| 7598 | * |
| 7599 | * The periodicity is determined by hdd_ctx->config->periodic_stats_disp_time. |
| 7600 | * Stats show up in wlan driver logs. |
| 7601 | * |
| 7602 | * Returns: None |
| 7603 | */ |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7604 | static void hdd_display_periodic_stats(struct hdd_context *hdd_ctx, |
| 7605 | bool data_in_interval) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7606 | { |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7607 | static uint32_t counter; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7608 | static bool data_in_time_period; |
| 7609 | ol_txrx_pdev_handle pdev; |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 7610 | ol_txrx_soc_handle soc; |
Arif Hussain | cca6043 | 2018-12-03 19:45:12 -0800 | [diff] [blame] | 7611 | uint32_t periodic_stats_disp_time = 0; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7612 | |
Arif Hussain | cca6043 | 2018-12-03 19:45:12 -0800 | [diff] [blame] | 7613 | ucfg_mlme_stats_get_periodic_display_time(hdd_ctx->psoc, |
| 7614 | &periodic_stats_disp_time); |
| 7615 | if (!periodic_stats_disp_time) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7616 | return; |
| 7617 | |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 7618 | soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 7619 | if (!soc) { |
| 7620 | hdd_err("soc is NULL"); |
| 7621 | return; |
| 7622 | } |
| 7623 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7624 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 7625 | if (!pdev) { |
| 7626 | hdd_err("pdev is NULL"); |
| 7627 | return; |
| 7628 | } |
| 7629 | |
| 7630 | counter++; |
| 7631 | if (data_in_interval) |
| 7632 | data_in_time_period = data_in_interval; |
| 7633 | |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7634 | if (counter * hdd_ctx->config->bus_bw_compute_interval >= |
Arif Hussain | cca6043 | 2018-12-03 19:45:12 -0800 | [diff] [blame] | 7635 | periodic_stats_disp_time * 1000) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7636 | if (data_in_time_period) { |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7637 | wlan_hdd_display_txrx_stats(hdd_ctx); |
Mohit Khanna | c964965 | 2018-11-28 18:10:28 -0800 | [diff] [blame^] | 7638 | dp_txrx_ext_dump_stats(soc, CDP_DP_RX_THREAD_STATS); |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 7639 | cdp_display_stats(soc, |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7640 | CDP_RX_RING_STATS, |
| 7641 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 7642 | cdp_display_stats(soc, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7643 | CDP_TXRX_PATH_STATS, |
| 7644 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7645 | wlan_hdd_display_netif_queue_history |
| 7646 | (hdd_ctx, QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7647 | qdf_dp_trace_dump_stats(); |
| 7648 | } |
| 7649 | counter = 0; |
| 7650 | data_in_time_period = false; |
| 7651 | } |
| 7652 | } |
| 7653 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7654 | /** |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7655 | * hdd_clear_rps_cpu_mask - clear RPS CPU mask for interfaces |
| 7656 | * @hdd_ctx: pointer to struct hdd_context |
| 7657 | * |
| 7658 | * Return: none |
| 7659 | */ |
| 7660 | static void hdd_clear_rps_cpu_mask(struct hdd_context *hdd_ctx) |
| 7661 | { |
| 7662 | struct hdd_adapter *adapter; |
| 7663 | |
| 7664 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 7665 | hdd_send_rps_disable_ind(adapter); |
| 7666 | } |
| 7667 | |
| 7668 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7669 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7670 | * @hdd_ctx - handle to hdd context |
| 7671 | * @tx_packets - transmit packet count |
| 7672 | * @rx_packets - receive packet count |
| 7673 | * |
| 7674 | * The function controls the bus bandwidth and dynamic control of |
| 7675 | * tcp delayed ack configuration |
| 7676 | * |
| 7677 | * Returns: None |
| 7678 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7679 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7680 | static void hdd_pld_request_bus_bandwidth(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 7681 | const uint64_t tx_packets, |
| 7682 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7683 | { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7684 | u64 total_pkts = tx_packets + rx_packets; |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7685 | uint64_t temp_tx = 0, avg_rx = 0; |
| 7686 | uint64_t no_rx_offload_pkts = 0, avg_no_rx_offload_pkts = 0; |
| 7687 | uint64_t rx_offload_pkts = 0, avg_rx_offload_pkts = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7688 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7689 | static enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7690 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7691 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7692 | uint16_t index = 0; |
| 7693 | bool vote_level_change = false; |
| 7694 | bool rx_level_change = false; |
| 7695 | bool tx_level_change = false; |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7696 | bool rxthread_high_tput_req = false; |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7697 | bool dptrace_high_tput_req; |
Srinivas Girigowda | 5033534 | 2018-09-07 15:21:01 -0700 | [diff] [blame] | 7698 | |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7699 | if (total_pkts > hdd_ctx->config->bus_bw_high_threshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7700 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7701 | else if (total_pkts > hdd_ctx->config->bus_bw_medium_threshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7702 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7703 | else if (total_pkts > hdd_ctx->config->bus_bw_low_threshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7704 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 7705 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7706 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7707 | |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7708 | dptrace_high_tput_req = |
| 7709 | next_vote_level > PLD_BUS_WIDTH_NONE ? true : false; |
| 7710 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7711 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7712 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 7713 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7714 | hdd_ctx->cur_vote_level = next_vote_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7715 | vote_level_change = true; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7716 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7717 | if ((next_vote_level == PLD_BUS_WIDTH_LOW) || |
| 7718 | (next_vote_level == PLD_BUS_WIDTH_NONE)) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7719 | if (hdd_ctx->hbw_requested) { |
| 7720 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 7721 | hdd_ctx->hbw_requested = false; |
| 7722 | } |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7723 | if (hdd_ctx->dynamic_rps) |
| 7724 | hdd_clear_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7725 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7726 | if (!hdd_ctx->hbw_requested) { |
| 7727 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 7728 | hdd_ctx->hbw_requested = true; |
| 7729 | } |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7730 | if (hdd_ctx->dynamic_rps) |
| 7731 | hdd_set_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7732 | } |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7733 | |
Manjunathappa Prakash | cb6df76 | 2018-05-29 18:54:58 -0700 | [diff] [blame] | 7734 | if (hdd_ctx->config->napi_cpu_affinity_mask) |
| 7735 | hdd_napi_apply_throughput_policy(hdd_ctx, |
| 7736 | tx_packets, |
| 7737 | rx_packets); |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7738 | |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7739 | if (rx_packets < hdd_ctx->config->bus_bw_low_threshold) |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7740 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, true); |
| 7741 | else |
| 7742 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7743 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7744 | |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7745 | qdf_dp_trace_apply_tput_policy(dptrace_high_tput_req); |
| 7746 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7747 | /* |
| 7748 | * Includes tcp+udp, if perf core is required for tcp, then |
| 7749 | * perf core is also required for udp. |
| 7750 | */ |
| 7751 | no_rx_offload_pkts = hdd_ctx->no_rx_offload_pkt_cnt; |
| 7752 | hdd_ctx->no_rx_offload_pkt_cnt = 0; |
| 7753 | rx_offload_pkts = rx_packets - no_rx_offload_pkts; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7754 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7755 | avg_no_rx_offload_pkts = (no_rx_offload_pkts + |
| 7756 | hdd_ctx->prev_no_rx_offload_pkts) / 2; |
| 7757 | hdd_ctx->prev_no_rx_offload_pkts = no_rx_offload_pkts; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 7758 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7759 | avg_rx_offload_pkts = (rx_offload_pkts + |
| 7760 | hdd_ctx->prev_rx_offload_pkts) / 2; |
| 7761 | hdd_ctx->prev_rx_offload_pkts = rx_offload_pkts; |
| 7762 | |
| 7763 | avg_rx = avg_no_rx_offload_pkts + avg_rx_offload_pkts; |
| 7764 | /* |
| 7765 | * Takes care to set Rx_thread affinity for below case |
| 7766 | * 1)LRO/GRO not supported ROME case |
| 7767 | * 2)when rx_ol is disabled in cases like concurrency etc |
| 7768 | * 3)For UDP cases |
| 7769 | */ |
| 7770 | if (avg_no_rx_offload_pkts > |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7771 | hdd_ctx->config->bus_bw_high_threshold) |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7772 | rxthread_high_tput_req = true; |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7773 | else |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7774 | rxthread_high_tput_req = false; |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7775 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7776 | if (cds_sched_handle_throughput_req(rxthread_high_tput_req)) |
| 7777 | hdd_warn("Rx thread high_tput(%d) affinity request failed", |
| 7778 | rxthread_high_tput_req); |
| 7779 | |
| 7780 | /* fine-tuning parameters for RX Flows */ |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7781 | if (avg_rx > hdd_ctx->config->tcp_delack_thres_high) { |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 7782 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 7783 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 7784 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 7785 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7786 | } else { |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7787 | hdd_ctx->rx_high_ind_cnt = 0; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7788 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7789 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7790 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7791 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7792 | struct wlan_rx_tp_data rx_tp_data = {0}; |
| 7793 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7794 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Jeff Johnson | b9feee4 | 2018-07-08 10:34:48 -0700 | [diff] [blame] | 7795 | next_rx_level, avg_rx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7796 | hdd_ctx->cur_rx_level = next_rx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7797 | rx_level_change = true; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7798 | /* Send throughput indication only if it is enabled. |
| 7799 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 7800 | * to default delayed ack. Note that this will disable the |
| 7801 | * dynamic delayed ack mechanism across the system |
| 7802 | */ |
Manjunathappa Prakash | bfd1276 | 2018-04-29 22:44:52 -0700 | [diff] [blame] | 7803 | if (hdd_ctx->en_tcp_delack_no_lro) |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7804 | rx_tp_data.rx_tp_flags |= TCP_DEL_ACK_IND; |
| 7805 | |
Mohit Khanna | 6272fb68 | 2017-04-13 09:34:36 -0700 | [diff] [blame] | 7806 | if (hdd_ctx->config->enable_tcp_adv_win_scale) |
| 7807 | rx_tp_data.rx_tp_flags |= TCP_ADV_WIN_SCL; |
| 7808 | |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7809 | rx_tp_data.level = next_rx_level; |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 7810 | wlan_hdd_update_tcp_rx_param(hdd_ctx, &rx_tp_data); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7811 | } |
| 7812 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7813 | /* fine-tuning parameters for TX Flows */ |
| 7814 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 7815 | hdd_ctx->prev_tx = tx_packets; |
| 7816 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 7817 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 7818 | else |
| 7819 | next_tx_level = WLAN_SVC_TP_LOW; |
| 7820 | |
Prakash Manjunathappa | e73e3b5 | 2018-02-27 18:56:22 -0800 | [diff] [blame] | 7821 | if ((hdd_ctx->config->enable_tcp_limit_output) && |
| 7822 | (hdd_ctx->cur_tx_level != next_tx_level)) { |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 7823 | struct wlan_tx_tp_data tx_tp_data = {0}; |
| 7824 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7825 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 7826 | next_tx_level, temp_tx); |
| 7827 | hdd_ctx->cur_tx_level = next_tx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7828 | tx_level_change = true; |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 7829 | tx_tp_data.level = next_tx_level; |
| 7830 | tx_tp_data.tcp_limit_output = true; |
| 7831 | wlan_hdd_update_tcp_tx_param(hdd_ctx, &tx_tp_data); |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7832 | } |
| 7833 | |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7834 | index = hdd_ctx->hdd_txrx_hist_idx; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7835 | if (vote_level_change || tx_level_change || rx_level_change) { |
| 7836 | hdd_ctx->hdd_txrx_hist[index].next_tx_level = next_tx_level; |
| 7837 | hdd_ctx->hdd_txrx_hist[index].next_rx_level = next_rx_level; |
| 7838 | hdd_ctx->hdd_txrx_hist[index].next_vote_level = next_vote_level; |
| 7839 | hdd_ctx->hdd_txrx_hist[index].interval_rx = rx_packets; |
| 7840 | hdd_ctx->hdd_txrx_hist[index].interval_tx = tx_packets; |
| 7841 | hdd_ctx->hdd_txrx_hist[index].qtime = qdf_get_log_timestamp(); |
| 7842 | hdd_ctx->hdd_txrx_hist_idx++; |
| 7843 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
| 7844 | } |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7845 | |
| 7846 | hdd_display_periodic_stats(hdd_ctx, (total_pkts > 0) ? true : false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7847 | } |
| 7848 | |
| 7849 | #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] | 7850 | static void __hdd_bus_bw_work_handler(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7851 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7852 | struct hdd_context *hdd_ctx = container_of(work, struct hdd_context, |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7853 | bus_bw_work); |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7854 | struct hdd_adapter *adapter = NULL, *con_sap_adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7855 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 7856 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 7857 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7858 | uint64_t total_tx = 0, total_rx = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7859 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7860 | bool connected = false; |
| 7861 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 7862 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7863 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7864 | return; |
| 7865 | |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 7866 | if (hdd_ctx->is_wiphy_suspended) |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7867 | goto restart_timer; |
| 7868 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7869 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 7870 | /* |
| 7871 | * Validate magic so we don't end up accessing |
| 7872 | * an invalid adapter. |
| 7873 | */ |
| 7874 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 7875 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7876 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7877 | if ((adapter->device_mode == QDF_STA_MODE || |
| 7878 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7879 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.connState |
| 7880 | != eConnectionState_Associated) { |
| 7881 | |
| 7882 | continue; |
| 7883 | } |
| 7884 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7885 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 7886 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 7887 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active == false) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7888 | |
| 7889 | continue; |
| 7890 | } |
| 7891 | |
| 7892 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 7893 | adapter->prev_tx_packets); |
| 7894 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 7895 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7896 | |
| 7897 | if (adapter->device_mode == QDF_SAP_MODE || |
| 7898 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 7899 | adapter->device_mode == QDF_IBSS_MODE) { |
| 7900 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 7901 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 7902 | cds_get_context(QDF_MODULE_ID_SOC), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7903 | adapter->session_id, |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7904 | &fwd_tx_packets, &fwd_rx_packets); |
| 7905 | if (ret == A_OK) { |
| 7906 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 7907 | fwd_tx_packets, |
| 7908 | adapter->prev_fwd_tx_packets); |
| 7909 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 7910 | fwd_tx_packets, |
| 7911 | adapter->prev_fwd_rx_packets); |
| 7912 | } |
| 7913 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7914 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7915 | if (adapter->device_mode == QDF_SAP_MODE) |
| 7916 | con_sap_adapter = adapter; |
| 7917 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7918 | total_rx += adapter->stats.rx_packets; |
| 7919 | total_tx += adapter->stats.tx_packets; |
| 7920 | |
| 7921 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 7922 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 7923 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7924 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 7925 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7926 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 7927 | connected = true; |
| 7928 | } |
| 7929 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7930 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7931 | hdd_err("bus bandwidth timer running in disconnected state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7932 | return; |
| 7933 | } |
| 7934 | |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7935 | /* add intra bss forwarded tx and rx packets */ |
| 7936 | tx_packets += fwd_tx_packets_diff; |
| 7937 | rx_packets += fwd_rx_packets_diff; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7938 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 7939 | if (ucfg_ipa_is_fw_wdi_activated(hdd_ctx->pdev)) { |
| 7940 | ucfg_ipa_uc_stat_query(hdd_ctx->pdev, &ipa_tx_packets, |
| 7941 | &ipa_rx_packets); |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7942 | tx_packets += (uint64_t)ipa_tx_packets; |
| 7943 | rx_packets += (uint64_t)ipa_rx_packets; |
| 7944 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7945 | if (con_sap_adapter) { |
| 7946 | con_sap_adapter->stats.tx_packets += ipa_tx_packets; |
| 7947 | con_sap_adapter->stats.rx_packets += ipa_rx_packets; |
| 7948 | } |
| 7949 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 7950 | ucfg_ipa_set_perf_level(hdd_ctx->pdev, tx_packets, rx_packets); |
| 7951 | ucfg_ipa_uc_stat_request(hdd_ctx->pdev, 2); |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7952 | } |
| 7953 | |
| 7954 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7955 | |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7956 | restart_timer: |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 7957 | /* ensure periodic timer should still be running before restarting it */ |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7958 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 7959 | if (hdd_ctx->bus_bw_timer_running) |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 7960 | qdf_timer_mod(&hdd_ctx->bus_bw_timer, |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7961 | hdd_ctx->config->bus_bw_compute_interval); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7962 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7963 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7964 | |
Rajeev Kumar | b2b5e69 | 2018-08-31 15:12:40 -0700 | [diff] [blame] | 7965 | static void hdd_bus_bw_work_handler(struct work_struct *work) |
| 7966 | { |
| 7967 | cds_ssr_protect(__func__); |
| 7968 | __hdd_bus_bw_work_handler(work); |
| 7969 | cds_ssr_unprotect(__func__); |
| 7970 | } |
| 7971 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7972 | /** |
| 7973 | * __hdd_bus_bw_cbk() - Bus bandwidth data structure callback. |
| 7974 | * @arg: Argument of timer function |
| 7975 | * |
| 7976 | * Schedule a workqueue in this function where all the processing is done. |
| 7977 | * |
| 7978 | * Return: None. |
| 7979 | */ |
| 7980 | static void __hdd_bus_bw_cbk(void *arg) |
| 7981 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7982 | struct hdd_context *hdd_ctx = (struct hdd_context *) arg; |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7983 | |
| 7984 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7985 | return; |
| 7986 | |
| 7987 | schedule_work(&hdd_ctx->bus_bw_work); |
| 7988 | } |
| 7989 | |
| 7990 | /** |
| 7991 | * hdd_bus_bw_cbk() - Wrapper for bus bw callback for SSR protection. |
| 7992 | * @arg: Argument of timer function |
| 7993 | * |
| 7994 | * Return: None. |
| 7995 | */ |
| 7996 | static void hdd_bus_bw_cbk(void *arg) |
| 7997 | { |
| 7998 | cds_ssr_protect(__func__); |
| 7999 | __hdd_bus_bw_cbk(arg); |
| 8000 | cds_ssr_unprotect(__func__); |
| 8001 | } |
| 8002 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8003 | int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8004 | { |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8005 | hdd_enter(); |
| 8006 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8007 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8008 | INIT_WORK(&hdd_ctx->bus_bw_work, hdd_bus_bw_work_handler); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 8009 | hdd_ctx->bus_bw_timer_running = false; |
| 8010 | qdf_spinlock_create(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8011 | qdf_timer_init(NULL, &hdd_ctx->bus_bw_timer, hdd_bus_bw_cbk, |
| 8012 | (void *)hdd_ctx, QDF_TIMER_TYPE_SW); |
| 8013 | |
| 8014 | hdd_exit(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8015 | |
| 8016 | return 0; |
| 8017 | } |
| 8018 | |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 8019 | void hdd_bus_bandwidth_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8020 | { |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8021 | hdd_enter(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8022 | |
Rajeev Kumar | c27efb6 | 2018-08-31 14:21:22 -0700 | [diff] [blame] | 8023 | QDF_BUG(!hdd_ctx->bus_bw_timer_running); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8024 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 8025 | qdf_timer_free(&hdd_ctx->bus_bw_timer); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 8026 | qdf_spinlock_destroy(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8027 | |
| 8028 | hdd_exit(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8029 | } |
Lin Bai | c5c0688 | 2017-09-21 13:58:43 +0800 | [diff] [blame] | 8030 | |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8031 | #endif /* MSM_PLATFORM */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8032 | |
| 8033 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8034 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 8035 | * @hdd_ctx: hdd context |
| 8036 | * |
| 8037 | * Return: 0 for success or error code |
| 8038 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8039 | 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] | 8040 | { |
| 8041 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 8042 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 8043 | if (!hdd_ctx->hdd_txrx_hist) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8044 | return -ENOMEM; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8045 | return 0; |
| 8046 | } |
| 8047 | |
| 8048 | /** |
| 8049 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 8050 | * @hdd_ctx: hdd context |
| 8051 | * |
| 8052 | * Return: none |
| 8053 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8054 | void wlan_hdd_deinit_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8055 | { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 8056 | if (!hdd_ctx || hdd_ctx->hdd_txrx_hist == NULL) |
| 8057 | return; |
| 8058 | |
| 8059 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 8060 | hdd_ctx->hdd_txrx_hist = NULL; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8061 | } |
| 8062 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8063 | static uint8_t *convert_level_to_string(uint32_t level) |
| 8064 | { |
| 8065 | switch (level) { |
| 8066 | /* initialize the wlan sub system */ |
| 8067 | case WLAN_SVC_TP_NONE: |
| 8068 | return "NONE"; |
| 8069 | case WLAN_SVC_TP_LOW: |
| 8070 | return "LOW"; |
| 8071 | case WLAN_SVC_TP_MEDIUM: |
| 8072 | return "MED"; |
| 8073 | case WLAN_SVC_TP_HIGH: |
| 8074 | return "HIGH"; |
| 8075 | default: |
| 8076 | return "INVAL"; |
| 8077 | } |
| 8078 | } |
| 8079 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8080 | |
| 8081 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8082 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 8083 | * @hdd_ctx: hdd context |
| 8084 | * |
| 8085 | * Return: none |
| 8086 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8087 | void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8088 | { |
| 8089 | int i; |
| 8090 | |
| 8091 | #ifdef MSM_PLATFORM |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8092 | hdd_nofl_info("BW compute Interval: %dms", |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 8093 | hdd_ctx->config->bus_bw_compute_interval); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8094 | 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] | 8095 | hdd_ctx->config->bus_bw_high_threshold, |
| 8096 | hdd_ctx->config->bus_bw_medium_threshold, |
| 8097 | hdd_ctx->config->bus_bw_low_threshold); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8098 | hdd_nofl_info("Enable TCP DEL ACK: %d", |
| 8099 | hdd_ctx->en_tcp_delack_no_lro); |
| 8100 | hdd_nofl_info("TCP DEL High TH: %d TCP DEL Low TH: %d", |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 8101 | hdd_ctx->config->tcp_delack_thres_high, |
| 8102 | hdd_ctx->config->tcp_delack_thres_low); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8103 | hdd_nofl_info("TCP TX HIGH TP TH: %d (Use to set tcp_output_bytes_limit)", |
| 8104 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8105 | #endif |
| 8106 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8107 | hdd_nofl_info("Total entries: %d Current index: %d", |
| 8108 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8109 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8110 | 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] | 8111 | |
| 8112 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8113 | /* using hdd_log to avoid printing function name */ |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 8114 | if (hdd_ctx->hdd_txrx_hist[i].qtime > 0) |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8115 | hdd_nofl_info("[%3d][%15llu]: %6llu, %6llu, %s, %s, %s", |
| 8116 | i, hdd_ctx->hdd_txrx_hist[i].qtime, |
| 8117 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
| 8118 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
| 8119 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8120 | hdd_ctx->hdd_txrx_hist[i]. |
| 8121 | next_vote_level), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8122 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8123 | hdd_ctx->hdd_txrx_hist[i]. |
| 8124 | next_rx_level), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8125 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8126 | hdd_ctx->hdd_txrx_hist[i]. |
| 8127 | next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8128 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8129 | } |
| 8130 | |
| 8131 | /** |
| 8132 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 8133 | * @hdd_ctx: hdd context |
| 8134 | * |
| 8135 | * Return: none |
| 8136 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8137 | void wlan_hdd_clear_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8138 | { |
| 8139 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8140 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 8141 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8142 | } |
| 8143 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8144 | /* length of the netif queue log needed per adapter */ |
| 8145 | #define ADAP_NETIFQ_LOG_LEN ((20 * WLAN_REASON_TYPE_MAX) + 50) |
| 8146 | |
| 8147 | /** |
| 8148 | * |
| 8149 | * hdd_display_netif_queue_history_compact() - display compact netifq history |
| 8150 | * @hdd_ctx: hdd context |
| 8151 | * |
| 8152 | * Return: none |
| 8153 | */ |
| 8154 | static void |
| 8155 | hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx) |
| 8156 | { |
| 8157 | int adapter_num = 0; |
| 8158 | int i; |
| 8159 | int bytes_written; |
| 8160 | u32 tbytes; |
| 8161 | qdf_time_t total, pause, unpause, curr_time, delta; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8162 | char temp_str[20 * WLAN_REASON_TYPE_MAX]; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8163 | char *comb_log_str; |
| 8164 | uint32_t comb_log_str_size; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8165 | struct hdd_adapter *adapter = NULL; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8166 | |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 8167 | comb_log_str_size = (ADAP_NETIFQ_LOG_LEN * CSR_ROAM_SESSION_MAX) + 1; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8168 | comb_log_str = qdf_mem_malloc(comb_log_str_size); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 8169 | if (!comb_log_str) |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8170 | return; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8171 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8172 | bytes_written = 0; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8173 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8174 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8175 | curr_time = qdf_system_ticks(); |
| 8176 | total = curr_time - adapter->start_time; |
| 8177 | delta = curr_time - adapter->last_time; |
| 8178 | |
| 8179 | if (adapter->pause_map) { |
| 8180 | pause = adapter->total_pause_time + delta; |
| 8181 | unpause = adapter->total_unpause_time; |
| 8182 | } else { |
| 8183 | unpause = adapter->total_unpause_time + delta; |
| 8184 | pause = adapter->total_pause_time; |
| 8185 | } |
| 8186 | |
| 8187 | tbytes = 0; |
| 8188 | qdf_mem_set(temp_str, 0, sizeof(temp_str)); |
| 8189 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 8190 | if (adapter->queue_oper_stats[i].pause_count == 0) |
| 8191 | continue; |
| 8192 | tbytes += |
| 8193 | snprintf( |
| 8194 | &temp_str[tbytes], |
| 8195 | (tbytes >= sizeof(temp_str) ? |
| 8196 | 0 : sizeof(temp_str) - tbytes), |
| 8197 | "%d(%d,%d) ", |
| 8198 | i, |
| 8199 | adapter->queue_oper_stats[i]. |
| 8200 | pause_count, |
| 8201 | adapter->queue_oper_stats[i]. |
| 8202 | unpause_count); |
| 8203 | } |
| 8204 | if (tbytes >= sizeof(temp_str)) |
| 8205 | hdd_warn("log truncated"); |
| 8206 | |
| 8207 | bytes_written += snprintf(&comb_log_str[bytes_written], |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8208 | bytes_written >= comb_log_str_size ? 0 : |
| 8209 | comb_log_str_size - bytes_written, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8210 | "[%d %d] (%d) %u/%ums %s|", |
| 8211 | adapter->session_id, adapter->device_mode, |
| 8212 | adapter->pause_map, |
| 8213 | qdf_system_ticks_to_msecs(pause), |
| 8214 | qdf_system_ticks_to_msecs(total), |
| 8215 | temp_str); |
| 8216 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8217 | adapter_num++; |
| 8218 | } |
| 8219 | |
| 8220 | /* using QDF_TRACE to avoid printing function name */ |
| 8221 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO_LOW, |
| 8222 | "STATS |%s", comb_log_str); |
| 8223 | |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8224 | if (bytes_written >= comb_log_str_size) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8225 | hdd_warn("log string truncated"); |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8226 | |
| 8227 | qdf_mem_free(comb_log_str); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8228 | } |
| 8229 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8230 | /** |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 8231 | * wlan_hdd_display_netif_queue_history() - display netif queue history |
Jeff Johnson | 58adbcf | 2017-09-03 08:53:31 -0700 | [diff] [blame] | 8232 | * @hdd_ctx: hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8233 | * |
| 8234 | * Return: none |
| 8235 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8236 | void |
| 8237 | wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx, |
| 8238 | enum qdf_stats_verbosity_level verb_lvl) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8239 | { |
| 8240 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8241 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8242 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8243 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8244 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8245 | if (verb_lvl == QDF_STATS_VERBOSITY_LEVEL_LOW) { |
| 8246 | hdd_display_netif_queue_history_compact(hdd_ctx); |
| 8247 | return; |
| 8248 | } |
| 8249 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8250 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8251 | hdd_nofl_info("Netif queue operation statistics:"); |
| 8252 | hdd_nofl_info("Session_id %d device mode %d", |
| 8253 | adapter->session_id, adapter->device_mode); |
| 8254 | hdd_nofl_info("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8255 | curr_time = qdf_system_ticks(); |
| 8256 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8257 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8258 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8259 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8260 | unpause = adapter->total_unpause_time; |
| 8261 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8262 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8263 | pause = adapter->total_pause_time; |
| 8264 | } |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8265 | hdd_nofl_info("Total: %ums Pause: %ums Unpause: %ums", |
| 8266 | qdf_system_ticks_to_msecs(total), |
| 8267 | qdf_system_ticks_to_msecs(pause), |
| 8268 | qdf_system_ticks_to_msecs(unpause)); |
| 8269 | hdd_nofl_info("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8270 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8271 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 8272 | qdf_time_t pause_delta = 0; |
| 8273 | |
| 8274 | if (adapter->pause_map & (1 << i)) |
| 8275 | pause_delta = delta; |
| 8276 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8277 | /* using hdd_log to avoid printing function name */ |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8278 | hdd_nofl_info("%s: %d: %d: %ums", |
| 8279 | hdd_reason_type_to_string(i), |
| 8280 | adapter->queue_oper_stats[i].pause_count, |
| 8281 | adapter->queue_oper_stats[i]. |
| 8282 | unpause_count, |
| 8283 | qdf_system_ticks_to_msecs( |
| 8284 | adapter->queue_oper_stats[i]. |
| 8285 | total_pause_time + pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8286 | } |
| 8287 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8288 | hdd_nofl_info("Netif queue operation history:"); |
| 8289 | hdd_nofl_info("Total entries: %d current index %d", |
| 8290 | WLAN_HDD_MAX_HISTORY_ENTRY, |
| 8291 | adapter->history_index); |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8292 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8293 | hdd_nofl_info("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8294 | |
| 8295 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8296 | /* using hdd_log to avoid printing function name */ |
| 8297 | if (adapter->queue_oper_history[i].time == 0) |
| 8298 | continue; |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8299 | hdd_nofl_info("%d: %u: %s: %s: %x", |
| 8300 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8301 | adapter->queue_oper_history[i].time), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8302 | hdd_action_type_to_string( |
| 8303 | adapter->queue_oper_history[i]. |
| 8304 | netif_action), |
| 8305 | hdd_reason_type_to_string( |
| 8306 | adapter->queue_oper_history[i]. |
| 8307 | netif_reason), |
| 8308 | adapter->queue_oper_history[i].pause_map); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8309 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8310 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8311 | } |
| 8312 | |
| 8313 | /** |
| 8314 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 8315 | * @hdd_ctx: hdd context |
| 8316 | * |
| 8317 | * Return: none |
| 8318 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8319 | void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8320 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8321 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8322 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8323 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8324 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8325 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8326 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8327 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8328 | adapter->history_index = 0; |
| 8329 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 8330 | adapter->total_pause_time = 0; |
| 8331 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8332 | } |
| 8333 | } |
| 8334 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8335 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 8336 | /** |
| 8337 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 8338 | * @hdd_ctx: hdd global context |
| 8339 | * |
| 8340 | * Return: none |
| 8341 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8342 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8343 | { |
| 8344 | uint8_t i; |
| 8345 | |
| 8346 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 8347 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 8348 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 8349 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 8350 | } |
| 8351 | } |
| 8352 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8353 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8354 | { |
| 8355 | } |
| 8356 | #endif |
| 8357 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8358 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 8359 | /** |
| 8360 | * 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] | 8361 | * @phddctx: struct hdd_context structure pointer |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8362 | * @enable: enable or disable this behaviour |
| 8363 | * |
| 8364 | * Return: int |
| 8365 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8366 | 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] | 8367 | { |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8368 | struct wow_pulse_mode wow_pulse_set_info; |
| 8369 | QDF_STATUS status; |
| 8370 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8371 | hdd_debug("wow pulse enable flag is %d", enable); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8372 | |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 8373 | if (!ucfg_pmo_is_wow_pulse_enabled(phddctx->psoc)) |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8374 | return 0; |
| 8375 | |
| 8376 | /* prepare the request to send to SME */ |
| 8377 | if (enable == true) { |
| 8378 | wow_pulse_set_info.wow_pulse_enable = true; |
| 8379 | wow_pulse_set_info.wow_pulse_pin = |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 8380 | ucfg_pmo_get_wow_pulse_pin(phddctx->psoc); |
| 8381 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8382 | wow_pulse_set_info.wow_pulse_interval_high = |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 8383 | ucfg_pmo_get_wow_pulse_interval_high(phddctx->psoc); |
| 8384 | |
| 8385 | wow_pulse_set_info.wow_pulse_interval_low = |
| 8386 | ucfg_pmo_get_wow_pulse_interval_low(phddctx->psoc); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8387 | } else { |
| 8388 | wow_pulse_set_info.wow_pulse_enable = false; |
| 8389 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 8390 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 8391 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 8392 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8393 | hdd_debug("enable %d pin %d low %d high %d", |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8394 | wow_pulse_set_info.wow_pulse_enable, |
| 8395 | wow_pulse_set_info.wow_pulse_pin, |
| 8396 | wow_pulse_set_info.wow_pulse_interval_low, |
| 8397 | wow_pulse_set_info.wow_pulse_interval_high); |
| 8398 | |
| 8399 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 8400 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8401 | hdd_debug("sme_set_wow_pulse failure!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8402 | return -EIO; |
| 8403 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8404 | hdd_debug("sme_set_wow_pulse success!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8405 | return 0; |
| 8406 | } |
| 8407 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8408 | 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] | 8409 | { |
| 8410 | return 0; |
| 8411 | } |
| 8412 | #endif |
| 8413 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8414 | #ifdef WLAN_FEATURE_FASTPATH |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 8415 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8416 | /** |
| 8417 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 8418 | * @hdd_cfg: hdd config |
| 8419 | * @context: lower layer context |
| 8420 | * |
| 8421 | * Return: none |
| 8422 | */ |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 8423 | void hdd_enable_fastpath(struct hdd_context *hdd_ctx, |
| 8424 | void *context) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8425 | { |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 8426 | if (cfg_get(hdd_ctx->psoc, CFG_DP_ENABLE_FASTPATH)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8427 | hif_enable_fastpath(context); |
| 8428 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8429 | #endif |
| 8430 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8431 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8432 | /** |
| 8433 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8434 | * @hdd_handle: opaque handle for the hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8435 | * @level: thermal level |
| 8436 | * |
| 8437 | * Change IPA data path to SW path when the thermal throttle level greater |
| 8438 | * than 0, and restore the original data path when throttle level is 0 |
| 8439 | * |
| 8440 | * Return: none |
| 8441 | */ |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8442 | 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] | 8443 | { |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8444 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8445 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8446 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 8447 | if (level > THROTTLE_LEVEL_0) |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 8448 | ucfg_ipa_send_mcc_scc_msg(hdd_ctx->pdev, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8449 | else |
| 8450 | /* restore original concurrency mode */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 8451 | 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] | 8452 | } |
| 8453 | |
| 8454 | /** |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8455 | * hdd_get_safe_channel() - Get safe channel from current regulatory |
| 8456 | * @hdd_ctx: pointer to hdd context |
| 8457 | * @adapter: pointer to softap adapter |
| 8458 | * |
| 8459 | * This function is used to get safe channel from current regulatory valid |
| 8460 | * channels to restart SAP if failed to get safe channel from PCL. |
| 8461 | * |
| 8462 | * Return: Channel number to restart SAP in case of success. In case of any |
| 8463 | * failure, the channel number returned is zero. |
| 8464 | */ |
| 8465 | static uint8_t |
| 8466 | hdd_get_safe_channel(struct hdd_context *hdd_ctx, |
| 8467 | struct hdd_adapter *adapter) |
| 8468 | { |
| 8469 | struct sir_pcl_list pcl = {0}; |
| 8470 | uint32_t i, j; |
| 8471 | bool found = false; |
| 8472 | int ret; |
| 8473 | |
| 8474 | /* Try for safe channel from all valid channel */ |
| 8475 | pcl.pcl_len = MAX_NUM_CHAN; |
| 8476 | ret = hdd_get_valid_chan(hdd_ctx, pcl.pcl_list, |
| 8477 | &pcl.pcl_len); |
| 8478 | if (ret) { |
| 8479 | hdd_err("error %d in getting valid channel list", ret); |
| 8480 | return INVALID_CHANNEL_ID; |
| 8481 | } |
| 8482 | |
| 8483 | for (i = 0; i < pcl.pcl_len; i++) { |
| 8484 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
| 8485 | found = false; |
| 8486 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
| 8487 | if (pcl.pcl_list[i] == |
| 8488 | hdd_ctx->unsafe_channel_list[j]) { |
| 8489 | hdd_debug("unsafe chan:%d", pcl.pcl_list[i]); |
| 8490 | found = true; |
| 8491 | break; |
| 8492 | } |
| 8493 | } |
| 8494 | |
| 8495 | if (found) |
| 8496 | continue; |
| 8497 | |
| 8498 | if ((pcl.pcl_list[i] >= |
| 8499 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
| 8500 | (pcl.pcl_list[i] <= |
| 8501 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
| 8502 | hdd_debug("found safe chan:%d", pcl.pcl_list[i]); |
| 8503 | return pcl.pcl_list[i]; |
| 8504 | } |
| 8505 | } |
| 8506 | |
| 8507 | return INVALID_CHANNEL_ID; |
| 8508 | } |
| 8509 | |
| 8510 | #else |
| 8511 | /** |
| 8512 | * hdd_set_thermal_level_cb() - set thermal level callback function |
| 8513 | * @hdd_handle: opaque handle for the hdd context |
| 8514 | * @level: thermal level |
| 8515 | * |
| 8516 | * Change IPA data path to SW path when the thermal throttle level greater |
| 8517 | * than 0, and restore the original data path when throttle level is 0 |
| 8518 | * |
| 8519 | * Return: none |
| 8520 | */ |
| 8521 | static void hdd_set_thermal_level_cb(hdd_handle_t hdd_handle, u_int8_t level) |
| 8522 | { |
| 8523 | } |
| 8524 | |
| 8525 | /** |
| 8526 | * hdd_get_safe_channel() - Get safe channel from current regulatory |
| 8527 | * @hdd_ctx: pointer to hdd context |
| 8528 | * @adapter: pointer to softap adapter |
| 8529 | * |
| 8530 | * This function is used to get safe channel from current regulatory valid |
| 8531 | * channels to restart SAP if failed to get safe channel from PCL. |
| 8532 | * |
| 8533 | * Return: Channel number to restart SAP in case of success. In case of any |
| 8534 | * failure, the channel number returned is zero. |
| 8535 | */ |
| 8536 | static uint8_t |
| 8537 | hdd_get_safe_channel(struct hdd_context *hdd_ctx, |
| 8538 | struct hdd_adapter *adapter) |
| 8539 | { |
| 8540 | return 0; |
| 8541 | } |
| 8542 | #endif |
| 8543 | |
| 8544 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8545 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 8546 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 8547 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8548 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8549 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 8550 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 8551 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8552 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8553 | * Return: Channel number to restart SAP in case of success. In case of any |
| 8554 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8555 | */ |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8556 | static uint8_t |
| 8557 | 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] | 8558 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8559 | struct sir_pcl_list pcl; |
| 8560 | QDF_STATUS status; |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8561 | uint32_t i; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8562 | mac_handle_t mac_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8563 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8564 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8565 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8566 | if (!hdd_ctx) { |
| 8567 | hdd_err("invalid HDD context"); |
| 8568 | return INVALID_CHANNEL_ID; |
| 8569 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8570 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8571 | mac_handle = hdd_ctx->mac_handle; |
| 8572 | if (!mac_handle) { |
| 8573 | hdd_err("invalid MAC handle"); |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 8574 | return INVALID_CHANNEL_ID; |
| 8575 | } |
| 8576 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 8577 | status = policy_mgr_get_pcl_for_existing_conn(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8578 | PM_SAP_MODE, pcl.pcl_list, &pcl.pcl_len, |
bings | 37bd58f | 2017-07-20 16:49:26 +0800 | [diff] [blame] | 8579 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list), |
| 8580 | false); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8581 | if (QDF_IS_STATUS_ERROR(status)) { |
| 8582 | hdd_err("Get PCL failed"); |
| 8583 | return INVALID_CHANNEL_ID; |
| 8584 | } |
| 8585 | |
Frank Liu | dc2cefb | 2017-06-21 15:38:18 +0800 | [diff] [blame] | 8586 | /* |
| 8587 | * In some scenarios, like hw dbs disabled, sap+sap case, if operating |
| 8588 | * channel is unsafe channel, the pcl may be empty, instead of return, |
| 8589 | * try to choose a safe channel from acs range. |
| 8590 | */ |
| 8591 | if (!pcl.pcl_len) |
| 8592 | hdd_debug("pcl length is zero!"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8593 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8594 | hdd_debug("start:%d end:%d", |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8595 | adapter->session.ap.sap_config.acs_cfg.start_ch, |
| 8596 | adapter->session.ap.sap_config.acs_cfg.end_ch); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8597 | |
| 8598 | /* PCL already takes unsafe channel into account */ |
| 8599 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8600 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8601 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8602 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8603 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8604 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8605 | hdd_debug("found PCL safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8606 | return pcl.pcl_list[i]; |
| 8607 | } |
| 8608 | } |
| 8609 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8610 | hdd_debug("no safe channel from PCL found in ACS range"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8611 | |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8612 | return hdd_get_safe_channel(hdd_ctx, adapter); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8613 | } |
| 8614 | |
| 8615 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8616 | * hdd_switch_sap_channel() - Move SAP to the given channel |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8617 | * @adapter: AP adapter |
| 8618 | * @channel: Channel |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8619 | * @forced: Force to switch channel, ignore SCC/MCC check |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8620 | * |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8621 | * Moves the SAP interface by invoking the function which |
| 8622 | * executes the callback to perform channel switch using (E)CSA. |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8623 | * |
| 8624 | * Return: None |
| 8625 | */ |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8626 | void hdd_switch_sap_channel(struct hdd_adapter *adapter, uint8_t channel, |
| 8627 | bool forced) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8628 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 8629 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8630 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8631 | mac_handle_t mac_handle; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8632 | |
| 8633 | if (!adapter) { |
| 8634 | hdd_err("invalid adapter"); |
| 8635 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8636 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8637 | |
| 8638 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 8639 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8640 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 8641 | if (!mac_handle) { |
| 8642 | hdd_err("invalid MAC handle"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8643 | return; |
| 8644 | } |
| 8645 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8646 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8647 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8648 | hdd_debug("chan:%d width:%d", |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 8649 | channel, hdd_ap_ctx->sap_config.ch_width_orig); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8650 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 8651 | policy_mgr_change_sap_channel_with_csa(hdd_ctx->psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 8652 | adapter->session_id, channel, |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8653 | hdd_ap_ctx->sap_config.ch_width_orig, forced); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8654 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8655 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8656 | 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] | 8657 | { |
| 8658 | struct hdd_external_acs_timer_context *timer_context; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8659 | int status; |
| 8660 | QDF_STATUS qdf_status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8661 | |
| 8662 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 8663 | |
| 8664 | if (QDF_TIMER_STATE_RUNNING == |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8665 | qdf_mc_timer_get_current_state(&adapter->session. |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8666 | ap.vendor_acs_timer)) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8667 | qdf_mc_timer_stop(&adapter->session.ap.vendor_acs_timer); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8668 | } |
| 8669 | timer_context = (struct hdd_external_acs_timer_context *) |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8670 | adapter->session.ap.vendor_acs_timer.user_data; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8671 | timer_context->reason = reason; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8672 | qdf_status = |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8673 | qdf_mc_timer_start(&adapter->session.ap.vendor_acs_timer, |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8674 | WLAN_VENDOR_ACS_WAIT_TIME); |
| 8675 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 8676 | hdd_err("failed to start external acs timer"); |
| 8677 | return -ENOSPC; |
| 8678 | } |
| 8679 | /* Update config to application */ |
| 8680 | status = hdd_cfg80211_update_acs_config(adapter, reason); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 8681 | hdd_info("Updated ACS config to nl with reason %d", reason); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8682 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8683 | return status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8684 | } |
| 8685 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8686 | #if defined(FEATURE_WLAN_CH_AVOID) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8687 | /** |
| 8688 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 8689 | * @hdd_ctx: hdd context pointer |
| 8690 | * |
| 8691 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 8692 | * and if ACS is enabled, driver will ask userspace to restart the |
| 8693 | * sap. User space on LTE coex indication restart driver. |
| 8694 | * |
| 8695 | * Return - none |
| 8696 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8697 | void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8698 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8699 | struct hdd_adapter *adapter; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8700 | uint32_t i; |
| 8701 | bool found = false; |
| 8702 | uint8_t restart_chan; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 8703 | uint8_t scc_on_lte_coex = 0; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 8704 | bool value; |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 8705 | QDF_STATUS status; |
| 8706 | bool is_acs_support_for_dfs_ltecoex = cfg_default(CFG_USER_ACS_DFS_LTE); |
| 8707 | bool is_vendor_acs_support = |
| 8708 | cfg_default(CFG_USER_AUTO_CHANNEL_SELECTION); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8709 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8710 | hdd_for_each_adapter(hdd_ctxt, adapter) { |
| 8711 | if (!(adapter->device_mode == QDF_SAP_MODE && |
| 8712 | adapter->session.ap.sap_config.acs_cfg.acs_mode)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8713 | hdd_debug("skip device mode:%d acs:%d", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8714 | adapter->device_mode, |
| 8715 | adapter->session.ap.sap_config. |
| 8716 | acs_cfg.acs_mode); |
| 8717 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8718 | } |
| 8719 | |
| 8720 | found = false; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 8721 | status = |
| 8722 | ucfg_policy_mgr_get_sta_sap_scc_lte_coex_chnl(hdd_ctxt->psoc, |
| 8723 | &scc_on_lte_coex); |
| 8724 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8725 | hdd_err("can't get scc on lte coex chnl, use def"); |
Tushnim Bhattacharyya | d2e085d | 2018-06-18 11:58:50 -0700 | [diff] [blame] | 8726 | /* |
| 8727 | * If STA+SAP is doing SCC & g_sta_sap_scc_on_lte_coex_chan |
| 8728 | * is set, no need to move SAP. |
| 8729 | */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 8730 | if (policy_mgr_is_sta_sap_scc(hdd_ctxt->psoc, |
Tushnim Bhattacharyya | d2e085d | 2018-06-18 11:58:50 -0700 | [diff] [blame] | 8731 | adapter->session.ap.operating_channel) && |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 8732 | scc_on_lte_coex) |
Tushnim Bhattacharyya | d2e085d | 2018-06-18 11:58:50 -0700 | [diff] [blame] | 8733 | hdd_debug("SAP is allowed on SCC channel, no need to move SAP"); |
| 8734 | else { |
| 8735 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
| 8736 | if (adapter->session.ap.operating_channel == |
| 8737 | hdd_ctxt->unsafe_channel_list[i]) { |
| 8738 | found = true; |
| 8739 | hdd_debug("operating ch:%d is unsafe", |
| 8740 | adapter->session.ap.operating_channel); |
| 8741 | break; |
| 8742 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8743 | } |
| 8744 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8745 | if (!found) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8746 | hdd_debug("ch:%d is safe. no need to change channel", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8747 | adapter->session.ap.operating_channel); |
| 8748 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8749 | } |
| 8750 | |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 8751 | status = ucfg_mlme_get_acs_support_for_dfs_ltecoex( |
| 8752 | hdd_ctxt->psoc, |
| 8753 | &is_acs_support_for_dfs_ltecoex); |
| 8754 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8755 | hdd_err("get_acs_support_for_dfs_ltecoex failed,set def"); |
| 8756 | |
| 8757 | status = ucfg_mlme_get_vendor_acs_support( |
| 8758 | hdd_ctxt->psoc, |
| 8759 | &is_vendor_acs_support); |
| 8760 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8761 | hdd_err("get_vendor_acs_support failed, set default"); |
| 8762 | |
| 8763 | if (is_vendor_acs_support && is_acs_support_for_dfs_ltecoex) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8764 | hdd_update_acs_timer_reason(adapter, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8765 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8766 | continue; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8767 | } else |
| 8768 | restart_chan = |
| 8769 | hdd_get_safe_channel_from_pcl_and_acs_range( |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8770 | adapter); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8771 | if (!restart_chan) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8772 | hdd_err("fail to restart SAP"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8773 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8774 | /* |
| 8775 | * SAP restart due to unsafe channel. While |
| 8776 | * restarting the SAP, make sure to clear |
| 8777 | * acs_channel, channel to reset to |
| 8778 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8779 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8780 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8781 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8782 | hdd_debug("sending coex indication"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8783 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 8784 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 8785 | ucfg_mlme_get_sap_internal_restart(hdd_ctxt->psoc, |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 8786 | &value); |
| 8787 | hdd_debug("driver to start sap: %d", value); |
| 8788 | if (value) |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8789 | hdd_switch_sap_channel(adapter, restart_chan, |
| 8790 | true); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 8791 | else |
| 8792 | return; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8793 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8794 | } |
| 8795 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 8796 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8797 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8798 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 8799 | * @hdd_ctx: HDD global context |
| 8800 | * |
| 8801 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8802 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8803 | * down to the lower layers. Then subscribe to subsequent channel |
| 8804 | * avoidance events. |
| 8805 | * |
| 8806 | * Return: None |
| 8807 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8808 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8809 | { |
| 8810 | uint16_t unsafe_channel_count; |
| 8811 | int index; |
| 8812 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8813 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 8814 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8815 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8816 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8817 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8818 | hdd_debug("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8819 | hdd_ctx->unsafe_channel_count); |
| 8820 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8821 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8822 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8823 | |
| 8824 | for (index = 0; index < unsafe_channel_count; index++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8825 | hdd_debug("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8826 | hdd_ctx->unsafe_channel_list[index]); |
| 8827 | |
| 8828 | } |
| 8829 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8830 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8831 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8832 | static void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8833 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8834 | { |
| 8835 | uint8_t restart_chan; |
| 8836 | |
| 8837 | restart_chan = hdd_get_safe_channel_from_pcl_and_acs_range(adapter); |
| 8838 | if (!restart_chan) { |
| 8839 | hdd_alert("fail to restart SAP"); |
| 8840 | return; |
| 8841 | } |
| 8842 | |
| 8843 | /* SAP restart due to unsafe channel. While restarting |
| 8844 | * the SAP, make sure to clear acs_channel, channel to |
| 8845 | * reset to 0. Otherwise these settings will override |
| 8846 | * the ACS while restart. |
| 8847 | */ |
| 8848 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8849 | |
| 8850 | hdd_debug("sending coex indication"); |
| 8851 | |
| 8852 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 8853 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8854 | hdd_switch_sap_channel(adapter, restart_chan, true); |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8855 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8856 | |
| 8857 | int hdd_clone_local_unsafe_chan(struct hdd_context *hdd_ctx, |
| 8858 | uint16_t **local_unsafe_list, uint16_t *local_unsafe_list_count) |
| 8859 | { |
| 8860 | uint32_t size; |
| 8861 | uint16_t *unsafe_list; |
| 8862 | uint16_t chan_count; |
| 8863 | |
| 8864 | if (!hdd_ctx || !local_unsafe_list_count || !local_unsafe_list_count) |
| 8865 | return -EINVAL; |
| 8866 | |
| 8867 | chan_count = QDF_MIN(hdd_ctx->unsafe_channel_count, |
| 8868 | NUM_CHANNELS); |
| 8869 | if (chan_count) { |
| 8870 | size = chan_count * sizeof(hdd_ctx->unsafe_channel_list[0]); |
| 8871 | unsafe_list = qdf_mem_malloc(size); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 8872 | if (!unsafe_list) |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8873 | return -ENOMEM; |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8874 | qdf_mem_copy(unsafe_list, hdd_ctx->unsafe_channel_list, size); |
| 8875 | } else { |
| 8876 | unsafe_list = NULL; |
| 8877 | } |
| 8878 | |
| 8879 | *local_unsafe_list = unsafe_list; |
| 8880 | *local_unsafe_list_count = chan_count; |
| 8881 | |
| 8882 | return 0; |
| 8883 | } |
| 8884 | |
| 8885 | bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx, |
| 8886 | uint16_t *local_unsafe_list, uint16_t local_unsafe_list_count) |
| 8887 | { |
| 8888 | int i, j; |
| 8889 | |
| 8890 | if (local_unsafe_list_count != hdd_ctx->unsafe_channel_count) |
| 8891 | return true; |
| 8892 | if (local_unsafe_list_count == 0) |
| 8893 | return false; |
| 8894 | for (i = 0; i < local_unsafe_list_count; i++) { |
| 8895 | for (j = 0; j < local_unsafe_list_count; j++) |
| 8896 | if (local_unsafe_list[i] == |
| 8897 | hdd_ctx->unsafe_channel_list[j]) |
| 8898 | break; |
| 8899 | if (j >= local_unsafe_list_count) |
| 8900 | break; |
| 8901 | } |
| 8902 | if (i >= local_unsafe_list_count) { |
| 8903 | hdd_info("unsafe chan list same"); |
| 8904 | return false; |
| 8905 | } |
| 8906 | |
| 8907 | return true; |
| 8908 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8909 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8910 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8911 | { |
| 8912 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8913 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8914 | static inline void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8915 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8916 | { |
| 8917 | hdd_debug("Channel avoidance is not enabled; Abort SAP restart"); |
| 8918 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8919 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8920 | |
| 8921 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8922 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 8923 | * user space |
| 8924 | * @frame_ind: Management frame data to be informed. |
| 8925 | * |
| 8926 | * This function is used to indicate management frame to |
| 8927 | * user space |
| 8928 | * |
| 8929 | * Return: None |
| 8930 | * |
| 8931 | */ |
| 8932 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 8933 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8934 | struct hdd_context *hdd_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8935 | struct hdd_adapter *adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8936 | int i; |
Pragaspathi Thilagaraj | 28ffc04 | 2018-07-18 15:19:36 +0530 | [diff] [blame] | 8937 | struct ieee80211_mgmt *mgmt = |
| 8938 | (struct ieee80211_mgmt *)frame_ind->frameBuf; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8939 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 8940 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 8941 | if (wlan_hdd_validate_context(hdd_ctx)) |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8942 | return; |
| 8943 | |
Pragaspathi Thilagaraj | 28ffc04 | 2018-07-18 15:19:36 +0530 | [diff] [blame] | 8944 | if (frame_ind->frame_len < ieee80211_hdrlen(mgmt->frame_control)) { |
| 8945 | hdd_err(" Invalid frame length"); |
| 8946 | return; |
| 8947 | } |
| 8948 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8949 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
| 8950 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 8951 | adapter = |
| 8952 | hdd_get_adapter_by_sme_session_id(hdd_ctx, i); |
| 8953 | if (adapter) |
| 8954 | break; |
| 8955 | } |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 8956 | } else if (SME_SESSION_ID_BROADCAST == frame_ind->sessionId) { |
| 8957 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 8958 | if ((NULL != adapter) && |
| 8959 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) { |
| 8960 | __hdd_indicate_mgmt_frame(adapter, |
| 8961 | frame_ind->frame_len, |
| 8962 | frame_ind->frameBuf, |
| 8963 | frame_ind->frameType, |
| 8964 | frame_ind->rxChan, |
| 8965 | frame_ind->rxRssi); |
| 8966 | } |
| 8967 | } |
| 8968 | adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8969 | } else { |
| 8970 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 8971 | frame_ind->sessionId); |
| 8972 | } |
| 8973 | |
| 8974 | if ((NULL != adapter) && |
| 8975 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 8976 | __hdd_indicate_mgmt_frame(adapter, |
| 8977 | frame_ind->frame_len, |
| 8978 | frame_ind->frameBuf, |
| 8979 | frame_ind->frameType, |
| 8980 | frame_ind->rxChan, |
| 8981 | frame_ind->rxRssi); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8982 | } |
| 8983 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8984 | void hdd_acs_response_timeout_handler(void *context) |
| 8985 | { |
| 8986 | struct hdd_external_acs_timer_context *timer_context = |
| 8987 | (struct hdd_external_acs_timer_context *)context; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8988 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8989 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8990 | uint8_t reason; |
| 8991 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8992 | hdd_enter(); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8993 | if (!timer_context) { |
| 8994 | hdd_err("invlaid timer context"); |
| 8995 | return; |
| 8996 | } |
| 8997 | adapter = timer_context->adapter; |
| 8998 | reason = timer_context->reason; |
| 8999 | |
| 9000 | |
| 9001 | if ((!adapter) || |
| 9002 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 9003 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 9004 | return; |
| 9005 | } |
| 9006 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 9007 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 9008 | return; |
| 9009 | |
| 9010 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 9011 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 9012 | else |
| 9013 | return; |
| 9014 | |
| 9015 | hdd_err("ACS timeout happened for %s reason %d", |
| 9016 | adapter->dev->name, reason); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9017 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9018 | switch (reason) { |
| 9019 | /* SAP init case */ |
| 9020 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 9021 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 9022 | false); |
| 9023 | wlan_hdd_cfg80211_start_acs(adapter); |
| 9024 | break; |
| 9025 | /* DFS detected on current channel */ |
| 9026 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 9027 | wlan_sap_update_next_channel( |
| 9028 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9029 | sme_update_new_channel_event(hdd_ctx->mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 9030 | adapter->session_id); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9031 | break; |
| 9032 | /* LTE coex event on current channel */ |
| 9033 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 9034 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 9035 | break; |
| 9036 | default: |
| 9037 | hdd_info("invalid reason for timer invoke"); |
| 9038 | |
| 9039 | } |
| 9040 | } |
| 9041 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9042 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9043 | * hdd_override_ini_config - Override INI config |
| 9044 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9045 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9046 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9047 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9048 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9049 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9050 | static void hdd_override_ini_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9051 | { |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9052 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9053 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9054 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
| 9055 | hdd_ctx->config->enableDFSChnlScan = enable_dfs_chan_scan; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9056 | hdd_debug("Module enable_dfs_chan_scan set to %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9057 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9058 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9059 | if (0 == enable_11d || 1 == enable_11d) { |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9060 | status = ucfg_mlme_set_11d_enabled(hdd_ctx->psoc, enable_11d); |
| 9061 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9062 | hdd_err("Failed to set 11d_enable flag"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9063 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 9064 | |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 9065 | if (hdd_ctx->config->action_oui_enable && !ucfg_action_oui_enabled()) { |
| 9066 | hdd_ctx->config->action_oui_enable = 0; |
Sourav Mohapatra | 5884106 | 2018-11-19 16:33:27 +0530 | [diff] [blame] | 9067 | hdd_err("Ignore action oui ini, since no action_oui component"); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 9068 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9069 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9070 | |
Ashish Kumar Dhanotiya | 12f6821 | 2018-09-04 22:00:14 +0530 | [diff] [blame] | 9071 | #ifdef ENABLE_MTRACE_LOG |
| 9072 | static void hdd_set_mtrace_for_each(struct hdd_context *hdd_ctx) |
| 9073 | { |
| 9074 | uint8_t module_id = 0; |
| 9075 | int qdf_print_idx = -1; |
| 9076 | |
| 9077 | qdf_print_idx = qdf_get_pidx(); |
| 9078 | for (module_id = 0; module_id < QDF_MODULE_ID_MAX; module_id++) |
| 9079 | qdf_print_set_category_verbose( |
| 9080 | qdf_print_idx, |
| 9081 | module_id, QDF_TRACE_LEVEL_TRACE, |
| 9082 | hdd_ctx->config->enable_mtrace); |
| 9083 | } |
| 9084 | #else |
| 9085 | static void hdd_set_mtrace_for_each(struct hdd_context *hdd_ctx) |
| 9086 | { |
| 9087 | } |
| 9088 | |
| 9089 | #endif |
| 9090 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9091 | /** |
| 9092 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 9093 | * @hdd_ctx - HDD context |
| 9094 | * |
| 9095 | * Set trace level for each module based on INI config. |
| 9096 | * |
| 9097 | * Return: None |
| 9098 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9099 | 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] | 9100 | { |
Wu Gao | bc6eaa1 | 2018-11-30 14:17:45 +0800 | [diff] [blame] | 9101 | hdd_qdf_trace_enable(QDF_MODULE_ID_DP, 0x7f); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 9102 | hdd_qdf_trace_enable(QDF_MODULE_ID_MLME, 0xffff); |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 9103 | hdd_qdf_trace_enable(QDF_MODULE_ID_FWOL, 0xffff); |
Kiran Kumar Lokere | 4ce4048 | 2018-08-30 16:31:00 -0700 | [diff] [blame] | 9104 | hdd_qdf_trace_enable(QDF_MODULE_ID_CRYPTO, 0xffff); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 9105 | |
Ashish Kumar Dhanotiya | 12f6821 | 2018-09-04 22:00:14 +0530 | [diff] [blame] | 9106 | hdd_set_mtrace_for_each(hdd_ctx); |
| 9107 | |
Nirav Shah | 5c083da | 2018-08-03 13:46:02 +0530 | [diff] [blame] | 9108 | hdd_cfg_print_global_config(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9109 | } |
| 9110 | |
| 9111 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9112 | * hdd_context_init() - Initialize HDD context |
| 9113 | * @hdd_ctx: HDD context. |
| 9114 | * |
| 9115 | * Initialize HDD context along with all the feature specific contexts. |
| 9116 | * |
| 9117 | * return: 0 on success and errno on failure. |
| 9118 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9119 | static int hdd_context_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9120 | { |
| 9121 | int ret; |
| 9122 | |
| 9123 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 9124 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 9125 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9126 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 9127 | init_completion(&hdd_ctx->ready_to_suspend); |
| 9128 | |
| 9129 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9130 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 9131 | |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 9132 | qdf_list_create(&hdd_ctx->hdd_adapters, 0); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9133 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9134 | ret = hdd_scan_context_init(hdd_ctx); |
| 9135 | if (ret) |
| 9136 | goto list_destroy; |
| 9137 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9138 | hdd_rx_wake_lock_create(hdd_ctx); |
| 9139 | |
| 9140 | ret = hdd_sap_context_init(hdd_ctx); |
| 9141 | if (ret) |
| 9142 | goto scan_destroy; |
| 9143 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9144 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 9145 | |
| 9146 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 9147 | |
| 9148 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 9149 | hdd_ctx->config); |
| 9150 | if (ret) |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 9151 | goto sap_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9152 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 9153 | qdf_wake_lock_create(&hdd_ctx->monitor_mode_wakelock, |
| 9154 | "monitor_mode_wakelock"); |
| 9155 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9156 | return 0; |
| 9157 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9158 | sap_destroy: |
| 9159 | hdd_sap_context_destroy(hdd_ctx); |
| 9160 | |
| 9161 | scan_destroy: |
| 9162 | hdd_scan_context_destroy(hdd_ctx); |
| 9163 | hdd_rx_wake_lock_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9164 | list_destroy: |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 9165 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 9166 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9167 | return ret; |
| 9168 | } |
| 9169 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9170 | void hdd_psoc_idle_timer_start(struct hdd_context *hdd_ctx) |
| 9171 | { |
| 9172 | uint32_t timeout_ms = hdd_ctx->config->iface_change_wait_time; |
| 9173 | enum wake_lock_reason reason = |
| 9174 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER; |
| 9175 | |
Rajeev Kumar | 7b7bb3f | 2018-12-20 12:09:54 -0800 | [diff] [blame] | 9176 | if (!timeout_ms) { |
| 9177 | hdd_info("psoc idle timer is disabled"); |
| 9178 | return; |
| 9179 | } |
| 9180 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9181 | hdd_debug("Starting psoc idle timer"); |
| 9182 | qdf_sched_delayed_work(&hdd_ctx->psoc_idle_timeout_work, timeout_ms); |
| 9183 | hdd_prevent_suspend_timeout(timeout_ms, reason); |
| 9184 | } |
| 9185 | |
| 9186 | void hdd_psoc_idle_timer_stop(struct hdd_context *hdd_ctx) |
| 9187 | { |
| 9188 | qdf_cancel_delayed_work(&hdd_ctx->psoc_idle_timeout_work); |
| 9189 | hdd_debug("Stopped psoc idle timer"); |
| 9190 | } |
| 9191 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9192 | /** |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9193 | * hdd_psoc_idle_shutdown() - perform an idle shutdown on the given psoc |
| 9194 | * @hdd_ctx: the hdd context which should be shutdown |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9195 | * |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9196 | * When no interfaces are "up" on a psoc, an idle shutdown timer is started. |
| 9197 | * If no interfaces are brought up before the timer expires, we do an |
| 9198 | * "idle shutdown," cutting power to the physical SoC to save power. This is |
| 9199 | * done completely transparently from the perspective of userspace. |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9200 | * |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9201 | * Return: None |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9202 | */ |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9203 | static void hdd_psoc_idle_shutdown(struct hdd_context *hdd_ctx) |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9204 | { |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9205 | struct hdd_psoc *hdd_psoc = hdd_ctx->hdd_psoc; |
| 9206 | QDF_STATUS status; |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9207 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9208 | hdd_enter(); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9209 | |
| 9210 | status = dsc_psoc_trans_start(hdd_psoc->dsc_psoc, "idle shutdown"); |
| 9211 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9212 | hdd_info("psoc busy, abort idle shutdown; status:%u", status); |
| 9213 | return; |
| 9214 | } |
| 9215 | |
| 9216 | QDF_BUG(!hdd_wlan_stop_modules(hdd_ctx, false)); |
| 9217 | |
| 9218 | hdd_psoc->state = psoc_state_idle; |
| 9219 | dsc_psoc_trans_stop(hdd_psoc->dsc_psoc); |
| 9220 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9221 | hdd_exit(); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9222 | } |
| 9223 | |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9224 | int hdd_psoc_idle_restart(struct hdd_context *hdd_ctx) |
| 9225 | { |
| 9226 | struct hdd_psoc *hdd_psoc = hdd_ctx->hdd_psoc; |
| 9227 | QDF_STATUS status; |
| 9228 | int errno; |
| 9229 | |
| 9230 | status = dsc_psoc_trans_start_wait(hdd_psoc->dsc_psoc, "idle restart"); |
| 9231 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9232 | hdd_info("unable to start 'idle restart'; status:%u", status); |
| 9233 | return qdf_status_to_os_return(status); |
| 9234 | } |
| 9235 | |
| 9236 | errno = hdd_wlan_start_modules(hdd_ctx, false); |
| 9237 | if (!errno) |
| 9238 | hdd_psoc->state = psoc_state_active; |
| 9239 | |
| 9240 | dsc_psoc_trans_stop(hdd_psoc->dsc_psoc); |
| 9241 | |
| 9242 | return errno; |
| 9243 | } |
| 9244 | |
| 9245 | /** |
| 9246 | * hdd_psoc_idle_timeout_callback() - Handler for psoc idle timeout |
| 9247 | * @priv: pointer to hdd context |
| 9248 | * |
| 9249 | * Return: None |
| 9250 | */ |
| 9251 | static void hdd_psoc_idle_timeout_callback(void *priv) |
| 9252 | { |
| 9253 | struct hdd_context *hdd_ctx = priv; |
| 9254 | |
| 9255 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 9256 | return; |
| 9257 | |
| 9258 | hdd_debug("Psoc idle timeout elapsed; starting psoc shutdown"); |
| 9259 | hdd_psoc_idle_shutdown(hdd_ctx); |
| 9260 | } |
| 9261 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 9262 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9263 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 9264 | { |
| 9265 | wlan_logging_set_log_to_console(hdd_ctx->config-> |
| 9266 | wlan_logging_to_console); |
| 9267 | wlan_logging_set_active(hdd_ctx->config->wlan_logging_enable); |
| 9268 | } |
| 9269 | #else |
| 9270 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 9271 | { } |
| 9272 | #endif |
| 9273 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9274 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9275 | static void hdd_init_wlan_logging_params(struct hdd_config *config, |
| 9276 | struct wlan_objmgr_psoc *psoc) |
| 9277 | { |
| 9278 | config->wlan_logging_enable = cfg_get(psoc, CFG_WLAN_LOGGING_SUPPORT); |
| 9279 | |
| 9280 | config->wlan_logging_to_console = |
| 9281 | cfg_get(psoc, CFG_WLAN_LOGGING_CONSOLE_SUPPORT); |
| 9282 | } |
| 9283 | #else |
| 9284 | static void hdd_init_wlan_logging_params(struct hdd_config *config, |
| 9285 | struct wlan_objmgr_psoc *psoc) |
| 9286 | { |
| 9287 | } |
| 9288 | #endif |
| 9289 | |
| 9290 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 9291 | static void hdd_init_wlan_auto_shutdown(struct hdd_config *config, |
| 9292 | struct wlan_objmgr_psoc *psoc) |
| 9293 | { |
| 9294 | config->wlan_auto_shutdown = cfg_get(psoc, CFG_WLAN_AUTO_SHUTDOWN); |
| 9295 | } |
| 9296 | #else |
| 9297 | static void hdd_init_wlan_auto_shutdown(struct hdd_config *config, |
| 9298 | struct wlan_objmgr_psoc *psoc) |
| 9299 | { |
| 9300 | } |
| 9301 | #endif |
| 9302 | |
| 9303 | #ifndef REMOVE_PKT_LOG |
| 9304 | static void hdd_init_packet_log(struct hdd_config *config, |
| 9305 | struct wlan_objmgr_psoc *psoc) |
| 9306 | { |
| 9307 | config->enable_packet_log = cfg_get(psoc, CFG_ENABLE_PACKET_LOG); |
| 9308 | } |
| 9309 | #else |
| 9310 | static void hdd_init_packet_log(struct hdd_config *config, |
| 9311 | struct wlan_objmgr_psoc *psoc) |
| 9312 | { |
| 9313 | } |
| 9314 | #endif |
| 9315 | |
Sandeep Puligilla | 43b6d1a | 2018-12-03 09:16:13 -0800 | [diff] [blame] | 9316 | #ifdef ENABLE_MTRACE_LOG |
| 9317 | static void hdd_init_mtrace_log(struct hdd_config *config, |
| 9318 | struct wlan_objmgr_psoc *psoc) |
| 9319 | { |
| 9320 | config->enable_mtrace = cfg_get(psoc, CFG_ENABLE_MTRACE); |
| 9321 | } |
| 9322 | #else |
| 9323 | static void hdd_init_mtrace_log(struct hdd_config *config, |
| 9324 | struct wlan_objmgr_psoc *psoc) |
| 9325 | { |
| 9326 | } |
| 9327 | #endif |
| 9328 | |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 9329 | #ifdef FEATURE_RUNTIME_PM |
| 9330 | static void hdd_init_runtime_pm(struct hdd_config *config, |
| 9331 | struct wlan_objmgr_psoc *psoc) |
| 9332 | { |
| 9333 | config->runtime_pm = cfg_get(psoc, CFG_ENABLE_RUNTIME_PM); |
| 9334 | } |
| 9335 | #else |
| 9336 | static void hdd_init_runtime_pm(struct hdd_config *config, |
| 9337 | struct wlan_objmgr_psoc *psoc) |
| 9338 | |
| 9339 | { |
| 9340 | } |
| 9341 | #endif |
| 9342 | |
| 9343 | #ifdef FEATURE_WLAN_DYNAMIC_CVM |
| 9344 | static void hdd_init_vc_mode_cfg_bitmap(struct hdd_config *config, |
| 9345 | struct wlan_objmgr_psoc *psoc) |
| 9346 | { |
| 9347 | config->vc_mode_cfg_bitmap = cfg_get(psoc, CFG_VC_MODE_BITMAP); |
| 9348 | } |
| 9349 | #else |
| 9350 | static void hdd_init_vc_mode_cfg_bitmap(struct hdd_config *config, |
| 9351 | struct wlan_objmgr_psoc *psoc) |
| 9352 | { |
| 9353 | } |
| 9354 | #endif |
| 9355 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9356 | /** |
| 9357 | * hdd_cfg_params_init() - Initialize hdd params in hdd_config strucuture |
| 9358 | * @hdd_ctx - Pointer to HDD context |
| 9359 | * |
| 9360 | * Return: None |
| 9361 | */ |
| 9362 | static void hdd_cfg_params_init(struct hdd_context *hdd_ctx) |
| 9363 | { |
| 9364 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
| 9365 | struct hdd_config *config = hdd_ctx->config; |
| 9366 | |
| 9367 | if (!psoc) { |
| 9368 | hdd_err("Invalid psoc"); |
| 9369 | return; |
| 9370 | } |
| 9371 | |
| 9372 | if (!config) { |
| 9373 | hdd_err("Invalid hdd config"); |
| 9374 | return; |
| 9375 | } |
| 9376 | |
| 9377 | config->bug_on_reinit_failure = cfg_get(psoc, |
| 9378 | CFG_BUG_ON_REINIT_FAILURE); |
| 9379 | |
| 9380 | config->is_ramdump_enabled = cfg_get(psoc, |
| 9381 | CFG_ENABLE_RAMDUMP_COLLECTION); |
| 9382 | |
| 9383 | config->iface_change_wait_time = cfg_get(psoc, |
| 9384 | CFG_INTERFACE_CHANGE_WAIT); |
| 9385 | |
| 9386 | config->multicast_host_fw_msgs = cfg_get(psoc, |
| 9387 | CFG_MULTICAST_HOST_FW_MSGS); |
| 9388 | |
| 9389 | config->private_wext_control = cfg_get(psoc, CFG_PRIVATE_WEXT_CONTROL); |
| 9390 | config->timer_multiplier = cfg_get(psoc, CFG_TIMER_MULTIPLIER); |
| 9391 | config->enablefwprint = cfg_get(psoc, CFG_ENABLE_FW_UART_PRINT); |
| 9392 | config->enable_fw_log = cfg_get(psoc, CFG_ENABLE_FW_LOG); |
Vignesh Viswanathan | a0358ff | 2018-11-27 09:53:07 +0530 | [diff] [blame] | 9393 | config->operating_channel = cfg_get(psoc, CFG_OPERATING_CHANNEL); |
| 9394 | config->num_vdevs = cfg_get(psoc, CFG_NUM_VDEV_ENABLE); |
Vignesh Viswanathan | a0358ff | 2018-11-27 09:53:07 +0530 | [diff] [blame] | 9395 | qdf_str_lcopy(config->enable_concurrent_sta, |
| 9396 | cfg_get(psoc, CFG_ENABLE_CONCURRENT_STA), |
| 9397 | CFG_CONCURRENT_IFACE_MAX_LEN); |
| 9398 | qdf_str_lcopy(config->dbs_scan_selection, |
| 9399 | cfg_get(psoc, CFG_DBS_SCAN_SELECTION), |
| 9400 | CFG_DBS_SCAN_PARAM_LENGTH); |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 9401 | config->inform_bss_rssi_raw = cfg_get(psoc, CFG_INFORM_BSS_RSSI_RAW); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 9402 | config->mac_provision = cfg_get(psoc, CFG_ENABLE_MAC_PROVISION); |
| 9403 | config->provisioned_intf_pool = |
| 9404 | cfg_get(psoc, CFG_PROVISION_INTERFACE_POOL); |
| 9405 | config->derived_intf_pool = cfg_get(psoc, CFG_DERIVED_INTERFACE_POOL); |
Sourav Mohapatra | 5884106 | 2018-11-19 16:33:27 +0530 | [diff] [blame] | 9406 | config->action_oui_enable = cfg_get(psoc, CFG_ENABLE_ACTION_OUI); |
Sourav Mohapatra | 5884106 | 2018-11-19 16:33:27 +0530 | [diff] [blame] | 9407 | qdf_str_lcopy(config->action_oui_str[0], |
| 9408 | cfg_get(psoc, CFG_ACTION_OUI_CONNECT_1X1), |
| 9409 | ACTION_OUI_MAX_STR_LEN); |
| 9410 | qdf_str_lcopy(config->action_oui_str[1], |
| 9411 | cfg_get(psoc, CFG_ACTION_OUI_ITO_EXTENSION), |
| 9412 | ACTION_OUI_MAX_STR_LEN); |
| 9413 | qdf_str_lcopy(config->action_oui_str[2], |
| 9414 | cfg_get(psoc, CFG_ACTION_OUI_CCKM_1X1), |
| 9415 | ACTION_OUI_MAX_STR_LEN); |
| 9416 | qdf_str_lcopy(config->action_oui_str[3], |
| 9417 | cfg_get(psoc, CFG_ACTION_OUI_ITO_ALTERNATE), |
| 9418 | ACTION_OUI_MAX_STR_LEN); |
| 9419 | qdf_str_lcopy(config->action_oui_str[4], |
| 9420 | cfg_get(psoc, CFG_ACTION_OUI_SWITCH_TO_11N_MODE), |
| 9421 | ACTION_OUI_MAX_STR_LEN); |
| 9422 | qdf_str_lcopy(config->action_oui_str[5], |
| 9423 | cfg_get(psoc, |
| 9424 | CFG_ACTION_OUI_CONNECT_1X1_WITH_1_CHAIN), |
| 9425 | ACTION_OUI_MAX_STR_LEN); |
Rajeev Kumar Sirasanagandla | d7987f1 | 2018-12-08 23:24:04 +0530 | [diff] [blame] | 9426 | qdf_str_lcopy(config->action_oui_str[6], |
| 9427 | cfg_get(psoc, |
| 9428 | CFG_ACTION_OUI_DISABLE_AGGRESSIVE_TX), |
| 9429 | ACTION_OUI_MAX_STR_LEN); |
Sourav Mohapatra | 9e014cf | 2018-12-11 09:39:33 +0530 | [diff] [blame] | 9430 | config->enable_rtt_support = cfg_get(psoc, CFG_ENABLE_RTT_SUPPORT); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9431 | |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 9432 | hdd_init_vc_mode_cfg_bitmap(config, psoc); |
| 9433 | hdd_init_runtime_pm(config, psoc); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9434 | hdd_init_wlan_auto_shutdown(config, psoc); |
| 9435 | hdd_init_wlan_logging_params(config, psoc); |
| 9436 | hdd_init_packet_log(config, psoc); |
Sandeep Puligilla | 43b6d1a | 2018-12-03 09:16:13 -0800 | [diff] [blame] | 9437 | hdd_init_mtrace_log(config, psoc); |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 9438 | hdd_dp_cfg_update(psoc, hdd_ctx); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9439 | } |
| 9440 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 9441 | struct hdd_context *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9442 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9443 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9444 | int ret = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9445 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9446 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9447 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9448 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 9449 | hdd_ctx = hdd_cfg80211_wiphy_alloc(); |
| 9450 | if (!hdd_ctx) { |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9451 | ret = -ENOMEM; |
| 9452 | goto err_out; |
| 9453 | } |
| 9454 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9455 | qdf_create_delayed_work(&hdd_ctx->psoc_idle_timeout_work, |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9456 | hdd_psoc_idle_timeout_callback, |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9457 | hdd_ctx); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9458 | |
| 9459 | mutex_init(&hdd_ctx->iface_change_lock); |
| 9460 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9461 | hdd_ctx->parent_dev = dev; |
Sreelakshmi Konamki | b53c629 | 2017-03-01 13:13:23 +0530 | [diff] [blame] | 9462 | hdd_ctx->last_scan_reject_session_id = 0xFF; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9463 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9464 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 9465 | if (!hdd_ctx->config) { |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9466 | ret = -ENOMEM; |
| 9467 | goto err_free_hdd_context; |
| 9468 | } |
| 9469 | |
| 9470 | /* Read and parse the qcom_cfg.ini file */ |
| 9471 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9472 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9473 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9474 | WLAN_INI_FILE); |
| 9475 | ret = -EINVAL; |
| 9476 | goto err_free_config; |
| 9477 | } |
| 9478 | |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 9479 | status = cfg_parse(WLAN_INI_FILE); |
| 9480 | if (QDF_IS_STATUS_ERROR(status)) |
| 9481 | hdd_err("Failed to parse cfg %s; status:%d\n", |
| 9482 | WLAN_INI_FILE, status); |
| 9483 | |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9484 | ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, DEFAULT_PSOC_ID); |
| 9485 | if (ret) { |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9486 | QDF_DEBUG_PANIC("Psoc creation fails!"); |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9487 | goto err_free_config; |
| 9488 | } |
| 9489 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9490 | hdd_cfg_params_init(hdd_ctx); |
| 9491 | |
Dustin Brown | 7f93993 | 2017-05-18 15:02:17 -0700 | [diff] [blame] | 9492 | hdd_debug("setting timer multiplier: %u", |
| 9493 | hdd_ctx->config->timer_multiplier); |
| 9494 | qdf_timer_set_multiplier(hdd_ctx->config->timer_multiplier); |
| 9495 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9496 | cds_set_fatal_event(cfg_get(hdd_ctx->psoc, |
| 9497 | CFG_ENABLE_FATAL_EVENT_TRIGGER)); |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 9498 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9499 | hdd_override_ini_config(hdd_ctx); |
| 9500 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9501 | ret = hdd_context_init(hdd_ctx); |
| 9502 | |
| 9503 | if (ret) |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9504 | goto err_hdd_objmgr_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9505 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9506 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9507 | goto skip_multicast_logging; |
| 9508 | |
| 9509 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 9510 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 9511 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 9512 | if (ret) |
| 9513 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 9514 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 9515 | ret = hdd_init_netlink_services(hdd_ctx); |
| 9516 | if (ret) |
| 9517 | goto err_deinit_txrx_histogram; |
| 9518 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 9519 | hdd_set_wlan_logging(hdd_ctx); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 9520 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9521 | skip_multicast_logging: |
| 9522 | hdd_set_trace_level_for_each(hdd_ctx); |
| 9523 | |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 9524 | cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); |
| 9525 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9526 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 9527 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9528 | return hdd_ctx; |
| 9529 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 9530 | err_deinit_txrx_histogram: |
| 9531 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 9532 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 9533 | err_deinit_hdd_context: |
| 9534 | hdd_context_deinit(hdd_ctx); |
| 9535 | |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9536 | err_hdd_objmgr_destroy: |
| 9537 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 9538 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9539 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9540 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9541 | |
| 9542 | err_free_hdd_context: |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9543 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Rajeev Kumar | fa55a69 | 2018-01-09 14:12:41 -0800 | [diff] [blame] | 9544 | wiphy_free(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9545 | |
| 9546 | err_out: |
| 9547 | return ERR_PTR(ret); |
| 9548 | } |
| 9549 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9550 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 9551 | /** |
| 9552 | * hdd_open_p2p_interface - Open P2P interface |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9553 | * @hdd_ctx: HDD context |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9554 | * |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9555 | * Return: QDF_STATUS |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9556 | */ |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9557 | static QDF_STATUS hdd_open_p2p_interface(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9558 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9559 | struct hdd_adapter *adapter; |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9560 | bool p2p_dev_addr_admin; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 9561 | bool is_p2p_locally_administered = false; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9562 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 9563 | cfg_p2p_get_device_addr_admin(hdd_ctx->psoc, &p2p_dev_addr_admin); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9564 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 9565 | if (p2p_dev_addr_admin) { |
| 9566 | if (hdd_ctx->num_provisioned_addr && |
| 9567 | !(hdd_ctx->provisioned_mac_addr[0].bytes[0] & 0x02)) { |
| 9568 | hdd_ctx->p2p_device_address = |
| 9569 | hdd_ctx->provisioned_mac_addr[0]; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9570 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 9571 | /* |
| 9572 | * Generate the P2P Device Address. This consists of |
| 9573 | * the device's primary MAC address with the locally |
| 9574 | * administered bit set. |
| 9575 | */ |
| 9576 | |
| 9577 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
| 9578 | is_p2p_locally_administered = true; |
| 9579 | } else if (!(hdd_ctx->derived_mac_addr[0].bytes[0] & 0x02)) { |
| 9580 | hdd_ctx->p2p_device_address = |
| 9581 | hdd_ctx->derived_mac_addr[0]; |
| 9582 | /* |
| 9583 | * Generate the P2P Device Address. This consists of |
| 9584 | * the device's primary MAC address with the locally |
| 9585 | * administered bit set. |
| 9586 | */ |
| 9587 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
| 9588 | is_p2p_locally_administered = true; |
| 9589 | } |
| 9590 | } |
| 9591 | if (!is_p2p_locally_administered) { |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9592 | uint8_t *p2p_dev_addr; |
| 9593 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 9594 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx, |
| 9595 | QDF_P2P_DEVICE_MODE); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9596 | if (!p2p_dev_addr) { |
| 9597 | hdd_err("Failed to get MAC address for new p2p device"); |
| 9598 | return QDF_STATUS_E_INVAL; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9599 | } |
| 9600 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9601 | qdf_mem_copy(hdd_ctx->p2p_device_address.bytes, |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 9602 | p2p_dev_addr, QDF_MAC_ADDR_SIZE); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9603 | } |
| 9604 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9605 | adapter = hdd_open_adapter(hdd_ctx, QDF_P2P_DEVICE_MODE, "p2p%d", |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9606 | hdd_ctx->p2p_device_address.bytes, |
| 9607 | NET_NAME_UNKNOWN, true); |
| 9608 | if (!adapter) { |
| 9609 | hdd_err("Failed to open p2p interface"); |
| 9610 | return QDF_STATUS_E_INVAL; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9611 | } |
| 9612 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9613 | return QDF_STATUS_SUCCESS; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9614 | } |
| 9615 | #else |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9616 | static inline QDF_STATUS hdd_open_p2p_interface(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9617 | { |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9618 | return QDF_STATUS_SUCCESS; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9619 | } |
| 9620 | #endif |
| 9621 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9622 | static QDF_STATUS hdd_open_ocb_interface(struct hdd_context *hdd_ctx) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9623 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9624 | struct hdd_adapter *adapter; |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9625 | |
| 9626 | adapter = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, "wlanocb%d", |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 9627 | wlan_hdd_get_intf_addr(hdd_ctx, |
| 9628 | QDF_OCB_MODE), |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9629 | NET_NAME_UNKNOWN, true); |
| 9630 | if (!adapter) { |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9631 | hdd_err("Failed to open 802.11p interface"); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9632 | return QDF_STATUS_E_INVAL; |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9633 | } |
| 9634 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9635 | return QDF_STATUS_SUCCESS; |
| 9636 | } |
| 9637 | |
| 9638 | static QDF_STATUS hdd_open_concurrent_interface(struct hdd_context *hdd_ctx) |
| 9639 | { |
| 9640 | struct hdd_adapter *adapter; |
| 9641 | |
Vignesh Viswanathan | a0358ff | 2018-11-27 09:53:07 +0530 | [diff] [blame] | 9642 | if (qdf_str_eq(hdd_ctx->config->enable_concurrent_sta, "")) |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9643 | return QDF_STATUS_SUCCESS; |
| 9644 | |
| 9645 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, |
Vignesh Viswanathan | a0358ff | 2018-11-27 09:53:07 +0530 | [diff] [blame] | 9646 | hdd_ctx->config->enable_concurrent_sta, |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 9647 | wlan_hdd_get_intf_addr(hdd_ctx, |
| 9648 | QDF_STA_MODE), |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9649 | NET_NAME_UNKNOWN, true); |
| 9650 | if (!adapter) { |
| 9651 | hdd_err("Failed to open concurrent station interface"); |
| 9652 | return QDF_STATUS_E_INVAL; |
| 9653 | } |
| 9654 | |
| 9655 | return QDF_STATUS_SUCCESS; |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9656 | } |
| 9657 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9658 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9659 | * hdd_start_station_adapter()- Start the Station Adapter |
| 9660 | * @adapter: HDD adapter |
| 9661 | * |
| 9662 | * This function initializes the adapter for the station mode. |
| 9663 | * |
| 9664 | * Return: 0 on success or errno on failure. |
| 9665 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9666 | int hdd_start_station_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9667 | { |
| 9668 | QDF_STATUS status; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9669 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9670 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 9671 | hdd_enter_dev(adapter->dev); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9672 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 9673 | hdd_err("session is already opened, %d", |
| 9674 | adapter->session_id); |
| 9675 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 9676 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9677 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9678 | ret = hdd_vdev_create(adapter, hdd_sme_roam_callback, adapter); |
| 9679 | if (ret) { |
| 9680 | hdd_err("failed to create vdev: %d", ret); |
| 9681 | return ret; |
| 9682 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9683 | status = hdd_init_station_mode(adapter); |
| 9684 | |
| 9685 | if (QDF_STATUS_SUCCESS != status) { |
| 9686 | hdd_err("Error Initializing station mode: %d", status); |
| 9687 | return qdf_status_to_os_return(status); |
| 9688 | } |
| 9689 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9690 | hdd_register_tx_flow_control(adapter, |
| 9691 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 9692 | hdd_tx_resume_cb, |
| 9693 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9694 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9695 | hdd_exit(); |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 9696 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9697 | return 0; |
| 9698 | } |
| 9699 | |
| 9700 | /** |
| 9701 | * hdd_start_ap_adapter()- Start AP Adapter |
| 9702 | * @adapter: HDD adapter |
| 9703 | * |
| 9704 | * This function initializes the adapter for the AP mode. |
| 9705 | * |
| 9706 | * Return: 0 on success errno on failure. |
| 9707 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9708 | int hdd_start_ap_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9709 | { |
| 9710 | QDF_STATUS status; |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9711 | bool is_ssr = false; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9712 | int ret; |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9713 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9714 | uint32_t fine_time_meas_cap = 0; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9715 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9716 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9717 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9718 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 9719 | hdd_err("session is already opened, %d", |
| 9720 | adapter->session_id); |
| 9721 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 9722 | } |
| 9723 | /* |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9724 | * In SSR case no need to create new sap context. |
| 9725 | * Otherwise create sap context first and then create |
| 9726 | * vdev as while creating the vdev, driver needs to |
| 9727 | * register SAP callback and that callback uses sap context |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9728 | */ |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9729 | if (adapter->session.ap.sap_context) { |
| 9730 | is_ssr = true; |
| 9731 | } else if (!hdd_sap_create_ctx(adapter)) { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9732 | hdd_err("sap creation failed"); |
| 9733 | return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); |
| 9734 | } |
| 9735 | |
| 9736 | ret = hdd_vdev_create(adapter, wlansap_roam_callback, |
| 9737 | adapter->session.ap.sap_context); |
| 9738 | if (ret) { |
| 9739 | hdd_err("failed to create vdev, status:%d", ret); |
| 9740 | hdd_sap_destroy_ctx(adapter); |
| 9741 | return ret; |
| 9742 | } |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9743 | |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9744 | if (adapter->device_mode == QDF_SAP_MODE) { |
| 9745 | ucfg_mlme_get_fine_time_meas_cap(hdd_ctx->psoc, |
| 9746 | &fine_time_meas_cap); |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9747 | sme_cli_set_command(adapter->session_id, |
| 9748 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_RESPONDER_ROLE, |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9749 | (bool)(fine_time_meas_cap & WMI_FW_AP_RTT_RESPR), |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9750 | VDEV_CMD); |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9751 | } |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9752 | |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9753 | status = hdd_init_ap_mode(adapter, is_ssr); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9754 | |
| 9755 | if (QDF_STATUS_SUCCESS != status) { |
| 9756 | hdd_err("Error Initializing the AP mode: %d", status); |
| 9757 | return qdf_status_to_os_return(status); |
| 9758 | } |
| 9759 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9760 | hdd_register_tx_flow_control(adapter, |
| 9761 | hdd_softap_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 9762 | hdd_softap_tx_resume_cb, |
| 9763 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9764 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9765 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9766 | return 0; |
| 9767 | } |
| 9768 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9769 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 9770 | /** |
| 9771 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 9772 | * @cds_cfg: CDS Configuration |
| 9773 | * @hdd_ctx: Pointer to hdd context |
| 9774 | * |
| 9775 | * Return: none |
| 9776 | */ |
| 9777 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 9778 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9779 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9780 | { |
| 9781 | cds_cfg->tx_flow_stop_queue_th = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 9782 | cfg_get(hdd_ctx->psoc, CFG_DP_TX_FLOW_STOP_QUEUE_TH); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9783 | cds_cfg->tx_flow_start_queue_offset = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 9784 | cfg_get(hdd_ctx->psoc, CFG_DP_TX_FLOW_START_QUEUE_OFFSET); |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 9785 | /* configuration for DP RX Threads */ |
| 9786 | cds_cfg->enable_dp_rx_threads = hdd_ctx->enable_dp_rx_threads; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9787 | } |
| 9788 | #else |
| 9789 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 9790 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9791 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9792 | { |
| 9793 | } |
| 9794 | #endif |
| 9795 | |
| 9796 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 9797 | /** |
| 9798 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 9799 | * @cds_cfg: CDS Configuration |
| 9800 | * @hdd_ctx: Pointer to hdd context |
| 9801 | * |
| 9802 | * Return: none |
| 9803 | */ |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 9804 | 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] | 9805 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9806 | { |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 9807 | bool is_rate_limit_enabled; |
| 9808 | QDF_STATUS status; |
| 9809 | |
| 9810 | status = ucfg_fwol_get_is_rate_limit_enabled(hdd_ctx->psoc, |
| 9811 | &is_rate_limit_enabled); |
| 9812 | if (QDF_IS_STATUS_ERROR(status)) |
| 9813 | return; |
| 9814 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9815 | cds_cfg->ra_ratelimit_interval = |
| 9816 | hdd_ctx->config->RArateLimitInterval; |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 9817 | cds_cfg->is_ra_ratelimit_enabled = is_rate_limit_enabled; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9818 | } |
| 9819 | #else |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 9820 | 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] | 9821 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9822 | { |
| 9823 | } |
| 9824 | #endif |
| 9825 | |
| 9826 | /** |
| 9827 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 9828 | * @hdd_ctx: HDD Context |
| 9829 | * |
| 9830 | * Return: 0 for Success, errno on failure |
| 9831 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9832 | static int hdd_update_cds_config(struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9833 | { |
| 9834 | struct cds_config_info *cds_cfg; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9835 | int value; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9836 | uint8_t band_capability; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9837 | uint8_t ito_repeat_count; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 9838 | bool crash_inject; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9839 | bool self_recovery; |
| 9840 | bool fw_timeout_crash; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9841 | QDF_STATUS status; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9842 | |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 9843 | cds_cfg = qdf_mem_malloc(sizeof(*cds_cfg)); |
| 9844 | if (!cds_cfg) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9845 | return -ENOMEM; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9846 | |
Srinivas Girigowda | 35b0031 | 2017-06-27 21:52:03 -0700 | [diff] [blame] | 9847 | cds_cfg->driver_type = QDF_DRIVER_TYPE_PRODUCTION; |
Bala Venkatesh | 46e2903 | 2018-11-14 18:24:55 +0530 | [diff] [blame] | 9848 | ucfg_mlme_get_sap_max_modulated_dtim(hdd_ctx->psoc, |
| 9849 | &cds_cfg->sta_maxlimod_dtim); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9850 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9851 | status = ucfg_mlme_get_crash_inject(hdd_ctx->psoc, &crash_inject); |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 9852 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9853 | hdd_err("Failed to get crash inject ini config"); |
| 9854 | goto exit; |
| 9855 | } |
| 9856 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9857 | status = ucfg_mlme_get_self_recovery(hdd_ctx->psoc, &self_recovery); |
| 9858 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9859 | hdd_err("Failed to get self recovery ini config"); |
| 9860 | goto exit; |
| 9861 | } |
| 9862 | |
| 9863 | status = ucfg_mlme_get_fw_timeout_crash(hdd_ctx->psoc, |
| 9864 | &fw_timeout_crash); |
| 9865 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9866 | hdd_err("Failed to get fw timeout crash ini config"); |
| 9867 | goto exit; |
| 9868 | } |
| 9869 | |
| 9870 | status = ucfg_mlme_get_ito_repeat_count(hdd_ctx->psoc, |
| 9871 | &ito_repeat_count); |
| 9872 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9873 | hdd_err("Failed to get ITO repeat count ini config"); |
| 9874 | goto exit; |
| 9875 | } |
| 9876 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 9877 | cds_cfg->force_target_assert_enabled = crash_inject; |
SaidiReddy Yenuga | cc733af | 2016-11-09 17:45:42 +0530 | [diff] [blame] | 9878 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 9879 | ucfg_mlme_get_sap_max_offload_peers(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9880 | cds_cfg->ap_maxoffload_peers = value; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 9881 | ucfg_mlme_get_sap_max_offload_reorder_buffs(hdd_ctx->psoc, |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9882 | &value); |
| 9883 | cds_cfg->ap_maxoffload_reorderbuffs = value; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9884 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9885 | cds_cfg->reorder_offload = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 9886 | cfg_get(hdd_ctx->psoc, CFG_DP_REORDER_OFFLOAD_SUPPORT); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9887 | |
| 9888 | /* IPA micro controller data path offload resource config item */ |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 9889 | cds_cfg->uc_offload_enabled = ucfg_ipa_uc_is_enabled(); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9890 | cds_cfg->max_scan = hdd_ctx->config->max_scan_count; |
| 9891 | |
Jeff Johnson | e2ba3cd | 2017-10-30 20:02:09 -0700 | [diff] [blame] | 9892 | cds_cfg->enable_rxthread = hdd_ctx->enable_rxthread; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 9893 | ucfg_mlme_get_sap_max_peers(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9894 | cds_cfg->max_station = value; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 9895 | cds_cfg->sub_20_channel_width = WLAN_SUB_20_CH_WIDTH_NONE; |
Orhan K AKYILDIZ | 30e8cbc | 2017-08-11 18:00:28 -0700 | [diff] [blame] | 9896 | cds_cfg->max_msdus_per_rxinorderind = |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 9897 | cfg_get(hdd_ctx->psoc, CFG_DP_MAX_MSDUS_PER_RXIND); |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9898 | cds_cfg->self_recovery_enabled = self_recovery; |
| 9899 | cds_cfg->fw_timeout_crash = fw_timeout_crash; |
Nachiket Kukade | e547a48 | 2018-05-22 16:43:30 +0530 | [diff] [blame] | 9900 | cds_cfg->active_uc_apf_mode = hdd_ctx->config->active_uc_apf_mode; |
| 9901 | 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] | 9902 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9903 | cds_cfg->ito_repeat_count = ito_repeat_count; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9904 | |
| 9905 | status = ucfg_mlme_get_band_capability(hdd_ctx->psoc, &band_capability); |
| 9906 | if (QDF_IS_STATUS_ERROR(status)) |
| 9907 | goto exit; |
| 9908 | |
| 9909 | cds_cfg->bandcapability = band_capability; |
Rachit Kankane | 0106e38 | 2018-05-16 18:59:28 +0530 | [diff] [blame] | 9910 | cds_cfg->num_vdevs = hdd_ctx->config->num_vdevs; |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 9911 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9912 | hdd_ra_populate_cds_config(cds_cfg, hdd_ctx); |
| 9913 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 9914 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9915 | cds_init_ini_config(cds_cfg); |
| 9916 | return 0; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9917 | |
| 9918 | exit: |
| 9919 | qdf_mem_free(cds_cfg); |
| 9920 | return -EINVAL; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9921 | } |
| 9922 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9923 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9924 | * hdd_update_user_config() - API to update user configuration |
| 9925 | * parameters to obj mgr which are used by multiple components |
| 9926 | * @hdd_ctx: HDD Context |
| 9927 | * |
| 9928 | * Return: 0 for Success, errno on failure |
| 9929 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9930 | static int hdd_update_user_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9931 | { |
| 9932 | struct wlan_objmgr_psoc_user_config *user_config; |
Wu Gao | e568979 | 2018-07-05 19:20:13 +0800 | [diff] [blame] | 9933 | bool skip_dfs_in_p2p_search = false; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9934 | uint8_t band_capability; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 9935 | uint8_t dual_mac_feature = DISABLE_DBS_CXN_AND_SCAN; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9936 | QDF_STATUS status; |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9937 | bool value = false; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9938 | |
| 9939 | status = ucfg_mlme_get_band_capability(hdd_ctx->psoc, &band_capability); |
| 9940 | if (QDF_IS_STATUS_ERROR(status)) |
| 9941 | return -EIO; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9942 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 9943 | status = ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 9944 | &dual_mac_feature); |
| 9945 | if (QDF_IS_STATUS_ERROR(status)) |
| 9946 | return -EIO; |
| 9947 | |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9948 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 9949 | if (!user_config) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9950 | return -ENOMEM; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9951 | |
| 9952 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9953 | status = ucfg_mlme_is_11d_enabled(hdd_ctx->psoc, &value); |
| 9954 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9955 | hdd_err("Invalid 11d_enable flag"); |
| 9956 | user_config->is_11d_support_enabled = value; |
| 9957 | |
| 9958 | value = false; |
| 9959 | status = ucfg_mlme_is_11h_enabled(hdd_ctx->psoc, &value); |
| 9960 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9961 | hdd_err("Invalid 11h_enable flag"); |
| 9962 | user_config->is_11h_support_enabled = value; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 9963 | cfg_p2p_get_skip_dfs_channel_p2p_search(hdd_ctx->psoc, |
Wu Gao | e568979 | 2018-07-05 19:20:13 +0800 | [diff] [blame] | 9964 | &skip_dfs_in_p2p_search); |
| 9965 | 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] | 9966 | user_config->band_capability = band_capability; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 9967 | wlan_objmgr_psoc_set_user_config(hdd_ctx->psoc, user_config); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9968 | |
| 9969 | qdf_mem_free(user_config); |
| 9970 | return 0; |
| 9971 | } |
| 9972 | |
| 9973 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9974 | * hdd_init_thermal_info - Initialize thermal level |
| 9975 | * @hdd_ctx: HDD context |
| 9976 | * |
| 9977 | * Initialize thermal level at SME layer and set the thermal level callback |
| 9978 | * which would be called when a configured thermal threshold is hit. |
| 9979 | * |
| 9980 | * Return: 0 on success and errno on failure |
| 9981 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9982 | static int hdd_init_thermal_info(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9983 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9984 | QDF_STATUS status; |
Manikandan Mohan | 9045e2e | 2018-11-26 16:44:19 -0800 | [diff] [blame] | 9985 | mac_handle_t mac_handle = hdd_ctx->mac_handle; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9986 | |
Manikandan Mohan | 9045e2e | 2018-11-26 16:44:19 -0800 | [diff] [blame] | 9987 | status = sme_init_thermal_info(mac_handle); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9988 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9989 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 9990 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9991 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9992 | sme_add_set_thermal_level_callback(mac_handle, |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9993 | hdd_set_thermal_level_cb); |
| 9994 | |
| 9995 | return 0; |
| 9996 | |
| 9997 | } |
| 9998 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9999 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 10000 | /** |
| 10001 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 10002 | * |
| 10003 | * Hold RTNL lock |
| 10004 | * |
| 10005 | * Return: True if held and false otherwise |
| 10006 | */ |
| 10007 | static inline bool hdd_hold_rtnl_lock(void) |
| 10008 | { |
| 10009 | rtnl_lock(); |
| 10010 | return true; |
| 10011 | } |
| 10012 | |
| 10013 | /** |
| 10014 | * hdd_release_rtnl_lock - Release RTNL lock |
| 10015 | * |
| 10016 | * Release RTNL lock |
| 10017 | * |
| 10018 | * Return: None |
| 10019 | */ |
| 10020 | static inline void hdd_release_rtnl_lock(void) |
| 10021 | { |
| 10022 | rtnl_unlock(); |
| 10023 | } |
| 10024 | #else |
| 10025 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 10026 | static inline void hdd_release_rtnl_lock(void) { } |
| 10027 | #endif |
| 10028 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10029 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10030 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10031 | /* MAX iwpriv command support */ |
| 10032 | #define PKTLOG_SET_BUFF_SIZE 3 |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10033 | #define PKTLOG_CLEAR_BUFF 4 |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10034 | #define MAX_PKTLOG_SIZE 16 |
| 10035 | |
| 10036 | /** |
| 10037 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 10038 | * @hdd_ctx: hdd context |
| 10039 | * @set_value2: pktlog buffer size value |
| 10040 | * |
| 10041 | * |
| 10042 | * Return: 0 for success or error. |
| 10043 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10044 | 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] | 10045 | { |
| 10046 | struct sir_wifi_start_log start_log = { 0 }; |
| 10047 | QDF_STATUS status; |
| 10048 | |
| 10049 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 10050 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 10051 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 10052 | start_log.user_triggered = 1; |
| 10053 | start_log.size = set_value2; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10054 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10055 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10056 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10057 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10058 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10059 | hdd_exit(); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10060 | return -EINVAL; |
| 10061 | } |
| 10062 | |
| 10063 | return 0; |
| 10064 | } |
| 10065 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10066 | /** |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10067 | * hdd_pktlog_clear_buff() - clear pktlog buffer |
| 10068 | * @hdd_ctx: hdd context |
| 10069 | * |
| 10070 | * Return: 0 for success or error. |
| 10071 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10072 | static int hdd_pktlog_clear_buff(struct hdd_context *hdd_ctx) |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10073 | { |
| 10074 | struct sir_wifi_start_log start_log; |
| 10075 | QDF_STATUS status; |
| 10076 | |
| 10077 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 10078 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 10079 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 10080 | start_log.user_triggered = 1; |
| 10081 | start_log.size = 0; |
| 10082 | start_log.is_pktlog_buff_clear = true; |
| 10083 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10084 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10085 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10086 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10087 | hdd_exit(); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10088 | return -EINVAL; |
| 10089 | } |
| 10090 | |
| 10091 | return 0; |
| 10092 | } |
| 10093 | |
| 10094 | |
| 10095 | /** |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10096 | * hdd_process_pktlog_command() - process pktlog command |
| 10097 | * @hdd_ctx: hdd context |
| 10098 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10099 | * @set_value2: pktlog buffer size value |
| 10100 | * |
| 10101 | * This function process pktlog command. |
| 10102 | * set_value2 only matters when set_value is 3 (set buff size) |
| 10103 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10104 | * |
| 10105 | * Return: 0 for success or error. |
| 10106 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10107 | 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] | 10108 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10109 | { |
| 10110 | int ret; |
| 10111 | bool enable; |
| 10112 | uint8_t user_triggered = 0; |
| 10113 | |
| 10114 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 10115 | if (0 != ret) |
| 10116 | return ret; |
| 10117 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10118 | hdd_debug("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10119 | |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10120 | if (set_value > PKTLOG_CLEAR_BUFF) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10121 | hdd_err("invalid pktlog value %d", set_value); |
| 10122 | return -EINVAL; |
| 10123 | } |
| 10124 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10125 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 10126 | if (set_value2 <= 0) { |
| 10127 | hdd_err("invalid pktlog size %d", set_value2); |
| 10128 | return -EINVAL; |
| 10129 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
| 10130 | hdd_err("Pktlog buff size is too large. max value is 16MB.\n"); |
| 10131 | return -EINVAL; |
| 10132 | } |
| 10133 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10134 | } else if (set_value == PKTLOG_CLEAR_BUFF) { |
| 10135 | return hdd_pktlog_clear_buff(hdd_ctx); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10136 | } |
| 10137 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10138 | /* |
| 10139 | * set_value = 0 then disable packetlog |
| 10140 | * set_value = 1 enable packetlog forcefully |
| 10141 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 10142 | * enable packetlog with AUTO type. |
| 10143 | */ |
| 10144 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 10145 | true : false; |
| 10146 | |
| 10147 | if (1 == set_value) { |
| 10148 | enable = true; |
| 10149 | user_triggered = 1; |
| 10150 | } |
| 10151 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10152 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10153 | } |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 10154 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10155 | /** |
| 10156 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 10157 | * @hdd_ctx: HDD context |
| 10158 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10159 | * @user_triggered: triggered through iwpriv |
| 10160 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10161 | * |
| 10162 | * Return: 0 on success; error number otherwise |
| 10163 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10164 | int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10165 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10166 | { |
| 10167 | struct sir_wifi_start_log start_log; |
| 10168 | QDF_STATUS status; |
| 10169 | |
| 10170 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 10171 | start_log.verbose_level = |
| 10172 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10173 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 10174 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10175 | start_log.size = size; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10176 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 10177 | /* |
| 10178 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 10179 | * commands. Host uses this flag to decide whether to send pktlog |
| 10180 | * disable command to fw without sending pktlog enable command |
| 10181 | * previously. For eg, If vendor sends pktlog disable command without |
| 10182 | * sending pktlog enable command, then host discards the packet |
| 10183 | * but for iwpriv command, host will send it to fw. |
| 10184 | */ |
| 10185 | start_log.is_iwpriv_command = 1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10186 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10187 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10188 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10189 | hdd_exit(); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10190 | return -EINVAL; |
| 10191 | } |
| 10192 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10193 | if (enable == true) |
| 10194 | hdd_ctx->is_pktlog_enabled = 1; |
| 10195 | else |
| 10196 | hdd_ctx->is_pktlog_enabled = 0; |
| 10197 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10198 | return 0; |
| 10199 | } |
| 10200 | #endif /* REMOVE_PKT_LOG */ |
| 10201 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10202 | void hdd_free_mac_address_lists(struct hdd_context *hdd_ctx) |
| 10203 | { |
| 10204 | hdd_debug("Resetting MAC address lists"); |
| 10205 | qdf_mem_set(hdd_ctx->provisioned_mac_addr, |
| 10206 | sizeof(hdd_ctx->provisioned_mac_addr), 0); |
| 10207 | qdf_mem_set(hdd_ctx->derived_mac_addr, |
| 10208 | sizeof(hdd_ctx->derived_mac_addr), 0); |
| 10209 | hdd_ctx->num_provisioned_addr = 0; |
| 10210 | hdd_ctx->num_derived_addr = 0; |
| 10211 | hdd_ctx->provisioned_intf_addr_mask = 0; |
| 10212 | hdd_ctx->derived_intf_addr_mask = 0; |
| 10213 | } |
| 10214 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10215 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10216 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 10217 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10218 | * @dev: Device Pointer |
| 10219 | * @num: Number of Valid Mac address |
| 10220 | * |
| 10221 | * Return: Pointer to MAC address buffer |
| 10222 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10223 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 10224 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10225 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10226 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10227 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10228 | |
| 10229 | /** |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10230 | * hdd_get_platform_wlan_derived_mac_buff() - API to query platform driver |
| 10231 | * for derived MAC address |
| 10232 | * @dev: Device Pointer |
| 10233 | * @num: Number of Valid Mac address |
| 10234 | * |
| 10235 | * Return: Pointer to MAC address buffer |
| 10236 | */ |
| 10237 | static uint8_t *hdd_get_platform_wlan_derived_mac_buff(struct device *dev, |
| 10238 | uint32_t *num) |
| 10239 | { |
| 10240 | return pld_get_wlan_derived_mac_address(dev, num); |
| 10241 | } |
| 10242 | |
| 10243 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10244 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 10245 | * @hdd_ctx: HDD Context |
| 10246 | * @num: Number of random mac addresses needed |
| 10247 | * |
| 10248 | * Generate random addresses using bit manipulation on the base mac address |
| 10249 | * |
| 10250 | * Return: None |
| 10251 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10252 | 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] | 10253 | { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10254 | uint32_t idx = hdd_ctx->num_derived_addr; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10255 | uint32_t iter; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10256 | uint8_t *buf = NULL; |
| 10257 | uint8_t macaddr_b3, tmp_br3; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10258 | /* |
| 10259 | * Consider first provisioned mac address as source address to derive |
| 10260 | * remaining addresses |
| 10261 | */ |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10262 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10263 | uint8_t *src = hdd_ctx->provisioned_mac_addr[0].bytes; |
| 10264 | |
| 10265 | for (iter = 0; iter < num; ++iter, ++idx) { |
| 10266 | buf = hdd_ctx->derived_mac_addr[idx].bytes; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10267 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 10268 | macaddr_b3 = buf[3]; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10269 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + idx) & |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10270 | INTF_MACADDR_MASK; |
| 10271 | macaddr_b3 += tmp_br3; |
| 10272 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 10273 | buf[0] |= 0x02; |
| 10274 | buf[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10275 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10276 | hdd_ctx->num_derived_addr++; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10277 | } |
| 10278 | } |
| 10279 | |
| 10280 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10281 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10282 | * @hdd_ctx: HDD Context |
| 10283 | * |
| 10284 | * API to get mac addresses from platform driver and update the driver |
| 10285 | * structures and configure FW with the base mac address. |
| 10286 | * Return: int |
| 10287 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10288 | static int hdd_platform_wlan_mac(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10289 | { |
| 10290 | uint32_t no_of_mac_addr, iter; |
| 10291 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 10292 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 10293 | uint8_t *addr, *buf; |
| 10294 | struct device *dev = hdd_ctx->parent_dev; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10295 | tSirMacAddr mac_addr; |
| 10296 | QDF_STATUS status; |
| 10297 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10298 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10299 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10300 | if (no_of_mac_addr == 0 || !addr) { |
| 10301 | hdd_debug("No mac configured from platform driver"); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10302 | return -EINVAL; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10303 | } |
| 10304 | |
| 10305 | hdd_free_mac_address_lists(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10306 | |
| 10307 | if (no_of_mac_addr > max_mac_addr) |
| 10308 | no_of_mac_addr = max_mac_addr; |
| 10309 | |
| 10310 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 10311 | |
| 10312 | for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10313 | buf = hdd_ctx->provisioned_mac_addr[iter].bytes; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10314 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10315 | hdd_info("provisioned MAC Addr [%d]" MAC_ADDRESS_STR, iter, |
| 10316 | MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10317 | } |
| 10318 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10319 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10320 | hdd_ctx->num_provisioned_addr = no_of_mac_addr; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 10321 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10322 | if (hdd_ctx->config->mac_provision) { |
| 10323 | addr = hdd_get_platform_wlan_derived_mac_buff(dev, |
| 10324 | &no_of_mac_addr); |
| 10325 | |
| 10326 | if (no_of_mac_addr == 0 || !addr) |
| 10327 | hdd_warn("No derived address from platform driver"); |
| 10328 | else if (no_of_mac_addr > |
| 10329 | (max_mac_addr - hdd_ctx->num_provisioned_addr)) |
| 10330 | no_of_mac_addr = (max_mac_addr - |
| 10331 | hdd_ctx->num_provisioned_addr); |
| 10332 | |
| 10333 | for (iter = 0; iter < no_of_mac_addr; ++iter, |
| 10334 | addr += mac_addr_size) { |
| 10335 | buf = hdd_ctx->derived_mac_addr[iter].bytes; |
| 10336 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
| 10337 | hdd_debug("derived MAC Addr [%d]" MAC_ADDRESS_STR, iter, |
| 10338 | MAC_ADDR_ARRAY(buf)); |
| 10339 | } |
| 10340 | hdd_ctx->num_derived_addr = no_of_mac_addr; |
| 10341 | } |
| 10342 | |
| 10343 | no_of_mac_addr = hdd_ctx->num_provisioned_addr + |
| 10344 | hdd_ctx->num_derived_addr; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10345 | if (no_of_mac_addr < max_mac_addr) |
| 10346 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 10347 | no_of_mac_addr); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10348 | |
| 10349 | status = sme_set_custom_mac_addr(mac_addr); |
| 10350 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10351 | return -EAGAIN; |
| 10352 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10353 | return 0; |
| 10354 | } |
| 10355 | |
| 10356 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10357 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 10358 | * @hdd_ctx: HDD Context |
| 10359 | * |
| 10360 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 10361 | * will generate its own MAC and update it to FW. |
| 10362 | * |
| 10363 | * Return: 0 for success |
| 10364 | * Non-zero error code for failure |
| 10365 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10366 | 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] | 10367 | { |
| 10368 | tSirMacAddr customMacAddr; |
| 10369 | QDF_STATUS status; |
| 10370 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10371 | if (hdd_ctx->num_provisioned_addr) |
| 10372 | qdf_mem_copy(&customMacAddr, |
| 10373 | &hdd_ctx->provisioned_mac_addr[0].bytes[0], |
| 10374 | sizeof(tSirMacAddr)); |
| 10375 | else |
| 10376 | qdf_mem_copy(&customMacAddr, |
| 10377 | &hdd_ctx->derived_mac_addr[0].bytes[0], |
| 10378 | sizeof(tSirMacAddr)); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10379 | status = sme_set_custom_mac_addr(customMacAddr); |
| 10380 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10381 | return -EAGAIN; |
| 10382 | return 0; |
| 10383 | } |
| 10384 | |
| 10385 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10386 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 10387 | * @hdd_ctx: HDD Context |
| 10388 | * |
| 10389 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 10390 | * is provisioned with mac addresses, driver uses it, else it will use |
| 10391 | * wlan_mac.bin to update HW MAC addresses. |
| 10392 | * |
| 10393 | * Return: None |
| 10394 | */ |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10395 | static int hdd_initialize_mac_address(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10396 | { |
| 10397 | QDF_STATUS status; |
| 10398 | int ret; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10399 | bool update_mac_addr_to_fw = true; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10400 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10401 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10402 | if (hdd_ctx->config->mac_provision || !ret) { |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10403 | hdd_info("using MAC address from platform driver"); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10404 | return ret; |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10405 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10406 | |
| 10407 | status = hdd_update_mac_config(hdd_ctx); |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10408 | if (QDF_IS_STATUS_SUCCESS(status)) { |
| 10409 | hdd_info("using MAC address from wlan_mac.bin"); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10410 | return 0; |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10411 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10412 | |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10413 | hdd_info("using default MAC address"); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10414 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10415 | /* Use fw provided MAC */ |
| 10416 | if (!qdf_is_macaddr_zero(&hdd_ctx->hw_macaddr)) { |
| 10417 | hdd_update_macaddr(hdd_ctx, hdd_ctx->hw_macaddr, false); |
| 10418 | update_mac_addr_to_fw = false; |
| 10419 | return 0; |
| 10420 | } else if (hdd_generate_macaddr_auto(hdd_ctx) != 0) { |
| 10421 | struct qdf_mac_addr mac_addr; |
| 10422 | |
| 10423 | hdd_err("MAC failure from device serial no."); |
Jeff Johnson | 51a8052 | 2018-12-11 20:19:44 -0800 | [diff] [blame] | 10424 | qdf_get_random_bytes(&mac_addr, sizeof(mac_addr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10425 | /* |
| 10426 | * Reset multicast bit (bit-0) and set |
| 10427 | * locally-administered bit |
| 10428 | */ |
| 10429 | mac_addr.bytes[0] = 0x2; |
| 10430 | hdd_update_macaddr(hdd_ctx, mac_addr, true); |
| 10431 | } |
| 10432 | |
| 10433 | if (update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10434 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10435 | if (ret) |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 10436 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10437 | } |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10438 | return ret; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10439 | } |
| 10440 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10441 | static int hdd_set_smart_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10442 | { |
| 10443 | int vdev_id = 0; |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 10444 | QDF_STATUS status; |
| 10445 | bool smart_chainmask_enabled; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10446 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10447 | int vpdev = PDEV_CMD; |
| 10448 | int ret; |
| 10449 | |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 10450 | status = ucfg_get_smart_chainmask_enabled(hdd_ctx->psoc, |
| 10451 | &smart_chainmask_enabled); |
| 10452 | if (QDF_IS_STATUS_ERROR(status)) |
| 10453 | return -EINVAL; |
| 10454 | |
| 10455 | ret = sme_cli_set_command(vdev_id, param_id, |
| 10456 | (int)smart_chainmask_enabled, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10457 | if (ret) |
| 10458 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 10459 | |
| 10460 | return ret; |
| 10461 | } |
| 10462 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10463 | static int hdd_set_alternative_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10464 | { |
| 10465 | int vdev_id = 0; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10466 | QDF_STATUS status; |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10467 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10468 | bool alternative_chainmask_enabled; |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10469 | int vpdev = PDEV_CMD; |
| 10470 | int ret; |
| 10471 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10472 | status = ucfg_get_alternative_chainmask_enabled( |
| 10473 | hdd_ctx->psoc, |
| 10474 | &alternative_chainmask_enabled); |
| 10475 | if (QDF_IS_STATUS_ERROR(status)) |
| 10476 | return -EINVAL; |
| 10477 | |
| 10478 | ret = sme_cli_set_command(vdev_id, param_id, |
| 10479 | (int)alternative_chainmask_enabled, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10480 | if (ret) |
| 10481 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 10482 | ret); |
| 10483 | |
| 10484 | return ret; |
| 10485 | } |
| 10486 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10487 | static int hdd_set_ani_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10488 | { |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10489 | QDF_STATUS status; |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10490 | int vdev_id = 0; |
| 10491 | int param_id = WMI_PDEV_PARAM_ANI_ENABLE; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10492 | bool value; |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10493 | int vpdev = PDEV_CMD; |
| 10494 | int ret; |
| 10495 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10496 | status = ucfg_fwol_get_ani_enabled(hdd_ctx->psoc, &value); |
| 10497 | if (QDF_IS_STATUS_ERROR(status)) |
| 10498 | return -EINVAL; |
| 10499 | |
| 10500 | ret = sme_cli_set_command(vdev_id, param_id, (int)value, vpdev); |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10501 | if (ret) |
| 10502 | hdd_err("WMI_PDEV_PARAM_ANI_ENABLE failed %d", ret); |
| 10503 | |
| 10504 | return ret; |
| 10505 | } |
| 10506 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 10507 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10508 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 10509 | * @hdd_ctx: HDD context |
| 10510 | * |
| 10511 | * Pre configurations to be done at lower layer before calling cds enable. |
| 10512 | * |
| 10513 | * Return: 0 on success and errno on failure. |
| 10514 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10515 | static int hdd_pre_enable_configure(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10516 | { |
| 10517 | int ret; |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 10518 | uint8_t val = 0; |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10519 | QDF_STATUS status; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10520 | uint32_t arp_ac_category; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 10521 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10522 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 10523 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Ajit Pal Singh | 5d26961 | 2018-04-19 16:29:12 +0530 | [diff] [blame] | 10524 | /* Register HL netdev flow control callback */ |
| 10525 | cdp_hl_fc_register(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10526 | |
| 10527 | /* |
| 10528 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 10529 | * The cfg download must occur before we update the SME config |
| 10530 | * since the SME config operation must access the cfg database |
| 10531 | */ |
| 10532 | status = hdd_set_sme_config(hdd_ctx); |
| 10533 | |
| 10534 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10535 | hdd_err("Failed hdd_set_sme_config: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10536 | ret = qdf_status_to_os_return(status); |
| 10537 | goto out; |
| 10538 | } |
| 10539 | |
Tushnim Bhattacharyya | ba8ee93 | 2017-03-23 09:27:40 -0700 | [diff] [blame] | 10540 | status = hdd_set_policy_mgr_user_cfg(hdd_ctx); |
| 10541 | if (QDF_STATUS_SUCCESS != status) { |
| 10542 | hdd_alert("Failed hdd_set_policy_mgr_user_cfg: %d", status); |
| 10543 | ret = qdf_status_to_os_return(status); |
| 10544 | goto out; |
| 10545 | } |
| 10546 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10547 | status = ucfg_mlme_get_tx_chainmask_1ss(hdd_ctx->psoc, &val); |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 10548 | if (QDF_STATUS_SUCCESS != status) { |
| 10549 | hdd_err("Get tx_chainmask_1ss from mlme failed"); |
| 10550 | ret = qdf_status_to_os_return(status); |
| 10551 | goto out; |
| 10552 | } |
| 10553 | 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] | 10554 | PDEV_CMD); |
| 10555 | if (0 != ret) { |
| 10556 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 10557 | goto out; |
| 10558 | } |
| 10559 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10560 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 10561 | if (ret) |
| 10562 | goto out; |
| 10563 | |
| 10564 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 10565 | if (ret) |
| 10566 | goto out; |
| 10567 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10568 | ret = hdd_set_ani_enabled(hdd_ctx); |
| 10569 | if (ret) |
| 10570 | goto out; |
| 10571 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10572 | status = ucfg_get_arp_ac_category(hdd_ctx->psoc, &arp_ac_category); |
| 10573 | |
| 10574 | if (QDF_IS_STATUS_ERROR(status)) |
| 10575 | return -EINVAL; |
| 10576 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 10577 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10578 | arp_ac_category, |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 10579 | PDEV_CMD); |
| 10580 | if (0 != ret) { |
| 10581 | hdd_err("WMI_PDEV_PARAM_ARP_AC_OVERRIDE ac: %d ret: %d", |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10582 | arp_ac_category, ret); |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 10583 | goto out; |
| 10584 | } |
| 10585 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10586 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 10587 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10588 | hdd_err("Failed to init channel list: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10589 | ret = qdf_status_to_os_return(status); |
| 10590 | goto out; |
| 10591 | } |
| 10592 | |
| 10593 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 10594 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10595 | hdd_err("config update failed"); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10596 | ret = -EINVAL; |
| 10597 | goto out; |
| 10598 | } |
| 10599 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10600 | |
| 10601 | hdd_init_channel_avoidance(hdd_ctx); |
| 10602 | |
| 10603 | out: |
| 10604 | return ret; |
| 10605 | } |
| 10606 | |
Rachit Kankane | 026e77a | 2018-07-31 16:21:09 +0530 | [diff] [blame] | 10607 | #ifdef FEATURE_P2P_LISTEN_OFFLOAD |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10608 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10609 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10610 | * @context: context registered with sme_register_p2p_lo_event(). HDD |
| 10611 | * always registers a hdd context pointer |
| 10612 | * @evt:event structure pointer |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10613 | * |
| 10614 | * This is the p2p listen offload stop event handler, it sends vendor |
| 10615 | * event back to supplicant to notify the stop reason. |
| 10616 | * |
| 10617 | * Return: None |
| 10618 | */ |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10619 | static void wlan_hdd_p2p_lo_event_callback(void *context, |
| 10620 | struct sir_p2p_lo_event *evt) |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10621 | { |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10622 | struct hdd_context *hdd_ctx = context; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10623 | struct sk_buff *vendor_event; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10624 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10625 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10626 | hdd_enter(); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10627 | |
| 10628 | if (hdd_ctx == NULL) { |
| 10629 | hdd_err("Invalid HDD context pointer"); |
| 10630 | return; |
| 10631 | } |
| 10632 | |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10633 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id); |
| 10634 | if (!adapter) { |
| 10635 | hdd_err("Cannot find adapter by vdev_id = %d", |
| 10636 | evt->vdev_id); |
| 10637 | return; |
| 10638 | } |
| 10639 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10640 | vendor_event = |
| 10641 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10642 | &(adapter->wdev), sizeof(uint32_t) + NLMSG_HDRLEN, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10643 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 10644 | GFP_KERNEL); |
| 10645 | |
| 10646 | if (!vendor_event) { |
| 10647 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 10648 | return; |
| 10649 | } |
| 10650 | |
| 10651 | if (nla_put_u32(vendor_event, |
| 10652 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 10653 | evt->reason_code)) { |
| 10654 | hdd_err("nla put failed"); |
| 10655 | kfree_skb(vendor_event); |
| 10656 | return; |
| 10657 | } |
| 10658 | |
| 10659 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10660 | hdd_debug("Sent P2P_LISTEN_OFFLOAD_STOP event for vdev_id = %d", |
| 10661 | evt->vdev_id); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10662 | } |
Rachit Kankane | 026e77a | 2018-07-31 16:21:09 +0530 | [diff] [blame] | 10663 | #else |
| 10664 | static void wlan_hdd_p2p_lo_event_callback(void *context, |
| 10665 | struct sir_p2p_lo_event *evt) |
| 10666 | { |
| 10667 | } |
| 10668 | #endif |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10669 | |
Rachit Kankane | f6834c4 | 2018-08-02 18:47:50 +0530 | [diff] [blame] | 10670 | #ifdef FEATURE_WLAN_DYNAMIC_CVM |
| 10671 | static inline int hdd_set_vc_mode_config(struct hdd_context *hdd_ctx) |
| 10672 | { |
| 10673 | return sme_set_vc_mode_config(hdd_ctx->config->vc_mode_cfg_bitmap); |
| 10674 | } |
| 10675 | #else |
| 10676 | static inline int hdd_set_vc_mode_config(struct hdd_context *hdd_ctx) |
| 10677 | { |
| 10678 | return QDF_STATUS_SUCCESS; |
| 10679 | } |
| 10680 | #endif |
| 10681 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10682 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10683 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 10684 | * @hdd_ctx: HDD context |
| 10685 | * |
| 10686 | * This function sends the adaptive dwell time config configuration to the |
| 10687 | * firmware via WMA |
| 10688 | * |
| 10689 | * Return: 0 - success, < 0 - failure |
| 10690 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10691 | static int hdd_adaptive_dwelltime_init(struct hdd_context *hdd_ctx) |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10692 | { |
| 10693 | QDF_STATUS status; |
| 10694 | struct adaptive_dwelltime_params dwelltime_params; |
| 10695 | |
| 10696 | dwelltime_params.is_enabled = |
| 10697 | hdd_ctx->config->adaptive_dwell_mode_enabled; |
| 10698 | dwelltime_params.dwelltime_mode = |
| 10699 | hdd_ctx->config->global_adapt_dwelltime_mode; |
| 10700 | dwelltime_params.lpf_weight = |
| 10701 | hdd_ctx->config->adapt_dwell_lpf_weight; |
| 10702 | dwelltime_params.passive_mon_intval = |
| 10703 | hdd_ctx->config->adapt_dwell_passive_mon_intval; |
| 10704 | dwelltime_params.wifi_act_threshold = |
| 10705 | hdd_ctx->config->adapt_dwell_wifi_act_threshold; |
| 10706 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10707 | status = sme_set_adaptive_dwelltime_config(hdd_ctx->mac_handle, |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10708 | &dwelltime_params); |
| 10709 | |
| 10710 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 10711 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10712 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 10713 | return -EAGAIN; |
| 10714 | } |
| 10715 | return 0; |
| 10716 | } |
| 10717 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10718 | int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10719 | { |
| 10720 | QDF_STATUS status; |
| 10721 | struct wmi_dbs_scan_sel_params dbs_scan_params; |
| 10722 | uint32_t i = 0; |
| 10723 | uint8_t count = 0, numentries = 0; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 10724 | uint8_t dual_mac_feature; |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10725 | uint8_t dbs_scan_config[CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 10726 | * CDS_DBS_SCAN_CLIENTS_MAX]; |
| 10727 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 10728 | status = ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 10729 | &dual_mac_feature); |
| 10730 | |
| 10731 | if (status != QDF_STATUS_SUCCESS) { |
| 10732 | hdd_err("can't get dual mac feature flag"); |
| 10733 | return -EINVAL; |
| 10734 | } |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10735 | /* check if DBS is enabled or supported */ |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 10736 | if ((dual_mac_feature == DISABLE_DBS_CXN_AND_SCAN) || |
| 10737 | (dual_mac_feature == ENABLE_DBS_CXN_AND_DISABLE_DBS_SCAN)) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10738 | return -EINVAL; |
| 10739 | |
| 10740 | hdd_string_to_u8_array(hdd_ctx->config->dbs_scan_selection, |
| 10741 | dbs_scan_config, &numentries, |
| 10742 | (CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 10743 | * CDS_DBS_SCAN_CLIENTS_MAX)); |
| 10744 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10745 | if (!numentries) { |
Dustin Brown | 6a8d39b | 2018-08-14 15:27:26 -0700 | [diff] [blame] | 10746 | hdd_debug("Do not send scan_selection_config"); |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10747 | return 0; |
| 10748 | } |
| 10749 | |
| 10750 | /* hdd_set_fw_log_params */ |
| 10751 | dbs_scan_params.num_clients = 0; |
| 10752 | while (count < (numentries - 2)) { |
| 10753 | dbs_scan_params.module_id[i] = dbs_scan_config[count]; |
| 10754 | dbs_scan_params.num_dbs_scans[i] = dbs_scan_config[count + 1]; |
| 10755 | dbs_scan_params.num_non_dbs_scans[i] = |
| 10756 | dbs_scan_config[count + 2]; |
| 10757 | dbs_scan_params.num_clients++; |
| 10758 | hdd_debug("module:%d NDS:%d NNDS:%d", |
| 10759 | dbs_scan_params.module_id[i], |
| 10760 | dbs_scan_params.num_dbs_scans[i], |
| 10761 | dbs_scan_params.num_non_dbs_scans[i]); |
| 10762 | count += CDS_DBS_SCAN_PARAM_PER_CLIENT; |
| 10763 | i++; |
| 10764 | } |
| 10765 | |
| 10766 | dbs_scan_params.pdev_id = 0; |
| 10767 | |
| 10768 | hdd_debug("clients:%d pdev:%d", |
| 10769 | dbs_scan_params.num_clients, dbs_scan_params.pdev_id); |
| 10770 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10771 | status = sme_set_dbs_scan_selection_config(hdd_ctx->mac_handle, |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10772 | &dbs_scan_params); |
| 10773 | hdd_debug("Sending DBS Scan Selection Configuration to fw"); |
| 10774 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10775 | hdd_err("Failed to send DBS Scan selection configuration!"); |
| 10776 | return -EAGAIN; |
| 10777 | } |
| 10778 | return 0; |
| 10779 | } |
| 10780 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10781 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 10782 | /** |
| 10783 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 10784 | * @hdd_ctx: HDD context |
| 10785 | * |
| 10786 | * Set auto shutdown callback to get indications from firmware to indicate |
| 10787 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 10788 | * |
| 10789 | * Return: 0 on success and errno on failure. |
| 10790 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10791 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10792 | { |
| 10793 | QDF_STATUS status; |
| 10794 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 10795 | if (!hdd_ctx->config->wlan_auto_shutdown) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10796 | return 0; |
| 10797 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10798 | status = sme_set_auto_shutdown_cb(hdd_ctx->mac_handle, |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10799 | wlan_hdd_auto_shutdown_cb); |
| 10800 | if (status != QDF_STATUS_SUCCESS) |
| 10801 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 10802 | status); |
| 10803 | |
| 10804 | return qdf_status_to_os_return(status); |
| 10805 | } |
| 10806 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10807 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10808 | { |
| 10809 | return 0; |
| 10810 | } |
| 10811 | #endif |
| 10812 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10813 | #ifdef MWS_COEX |
| 10814 | /** |
| 10815 | * hdd_set_mws_coex() - Set MWS coex configurations |
| 10816 | * @hdd_ctx: HDD context |
| 10817 | * |
| 10818 | * This function sends MWS-COEX 4G quick FTDM and |
| 10819 | * MWS-COEX 5G-NR power limit to FW |
| 10820 | * |
| 10821 | * Return: 0 on success and errno on failure. |
| 10822 | */ |
| 10823 | static int hdd_init_mws_coex(struct hdd_context *hdd_ctx) |
| 10824 | { |
| 10825 | int ret = 0; |
lifeng | db340e7 | 2018-11-20 00:50:20 +0800 | [diff] [blame] | 10826 | uint32_t mws_coex_4g_quick_tdm = 0, mws_coex_5g_nr_pwr_limit = 0; |
| 10827 | |
| 10828 | ucfg_mlme_get_mws_coex_4g_quick_tdm(hdd_ctx->psoc, |
| 10829 | &mws_coex_4g_quick_tdm); |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10830 | |
| 10831 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_MWSCOEX_4G_ALLOW_QUICK_FTDM, |
lifeng | db340e7 | 2018-11-20 00:50:20 +0800 | [diff] [blame] | 10832 | mws_coex_4g_quick_tdm, |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10833 | PDEV_CMD); |
| 10834 | if (ret) { |
| 10835 | hdd_warn("Unable to send MWS-COEX 4G quick FTDM policy"); |
| 10836 | return ret; |
| 10837 | } |
| 10838 | |
lifeng | db340e7 | 2018-11-20 00:50:20 +0800 | [diff] [blame] | 10839 | ucfg_mlme_get_mws_coex_5g_nr_pwr_limit(hdd_ctx->psoc, |
| 10840 | &mws_coex_5g_nr_pwr_limit); |
| 10841 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10842 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_MWSCOEX_SET_5GNR_PWR_LIMIT, |
lifeng | db340e7 | 2018-11-20 00:50:20 +0800 | [diff] [blame] | 10843 | mws_coex_5g_nr_pwr_limit, |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10844 | PDEV_CMD); |
| 10845 | if (ret) { |
| 10846 | hdd_warn("Unable to send MWS-COEX 4G quick FTDM policy"); |
| 10847 | return ret; |
| 10848 | } |
lifeng | db340e7 | 2018-11-20 00:50:20 +0800 | [diff] [blame] | 10849 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10850 | return ret; |
| 10851 | } |
| 10852 | #else |
| 10853 | static int hdd_init_mws_coex(struct hdd_context *hdd_ctx) |
| 10854 | { |
| 10855 | return 0; |
| 10856 | } |
| 10857 | #endif |
| 10858 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10859 | /** |
| 10860 | * hdd_features_init() - Init features |
| 10861 | * @hdd_ctx: HDD context |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10862 | * |
| 10863 | * Initialize features and their feature context after WLAN firmware is up. |
| 10864 | * |
| 10865 | * Return: 0 on success and errno on failure. |
| 10866 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10867 | static int hdd_features_init(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10868 | { |
| 10869 | tSirTxPowerLimit hddtxlimit; |
| 10870 | QDF_STATUS status; |
| 10871 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10872 | mac_handle_t mac_handle; |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 10873 | struct hdd_config *cfg; |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 10874 | bool b_cts2self, is_imps_enabled; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10875 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10876 | hdd_enter(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10877 | |
Dustin Brown | ad698ae | 2018-09-05 17:19:30 -0700 | [diff] [blame] | 10878 | ret = hdd_update_country_code(hdd_ctx); |
| 10879 | if (ret) { |
| 10880 | hdd_err("Failed to update country code; errno:%d", ret); |
| 10881 | return -EINVAL; |
| 10882 | } |
| 10883 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10884 | ret = hdd_init_mws_coex(hdd_ctx); |
| 10885 | if (ret) |
| 10886 | hdd_warn("Error initializing mws-coex"); |
| 10887 | |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 10888 | cfg = hdd_ctx->config; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10889 | /* FW capabilities received, Set the Dot11 mode */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10890 | mac_handle = hdd_ctx->mac_handle; |
| 10891 | sme_setdef_dot11mode(mac_handle); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10892 | |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 10893 | ucfg_mlme_is_imps_enabled(hdd_ctx->psoc, &is_imps_enabled); |
| 10894 | hdd_set_idle_ps_config(hdd_ctx, is_imps_enabled); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10895 | |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 10896 | /* Send Enable/Disable data stall detection cmd to FW */ |
| 10897 | sme_cli_set_command(0, WMI_PDEV_PARAM_DATA_STALL_DETECT_ENABLE, |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 10898 | cdp_cfg_get(cds_get_context(QDF_MODULE_ID_SOC), |
| 10899 | cfg_dp_enable_data_stall), PDEV_CMD); |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 10900 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10901 | ucfg_mlme_get_go_cts2self_for_sta(hdd_ctx->psoc, &b_cts2self); |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 10902 | if (b_cts2self) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10903 | sme_set_cts2self_for_p2p_go(mac_handle); |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 10904 | |
Rachit Kankane | f6834c4 | 2018-08-02 18:47:50 +0530 | [diff] [blame] | 10905 | if (hdd_set_vc_mode_config(hdd_ctx)) |
Nachiket Kukade | 8983cf6 | 2017-10-12 18:14:48 +0530 | [diff] [blame] | 10906 | hdd_warn("Error in setting Voltage Corner mode config to FW"); |
| 10907 | |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10908 | if (hdd_rx_ol_init(hdd_ctx)) |
| 10909 | hdd_err("Unable to initialize Rx LRO/GRO in fw"); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10910 | |
| 10911 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 10912 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 10913 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10914 | if (hdd_dbs_scan_selection_init(hdd_ctx)) |
| 10915 | hdd_err("Unable to send DBS scan selection setting to FW"); |
| 10916 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10917 | ret = hdd_init_thermal_info(hdd_ctx); |
| 10918 | if (ret) { |
| 10919 | hdd_err("Error while initializing thermal information"); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10920 | return ret; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10921 | } |
| 10922 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10923 | /** |
| 10924 | * In case of SSR/PDR, if pktlog was enabled manually before |
| 10925 | * SSR/PDR, Then enabled it again automatically after Wlan |
| 10926 | * device up. |
| 10927 | */ |
| 10928 | if (cds_is_driver_recovering()) { |
| 10929 | if (hdd_ctx->is_pktlog_enabled) |
| 10930 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
Alok Kumar | 5a75b9d | 2018-08-31 10:55:43 +0530 | [diff] [blame] | 10931 | } else if (cds_is_packet_log_enabled()) |
| 10932 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 10933 | |
gaurank kathpalia | 3d2e385 | 2018-10-03 22:03:23 +0530 | [diff] [blame] | 10934 | hddtxlimit.txPower2g = ucfg_get_tx_power(hdd_ctx->psoc, BAND_2G); |
| 10935 | hddtxlimit.txPower5g = ucfg_get_tx_power(hdd_ctx->psoc, BAND_5G); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10936 | status = sme_txpower_limit(mac_handle, &hddtxlimit); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10937 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10938 | hdd_err("Error setting txlimit in sme: %d", status); |
| 10939 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10940 | wlan_hdd_tsf_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10941 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 10942 | status = sme_enable_disable_chanavoidind_event(mac_handle, 0); |
| 10943 | if (QDF_IS_STATUS_ERROR(status) && (status != QDF_STATUS_E_NOSUPPORT)) { |
| 10944 | hdd_err("Failed to disable Chan Avoidance Indication"); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 10945 | return -EINVAL; |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 10946 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10947 | |
| 10948 | /* register P2P Listen Offload event callback */ |
| 10949 | if (wma_is_p2p_lo_capable()) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10950 | sme_register_p2p_lo_event(mac_handle, hdd_ctx, |
| 10951 | wlan_hdd_p2p_lo_event_callback); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10952 | |
| 10953 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 10954 | |
| 10955 | if (ret) |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 10956 | return -EINVAL; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10957 | |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10958 | wlan_hdd_init_chan_info(hdd_ctx); |
Varun Reddy Yeturu | 3c9f89c | 2018-04-18 19:10:34 -0700 | [diff] [blame] | 10959 | wlan_hdd_twt_init(hdd_ctx); |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10960 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10961 | hdd_exit(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10962 | return 0; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10963 | } |
| 10964 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10965 | /** |
| 10966 | * hdd_features_deinit() - Deinit features |
| 10967 | * @hdd_ctx: HDD context |
| 10968 | * |
| 10969 | * De-Initialize features and their feature context. |
| 10970 | * |
| 10971 | * Return: none. |
| 10972 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10973 | static void hdd_features_deinit(struct hdd_context *hdd_ctx) |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10974 | { |
Varun Reddy Yeturu | 3c9f89c | 2018-04-18 19:10:34 -0700 | [diff] [blame] | 10975 | wlan_hdd_twt_deinit(hdd_ctx); |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10976 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10977 | wlan_hdd_tsf_deinit(hdd_ctx); |
jitiphil | 4e3bef4 | 2018-11-14 14:31:13 +0530 | [diff] [blame] | 10978 | if (cds_is_packet_log_enabled()) |
| 10979 | hdd_pktlog_enable_disable(hdd_ctx, false, 0, 0); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10980 | } |
| 10981 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10982 | /** |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10983 | * hdd_register_bcn_cb() - register scan beacon callback |
| 10984 | * @hdd_ctx - Pointer to the HDD context |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10985 | * |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10986 | * Return: QDF_STATUS |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10987 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10988 | 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] | 10989 | { |
| 10990 | QDF_STATUS status; |
| 10991 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10992 | status = ucfg_scan_register_bcn_cb(hdd_ctx->psoc, |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10993 | wlan_cfg80211_inform_bss_frame, |
| 10994 | SCAN_CB_TYPE_INFORM_BCN); |
| 10995 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10996 | hdd_err("failed with status code %08d [x%08x]", |
| 10997 | status, status); |
| 10998 | return status; |
| 10999 | } |
| 11000 | |
| 11001 | return QDF_STATUS_SUCCESS; |
| 11002 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 11003 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 11004 | /** |
Manjunathappa Prakash | a0cbc92 | 2018-05-08 19:48:34 -0700 | [diff] [blame] | 11005 | * hdd_v2_flow_pool_map() - Flow pool create callback when vdev is active |
| 11006 | * @vdev_id: vdev_id, corresponds to flow_pool |
| 11007 | * |
| 11008 | * Return: none. |
| 11009 | */ |
| 11010 | static void hdd_v2_flow_pool_map(int vdev_id) |
| 11011 | { |
| 11012 | QDF_STATUS status; |
| 11013 | |
| 11014 | status = cdp_flow_pool_map(cds_get_context(QDF_MODULE_ID_SOC), |
| 11015 | cds_get_context(QDF_MODULE_ID_TXRX), |
| 11016 | vdev_id); |
| 11017 | /* |
| 11018 | * For Adrastea flow control v2 is based on FW MAP events, |
| 11019 | * so this above callback is not implemented. |
| 11020 | * Hence this is not actual failure. Dont return failure |
| 11021 | */ |
| 11022 | if ((status != QDF_STATUS_SUCCESS) && |
| 11023 | (status != QDF_STATUS_E_INVAL)) { |
| 11024 | hdd_err("vdev_id: %d, failed to create flow pool status %d", |
| 11025 | vdev_id, status); |
| 11026 | } |
| 11027 | } |
| 11028 | |
| 11029 | /** |
| 11030 | * hdd_v2_flow_pool_unmap() - Flow pool create callback when vdev is not active |
| 11031 | * @vdev_id: vdev_id, corresponds to flow_pool |
| 11032 | * |
| 11033 | * Return: none. |
| 11034 | */ |
| 11035 | static void hdd_v2_flow_pool_unmap(int vdev_id) |
| 11036 | { |
| 11037 | cdp_flow_pool_unmap(cds_get_context(QDF_MODULE_ID_SOC), |
| 11038 | cds_get_context(QDF_MODULE_ID_TXRX), vdev_id); |
| 11039 | } |
| 11040 | |
| 11041 | /** |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11042 | * hdd_action_oui_config() - Configure action_oui strings |
| 11043 | * @hdd_ctx: pointer to hdd context |
| 11044 | * |
| 11045 | * This is a HDD wrapper function which invokes ucfg api |
| 11046 | * of action_oui component to parse action oui strings. |
| 11047 | * |
| 11048 | * Return: None |
| 11049 | */ |
| 11050 | static void hdd_action_oui_config(struct hdd_context *hdd_ctx) |
| 11051 | { |
| 11052 | QDF_STATUS status; |
| 11053 | uint32_t id; |
| 11054 | uint8_t *str; |
| 11055 | |
| 11056 | if (!hdd_ctx->config->action_oui_enable) |
| 11057 | return; |
| 11058 | |
| 11059 | for (id = 0; id < ACTION_OUI_MAXIMUM_ID; id++) { |
| 11060 | str = hdd_ctx->config->action_oui_str[id]; |
| 11061 | if (!qdf_str_len(str)) |
| 11062 | continue; |
| 11063 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11064 | status = ucfg_action_oui_parse(hdd_ctx->psoc, str, id); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11065 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11066 | hdd_err("Failed to parse action_oui str: %u", id); |
| 11067 | } |
| 11068 | } |
| 11069 | |
| 11070 | /** |
| 11071 | * hdd_action_oui_send() - Send action_oui extensions to firmware |
| 11072 | * @hdd_ctx: pointer to hdd context |
| 11073 | * |
| 11074 | * This is a HDD wrapper function which invokes ucfg api |
| 11075 | * of action_oui component to send action oui extensions to firmware. |
| 11076 | * |
| 11077 | * Return: None |
| 11078 | */ |
| 11079 | static void hdd_action_oui_send(struct hdd_context *hdd_ctx) |
| 11080 | { |
| 11081 | QDF_STATUS status; |
| 11082 | |
| 11083 | if (!hdd_ctx->config->action_oui_enable) |
| 11084 | return; |
| 11085 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11086 | status = ucfg_action_oui_send(hdd_ctx->psoc); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11087 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11088 | hdd_err("Failed to send one or all action_ouis"); |
| 11089 | } |
| 11090 | |
| 11091 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11092 | * hdd_configure_cds() - Configure cds modules |
| 11093 | * @hdd_ctx: HDD context |
| 11094 | * @adapter: Primary adapter context |
| 11095 | * |
| 11096 | * Enable Cds modules after WLAN firmware is up. |
| 11097 | * |
| 11098 | * Return: 0 on success and errno on failure. |
| 11099 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 11100 | int hdd_configure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11101 | { |
| 11102 | int ret; |
| 11103 | QDF_STATUS status; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11104 | int set_value; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11105 | mac_handle_t mac_handle; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11106 | bool enable_rts_sifsbursting; |
| 11107 | uint8_t enable_phy_reg_retention; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11108 | uint8_t max_mpdus_inampdu, is_force_1x1 = 0; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11109 | uint32_t num_abg_tx_chains = 0; |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 11110 | uint16_t num_11b_tx_chains = 0; |
| 11111 | uint16_t num_11ag_tx_chains = 0; |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 11112 | struct policy_mgr_dp_cbacks dp_cbs = {0}; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 11113 | bool value; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 11114 | enum pmo_auto_pwr_detect_failure_mode auto_power_fail_mode; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 11115 | bool bval = false; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11116 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11117 | mac_handle = hdd_ctx->mac_handle; |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11118 | |
| 11119 | hdd_action_oui_send(hdd_ctx); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11120 | status = ucfg_policy_mgr_get_force_1x1(hdd_ctx->psoc, &is_force_1x1); |
| 11121 | if (status != QDF_STATUS_SUCCESS) { |
| 11122 | hdd_err("Failed to get force 1x1 value"); |
| 11123 | goto out; |
| 11124 | } |
| 11125 | if (is_force_1x1) |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11126 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_SET_IOT_PATTERN, |
| 11127 | 1, PDEV_CMD); |
| 11128 | /* set chip power save failure detected callback */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11129 | sme_set_chip_pwr_save_fail_cb(mac_handle, |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11130 | hdd_chip_pwr_save_fail_detected_cb); |
| 11131 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11132 | status = ucfg_get_max_mpdus_inampdu(hdd_ctx->psoc, |
| 11133 | &max_mpdus_inampdu); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11134 | if (status) { |
| 11135 | hdd_err("Failed to get max mpdus in ampdu value"); |
| 11136 | goto out; |
| 11137 | } |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11138 | |
| 11139 | if (max_mpdus_inampdu) { |
| 11140 | set_value = max_mpdus_inampdu; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11141 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_MAX_MPDUS_IN_AMPDU, |
| 11142 | set_value, PDEV_CMD); |
| 11143 | } |
| 11144 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11145 | status = ucfg_get_enable_rts_sifsbursting(hdd_ctx->psoc, |
| 11146 | &enable_rts_sifsbursting); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11147 | if (status) { |
| 11148 | hdd_err("Failed to get rts sifs bursting value"); |
| 11149 | goto out; |
| 11150 | } |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11151 | |
| 11152 | if (enable_rts_sifsbursting) { |
| 11153 | set_value = enable_rts_sifsbursting; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11154 | sme_cli_set_command(0, |
| 11155 | (int)WMI_PDEV_PARAM_ENABLE_RTS_SIFS_BURSTING, |
| 11156 | set_value, PDEV_CMD); |
| 11157 | } |
| 11158 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 11159 | ucfg_mlme_get_sap_get_peer_info(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 11160 | if (value) { |
| 11161 | set_value = value; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11162 | sme_cli_set_command(0, |
| 11163 | (int)WMI_PDEV_PARAM_PEER_STATS_INFO_ENABLE, |
| 11164 | set_value, PDEV_CMD); |
| 11165 | } |
| 11166 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11167 | status = ucfg_mlme_get_num_11b_tx_chains(hdd_ctx->psoc, |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 11168 | &num_11b_tx_chains); |
| 11169 | if (status != QDF_STATUS_SUCCESS) { |
| 11170 | hdd_err("Failed to get num_11b_tx_chains"); |
| 11171 | goto out; |
| 11172 | } |
| 11173 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11174 | status = ucfg_mlme_get_num_11ag_tx_chains(hdd_ctx->psoc, |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 11175 | &num_11ag_tx_chains); |
| 11176 | if (status != QDF_STATUS_SUCCESS) { |
| 11177 | hdd_err("Failed to get num_11ag_tx_chains"); |
| 11178 | goto out; |
| 11179 | } |
| 11180 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 11181 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 11182 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11183 | hdd_err("unable to get vht_enable2x2"); |
| 11184 | |
| 11185 | if (!bval) { |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11186 | if (num_11b_tx_chains > 1) |
| 11187 | num_11b_tx_chains = 1; |
| 11188 | if (num_11ag_tx_chains > 1) |
| 11189 | num_11ag_tx_chains = 1; |
| 11190 | } |
| 11191 | WMI_PDEV_PARAM_SET_11B_TX_CHAIN_NUM(num_abg_tx_chains, |
| 11192 | num_11b_tx_chains); |
| 11193 | WMI_PDEV_PARAM_SET_11AG_TX_CHAIN_NUM(num_abg_tx_chains, |
| 11194 | num_11ag_tx_chains); |
| 11195 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_ABG_MODE_TX_CHAIN_NUM, |
| 11196 | num_abg_tx_chains, PDEV_CMD); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11197 | |
Paul Zhang | 02526cd | 2018-09-20 17:47:46 +0800 | [diff] [blame] | 11198 | if (!ucfg_reg_is_regdb_offloaded(hdd_ctx->psoc)) |
| 11199 | ucfg_reg_program_default_cc(hdd_ctx->pdev, |
| 11200 | hdd_ctx->reg.reg_domain); |
| 11201 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11202 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 11203 | if (ret) { |
| 11204 | hdd_err("Failed to pre-configure cds"); |
| 11205 | goto out; |
| 11206 | } |
| 11207 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 11208 | /* Always get latest IPA resources allocated from cds_open and configure |
| 11209 | * IPA module before configuring them to FW. Sequence required as crash |
| 11210 | * observed otherwise. |
| 11211 | */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 11212 | if (ucfg_ipa_uc_ol_init(hdd_ctx->pdev, |
| 11213 | cds_get_context(QDF_MODULE_ID_QDF_DEVICE))) { |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 11214 | hdd_err("Failed to setup pipes"); |
| 11215 | goto out; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 11216 | } |
| 11217 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11218 | /* |
| 11219 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 11220 | * else |
| 11221 | */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11222 | status = cds_enable(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11223 | |
| 11224 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11225 | hdd_err("cds_enable failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11226 | goto out; |
| 11227 | } |
| 11228 | |
| 11229 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 11230 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11231 | hdd_err("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11232 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11233 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 11234 | status = hdd_register_bcn_cb(hdd_ctx); |
| 11235 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 11236 | hdd_err("hdd_register_bcn_cb failed"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 11237 | goto cds_disable; |
| 11238 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11239 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 11240 | ret = hdd_features_init(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11241 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11242 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11243 | |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 11244 | /* Donot disable rx offload on concurrency for lithium based targets */ |
| 11245 | if (!(hdd_ctx->target_type == TARGET_TYPE_QCA6290 || |
| 11246 | hdd_ctx->target_type == TARGET_TYPE_QCA6390)) |
| 11247 | if (hdd_ctx->ol_enable) |
| 11248 | dp_cbs.hdd_disable_rx_ol_in_concurrency = |
| 11249 | hdd_disable_rx_ol_in_concurrency; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 11250 | dp_cbs.hdd_set_rx_mode_rps_cb = hdd_set_rx_mode_rps; |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 11251 | 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] | 11252 | dp_cbs.hdd_v2_flow_pool_map = hdd_v2_flow_pool_map; |
| 11253 | dp_cbs.hdd_v2_flow_pool_unmap = hdd_v2_flow_pool_unmap; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11254 | status = policy_mgr_register_dp_cb(hdd_ctx->psoc, &dp_cbs); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 11255 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 11256 | hdd_debug("Failed to register DP cb with Policy Manager"); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 11257 | goto cds_disable; |
| 11258 | } |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11259 | status = policy_mgr_register_mode_change_cb(hdd_ctx->psoc, |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 11260 | wlan_hdd_send_mode_change_event); |
| 11261 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 11262 | hdd_debug("Failed to register mode change cb with Policy Manager"); |
| 11263 | goto cds_disable; |
| 11264 | } |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 11265 | |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 11266 | if (hdd_green_ap_enable_egap(hdd_ctx)) |
Nachiket Kukade | fbd1afc | 2017-07-12 17:41:54 +0530 | [diff] [blame] | 11267 | hdd_debug("enhance green ap is not enabled"); |
| 11268 | |
Nachiket Kukade | dd30266 | 2017-07-13 17:31:44 +0530 | [diff] [blame] | 11269 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 11270 | hdd_debug("Failed to set wow pulse"); |
| 11271 | |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 11272 | bval = false; |
| 11273 | if (QDF_IS_STATUS_ERROR(ucfg_fwol_get_gcmp_enable(hdd_ctx->psoc, |
| 11274 | &bval))) |
| 11275 | hdd_err("Unable to get GCMP enable config param"); |
| 11276 | |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 11277 | sme_cli_set_command(0, WMI_PDEV_PARAM_GCMP_SUPPORT_ENABLE, |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 11278 | bval, PDEV_CMD); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 11279 | |
| 11280 | auto_power_fail_mode = |
| 11281 | ucfg_pmo_get_auto_power_fail_mode(hdd_ctx->psoc); |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 11282 | sme_cli_set_command(0, WMI_PDEV_AUTO_DETECT_POWER_FAILURE, |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 11283 | auto_power_fail_mode, PDEV_CMD); |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 11284 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11285 | status = ucfg_get_enable_phy_reg_retention(hdd_ctx->psoc, |
| 11286 | &enable_phy_reg_retention); |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 11287 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11288 | if (QDF_IS_STATUS_ERROR(status)) |
| 11289 | return -EINVAL; |
| 11290 | |
| 11291 | if (enable_phy_reg_retention) |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 11292 | wma_cli_set_command(0, WMI_PDEV_PARAM_FAST_PWR_TRANSITION, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11293 | enable_phy_reg_retention, PDEV_CMD); |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 11294 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11295 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11296 | |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11297 | cds_disable: |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11298 | cds_disable(hdd_ctx->psoc); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11299 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11300 | out: |
| 11301 | return -EINVAL; |
| 11302 | } |
| 11303 | |
| 11304 | /** |
| 11305 | * hdd_deconfigure_cds() -De-Configure cds |
| 11306 | * @hdd_ctx: HDD context |
| 11307 | * |
| 11308 | * Deconfigure Cds modules before WLAN firmware is down. |
| 11309 | * |
| 11310 | * Return: 0 on success and errno on failure. |
| 11311 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11312 | static int hdd_deconfigure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11313 | { |
| 11314 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 11315 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11316 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11317 | hdd_enter(); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 11318 | |
| 11319 | /* De-init features */ |
| 11320 | hdd_features_deinit(hdd_ctx); |
| 11321 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11322 | qdf_status = policy_mgr_deregister_mode_change_cb(hdd_ctx->psoc); |
Srinivas Girigowda | d241288 | 2018-09-07 15:42:04 -0700 | [diff] [blame] | 11323 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 11324 | hdd_debug("Failed to deregister mode change cb with Policy Manager"); |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 11325 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11326 | qdf_status = cds_disable(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11327 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11328 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 11329 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 11330 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11331 | } |
| 11332 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 11333 | 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] | 11334 | hdd_err("Failed to disconnect pipes"); |
| 11335 | ret = -EINVAL; |
| 11336 | } |
| 11337 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11338 | hdd_exit(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 11339 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11340 | } |
| 11341 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 11342 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 11343 | static void hdd_deregister_policy_manager_callback( |
| 11344 | struct wlan_objmgr_psoc *psoc) |
| 11345 | { |
| 11346 | if (QDF_STATUS_SUCCESS != |
| 11347 | policy_mgr_deregister_hdd_cb(psoc)) { |
| 11348 | hdd_err("HDD callback deregister with policy manager failed"); |
| 11349 | } |
| 11350 | } |
| 11351 | #else |
| 11352 | static void hdd_deregister_policy_manager_callback( |
| 11353 | struct wlan_objmgr_psoc *psoc) |
| 11354 | { |
| 11355 | } |
| 11356 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11357 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11358 | 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] | 11359 | { |
| 11360 | void *hif_ctx; |
| 11361 | qdf_device_t qdf_ctx; |
| 11362 | QDF_STATUS qdf_status; |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11363 | bool is_recovery_stop = cds_is_driver_recovering(); |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 11364 | int ret = 0; |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11365 | int active_threads; |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 11366 | int debugfs_threads; |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 11367 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11368 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11369 | hdd_enter(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11370 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11371 | hdd_deregister_policy_manager_callback(hdd_ctx->psoc); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 11372 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11373 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 11374 | if (!qdf_ctx) { |
| 11375 | hdd_err("QDF device context NULL"); |
| 11376 | return -EINVAL; |
| 11377 | } |
| 11378 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11379 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 11380 | hdd_ctx->stop_modules_in_progress = true; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 11381 | cds_set_module_stop_in_progress(true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11382 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11383 | active_threads = cds_return_external_threads_count(); |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 11384 | debugfs_threads = hdd_return_debugfs_threads_count(); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11385 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 11386 | if (active_threads > 0 || debugfs_threads > 0 || |
| 11387 | hdd_ctx->is_wiphy_suspended) { |
| 11388 | hdd_warn("External threads %d, Debugfs threads %d, wiphy suspend %d", |
| 11389 | active_threads, debugfs_threads, |
| 11390 | hdd_ctx->is_wiphy_suspended); |
| 11391 | |
| 11392 | if (active_threads) |
| 11393 | cds_print_external_threads(); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11394 | |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 11395 | if (IS_IDLE_STOP && !ftm_mode) { |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11396 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 11397 | hdd_psoc_idle_timer_start(hdd_ctx); |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 11398 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 11399 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11400 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11401 | return 0; |
| 11402 | } |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 11403 | } |
| 11404 | |
Kabilan Kannan | 6edafeb | 2017-11-16 16:34:34 -0800 | [diff] [blame] | 11405 | /* free user wowl patterns */ |
| 11406 | hdd_free_user_wowl_ptrns(); |
| 11407 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11408 | switch (hdd_ctx->driver_status) { |
| 11409 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11410 | hdd_debug("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11411 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11412 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11413 | hdd_debug("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11414 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11415 | case DRIVER_MODULES_ENABLED: |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 11416 | hdd_info("Wlan transitioning (CLOSED <- ENABLED)"); |
| 11417 | |
| 11418 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE) |
| 11419 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11420 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 11421 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11422 | if (hdd_deconfigure_cds(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11423 | hdd_err("Failed to de-configure CDS"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11424 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11425 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11426 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11427 | hdd_debug("successfully Disabled the CDS modules!"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11428 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11429 | break; |
| 11430 | default: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11431 | QDF_DEBUG_PANIC("Unknown driver state:%d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11432 | hdd_ctx->driver_status); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11433 | ret = -EINVAL; |
| 11434 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11435 | } |
| 11436 | |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 11437 | hdd_sysfs_destroy_powerstats_interface(); |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 11438 | hdd_sysfs_destroy_version_interface(); |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 11439 | hdd_sysfs_destroy_driver_root_obj(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11440 | hdd_debug("Closing CDS modules!"); |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 11441 | |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 11442 | qdf_status = cds_post_disable(); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 11443 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11444 | hdd_err("Failed to process post CDS disable Modules! :%d", |
| 11445 | qdf_status); |
| 11446 | ret = -EINVAL; |
| 11447 | QDF_ASSERT(0); |
| 11448 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 11449 | |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 11450 | /* De-register the SME callbacks */ |
| 11451 | hdd_deregister_cb(hdd_ctx); |
| 11452 | |
psimha | deea0a1 | 2017-12-18 14:50:02 -0800 | [diff] [blame] | 11453 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
| 11454 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11455 | qdf_status = cds_dp_close(hdd_ctx->psoc); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 11456 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11457 | hdd_warn("Failed to stop CDS DP: %d", qdf_status); |
| 11458 | ret = -EINVAL; |
| 11459 | QDF_ASSERT(0); |
| 11460 | } |
| 11461 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11462 | qdf_status = cds_close(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11463 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11464 | hdd_warn("Failed to stop CDS: %d", qdf_status); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 11465 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11466 | QDF_ASSERT(0); |
| 11467 | } |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 11468 | |
| 11469 | qdf_status = wbuff_module_deinit(); |
| 11470 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
| 11471 | hdd_err("WBUFF de-init unsuccessful; status: %d", qdf_status); |
| 11472 | |
Sandeep Puligilla | b7beb47 | 2018-08-13 22:54:20 -0700 | [diff] [blame] | 11473 | hdd_component_pdev_close(hdd_ctx->pdev); |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 11474 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11475 | hdd_component_psoc_close(hdd_ctx->psoc); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 11476 | dispatcher_pdev_close(hdd_ctx->pdev); |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 11477 | ret = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 11478 | if (ret) { |
| 11479 | hdd_err("Failed to destroy pdev; errno:%d", ret); |
| 11480 | QDF_ASSERT(0); |
| 11481 | } |
| 11482 | |
| 11483 | /* |
| 11484 | * Reset total mac phy during module stop such that during |
| 11485 | * next module start same psoc is used to populate new service |
| 11486 | * ready data |
| 11487 | */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11488 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->psoc); |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 11489 | if (tgt_hdl) |
| 11490 | target_psoc_set_total_mac_phy_cnt(tgt_hdl, 0); |
| 11491 | |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 11492 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11493 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 11494 | if (!hif_ctx) { |
| 11495 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11496 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11497 | } |
| 11498 | |
Arunk Khandavalli | 4b40433 | 2017-09-26 12:46:00 +0530 | [diff] [blame] | 11499 | if (hdd_ctx->target_hw_name) { |
| 11500 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 11501 | hdd_ctx->target_hw_name = NULL; |
| 11502 | } |
| 11503 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 11504 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11505 | |
| 11506 | ol_cds_free(); |
| 11507 | |
Dustin Brown | c2a156e | 2018-10-25 16:56:27 -0700 | [diff] [blame] | 11508 | if (IS_IDLE_STOP) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11509 | ret = pld_power_off(qdf_ctx->dev); |
| 11510 | if (ret) |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11511 | hdd_err("Failed to power down device; errno:%d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11512 | } |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11513 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11514 | /* Free the cache channels of the command SET_DISABLE_CHANNEL_LIST */ |
| 11515 | wlan_hdd_free_cache_channels(hdd_ctx); |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 11516 | |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 11517 | hdd_check_for_leaks(hdd_ctx, is_recovery_stop); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 11518 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11519 | |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 11520 | /* Once the firmware sequence is completed reset this flag */ |
| 11521 | hdd_ctx->imps_enabled = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11522 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11523 | hdd_info("Wlan transitioned (now CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11524 | |
Kai Liu | eabb1df | 2018-11-08 14:58:54 +0800 | [diff] [blame] | 11525 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, PLD_BUS_WIDTH_NONE); |
| 11526 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11527 | done: |
| 11528 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 11529 | cds_set_module_stop_in_progress(false); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11530 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11531 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11532 | hdd_exit(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11533 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11534 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11535 | } |
| 11536 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11537 | |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11538 | #ifdef WLAN_FEATURE_MEMDUMP_ENABLE |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11539 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11540 | * hdd_state_info_dump() - prints state information of hdd layer |
| 11541 | * @buf: buffer pointer |
| 11542 | * @size: size of buffer to be filled |
| 11543 | * |
| 11544 | * This function is used to dump state information of hdd layer |
| 11545 | * |
| 11546 | * Return: None |
| 11547 | */ |
| 11548 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 11549 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11550 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 11551 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11552 | struct hdd_adapter *adapter; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11553 | uint16_t len = 0; |
| 11554 | char *buf = *buf_ptr; |
| 11555 | |
| 11556 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11557 | if (!hdd_ctx) { |
| 11558 | hdd_err("Failed to get hdd context "); |
| 11559 | return; |
| 11560 | } |
| 11561 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11562 | hdd_debug("size of buffer: %d", *size); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11563 | |
| 11564 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 11565 | "\n is_wiphy_suspended %d", hdd_ctx->is_wiphy_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11566 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 11567 | "\n is_scheduler_suspended %d", |
| 11568 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11569 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11570 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11571 | if (adapter->dev) |
| 11572 | len += scnprintf(buf + len, *size - len, |
| 11573 | "\n device name: %s", adapter->dev->name); |
wadesong | 42968e9 | 2017-06-08 14:11:21 +0800 | [diff] [blame] | 11574 | len += scnprintf(buf + len, *size - len, |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11575 | "\n device_mode: %d", adapter->device_mode); |
| 11576 | switch (adapter->device_mode) { |
| 11577 | case QDF_STA_MODE: |
| 11578 | case QDF_P2P_CLIENT_MODE: |
| 11579 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 11580 | len += scnprintf(buf + len, *size - len, |
| 11581 | "\n connState: %d", |
| 11582 | hdd_sta_ctx->conn_info.connState); |
| 11583 | break; |
| 11584 | |
| 11585 | default: |
| 11586 | break; |
| 11587 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11588 | } |
| 11589 | |
| 11590 | *size -= len; |
| 11591 | *buf_ptr += len; |
| 11592 | } |
| 11593 | |
| 11594 | /** |
| 11595 | * hdd_register_debug_callback() - registration function for hdd layer |
| 11596 | * to print hdd state information |
| 11597 | * |
| 11598 | * Return: None |
| 11599 | */ |
| 11600 | static void hdd_register_debug_callback(void) |
| 11601 | { |
| 11602 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 11603 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11604 | #else /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Wen Gong | aa6d55d | 2018-04-26 16:33:21 +0800 | [diff] [blame] | 11605 | static void hdd_register_debug_callback(void) |
| 11606 | { |
| 11607 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11608 | #endif /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11609 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 11610 | /* |
| 11611 | * wlan_init_bug_report_lock() - Initialize bug report lock |
| 11612 | * |
| 11613 | * This function is used to create bug report lock |
| 11614 | * |
| 11615 | * Return: None |
| 11616 | */ |
| 11617 | static void wlan_init_bug_report_lock(void) |
| 11618 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 11619 | struct cds_context *p_cds_context; |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 11620 | |
| 11621 | p_cds_context = cds_get_global_context(); |
| 11622 | if (!p_cds_context) { |
| 11623 | hdd_err("cds context is NULL"); |
| 11624 | return; |
| 11625 | } |
| 11626 | |
| 11627 | qdf_spinlock_create(&p_cds_context->bug_report_lock); |
| 11628 | } |
| 11629 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11630 | #ifdef CONFIG_DP_TRACE |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11631 | void hdd_dp_trace_init(struct hdd_config *config) |
| 11632 | { |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11633 | bool live_mode = DP_TRACE_CONFIG_DEFAULT_LIVE_MODE; |
| 11634 | uint8_t thresh = DP_TRACE_CONFIG_DEFAULT_THRESH; |
| 11635 | uint16_t thresh_time_limit = DP_TRACE_CONFIG_DEFAULT_THRESH_TIME_LIMIT; |
| 11636 | uint8_t verbosity = DP_TRACE_CONFIG_DEFAULT_VERBOSTY; |
| 11637 | uint8_t proto_bitmap = DP_TRACE_CONFIG_DEFAULT_BITMAP; |
| 11638 | uint8_t config_params[DP_TRACE_CONFIG_NUM_PARAMS]; |
| 11639 | uint8_t num_entries = 0; |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11640 | uint32_t bw_compute_interval; |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11641 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11642 | if (!config->enable_dp_trace) { |
| 11643 | hdd_err("dp trace is disabled from ini"); |
| 11644 | return; |
| 11645 | } |
| 11646 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11647 | hdd_string_to_u8_array(config->dp_trace_config, config_params, |
| 11648 | &num_entries, sizeof(config_params)); |
| 11649 | |
| 11650 | /* calculating, num bw timer intervals in a second (1000ms) */ |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11651 | bw_compute_interval = GET_BW_COMPUTE_INTV(config); |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 11652 | if (bw_compute_interval <= 1000 && bw_compute_interval > 0) |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11653 | thresh_time_limit = 1000 / bw_compute_interval; |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 11654 | else if (bw_compute_interval > 1000) { |
| 11655 | hdd_err("busBandwidthComputeInterval > 1000, using 1000"); |
| 11656 | thresh_time_limit = 1; |
| 11657 | } else |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11658 | hdd_err("busBandwidthComputeInterval is 0, using defaults"); |
| 11659 | |
| 11660 | switch (num_entries) { |
| 11661 | case 4: |
| 11662 | proto_bitmap = config_params[3]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11663 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11664 | case 3: |
| 11665 | verbosity = config_params[2]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11666 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11667 | case 2: |
| 11668 | thresh = config_params[1]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11669 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11670 | case 1: |
| 11671 | live_mode = config_params[0]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11672 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11673 | default: |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 11674 | hdd_debug("live_mode %u thresh %u time_limit %u verbosity %u bitmap 0x%x", |
| 11675 | live_mode, thresh, thresh_time_limit, |
| 11676 | verbosity, proto_bitmap); |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11677 | }; |
| 11678 | |
| 11679 | qdf_dp_trace_init(live_mode, thresh, thresh_time_limit, |
| 11680 | verbosity, proto_bitmap); |
| 11681 | |
| 11682 | } |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11683 | #endif |
| 11684 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11685 | #ifdef DISABLE_CHANNEL_LIST |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11686 | static QDF_STATUS wlan_hdd_cache_chann_mutex_create(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11687 | { |
| 11688 | return qdf_mutex_create(&hdd_ctx->cache_channel_lock); |
| 11689 | } |
| 11690 | #else |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11691 | static QDF_STATUS wlan_hdd_cache_chann_mutex_create(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11692 | { |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11693 | return QDF_STATUS_SUCCESS; |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11694 | } |
| 11695 | #endif |
| 11696 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11697 | static QDF_STATUS |
| 11698 | hdd_open_adapters_for_mission_mode(struct hdd_context *hdd_ctx) |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11699 | { |
| 11700 | struct hdd_adapter *adapter; |
| 11701 | enum dot11p_mode dot11p_mode; |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11702 | QDF_STATUS status; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11703 | |
| 11704 | ucfg_mlme_get_dot11p_mode(hdd_ctx->psoc, &dot11p_mode); |
| 11705 | |
| 11706 | /* Create only 802.11p interface? */ |
| 11707 | if (dot11p_mode == CFG_11P_STANDALONE) |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11708 | return hdd_open_ocb_interface(hdd_ctx); |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11709 | |
| 11710 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, "wlan%d", |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 11711 | wlan_hdd_get_intf_addr(hdd_ctx, |
| 11712 | QDF_STA_MODE), |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11713 | NET_NAME_UNKNOWN, true); |
| 11714 | if (!adapter) |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11715 | return QDF_STATUS_E_INVAL; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11716 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11717 | /* opening concurrent STA is best effort, continue on error */ |
| 11718 | hdd_open_concurrent_interface(hdd_ctx); |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11719 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11720 | status = hdd_open_p2p_interface(hdd_ctx); |
| 11721 | if (status) |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11722 | goto err_close_adapters; |
| 11723 | |
| 11724 | /* Open 802.11p Interface */ |
| 11725 | if (dot11p_mode == CFG_11P_CONCURRENT) { |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11726 | status = hdd_open_ocb_interface(hdd_ctx); |
| 11727 | if (QDF_IS_STATUS_ERROR(status)) |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11728 | goto err_close_adapters; |
| 11729 | } |
| 11730 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11731 | return QDF_STATUS_SUCCESS; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11732 | |
| 11733 | err_close_adapters: |
| 11734 | hdd_close_all_adapters(hdd_ctx, true); |
| 11735 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11736 | return status; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11737 | } |
| 11738 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11739 | static QDF_STATUS hdd_open_adapters_for_ftm_mode(struct hdd_context *hdd_ctx) |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11740 | { |
| 11741 | struct hdd_adapter *adapter; |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11742 | |
| 11743 | adapter = hdd_open_adapter(hdd_ctx, QDF_FTM_MODE, "wlan%d", |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 11744 | wlan_hdd_get_intf_addr(hdd_ctx, |
| 11745 | QDF_FTM_MODE), |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11746 | NET_NAME_UNKNOWN, true); |
| 11747 | |
| 11748 | return adapter ? QDF_STATUS_SUCCESS : QDF_STATUS_E_INVAL; |
| 11749 | } |
| 11750 | |
| 11751 | static QDF_STATUS |
| 11752 | hdd_open_adapters_for_monitor_mode(struct hdd_context *hdd_ctx) |
| 11753 | { |
| 11754 | struct hdd_adapter *adapter; |
| 11755 | |
| 11756 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 11757 | wlan_hdd_get_intf_addr(hdd_ctx, |
| 11758 | QDF_MONITOR_MODE), |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11759 | NET_NAME_UNKNOWN, true); |
| 11760 | |
| 11761 | return adapter ? QDF_STATUS_SUCCESS : QDF_STATUS_E_INVAL; |
| 11762 | } |
| 11763 | |
| 11764 | static QDF_STATUS hdd_open_adapters_for_epping_mode(struct hdd_context *hdd_ctx) |
| 11765 | { |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11766 | QDF_STATUS status; |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11767 | qdf_device_t qdf_dev; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11768 | |
| 11769 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 11770 | QDF_BUG(qdf_dev); |
| 11771 | if (!qdf_dev) |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11772 | return QDF_STATUS_E_INVAL; |
| 11773 | |
| 11774 | status = epping_open(); |
| 11775 | if (QDF_IS_STATUS_ERROR(status)) |
| 11776 | return status; |
| 11777 | |
| 11778 | if (epping_enable(qdf_dev->dev)) { |
| 11779 | status = QDF_STATUS_E_INVAL; |
| 11780 | goto epping_close; |
| 11781 | } |
| 11782 | |
| 11783 | return QDF_STATUS_SUCCESS; |
| 11784 | |
| 11785 | epping_close: |
| 11786 | epping_close(); |
| 11787 | |
| 11788 | return status; |
| 11789 | } |
| 11790 | |
| 11791 | typedef QDF_STATUS (*hdd_open_mode_handler)(struct hdd_context *hdd_ctx); |
| 11792 | |
| 11793 | static const hdd_open_mode_handler |
| 11794 | hdd_open_mode_handlers[QDF_GLOBAL_MAX_MODE] = { |
| 11795 | [QDF_GLOBAL_MISSION_MODE] = hdd_open_adapters_for_mission_mode, |
| 11796 | [QDF_GLOBAL_FTM_MODE] = hdd_open_adapters_for_ftm_mode, |
| 11797 | [QDF_GLOBAL_MONITOR_MODE] = hdd_open_adapters_for_monitor_mode, |
| 11798 | [QDF_GLOBAL_EPPING_MODE] = hdd_open_adapters_for_epping_mode, |
| 11799 | }; |
| 11800 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11801 | static QDF_STATUS hdd_open_adapters_for_mode(struct hdd_context *hdd_ctx, |
| 11802 | enum QDF_GLOBAL_MODE driver_mode) |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11803 | { |
| 11804 | QDF_STATUS status; |
| 11805 | |
| 11806 | if (driver_mode < 0 || |
| 11807 | driver_mode >= QDF_GLOBAL_MAX_MODE || |
| 11808 | !hdd_open_mode_handlers[driver_mode]) { |
| 11809 | hdd_err("Driver mode %d not supported", driver_mode); |
| 11810 | return -ENOTSUPP; |
| 11811 | } |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11812 | |
| 11813 | hdd_hold_rtnl_lock(); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11814 | status = hdd_open_mode_handlers[driver_mode](hdd_ctx); |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11815 | hdd_release_rtnl_lock(); |
| 11816 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11817 | return status; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11818 | } |
| 11819 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11820 | int hdd_wlan_startup(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11821 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11822 | QDF_STATUS status; |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11823 | int errno; |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 11824 | bool is_imps_enabled; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11825 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11826 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11827 | |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11828 | hdd_action_oui_config(hdd_ctx); |
| 11829 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 11830 | qdf_nbuf_init_replenish_timer(); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11831 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11832 | status = wlan_hdd_cache_chann_mutex_create(hdd_ctx); |
| 11833 | if (QDF_IS_STATUS_ERROR(status)) |
| 11834 | return qdf_status_to_os_return(status); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11835 | |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 11836 | #ifdef FEATURE_WLAN_CH_AVOID |
| 11837 | mutex_init(&hdd_ctx->avoid_freq_lock); |
| 11838 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11839 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 11840 | osif_request_manager_init(); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 11841 | qdf_atomic_init(&hdd_ctx->con_mode_flag); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11842 | hdd_driver_memdump_init(); |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 11843 | hdd_bus_bandwidth_init(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11844 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11845 | errno = hdd_wlan_start_modules(hdd_ctx, false); |
| 11846 | if (errno) { |
| 11847 | hdd_err("Failed to start modules; errno:%d", errno); |
| 11848 | goto memdump_deinit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11849 | } |
| 11850 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 11851 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11852 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11853 | hdd_ctx->mac_handle = cds_get_context(QDF_MODULE_ID_SME); |
| 11854 | if (!hdd_ctx->mac_handle) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11855 | hdd_err("Mac Handle is null"); |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11856 | goto stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11857 | } |
| 11858 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11859 | errno = hdd_wiphy_init(hdd_ctx); |
| 11860 | if (errno) { |
| 11861 | hdd_err("Failed to initialize wiphy; errno:%d", errno); |
| 11862 | goto stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11863 | } |
| 11864 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11865 | hdd_dp_trace_init(hdd_ctx->config); |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 11866 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 11867 | errno = hdd_initialize_mac_address(hdd_ctx); |
| 11868 | if (errno) { |
| 11869 | hdd_err("MAC initializtion failed: %d", errno); |
| 11870 | goto unregister_wiphy; |
| 11871 | } |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 11872 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11873 | errno = register_netdevice_notifier(&hdd_netdev_notifier); |
| 11874 | if (errno) { |
| 11875 | hdd_err("register_netdevice_notifier failed; errno:%d", errno); |
| 11876 | goto unregister_wiphy; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11877 | } |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 11878 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11879 | errno = register_reboot_notifier(&system_reboot_notifier); |
| 11880 | if (errno) { |
| 11881 | hdd_err("Failed to register reboot notifier; errno:%d", errno); |
| 11882 | goto unregister_netdev; |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 11883 | } |
| 11884 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 11885 | wlan_hdd_update_11n_mode(hdd_ctx->config); |
| 11886 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11887 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 11888 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 11889 | QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11890 | hdd_skip_acs_scan_timer_handler, |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11891 | hdd_ctx); |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11892 | if (QDF_IS_STATUS_ERROR(status)) |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 11893 | hdd_err("Failed to init ACS Skip timer"); |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11894 | |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 11895 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11896 | #endif |
| 11897 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 11898 | hdd_lpass_notify_wlan_version(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11899 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11900 | errno = hdd_register_notifiers(hdd_ctx); |
| 11901 | if (errno) |
| 11902 | goto unregister_reboot; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 11903 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11904 | status = wlansap_global_init(); |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11905 | if (QDF_IS_STATUS_ERROR(status)) |
| 11906 | goto unregister_notifiers; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11907 | |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 11908 | ucfg_mlme_is_imps_enabled(hdd_ctx->psoc, &is_imps_enabled); |
| 11909 | hdd_set_idle_ps_config(hdd_ctx, is_imps_enabled); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11910 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11911 | hdd_exit(); |
| 11912 | |
| 11913 | return 0; |
| 11914 | |
| 11915 | unregister_notifiers: |
| 11916 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11917 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11918 | unregister_reboot: |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 11919 | unregister_reboot_notifier(&system_reboot_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11920 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11921 | unregister_netdev: |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11922 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 11923 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11924 | unregister_wiphy: |
Rachit Kankane | 3080733 | 2018-06-27 18:39:36 +0530 | [diff] [blame] | 11925 | qdf_dp_trace_deinit(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11926 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11927 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11928 | stop_modules: |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 11929 | hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11930 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11931 | memdump_deinit: |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 11932 | hdd_bus_bandwidth_deinit(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11933 | hdd_driver_memdump_deinit(); |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 11934 | osif_request_manager_deinit(); |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11935 | qdf_nbuf_deinit_replenish_timer(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 11936 | |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 11937 | if (cds_is_fw_down()) |
| 11938 | hdd_err("Not setting the complete event as fw is down"); |
| 11939 | else |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11940 | hdd_start_complete(errno); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11941 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11942 | hdd_exit(); |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11943 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11944 | return errno; |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11945 | } |
| 11946 | |
| 11947 | QDF_STATUS hdd_psoc_create_vdevs(struct hdd_context *hdd_ctx) |
| 11948 | { |
| 11949 | enum QDF_GLOBAL_MODE driver_mode = hdd_get_conparam(); |
| 11950 | QDF_STATUS status; |
| 11951 | |
| 11952 | status = hdd_open_adapters_for_mode(hdd_ctx, driver_mode); |
| 11953 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11954 | hdd_err("Failed to create vdevs; status:%d", status); |
| 11955 | return status; |
| 11956 | } |
| 11957 | |
| 11958 | if (hdd_ctx->rps) |
| 11959 | hdd_set_rps_cpu_mask(hdd_ctx); |
| 11960 | |
| 11961 | if (driver_mode != QDF_GLOBAL_FTM_MODE) |
| 11962 | hdd_psoc_idle_timer_start(hdd_ctx); |
| 11963 | |
| 11964 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11965 | } |
| 11966 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11967 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11968 | * hdd_wlan_update_target_info() - update target type info |
| 11969 | * @hdd_ctx: HDD context |
| 11970 | * @context: hif context |
| 11971 | * |
| 11972 | * Update target info received from firmware in hdd context |
| 11973 | * Return:None |
| 11974 | */ |
| 11975 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11976 | 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] | 11977 | { |
| 11978 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 11979 | |
| 11980 | if (!tgt_info) { |
| 11981 | hdd_err("Target info is Null"); |
| 11982 | return; |
| 11983 | } |
| 11984 | |
| 11985 | hdd_ctx->target_type = tgt_info->target_type; |
| 11986 | } |
| 11987 | |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11988 | 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] | 11989 | { |
| 11990 | struct hdd_context *hdd_ctx = (struct hdd_context *)data; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11991 | int status; |
| 11992 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11993 | struct osif_request *request = NULL; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11994 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11995 | hdd_enter(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11996 | |
| 11997 | if (!rsp) { |
| 11998 | hdd_err("data is null"); |
| 11999 | return; |
| 12000 | } |
| 12001 | |
| 12002 | status = wlan_hdd_validate_context(hdd_ctx); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 12003 | if (status != 0) |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12004 | return; |
| 12005 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 12006 | request = osif_request_get(context); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 12007 | if (!request) { |
| 12008 | hdd_err("obselete request"); |
| 12009 | return; |
| 12010 | } |
| 12011 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12012 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id); |
| 12013 | if ((NULL == adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
| 12014 | hdd_err("Invalid adapter or adapter has invalid magic"); |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 12015 | osif_request_put(request); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12016 | return; |
| 12017 | } |
| 12018 | |
Alok Kumar | ce2c29a | 2018-10-12 15:44:02 +0530 | [diff] [blame] | 12019 | hdd_debug("rsp->arp_req_enqueue :%x", rsp->arp_req_enqueue); |
| 12020 | hdd_debug("rsp->arp_req_tx_success :%x", rsp->arp_req_tx_success); |
| 12021 | hdd_debug("rsp->arp_req_tx_failure :%x", rsp->arp_req_tx_failure); |
| 12022 | hdd_debug("rsp->arp_rsp_recvd :%x", rsp->arp_rsp_recvd); |
| 12023 | hdd_debug("rsp->out_of_order_arp_rsp_drop_cnt :%x", |
| 12024 | rsp->out_of_order_arp_rsp_drop_cnt); |
| 12025 | hdd_debug("rsp->dad_detected :%x", rsp->dad_detected); |
| 12026 | hdd_debug("rsp->connect_status :%x", rsp->connect_status); |
| 12027 | hdd_debug("rsp->ba_session_establishment_status :%x", |
| 12028 | rsp->ba_session_establishment_status); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12029 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12030 | 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] | 12031 | adapter->dad |= rsp->dad_detected; |
| 12032 | adapter->con_status = rsp->connect_status; |
| 12033 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12034 | /* Flag true indicates connectivity check stats present. */ |
| 12035 | if (rsp->connect_stats_present) { |
Alok Kumar | ce2c29a | 2018-10-12 15:44:02 +0530 | [diff] [blame] | 12036 | hdd_debug("rsp->tcp_ack_recvd :%x", rsp->tcp_ack_recvd); |
| 12037 | hdd_debug("rsp->icmpv4_rsp_recvd :%x", rsp->icmpv4_rsp_recvd); |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12038 | adapter->hdd_stats.hdd_tcp_stats.rx_fw_cnt = rsp->tcp_ack_recvd; |
| 12039 | adapter->hdd_stats.hdd_icmpv4_stats.rx_fw_cnt = |
| 12040 | rsp->icmpv4_rsp_recvd; |
| 12041 | } |
| 12042 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 12043 | osif_request_complete(request); |
| 12044 | osif_request_put(request); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12045 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12046 | hdd_exit(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12047 | } |
| 12048 | |
| 12049 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12050 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12051 | * @hdd_ctx: HDD context |
| 12052 | * |
| 12053 | * Register the HDD callbacks to CDS/SME. |
| 12054 | * |
| 12055 | * Return: 0 for success or Error code for failure |
| 12056 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12057 | int hdd_register_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12058 | { |
| 12059 | QDF_STATUS status; |
| 12060 | int ret = 0; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12061 | mac_handle_t mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12062 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12063 | hdd_enter(); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 12064 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 12065 | hdd_err("in ftm mode, no need to register callbacks"); |
| 12066 | return ret; |
| 12067 | } |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12068 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12069 | mac_handle = hdd_ctx->mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12070 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12071 | sme_register_oem_data_rsp_callback(mac_handle, |
| 12072 | hdd_send_oem_data_rsp_msg); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12073 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12074 | sme_register_mgmt_frame_ind_callback(mac_handle, |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 12075 | hdd_indicate_mgmt_frame); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12076 | sme_set_tsfcb(mac_handle, hdd_get_tsf_cb, hdd_ctx); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12077 | sme_stats_ext_register_callback(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12078 | wlan_hdd_cfg80211_stats_ext_callback); |
| 12079 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12080 | sme_ext_scan_register_callback(mac_handle, |
| 12081 | wlan_hdd_cfg80211_extscan_callback); |
| 12082 | sme_stats_ext2_register_callback(mac_handle, |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 12083 | wlan_hdd_cfg80211_stats_ext2_callback); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12084 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12085 | sme_set_rssi_threshold_breached_cb(mac_handle, |
| 12086 | hdd_rssi_threshold_breached); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12087 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12088 | sme_set_link_layer_stats_ind_cb(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12089 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 12090 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12091 | 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] | 12092 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12093 | sme_set_link_layer_ext_cb(mac_handle, |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 12094 | wlan_hdd_cfg80211_link_layer_stats_ext_callback); |
| 12095 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12096 | status = sme_set_lost_link_info_cb(mac_handle, |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 12097 | hdd_lost_link_info_cb); |
| 12098 | /* print error and not block the startup process */ |
| 12099 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12100 | hdd_err("set lost link info callback failed"); |
| 12101 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 12102 | ret = hdd_register_data_stall_detect_cb(); |
| 12103 | if (ret) { |
| 12104 | hdd_err("Register data stall detect detect callback failed."); |
| 12105 | return ret; |
| 12106 | } |
| 12107 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12108 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 12109 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12110 | sme_register_set_connection_info_cb(mac_handle, |
| 12111 | hdd_set_connection_in_progress, |
| 12112 | hdd_is_connection_in_progress); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 12113 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12114 | status = sme_congestion_register_callback(mac_handle, |
| 12115 | hdd_update_cca_info_cb); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 12116 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12117 | hdd_err("set congestion callback failed"); |
| 12118 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12119 | status = sme_set_bt_activity_info_cb(mac_handle, |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 12120 | hdd_bt_activity_cb); |
| 12121 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12122 | hdd_err("set bt activity info callback failed"); |
| 12123 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12124 | status = sme_register_tx_queue_cb(mac_handle, |
Varun Reddy Yeturu | 076eaa8 | 2018-01-16 12:16:14 -0800 | [diff] [blame] | 12125 | hdd_tx_queue_cb); |
| 12126 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12127 | hdd_err("Register tx queue callback failed"); |
| 12128 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12129 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12130 | |
| 12131 | return ret; |
| 12132 | } |
| 12133 | |
| 12134 | /** |
| 12135 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 12136 | * @hdd_ctx: HDD context |
| 12137 | * |
| 12138 | * De-Register the HDD callbacks to CDS/SME. |
| 12139 | * |
| 12140 | * Return: void |
| 12141 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12142 | void hdd_deregister_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12143 | { |
| 12144 | QDF_STATUS status; |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 12145 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12146 | mac_handle_t mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12147 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12148 | hdd_enter(); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 12149 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 12150 | hdd_err("in ftm mode, no need to deregister callbacks"); |
| 12151 | return; |
| 12152 | } |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12153 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12154 | mac_handle = hdd_ctx->mac_handle; |
| 12155 | sme_deregister_tx_queue_cb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12156 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12157 | sme_reset_link_layer_stats_ind_cb(mac_handle); |
| 12158 | sme_reset_rssi_threshold_breached_cb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12159 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12160 | sme_stats_ext_register_callback(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12161 | wlan_hdd_cfg80211_stats_ext_callback); |
| 12162 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12163 | status = sme_reset_tsfcb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12164 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12165 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 12166 | status); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12167 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 12168 | ret = hdd_deregister_data_stall_detect_cb(); |
| 12169 | if (ret) |
| 12170 | hdd_err("Failed to de-register data stall detect event callback"); |
| 12171 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12172 | sme_deregister_oem_data_rsp_callback(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12173 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12174 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12175 | } |
| 12176 | |
| 12177 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12178 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
| 12179 | * @adapter: Pointer to the HDD |
| 12180 | * @enable: bool value |
| 12181 | * |
| 12182 | * This to take counter measure to handle deauth req from HDD |
| 12183 | * |
| 12184 | * Return: None |
| 12185 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12186 | QDF_STATUS hdd_softap_sta_deauth(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 12187 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12188 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12189 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12190 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12191 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12192 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12193 | /* Ignore request to deauth bcmc station */ |
| 12194 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12195 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12196 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12197 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12198 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 12199 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12200 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12201 | hdd_exit(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12202 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12203 | } |
| 12204 | |
| 12205 | /** |
| 12206 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
| 12207 | * @adapter: Pointer to the HDD |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 12208 | * @p_del_sta_params: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12209 | * |
| 12210 | * This to take counter measure to handle deauth req from HDD |
| 12211 | * |
| 12212 | * Return: None |
| 12213 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12214 | void hdd_softap_sta_disassoc(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 12215 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12216 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12217 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12218 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12219 | /* Ignore request to disassoc bcmc station */ |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 12220 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12221 | return; |
| 12222 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12223 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 12224 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12225 | } |
| 12226 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12227 | void wlan_hdd_disable_roaming(struct hdd_adapter *cur_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12228 | { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12229 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(cur_adapter); |
| 12230 | struct hdd_adapter *adapter = NULL; |
| 12231 | struct csr_roam_profile *roam_profile; |
| 12232 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12233 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12234 | if (!policy_mgr_is_sta_active_connection_exists(hdd_ctx->psoc)) { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12235 | hdd_debug("No active sta session"); |
| 12236 | return; |
| 12237 | } |
| 12238 | |
| 12239 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12240 | roam_profile = hdd_roam_profile(adapter); |
| 12241 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 12242 | |
| 12243 | if (cur_adapter->session_id != adapter->session_id && |
| 12244 | adapter->device_mode == QDF_STA_MODE && |
| 12245 | hdd_conn_is_connected(sta_ctx)) { |
| 12246 | hdd_debug("%d Disable roaming", adapter->session_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12247 | sme_stop_roaming(hdd_ctx->mac_handle, |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12248 | adapter->session_id, |
| 12249 | ecsr_driver_disabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12250 | } |
| 12251 | } |
| 12252 | } |
| 12253 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12254 | void wlan_hdd_enable_roaming(struct hdd_adapter *cur_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12255 | { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12256 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(cur_adapter); |
| 12257 | struct hdd_adapter *adapter = NULL; |
| 12258 | struct csr_roam_profile *roam_profile; |
| 12259 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12260 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12261 | if (!policy_mgr_is_sta_active_connection_exists(hdd_ctx->psoc)) { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12262 | hdd_debug("No active sta session"); |
| 12263 | return; |
| 12264 | } |
| 12265 | |
| 12266 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12267 | roam_profile = hdd_roam_profile(adapter); |
| 12268 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 12269 | |
| 12270 | if (cur_adapter->session_id != adapter->session_id && |
| 12271 | adapter->device_mode == QDF_STA_MODE && |
| 12272 | hdd_conn_is_connected(sta_ctx)) { |
| 12273 | hdd_debug("%d Enable roaming", adapter->session_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12274 | sme_start_roaming(hdd_ctx->mac_handle, |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12275 | adapter->session_id, |
| 12276 | REASON_DRIVER_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12277 | } |
| 12278 | } |
| 12279 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12280 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 12281 | /** |
| 12282 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 12283 | * @skb: sk buffer pointer |
| 12284 | * |
| 12285 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 12286 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 12287 | * |
| 12288 | * Return: None |
| 12289 | */ |
| 12290 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 12291 | { |
| 12292 | #ifdef CNSS_GENL |
| 12293 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 12294 | #else |
| 12295 | nl_srv_bcast(skb); |
| 12296 | #endif |
| 12297 | } |
| 12298 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12299 | 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] | 12300 | { |
| 12301 | struct sk_buff *skb; |
| 12302 | struct nlmsghdr *nlh; |
| 12303 | tAniMsgHdr *ani_hdr; |
| 12304 | void *nl_data = NULL; |
| 12305 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12306 | struct radio_index_tlv *radio_info; |
| 12307 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12308 | |
| 12309 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 12310 | flags = GFP_ATOMIC; |
| 12311 | |
| 12312 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 12313 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12314 | if (skb == NULL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12315 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12316 | |
| 12317 | nlh = (struct nlmsghdr *)skb->data; |
| 12318 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 12319 | nlh->nlmsg_flags = 0; |
| 12320 | nlh->nlmsg_seq = 0; |
| 12321 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 12322 | |
| 12323 | ani_hdr = NLMSG_DATA(nlh); |
| 12324 | ani_hdr->type = type; |
| 12325 | |
| 12326 | switch (type) { |
| 12327 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 12328 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12329 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12330 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 12331 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12332 | ani_hdr->length = 0; |
| 12333 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12334 | break; |
| 12335 | case WLAN_SVC_WLAN_STATUS_IND: |
| 12336 | case WLAN_SVC_WLAN_VERSION_IND: |
| 12337 | case WLAN_SVC_DFS_CAC_START_IND: |
| 12338 | case WLAN_SVC_DFS_CAC_END_IND: |
| 12339 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 12340 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 12341 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 12342 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 12343 | case WLAN_SVC_RPS_ENABLE_IND: |
Orhan K AKYILDIZ | e7445a2 | 2017-01-19 21:21:47 -0800 | [diff] [blame] | 12344 | case WLAN_SVC_CORE_MINFREQ: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12345 | ani_hdr->length = len; |
| 12346 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 12347 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 12348 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12349 | break; |
| 12350 | |
| 12351 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 12352 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12353 | type); |
| 12354 | kfree_skb(skb); |
| 12355 | return; |
| 12356 | } |
| 12357 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12358 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 12359 | * Add radio index at the end of the svc event in TLV format |
| 12360 | * to maintain the backward compatibility with userspace |
| 12361 | * applications. |
| 12362 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12363 | |
| 12364 | tlv_len = 0; |
| 12365 | |
| 12366 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 12367 | < WLAN_NL_MAX_PAYLOAD) { |
| 12368 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 12369 | sizeof(*ani_hdr) + len); |
| 12370 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 12371 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 12372 | radio_info->radio = radio; |
| 12373 | tlv_len = sizeof(*radio_info); |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 12374 | hdd_debug("Added radio index tlv - radio index %d", |
| 12375 | radio_info->radio); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12376 | } |
| 12377 | |
| 12378 | nlh->nlmsg_len += tlv_len; |
| 12379 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 12380 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 12381 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12382 | } |
| 12383 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12384 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 12385 | void wlan_hdd_auto_shutdown_cb(void) |
| 12386 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12387 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12388 | |
| 12389 | if (!hdd_ctx) |
| 12390 | return; |
| 12391 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12392 | hdd_debug("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12393 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 12394 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12395 | } |
| 12396 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12397 | 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] | 12398 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12399 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12400 | bool ap_connected = false, sta_connected = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12401 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12402 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12403 | mac_handle = hdd_ctx->mac_handle; |
| 12404 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12405 | return; |
| 12406 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 12407 | if (hdd_ctx->config->wlan_auto_shutdown == 0) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12408 | return; |
| 12409 | |
| 12410 | if (enable == false) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12411 | if (sme_set_auto_shutdown_timer(mac_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12412 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12413 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12414 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12415 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 12416 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12417 | return; |
| 12418 | } |
| 12419 | |
| 12420 | /* To enable shutdown timer check conncurrency */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12421 | if (policy_mgr_concurrent_open_sessions_running(hdd_ctx->psoc)) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12422 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12423 | if (adapter->device_mode == QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12424 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 12425 | conn_info.connState == |
| 12426 | eConnectionState_Associated) { |
| 12427 | sta_connected = true; |
| 12428 | break; |
| 12429 | } |
| 12430 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12431 | |
| 12432 | if (adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12433 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 12434 | ap_active == true) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12435 | ap_connected = true; |
| 12436 | break; |
| 12437 | } |
| 12438 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12439 | } |
| 12440 | } |
| 12441 | |
| 12442 | if (ap_connected == true || sta_connected == true) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12443 | hdd_debug("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12444 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12445 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 12446 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12447 | if (sme_set_auto_shutdown_timer(mac_handle, |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 12448 | hdd_ctx->config->wlan_auto_shutdown) |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 12449 | != QDF_STATUS_SUCCESS) |
| 12450 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 12451 | else |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 12452 | hdd_info("Auto Shutdown timer for %d seconds enabled", |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 12453 | hdd_ctx->config->wlan_auto_shutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12454 | } |
| 12455 | #endif |
| 12456 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 12457 | struct hdd_adapter * |
| 12458 | hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, |
| 12459 | bool check_start_bss) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12460 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12461 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12462 | struct hdd_adapter *adapter, *con_sap_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12463 | |
| 12464 | con_sap_adapter = NULL; |
| 12465 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12466 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 12467 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 12468 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12469 | adapter != this_sap_adapter) { |
| 12470 | if (check_start_bss) { |
| 12471 | if (test_bit(SOFTAP_BSS_STARTED, |
| 12472 | &adapter->event_flags)) { |
| 12473 | con_sap_adapter = adapter; |
| 12474 | break; |
| 12475 | } |
| 12476 | } else { |
| 12477 | con_sap_adapter = adapter; |
| 12478 | break; |
| 12479 | } |
| 12480 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12481 | } |
| 12482 | |
| 12483 | return con_sap_adapter; |
| 12484 | } |
| 12485 | |
| 12486 | #ifdef MSM_PLATFORM |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12487 | static inline bool hdd_adapter_is_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12488 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12489 | return adapter->device_mode == QDF_STA_MODE || |
| 12490 | adapter->device_mode == QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12491 | } |
| 12492 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12493 | static inline bool hdd_adapter_is_ap(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12494 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12495 | return adapter->device_mode == QDF_SAP_MODE || |
| 12496 | adapter->device_mode == QDF_P2P_GO_MODE; |
| 12497 | } |
| 12498 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12499 | static bool hdd_any_adapter_is_assoc(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12500 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12501 | struct hdd_adapter *adapter; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12502 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12503 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12504 | if (hdd_adapter_is_sta(adapter) && |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12505 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 12506 | conn_info.connState == eConnectionState_Associated) { |
| 12507 | return true; |
| 12508 | } |
| 12509 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12510 | if (hdd_adapter_is_ap(adapter) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 12511 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12512 | return true; |
| 12513 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12514 | } |
| 12515 | |
| 12516 | return false; |
| 12517 | } |
| 12518 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12519 | 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] | 12520 | { |
| 12521 | bool is_running; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12522 | |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 12523 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12524 | is_running = hdd_ctx->bus_bw_timer_running; |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 12525 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12526 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12527 | return is_running; |
| 12528 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12529 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12530 | 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] | 12531 | { |
| 12532 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 12533 | hdd_ctx->bus_bw_timer_running = true; |
| 12534 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 12535 | hdd_ctx->config->bus_bw_compute_interval); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12536 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 12537 | } |
| 12538 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12539 | void hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12540 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12541 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12542 | |
| 12543 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 12544 | hdd_debug("Bandwidth compute timer already started"); |
| 12545 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12546 | } |
| 12547 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12548 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 12549 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12550 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12551 | } |
| 12552 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12553 | 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] | 12554 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12555 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12556 | |
| 12557 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 12558 | hdd_debug("Bandwidth compute timer already started"); |
| 12559 | return; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 12560 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12561 | |
| 12562 | if (hdd_any_adapter_is_assoc(hdd_ctx)) |
| 12563 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 12564 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12565 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12566 | } |
| 12567 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12568 | 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] | 12569 | { |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 12570 | ucfg_ipa_set_perf_level(hdd_ctx->pdev, 0, 0); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12571 | |
| 12572 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12573 | hdd_ctx->bus_bw_timer_running = false; |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 12574 | qdf_timer_sync_cancel(&hdd_ctx->bus_bw_timer); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12575 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 12576 | |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 12577 | /* work callback is long running; flush outside of lock */ |
| 12578 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12579 | hdd_reset_tcp_delack(hdd_ctx); |
| 12580 | } |
| 12581 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12582 | void hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12583 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12584 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12585 | |
| 12586 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 12587 | hdd_debug("Bandwidth compute timer already stopped"); |
| 12588 | return; |
| 12589 | } |
| 12590 | |
| 12591 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 12592 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12593 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12594 | } |
| 12595 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12596 | 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] | 12597 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12598 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12599 | |
| 12600 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 12601 | hdd_debug("Bandwidth compute timer already stopped"); |
| 12602 | return; |
| 12603 | } |
| 12604 | |
| 12605 | if (!hdd_any_adapter_is_assoc(hdd_ctx)) |
| 12606 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 12607 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12608 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12609 | } |
| 12610 | #endif |
| 12611 | |
| 12612 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12613 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 12614 | * @ap_adapter: SAP adapter |
| 12615 | * |
| 12616 | * This function will process the stopping of sap adapter. |
| 12617 | * |
| 12618 | * Return: None |
| 12619 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12620 | void wlan_hdd_stop_sap(struct hdd_adapter *ap_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12621 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12622 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 12623 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12624 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12625 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12626 | |
| 12627 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12628 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12629 | return; |
| 12630 | } |
| 12631 | |
| 12632 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 12633 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 12634 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12635 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 12636 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12637 | mutex_lock(&hdd_ctx->sap_lock); |
| 12638 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 12639 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12640 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12641 | hdd_debug("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 12642 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12643 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 12644 | sap_context)) { |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 12645 | qdf_status = qdf_wait_for_event_completion(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 12646 | qdf_stop_bss_event, |
Vignesh Viswanathan | 865daaa | 2018-10-11 19:30:44 +0530 | [diff] [blame] | 12647 | SME_CMD_START_STOP_BSS_TIMEOUT); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12648 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12649 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12650 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12651 | return; |
| 12652 | } |
| 12653 | } |
| 12654 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12655 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12656 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12657 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 12658 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12659 | false); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12660 | hdd_debug("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12661 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12662 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12663 | } |
| 12664 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12665 | } |
| 12666 | |
| 12667 | /** |
| 12668 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 12669 | * @ap_adapter: SAP adapter |
| 12670 | * |
| 12671 | * This function will process the starting of sap adapter. |
| 12672 | * |
| 12673 | * Return: None |
| 12674 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12675 | void wlan_hdd_start_sap(struct hdd_adapter *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12676 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12677 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 12678 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12679 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12680 | struct hdd_context *hdd_ctx; |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 12681 | tsap_config_t *sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12682 | |
| 12683 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12684 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12685 | return; |
| 12686 | } |
| 12687 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 12688 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 12689 | hdd_err("SoftAp role has not been enabled"); |
| 12690 | return; |
| 12691 | } |
| 12692 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12693 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 12694 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 12695 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 12696 | sap_config = &ap_adapter->session.ap.sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12697 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12698 | mutex_lock(&hdd_ctx->sap_lock); |
| 12699 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 12700 | goto end; |
| 12701 | |
| 12702 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12703 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12704 | goto end; |
| 12705 | } |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 12706 | wlan_reg_set_channel_params(hdd_ctx->pdev, |
Abhinav Kumar | 6f69448 | 2018-09-04 16:07:39 +0530 | [diff] [blame] | 12707 | hdd_ap_ctx->sap_config.channel, 0, |
| 12708 | &hdd_ap_ctx->sap_config.ch_params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12709 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 12710 | qdf_event_reset(&hostapd_state->qdf_event); |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 12711 | 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] | 12712 | &hdd_ap_ctx->sap_config, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12713 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12714 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12715 | goto end; |
| 12716 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12717 | hdd_debug("Waiting for SAP to start"); |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 12718 | qdf_status = qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Vignesh Viswanathan | 865daaa | 2018-10-11 19:30:44 +0530 | [diff] [blame] | 12719 | SME_CMD_START_STOP_BSS_TIMEOUT); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12720 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12721 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12722 | goto end; |
| 12723 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12724 | hdd_info("SAP Start Success"); |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 12725 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12726 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12727 | if (hostapd_state->bss_state == BSS_START) { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12728 | policy_mgr_incr_active_session(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12729 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12730 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 12731 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12732 | true); |
| 12733 | } |
Sourav Mohapatra | 9bc6711 | 2017-11-08 09:36:11 +0530 | [diff] [blame] | 12734 | mutex_unlock(&hdd_ctx->sap_lock); |
| 12735 | |
| 12736 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12737 | end: |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 12738 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12739 | mutex_unlock(&hdd_ctx->sap_lock); |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 12740 | /* SAP context and beacon cleanup will happen during driver unload |
| 12741 | * in hdd_stop_adapter |
| 12742 | */ |
| 12743 | hdd_err("SAP restart after SSR failed! Reload WLAN and try SAP again"); |
| 12744 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12745 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12746 | |
| 12747 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12748 | * hdd_get_fw_version() - Get FW version |
| 12749 | * @hdd_ctx: pointer to HDD context. |
| 12750 | * @major_spid: FW version - major spid. |
| 12751 | * @minor_spid: FW version - minor spid |
| 12752 | * @ssid: FW version - ssid |
| 12753 | * @crmid: FW version - crmid |
| 12754 | * |
| 12755 | * This function is called to get the firmware build version stored |
| 12756 | * as part of the HDD context |
| 12757 | * |
| 12758 | * Return: None |
| 12759 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12760 | void hdd_get_fw_version(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12761 | uint32_t *major_spid, uint32_t *minor_spid, |
| 12762 | uint32_t *siid, uint32_t *crmid) |
| 12763 | { |
| 12764 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 12765 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 12766 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 12767 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 12768 | } |
| 12769 | |
| 12770 | #ifdef QCA_CONFIG_SMP |
| 12771 | /** |
| 12772 | * wlan_hdd_get_cpu() - get cpu_index |
| 12773 | * |
| 12774 | * Return: cpu_index |
| 12775 | */ |
| 12776 | int wlan_hdd_get_cpu(void) |
| 12777 | { |
| 12778 | int cpu_index = get_cpu(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12779 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12780 | put_cpu(); |
| 12781 | return cpu_index; |
| 12782 | } |
| 12783 | #endif |
| 12784 | |
| 12785 | /** |
| 12786 | * hdd_get_fwpath() - get framework path |
| 12787 | * |
| 12788 | * This function is used to get the string written by |
| 12789 | * userspace to start the wlan driver |
| 12790 | * |
| 12791 | * Return: string |
| 12792 | */ |
| 12793 | const char *hdd_get_fwpath(void) |
| 12794 | { |
| 12795 | return fwpath.string; |
| 12796 | } |
| 12797 | |
Dustin Brown | 94ce20f | 2018-09-04 13:11:38 -0700 | [diff] [blame] | 12798 | static inline int hdd_state_query_cb(void) |
| 12799 | { |
| 12800 | return !!wlan_hdd_validate_context(cds_get_context(QDF_MODULE_ID_HDD)); |
| 12801 | } |
| 12802 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12803 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12804 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12805 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12806 | * This function initilizes CDS global context with the help of cds_init. This |
| 12807 | * has to be the first function called after probe to get a valid global |
| 12808 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12809 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12810 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12811 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12812 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12813 | { |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 12814 | QDF_STATUS status; |
Dustin Brown | fe50cef | 2018-12-10 10:42:37 -0800 | [diff] [blame] | 12815 | int ret; |
| 12816 | |
| 12817 | hdd_dsc_init(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12818 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 12819 | status = cds_init(); |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 12820 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12821 | hdd_err("Failed to allocate CDS context"); |
| 12822 | ret = -ENOMEM; |
Dustin Brown | fe50cef | 2018-12-10 10:42:37 -0800 | [diff] [blame] | 12823 | goto deinit_dsc; |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 12824 | } |
Dustin Brown | 94ce20f | 2018-09-04 13:11:38 -0700 | [diff] [blame] | 12825 | qdf_register_module_state_query_callback(hdd_state_query_cb); |
Hanumanth Reddy Pothula | 788a37e | 2017-08-17 18:40:11 +0530 | [diff] [blame] | 12826 | |
| 12827 | wlan_init_bug_report_lock(); |
| 12828 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12829 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12830 | wlan_logging_sock_init_svc(); |
| 12831 | #endif |
| 12832 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 12833 | qdf_timer_init(NULL, &hdd_drv_ops_inactivity_timer, |
| 12834 | (void *)hdd_drv_ops_inactivity_handler, NULL, |
| 12835 | QDF_TIMER_TYPE_SW); |
| 12836 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12837 | hdd_trace_init(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 12838 | hdd_register_debug_callback(); |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12839 | wlan_roam_debug_init(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12840 | |
Dustin Brown | fe50cef | 2018-12-10 10:42:37 -0800 | [diff] [blame] | 12841 | return 0; |
| 12842 | |
| 12843 | deinit_dsc: |
| 12844 | hdd_dsc_deinit(); |
| 12845 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12846 | return ret; |
| 12847 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12848 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12849 | /** |
| 12850 | * hdd_deinit() - Deinitialize Driver |
| 12851 | * |
| 12852 | * This function frees CDS global context with the help of cds_deinit. This |
| 12853 | * has to be the last function call in remove callback to free the global |
| 12854 | * context. |
| 12855 | */ |
| 12856 | void hdd_deinit(void) |
| 12857 | { |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12858 | wlan_roam_debug_deinit(); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 12859 | qdf_timer_free(&hdd_drv_ops_inactivity_timer); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12860 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12861 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12862 | wlan_logging_sock_deinit_svc(); |
| 12863 | #endif |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12864 | |
| 12865 | wlan_destroy_bug_report_lock(); |
| 12866 | cds_deinit(); |
Dustin Brown | fe50cef | 2018-12-10 10:42:37 -0800 | [diff] [blame] | 12867 | |
| 12868 | hdd_dsc_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12869 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12870 | |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 12871 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 12872 | #define HDD_WLAN_START_WAIT_TIME ((CDS_WMA_TIMEOUT + 5000) * 100) |
| 12873 | #else |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12874 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 12875 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12876 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12877 | static int wlan_hdd_state_ctrl_param_open(struct inode *inode, |
| 12878 | struct file *file) |
| 12879 | { |
| 12880 | return 0; |
| 12881 | } |
| 12882 | |
| 12883 | static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, |
| 12884 | const char __user *user_buf, |
| 12885 | size_t count, |
| 12886 | loff_t *f_pos) |
| 12887 | { |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12888 | char buf[3]; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12889 | static const char wlan_off_str[] = "OFF"; |
| 12890 | static const char wlan_on_str[] = "ON"; |
| 12891 | int ret; |
| 12892 | unsigned long rc; |
| 12893 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12894 | if (copy_from_user(buf, user_buf, 3)) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12895 | pr_err("Failed to read buffer\n"); |
| 12896 | return -EINVAL; |
| 12897 | } |
| 12898 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12899 | if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12900 | pr_debug("Wifi turning off from UI\n"); |
| 12901 | goto exit; |
| 12902 | } |
| 12903 | |
Srinivas Girigowda | d241288 | 2018-09-07 15:42:04 -0700 | [diff] [blame] | 12904 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) == 0) |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 12905 | pr_info("Wifi Turning On from UI\n"); |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 12906 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12907 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12908 | pr_err("Invalid value received from framework"); |
| 12909 | goto exit; |
| 12910 | } |
| 12911 | |
| 12912 | if (!cds_is_driver_loaded()) { |
Sachin Ahuja | ee62b54 | 2017-04-21 14:14:16 +0530 | [diff] [blame] | 12913 | init_completion(&wlan_start_comp); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12914 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 12915 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 12916 | if (!rc) { |
Srinivas Girigowda | 09625b0 | 2018-09-10 15:28:09 -0700 | [diff] [blame] | 12917 | hdd_alert("Timed-out!!"); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12918 | ret = -EINVAL; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12919 | return ret; |
| 12920 | } |
| 12921 | |
| 12922 | hdd_start_complete(0); |
| 12923 | } |
| 12924 | |
| 12925 | exit: |
| 12926 | return count; |
| 12927 | } |
| 12928 | |
| 12929 | |
| 12930 | const struct file_operations wlan_hdd_state_fops = { |
| 12931 | .owner = THIS_MODULE, |
| 12932 | .open = wlan_hdd_state_ctrl_param_open, |
| 12933 | .write = wlan_hdd_state_ctrl_param_write, |
| 12934 | }; |
| 12935 | |
| 12936 | static int wlan_hdd_state_ctrl_param_create(void) |
| 12937 | { |
| 12938 | unsigned int wlan_hdd_state_major = 0; |
| 12939 | int ret; |
| 12940 | struct device *dev; |
| 12941 | |
| 12942 | device = MKDEV(wlan_hdd_state_major, 0); |
| 12943 | |
| 12944 | ret = alloc_chrdev_region(&device, 0, dev_num, "qcwlanstate"); |
| 12945 | if (ret) { |
| 12946 | pr_err("Failed to register qcwlanstate"); |
| 12947 | goto dev_alloc_err; |
| 12948 | } |
| 12949 | wlan_hdd_state_major = MAJOR(device); |
| 12950 | |
| 12951 | class = class_create(THIS_MODULE, WLAN_MODULE_NAME); |
| 12952 | if (IS_ERR(class)) { |
| 12953 | pr_err("wlan_hdd_state class_create error"); |
| 12954 | goto class_err; |
| 12955 | } |
| 12956 | |
| 12957 | dev = device_create(class, NULL, device, NULL, WLAN_MODULE_NAME); |
| 12958 | if (IS_ERR(dev)) { |
| 12959 | pr_err("wlan_hdd_statedevice_create error"); |
| 12960 | goto err_class_destroy; |
| 12961 | } |
| 12962 | |
| 12963 | cdev_init(&wlan_hdd_state_cdev, &wlan_hdd_state_fops); |
| 12964 | ret = cdev_add(&wlan_hdd_state_cdev, device, dev_num); |
| 12965 | if (ret) { |
| 12966 | pr_err("Failed to add cdev error"); |
| 12967 | goto cdev_add_err; |
| 12968 | } |
| 12969 | |
| 12970 | pr_info("wlan_hdd_state %s major(%d) initialized", |
| 12971 | WLAN_MODULE_NAME, wlan_hdd_state_major); |
| 12972 | |
| 12973 | return 0; |
| 12974 | |
| 12975 | cdev_add_err: |
| 12976 | device_destroy(class, device); |
| 12977 | err_class_destroy: |
| 12978 | class_destroy(class); |
| 12979 | class_err: |
| 12980 | unregister_chrdev_region(device, dev_num); |
| 12981 | dev_alloc_err: |
| 12982 | return -ENODEV; |
| 12983 | } |
| 12984 | |
| 12985 | static void wlan_hdd_state_ctrl_param_destroy(void) |
| 12986 | { |
| 12987 | cdev_del(&wlan_hdd_state_cdev); |
| 12988 | device_destroy(class, device); |
| 12989 | class_destroy(class); |
| 12990 | unregister_chrdev_region(device, dev_num); |
| 12991 | |
| 12992 | pr_info("Device node unregistered"); |
| 12993 | } |
| 12994 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12995 | /** |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 12996 | * hdd_component_init() - Initialize all components |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12997 | * |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 12998 | * Return: QDF_STATUS |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12999 | */ |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13000 | static QDF_STATUS hdd_component_init(void) |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13001 | { |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13002 | QDF_STATUS status; |
| 13003 | |
| 13004 | /* initialize converged components */ |
Arif Hussain | 4969811 | 2018-07-31 00:32:50 -0700 | [diff] [blame] | 13005 | status = target_if_init(wma_get_psoc_from_scn_handle); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13006 | if (QDF_IS_STATUS_ERROR(status)) |
| 13007 | return status; |
| 13008 | |
Arif Hussain | 4969811 | 2018-07-31 00:32:50 -0700 | [diff] [blame] | 13009 | status = dispatcher_init(); |
| 13010 | if (QDF_IS_STATUS_ERROR(status)) |
| 13011 | goto target_if_deinit; |
| 13012 | |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13013 | /* initialize non-converged components */ |
| 13014 | status = ucfg_mlme_init(); |
| 13015 | if (QDF_IS_STATUS_ERROR(status)) |
| 13016 | goto dispatcher_deinit; |
| 13017 | |
| 13018 | status = ucfg_fwol_init(); |
| 13019 | if (QDF_IS_STATUS_ERROR(status)) |
| 13020 | goto mlme_deinit; |
| 13021 | |
| 13022 | status = disa_init(); |
| 13023 | if (QDF_IS_STATUS_ERROR(status)) |
| 13024 | goto fwol_deinit; |
| 13025 | |
| 13026 | status = pmo_init(); |
| 13027 | if (QDF_IS_STATUS_ERROR(status)) |
| 13028 | goto disa_deinit; |
| 13029 | |
| 13030 | status = ucfg_ocb_init(); |
| 13031 | if (QDF_IS_STATUS_ERROR(status)) |
| 13032 | goto pmo_deinit; |
| 13033 | |
| 13034 | status = ipa_init(); |
| 13035 | if (QDF_IS_STATUS_ERROR(status)) |
| 13036 | goto ocb_deinit; |
| 13037 | |
| 13038 | status = ucfg_action_oui_init(); |
| 13039 | if (QDF_IS_STATUS_ERROR(status)) |
| 13040 | goto ipa_deinit; |
| 13041 | |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13042 | status = nan_init(); |
| 13043 | if (QDF_IS_STATUS_ERROR(status)) |
| 13044 | goto action_oui_deinit; |
| 13045 | |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13046 | status = ucfg_p2p_init(); |
| 13047 | if (QDF_IS_STATUS_ERROR(status)) |
| 13048 | goto nan_deinit; |
| 13049 | |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13050 | status = policy_mgr_init(); |
| 13051 | if (QDF_IS_STATUS_ERROR(status)) |
| 13052 | goto p2p_deinit; |
| 13053 | |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13054 | status = ucfg_tdls_init(); |
| 13055 | if (QDF_IS_STATUS_ERROR(status)) |
| 13056 | goto policy_deinit; |
| 13057 | |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13058 | return QDF_STATUS_SUCCESS; |
| 13059 | |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13060 | policy_deinit: |
| 13061 | policy_mgr_deinit(); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13062 | p2p_deinit: |
| 13063 | ucfg_p2p_deinit(); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13064 | nan_deinit: |
| 13065 | nan_deinit(); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13066 | action_oui_deinit: |
| 13067 | ucfg_action_oui_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13068 | ipa_deinit: |
| 13069 | ipa_deinit(); |
| 13070 | ocb_deinit: |
| 13071 | ucfg_ocb_deinit(); |
| 13072 | pmo_deinit: |
| 13073 | pmo_deinit(); |
| 13074 | disa_deinit: |
| 13075 | disa_deinit(); |
| 13076 | fwol_deinit: |
| 13077 | ucfg_fwol_deinit(); |
| 13078 | mlme_deinit: |
| 13079 | ucfg_mlme_deinit(); |
| 13080 | dispatcher_deinit: |
| 13081 | dispatcher_deinit(); |
Arif Hussain | 4969811 | 2018-07-31 00:32:50 -0700 | [diff] [blame] | 13082 | target_if_deinit: |
| 13083 | target_if_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13084 | |
| 13085 | return status; |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13086 | } |
| 13087 | |
| 13088 | /** |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13089 | * hdd_component_deinit() - Deinitialize all components |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13090 | * |
| 13091 | * Return: None |
| 13092 | */ |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13093 | static void hdd_component_deinit(void) |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13094 | { |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13095 | /* deinitialize non-converged components */ |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13096 | ucfg_tdls_deinit(); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13097 | policy_mgr_deinit(); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13098 | ucfg_p2p_deinit(); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13099 | nan_deinit(); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 13100 | ucfg_action_oui_deinit(); |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 13101 | ipa_deinit(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 13102 | ucfg_ocb_deinit(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13103 | pmo_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13104 | disa_deinit(); |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13105 | ucfg_fwol_deinit(); |
Vignesh Viswanathan | a0921c4 | 2018-09-04 19:03:35 +0530 | [diff] [blame] | 13106 | ucfg_mlme_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13107 | |
| 13108 | /* deinitialize converged components */ |
| 13109 | dispatcher_deinit(); |
Arif Hussain | 4969811 | 2018-07-31 00:32:50 -0700 | [diff] [blame] | 13110 | target_if_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13111 | } |
| 13112 | |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13113 | QDF_STATUS hdd_component_psoc_open(struct wlan_objmgr_psoc *psoc) |
| 13114 | { |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13115 | QDF_STATUS status; |
| 13116 | |
| 13117 | status = ucfg_mlme_psoc_open(psoc); |
| 13118 | if (QDF_IS_STATUS_ERROR(status)) |
| 13119 | return status; |
| 13120 | |
| 13121 | status = ucfg_fwol_psoc_open(psoc); |
| 13122 | if (QDF_IS_STATUS_ERROR(status)) |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13123 | goto err_fwol; |
| 13124 | |
| 13125 | status = ucfg_pmo_psoc_open(psoc); |
| 13126 | if (QDF_IS_STATUS_ERROR(status)) |
| 13127 | goto err_pmo; |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13128 | |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13129 | status = ucfg_policy_mgr_psoc_open(psoc); |
| 13130 | if (QDF_IS_STATUS_ERROR(status)) |
| 13131 | goto err_plcy_mgr; |
| 13132 | |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13133 | status = ucfg_p2p_psoc_open(psoc); |
| 13134 | if (QDF_IS_STATUS_ERROR(status)) |
| 13135 | goto err_p2p; |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13136 | |
| 13137 | status = ucfg_tdls_psoc_open(psoc); |
| 13138 | if (QDF_IS_STATUS_ERROR(status)) |
| 13139 | goto err_tdls; |
| 13140 | |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13141 | return status; |
| 13142 | |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13143 | err_tdls: |
| 13144 | ucfg_tdls_psoc_close(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13145 | err_p2p: |
| 13146 | ucfg_p2p_psoc_close(psoc); |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13147 | err_plcy_mgr: |
| 13148 | ucfg_pmo_psoc_close(psoc); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13149 | err_pmo: |
| 13150 | ucfg_fwol_psoc_close(psoc); |
| 13151 | err_fwol: |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13152 | ucfg_mlme_psoc_close(psoc); |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13153 | |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13154 | return status; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13155 | } |
| 13156 | |
| 13157 | void hdd_component_psoc_close(struct wlan_objmgr_psoc *psoc) |
| 13158 | { |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13159 | ucfg_tdls_psoc_close(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13160 | ucfg_p2p_psoc_close(psoc); |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13161 | ucfg_policy_mgr_psoc_close(psoc); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13162 | ucfg_pmo_psoc_close(psoc); |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13163 | ucfg_fwol_psoc_close(psoc); |
Vignesh Viswanathan | a0921c4 | 2018-09-04 19:03:35 +0530 | [diff] [blame] | 13164 | ucfg_mlme_psoc_close(psoc); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13165 | } |
| 13166 | |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13167 | void hdd_component_psoc_enable(struct wlan_objmgr_psoc *psoc) |
| 13168 | { |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 13169 | ocb_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13170 | disa_psoc_enable(psoc); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13171 | nan_psoc_enable(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13172 | p2p_psoc_enable(psoc); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13173 | policy_mgr_psoc_enable(psoc); |
Wu Gao | a67c380 | 2018-12-27 12:07:52 +0800 | [diff] [blame] | 13174 | ucfg_tdls_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13175 | } |
| 13176 | |
| 13177 | void hdd_component_psoc_disable(struct wlan_objmgr_psoc *psoc) |
| 13178 | { |
Wu Gao | a67c380 | 2018-12-27 12:07:52 +0800 | [diff] [blame] | 13179 | ucfg_tdls_psoc_disable(psoc); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13180 | policy_mgr_psoc_disable(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13181 | p2p_psoc_disable(psoc); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13182 | nan_psoc_disable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13183 | disa_psoc_disable(psoc); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 13184 | ocb_psoc_disable(psoc); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13185 | } |
| 13186 | |
Sandeep Puligilla | b7beb47 | 2018-08-13 22:54:20 -0700 | [diff] [blame] | 13187 | QDF_STATUS hdd_component_pdev_open(struct wlan_objmgr_pdev *pdev) |
| 13188 | { |
| 13189 | return ucfg_mlme_pdev_open(pdev); |
| 13190 | } |
| 13191 | |
| 13192 | void hdd_component_pdev_close(struct wlan_objmgr_pdev *pdev) |
| 13193 | { |
| 13194 | ucfg_mlme_pdev_close(pdev); |
| 13195 | } |
| 13196 | |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13197 | static struct hdd_driver __hdd_driver; |
| 13198 | |
| 13199 | static QDF_STATUS hdd_driver_ctx_init(struct hdd_driver *hdd_driver) |
| 13200 | { |
| 13201 | QDF_BUG(hdd_driver); |
| 13202 | if (!hdd_driver) |
| 13203 | return QDF_STATUS_E_INVAL; |
| 13204 | |
| 13205 | hdd_driver->state = driver_state_uninit; |
| 13206 | |
| 13207 | return dsc_driver_create(&hdd_driver->dsc_driver); |
| 13208 | } |
| 13209 | |
| 13210 | static void hdd_driver_ctx_deinit(struct hdd_driver *hdd_driver) |
| 13211 | { |
| 13212 | QDF_BUG(hdd_driver); |
| 13213 | if (!hdd_driver) |
| 13214 | return; |
| 13215 | |
| 13216 | dsc_driver_destroy(&hdd_driver->dsc_driver); |
| 13217 | qdf_mem_zero(hdd_driver, sizeof(*hdd_driver)); |
| 13218 | } |
| 13219 | |
| 13220 | struct hdd_driver *hdd_driver_get(void) |
| 13221 | { |
| 13222 | return &__hdd_driver; |
| 13223 | } |
| 13224 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13225 | static QDF_STATUS hdd_qdf_print_init(void) |
| 13226 | { |
| 13227 | QDF_STATUS status; |
| 13228 | int qdf_print_idx; |
| 13229 | |
| 13230 | status = qdf_print_setup(); |
| 13231 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13232 | pr_err("Failed qdf_print_setup; status:%u\n", status); |
| 13233 | return status; |
| 13234 | } |
| 13235 | |
| 13236 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, "MCL_WLAN"); |
| 13237 | if (qdf_print_idx < 0) { |
| 13238 | pr_err("Failed to register for qdf_print_ctrl\n"); |
| 13239 | return QDF_STATUS_E_FAILURE; |
| 13240 | } |
| 13241 | |
| 13242 | qdf_set_pidx(qdf_print_idx); |
| 13243 | |
| 13244 | return QDF_STATUS_SUCCESS; |
| 13245 | } |
| 13246 | |
| 13247 | static void hdd_qdf_print_deinit(void) |
| 13248 | { |
| 13249 | int qdf_pidx = qdf_get_pidx(); |
| 13250 | |
| 13251 | qdf_set_pidx(-1); |
| 13252 | qdf_print_ctrl_cleanup(qdf_pidx); |
| 13253 | |
| 13254 | /* currently, no qdf print 'un-setup'*/ |
| 13255 | } |
| 13256 | |
| 13257 | static QDF_STATUS hdd_qdf_init(void) |
| 13258 | { |
| 13259 | QDF_STATUS status; |
| 13260 | |
| 13261 | status = hdd_qdf_print_init(); |
| 13262 | if (QDF_IS_STATUS_ERROR(status)) |
| 13263 | goto exit; |
| 13264 | |
| 13265 | status = qdf_debugfs_init(); |
| 13266 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13267 | hdd_err("Failed to init debugfs; status:%u", status); |
| 13268 | goto print_deinit; |
| 13269 | } |
| 13270 | |
| 13271 | qdf_lock_stats_init(); |
| 13272 | qdf_mem_init(); |
| 13273 | qdf_mc_timer_manager_init(); |
| 13274 | qdf_event_list_init(); |
| 13275 | |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 13276 | status = qdf_talloc_feature_init(); |
| 13277 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13278 | hdd_err("Failed to init talloc; status:%u", status); |
| 13279 | goto event_deinit; |
| 13280 | } |
| 13281 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13282 | status = qdf_cpuhp_init(); |
| 13283 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13284 | hdd_err("Failed to init cpuhp; status:%u", status); |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 13285 | goto talloc_deinit; |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13286 | } |
| 13287 | |
| 13288 | status = qdf_trace_spin_lock_init(); |
| 13289 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13290 | hdd_err("Failed to init spinlock; status:%u", status); |
| 13291 | goto cpuhp_deinit; |
| 13292 | } |
| 13293 | |
| 13294 | qdf_trace_init(); |
| 13295 | qdf_register_debugcb_init(); |
| 13296 | |
| 13297 | return QDF_STATUS_SUCCESS; |
| 13298 | |
| 13299 | cpuhp_deinit: |
| 13300 | qdf_cpuhp_deinit(); |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 13301 | talloc_deinit: |
| 13302 | qdf_talloc_feature_deinit(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13303 | event_deinit: |
| 13304 | qdf_event_list_destroy(); |
| 13305 | qdf_mc_timer_manager_exit(); |
| 13306 | qdf_mem_exit(); |
| 13307 | qdf_lock_stats_deinit(); |
| 13308 | qdf_debugfs_exit(); |
| 13309 | print_deinit: |
| 13310 | hdd_qdf_print_deinit(); |
| 13311 | |
| 13312 | exit: |
| 13313 | return status; |
| 13314 | } |
| 13315 | |
| 13316 | static void hdd_qdf_deinit(void) |
| 13317 | { |
| 13318 | /* currently, no debugcb deinit */ |
| 13319 | |
| 13320 | qdf_trace_deinit(); |
| 13321 | |
| 13322 | /* currently, no trace spinlock deinit */ |
| 13323 | |
| 13324 | qdf_cpuhp_deinit(); |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 13325 | qdf_talloc_feature_deinit(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13326 | qdf_event_list_destroy(); |
| 13327 | qdf_mc_timer_manager_exit(); |
| 13328 | qdf_mem_exit(); |
| 13329 | qdf_lock_stats_deinit(); |
| 13330 | qdf_debugfs_exit(); |
| 13331 | hdd_qdf_print_deinit(); |
| 13332 | } |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13333 | |
| 13334 | /** |
| 13335 | * hdd_driver_load() - Perform the driver-level load operation |
| 13336 | * |
| 13337 | * Note: this is used in both static and DLKM driver builds |
| 13338 | * |
| 13339 | * Return: Errno |
| 13340 | */ |
| 13341 | static int hdd_driver_load(void) |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13342 | { |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13343 | struct hdd_driver *hdd_driver = hdd_driver_get(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13344 | QDF_STATUS status; |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13345 | int errno; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13346 | |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 13347 | pr_err("%s: Loading driver v%s\n", |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 13348 | WLAN_MODULE_NAME, |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 13349 | g_wlan_driver_version); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13350 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13351 | status = hdd_qdf_init(); |
| 13352 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13353 | errno = qdf_status_to_os_return(status); |
| 13354 | goto exit; |
| 13355 | } |
| 13356 | |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13357 | status = hdd_driver_ctx_init(hdd_driver); |
| 13358 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13359 | hdd_err("Failed to init driver context; status:%u", status); |
| 13360 | errno = qdf_status_to_os_return(status); |
| 13361 | goto qdf_deinit; |
| 13362 | } |
| 13363 | |
| 13364 | status = dsc_driver_trans_start(hdd_driver->dsc_driver, "load"); |
| 13365 | QDF_BUG(QDF_IS_STATUS_SUCCESS(status)); |
| 13366 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13367 | errno = qdf_status_to_os_return(status); |
| 13368 | goto hdd_driver_deinit; |
| 13369 | } |
| 13370 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13371 | errno = hdd_init(); |
| 13372 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13373 | hdd_err("Failed to init HDD; errno:%d", errno); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13374 | goto trans_stop; |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13375 | } |
| 13376 | |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13377 | status = hdd_component_init(); |
| 13378 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13379 | hdd_err("Failed to init components; status:%u", status); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13380 | errno = qdf_status_to_os_return(status); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13381 | goto hdd_deinit; |
| 13382 | } |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13383 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13384 | status = qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
| 13385 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13386 | hdd_err("Failed to create wake lock; status:%u", status); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13387 | errno = qdf_status_to_os_return(status); |
| 13388 | goto comp_deinit; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13389 | } |
| 13390 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13391 | hdd_set_conparam(con_mode); |
| 13392 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13393 | errno = wlan_hdd_state_ctrl_param_create(); |
| 13394 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13395 | hdd_err("Failed to create ctrl param; errno:%d", errno); |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13396 | goto wakelock_destroy; |
| 13397 | } |
| 13398 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13399 | errno = pld_init(); |
| 13400 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13401 | hdd_err("Failed to init PLD; errno:%d", errno); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13402 | goto param_destroy; |
| 13403 | } |
| 13404 | |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13405 | hdd_driver->state = driver_state_loaded; |
| 13406 | dsc_driver_trans_stop(hdd_driver->dsc_driver); |
| 13407 | |
| 13408 | /* psoc probe can happen in registration; do after 'load' transition */ |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13409 | errno = wlan_hdd_register_driver(); |
| 13410 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13411 | hdd_err("Failed to register driver; errno:%d", errno); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13412 | goto pld_deinit; |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 13413 | } |
| 13414 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13415 | hdd_debug("%s: driver loaded", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13416 | |
| 13417 | return 0; |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13418 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13419 | pld_deinit: |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13420 | status = dsc_driver_trans_start(hdd_driver->dsc_driver, "unload"); |
| 13421 | QDF_BUG(QDF_IS_STATUS_SUCCESS(status)); |
| 13422 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13423 | pld_deinit(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13424 | |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13425 | param_destroy: |
| 13426 | wlan_hdd_state_ctrl_param_destroy(); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13427 | wakelock_destroy: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 13428 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13429 | comp_deinit: |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13430 | hdd_component_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13431 | hdd_deinit: |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13432 | hdd_deinit(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13433 | trans_stop: |
| 13434 | hdd_driver->state = driver_state_deinit; |
| 13435 | dsc_driver_trans_stop(hdd_driver->dsc_driver); |
| 13436 | hdd_driver_deinit: |
| 13437 | hdd_driver_ctx_deinit(hdd_driver); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13438 | qdf_deinit: |
| 13439 | hdd_qdf_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13440 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13441 | exit: |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13442 | return errno; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13443 | } |
| 13444 | |
| 13445 | /** |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13446 | * hdd_driver_unload() - Performs the driver-level unload operation |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13447 | * |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13448 | * Note: this is used in both static and DLKM driver builds |
| 13449 | * |
| 13450 | * Return: None |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13451 | */ |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13452 | static void hdd_driver_unload(void) |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13453 | { |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13454 | struct hdd_driver *hdd_driver = hdd_driver_get(); |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 13455 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13456 | QDF_STATUS status; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 13457 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13458 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 13459 | QWLAN_VERSIONSTR); |
| 13460 | |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13461 | status = dsc_driver_trans_start_wait(hdd_driver->dsc_driver, "unload"); |
| 13462 | QDF_BUG(QDF_IS_STATUS_SUCCESS(status)); |
| 13463 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13464 | hdd_err("Unable to unload wlan; status:%u", status); |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 13465 | return; |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13466 | } |
| 13467 | |
| 13468 | dsc_driver_wait_for_ops(hdd_driver->dsc_driver); |
| 13469 | |
| 13470 | if (!hdd_wait_for_recovery_completion()) { |
| 13471 | dsc_driver_trans_stop(hdd_driver->dsc_driver); |
| 13472 | return; |
| 13473 | } |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 13474 | |
Will Huang | ba035ec | 2018-07-05 11:13:30 +0800 | [diff] [blame] | 13475 | cds_set_driver_loaded(false); |
| 13476 | cds_set_unload_in_progress(true); |
| 13477 | |
| 13478 | if (!cds_wait_for_external_threads_completion(__func__)) |
| 13479 | hdd_warn("External threads are still active attempting " |
| 13480 | "driver unload anyway"); |
| 13481 | |
Rajeev Kumar | 3505ae5 | 2018-05-10 18:44:45 -0700 | [diff] [blame] | 13482 | if (hdd_ctx) |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 13483 | hdd_psoc_idle_timer_stop(hdd_ctx); |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 13484 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13485 | wlan_hdd_unregister_driver(); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13486 | pld_deinit(); |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13487 | wlan_hdd_state_ctrl_param_destroy(); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13488 | hdd_set_conparam(0); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 13489 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13490 | hdd_component_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13491 | hdd_deinit(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13492 | |
| 13493 | hdd_driver->state = driver_state_deinit; |
| 13494 | dsc_driver_trans_stop(hdd_driver->dsc_driver); |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 13495 | |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13496 | hdd_driver_ctx_deinit(hdd_driver); |
| 13497 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13498 | hdd_qdf_deinit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13499 | } |
| 13500 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13501 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13502 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13503 | * wlan_boot_cb() - Wlan boot callback |
| 13504 | * @kobj: object whose directory we're creating the link in. |
| 13505 | * @attr: attribute the user is interacting with |
| 13506 | * @buff: the buffer containing the user data |
| 13507 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13508 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13509 | * This callback is invoked when the fs is ready to start the |
| 13510 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13511 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13512 | * 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] | 13513 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13514 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13515 | struct kobj_attribute *attr, |
| 13516 | const char *buf, |
| 13517 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13518 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13519 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13520 | if (wlan_loader->loaded_state) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13521 | hdd_err("wlan driver already initialized"); |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13522 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13523 | } |
| 13524 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13525 | if (hdd_driver_load()) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13526 | return -EIO; |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13527 | |
| 13528 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13529 | |
| 13530 | return count; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13531 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13532 | |
| 13533 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13534 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 13535 | * |
| 13536 | * Return: None |
| 13537 | * |
| 13538 | */ |
| 13539 | static void hdd_sysfs_cleanup(void) |
| 13540 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13541 | /* remove from group */ |
| 13542 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 13543 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 13544 | wlan_loader->attr_group); |
| 13545 | |
| 13546 | /* unlink the object from parent */ |
| 13547 | kobject_del(wlan_loader->boot_wlan_obj); |
| 13548 | |
| 13549 | /* free the object */ |
| 13550 | kobject_put(wlan_loader->boot_wlan_obj); |
| 13551 | |
| 13552 | kfree(wlan_loader->attr_group); |
| 13553 | kfree(wlan_loader); |
| 13554 | |
| 13555 | wlan_loader = NULL; |
| 13556 | } |
| 13557 | |
| 13558 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13559 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 13560 | * ready |
| 13561 | * |
| 13562 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 13563 | * when the filesystem is ready. |
| 13564 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13565 | * QDF API cannot be used here since this function is called even before |
| 13566 | * initializing WLAN driver. |
| 13567 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 13568 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13569 | */ |
| 13570 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13571 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13572 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13573 | |
| 13574 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 13575 | if (!wlan_loader) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13576 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13577 | |
| 13578 | wlan_loader->boot_wlan_obj = NULL; |
| 13579 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 13580 | GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 13581 | if (!wlan_loader->attr_group) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13582 | goto error_return; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13583 | |
| 13584 | wlan_loader->loaded_state = 0; |
| 13585 | wlan_loader->attr_group->attrs = attrs; |
| 13586 | |
Qun Zhang | 4a83a46 | 2018-09-11 16:28:51 +0800 | [diff] [blame] | 13587 | wlan_loader->boot_wlan_obj = kobject_create_and_add(WLAN_LOADER_NAME, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13588 | kernel_kobj); |
| 13589 | if (!wlan_loader->boot_wlan_obj) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13590 | hdd_err("sysfs create and add failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13591 | goto error_return; |
| 13592 | } |
| 13593 | |
| 13594 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 13595 | wlan_loader->attr_group); |
| 13596 | if (ret) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13597 | hdd_err("sysfs create group failed; errno:%d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13598 | goto error_return; |
| 13599 | } |
| 13600 | |
| 13601 | return 0; |
| 13602 | |
| 13603 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13604 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13605 | |
| 13606 | return ret; |
| 13607 | } |
| 13608 | |
| 13609 | /** |
| 13610 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 13611 | * |
| 13612 | * Return: 0 on success or errno on failure |
| 13613 | */ |
| 13614 | static int wlan_deinit_sysfs(void) |
| 13615 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13616 | if (!wlan_loader) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13617 | hdd_err("wlan_loader is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13618 | return -EINVAL; |
| 13619 | } |
| 13620 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13621 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13622 | return 0; |
| 13623 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13624 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13625 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13626 | |
| 13627 | #ifdef MODULE |
| 13628 | /** |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13629 | * hdd_module_init() - Module init helper |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13630 | * |
| 13631 | * Module init helper function used by both module and static driver. |
| 13632 | * |
| 13633 | * Return: 0 for success, errno on failure |
| 13634 | */ |
| 13635 | static int hdd_module_init(void) |
| 13636 | { |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13637 | if (hdd_driver_load()) |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 13638 | return -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13639 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 13640 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13641 | } |
| 13642 | #else |
| 13643 | static int __init hdd_module_init(void) |
| 13644 | { |
| 13645 | int ret = -EINVAL; |
| 13646 | |
| 13647 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 13648 | if (ret) |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13649 | hdd_err("Failed to create sysfs entry"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13650 | |
| 13651 | return ret; |
| 13652 | } |
| 13653 | #endif |
| 13654 | |
| 13655 | |
| 13656 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13657 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13658 | * hdd_module_exit() - Exit function |
| 13659 | * |
| 13660 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 13661 | * |
| 13662 | * Return: None |
| 13663 | */ |
| 13664 | static void __exit hdd_module_exit(void) |
| 13665 | { |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13666 | hdd_driver_unload(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13667 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13668 | #else |
| 13669 | static void __exit hdd_module_exit(void) |
| 13670 | { |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13671 | hdd_driver_unload(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13672 | wlan_deinit_sysfs(); |
| 13673 | } |
| 13674 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13675 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13676 | static int fwpath_changed_handler(const char *kmessage, |
| 13677 | const struct kernel_param *kp) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13678 | { |
| 13679 | return param_set_copystring(kmessage, kp); |
| 13680 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13681 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 13682 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
| 13683 | static bool is_monitor_mode_supported(void) |
| 13684 | { |
| 13685 | return true; |
| 13686 | } |
| 13687 | #else |
| 13688 | static bool is_monitor_mode_supported(void) |
| 13689 | { |
| 13690 | pr_err("Monitor mode not supported!"); |
| 13691 | return false; |
| 13692 | } |
| 13693 | #endif |
| 13694 | |
| 13695 | #ifdef WLAN_FEATURE_EPPING |
| 13696 | static bool is_epping_mode_supported(void) |
| 13697 | { |
| 13698 | return true; |
| 13699 | } |
| 13700 | #else |
| 13701 | static bool is_epping_mode_supported(void) |
| 13702 | { |
| 13703 | pr_err("Epping mode not supported!"); |
| 13704 | return false; |
| 13705 | } |
| 13706 | #endif |
| 13707 | |
Ryan Hsu | 6e9db0b | 2018-06-01 10:45:51 -0700 | [diff] [blame] | 13708 | #ifdef QCA_WIFI_FTM |
| 13709 | static bool is_ftm_mode_supported(void) |
| 13710 | { |
| 13711 | return true; |
| 13712 | } |
| 13713 | #else |
| 13714 | static bool is_ftm_mode_supported(void) |
| 13715 | { |
| 13716 | pr_err("FTM mode not supported!"); |
| 13717 | return false; |
| 13718 | } |
| 13719 | #endif |
| 13720 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13721 | /** |
| 13722 | * is_con_mode_valid() check con mode is valid or not |
| 13723 | * @mode: global con mode |
| 13724 | * |
| 13725 | * Return: TRUE on success FALSE on failure |
| 13726 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13727 | static bool is_con_mode_valid(enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13728 | { |
| 13729 | switch (mode) { |
| 13730 | case QDF_GLOBAL_MONITOR_MODE: |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 13731 | return is_monitor_mode_supported(); |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13732 | case QDF_GLOBAL_EPPING_MODE: |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 13733 | return is_epping_mode_supported(); |
| 13734 | case QDF_GLOBAL_FTM_MODE: |
Ryan Hsu | 6e9db0b | 2018-06-01 10:45:51 -0700 | [diff] [blame] | 13735 | return is_ftm_mode_supported(); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13736 | case QDF_GLOBAL_MISSION_MODE: |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13737 | return true; |
| 13738 | default: |
| 13739 | return false; |
| 13740 | } |
| 13741 | } |
| 13742 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13743 | static void hdd_stop_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13744 | enum QDF_GLOBAL_MODE curr_mode) |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13745 | { |
| 13746 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) |
| 13747 | return; |
| 13748 | |
| 13749 | switch (curr_mode) { |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13750 | case QDF_GLOBAL_MONITOR_MODE: |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 13751 | hdd_info("Release wakelock for monitor mode!"); |
| 13752 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 13753 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
Dundi Raviteja | 0a2a65b | 2018-04-30 12:34:11 +0530 | [diff] [blame] | 13754 | /* fallthrough */ |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 13755 | case QDF_GLOBAL_MISSION_MODE: |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13756 | case QDF_GLOBAL_FTM_MODE: |
| 13757 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 13758 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->pdev, NULL); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 13759 | hdd_stop_all_adapters(hdd_ctx); |
Ashish Kumar Dhanotiya | 6ff329e | 2018-10-05 20:38:10 +0530 | [diff] [blame] | 13760 | hdd_deinit_all_adapters(hdd_ctx, false); |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13761 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13762 | break; |
| 13763 | default: |
| 13764 | break; |
| 13765 | } |
| 13766 | } |
| 13767 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13768 | static void hdd_cleanup_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13769 | enum QDF_GLOBAL_MODE curr_mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13770 | { |
Ashish Kumar Dhanotiya | 0024313 | 2017-01-24 16:37:34 +0530 | [diff] [blame] | 13771 | int driver_status; |
| 13772 | |
| 13773 | driver_status = hdd_ctx->driver_status; |
| 13774 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13775 | switch (curr_mode) { |
| 13776 | case QDF_GLOBAL_MISSION_MODE: |
| 13777 | case QDF_GLOBAL_MONITOR_MODE: |
| 13778 | case QDF_GLOBAL_FTM_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13779 | hdd_close_all_adapters(hdd_ctx, false); |
| 13780 | break; |
| 13781 | case QDF_GLOBAL_EPPING_MODE: |
| 13782 | epping_disable(); |
| 13783 | epping_close(); |
| 13784 | break; |
| 13785 | default: |
| 13786 | return; |
| 13787 | } |
| 13788 | } |
| 13789 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13790 | static int |
| 13791 | hdd_parse_driver_mode(const char *mode_str, enum QDF_GLOBAL_MODE *out_mode) |
| 13792 | { |
| 13793 | int mode; |
| 13794 | int errno; |
| 13795 | |
Dustin Brown | 62743f4 | 2018-10-24 14:53:18 -0700 | [diff] [blame] | 13796 | *out_mode = QDF_GLOBAL_MAX_MODE; |
| 13797 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13798 | errno = kstrtoint(mode_str, 0, &mode); |
| 13799 | if (!errno) |
| 13800 | *out_mode = (enum QDF_GLOBAL_MODE)mode; |
| 13801 | |
| 13802 | return errno; |
| 13803 | } |
| 13804 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13805 | /** |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13806 | * __con_mode_handler() - Handles module param con_mode change |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13807 | * @kmessage: con mode name on which driver to be bring up |
| 13808 | * @kp: The associated kernel parameter |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13809 | * @hdd_ctx: Pointer to the global HDD context |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13810 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13811 | * This function is invoked when user updates con mode using sys entry, |
| 13812 | * to initialize and bring-up driver in that specific mode. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13813 | * |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13814 | * Return: Errno |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13815 | */ |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13816 | static int __con_mode_handler(const char *kmessage, |
| 13817 | const struct kernel_param *kp, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13818 | struct hdd_context *hdd_ctx) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13819 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13820 | enum QDF_GLOBAL_MODE curr_mode; |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13821 | enum QDF_GLOBAL_MODE next_mode; |
| 13822 | int errno; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13823 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13824 | hdd_info("Driver mode changing to %s", kmessage); |
Dustin Brown | ab6029b | 2017-05-24 13:04:19 -0700 | [diff] [blame] | 13825 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13826 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 13827 | if (errno) |
| 13828 | return errno; |
| 13829 | |
| 13830 | errno = hdd_parse_driver_mode(kmessage, &next_mode); |
| 13831 | if (errno) { |
| 13832 | hdd_err_rl("Failed to parse driver mode '%s'", kmessage); |
| 13833 | return errno; |
| 13834 | } |
| 13835 | |
| 13836 | if (!is_con_mode_valid(next_mode)) { |
| 13837 | hdd_err_rl("Requested driver mode is invalid"); |
| 13838 | return -EINVAL; |
| 13839 | } |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13840 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 13841 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 1); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 13842 | mutex_lock(&hdd_init_deinit_lock); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13843 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13844 | curr_mode = hdd_get_conparam(); |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13845 | if (curr_mode == next_mode) { |
| 13846 | hdd_err_rl("Driver is already in the requested mode"); |
| 13847 | errno = 0; |
| 13848 | goto unlock; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13849 | } |
| 13850 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13851 | /* ensure adapters are stopped */ |
| 13852 | hdd_stop_present_mode(hdd_ctx, curr_mode); |
| 13853 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13854 | errno = hdd_wlan_stop_modules(hdd_ctx, true); |
| 13855 | if (errno) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13856 | hdd_err("Stop wlan modules failed"); |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13857 | goto unlock; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13858 | } |
| 13859 | |
Dustin Brown | dd4e50f | 2018-05-24 15:43:42 -0700 | [diff] [blame] | 13860 | /* Cleanup present mode before switching to new mode */ |
| 13861 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
Ashish Kumar Dhanotiya | cda5766 | 2017-08-14 14:45:25 +0530 | [diff] [blame] | 13862 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13863 | hdd_set_conparam(next_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13864 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13865 | errno = hdd_wlan_start_modules(hdd_ctx, false); |
| 13866 | if (errno) { |
| 13867 | hdd_err("Start wlan modules failed: %d", errno); |
| 13868 | goto unlock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13869 | } |
| 13870 | |
jitiphil | 7af5cf2 | 2018-10-26 16:06:27 +0530 | [diff] [blame] | 13871 | errno = hdd_open_adapters_for_mode(hdd_ctx, next_mode); |
| 13872 | if (errno) { |
| 13873 | hdd_err("Failed to open adapters"); |
| 13874 | goto unlock; |
| 13875 | } |
| 13876 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13877 | if (next_mode == QDF_GLOBAL_MONITOR_MODE) { |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 13878 | struct hdd_adapter *adapter = |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13879 | hdd_get_adapter(hdd_ctx, QDF_MONITOR_MODE); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 13880 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13881 | QDF_BUG(adapter); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 13882 | if (!adapter) { |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13883 | hdd_err("Failed to get monitor adapter"); |
| 13884 | goto unlock; |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 13885 | } |
| 13886 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13887 | errno = hdd_start_adapter(adapter); |
| 13888 | if (errno) { |
| 13889 | hdd_err("Failed to start monitor adapter"); |
| 13890 | goto unlock; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13891 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13892 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13893 | hdd_info("Acquire wakelock for monitor mode"); |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 13894 | qdf_wake_lock_acquire(&hdd_ctx->monitor_mode_wakelock, |
| 13895 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 13896 | } |
| 13897 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 13898 | /* con_mode is a global module parameter */ |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13899 | con_mode = next_mode; |
| 13900 | hdd_info("Driver mode successfully changed to %s", kmessage); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13901 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13902 | errno = 0; |
| 13903 | |
| 13904 | unlock: |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 13905 | mutex_unlock(&hdd_init_deinit_lock); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 13906 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 0); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13907 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13908 | return errno; |
| 13909 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13910 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13911 | 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] | 13912 | { |
Dustin Brown | 67d3041 | 2018-09-20 12:10:22 -0700 | [diff] [blame] | 13913 | struct hdd_driver *hdd_driver = hdd_driver_get(); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13914 | struct hdd_context *hdd_ctx; |
Dustin Brown | 67d3041 | 2018-09-20 12:10:22 -0700 | [diff] [blame] | 13915 | QDF_STATUS status; |
| 13916 | int errno; |
| 13917 | |
| 13918 | hdd_enter(); |
| 13919 | |
Dustin Brown | 13fa987 | 2018-11-13 10:57:45 -0800 | [diff] [blame] | 13920 | /* This handler will be invoked before module init when the wlan driver |
| 13921 | * is loaded using 'insmod wlan.ko con_mode=5' for example. Return |
| 13922 | * success in this case, as module init will bring up the correct |
| 13923 | * con_mode when it runs. |
| 13924 | */ |
| 13925 | if (hdd_driver->state == driver_state_uninit) |
| 13926 | return 0; |
| 13927 | |
Rajeev Kumar | acb73d0 | 2018-12-18 14:07:40 -0800 | [diff] [blame] | 13928 | if (hdd_driver->state == driver_state_deinit) { |
| 13929 | hdd_err_rl("driver is unloaded so load again"); |
| 13930 | return -EAGAIN; |
| 13931 | } |
| 13932 | |
Dustin Brown | 67d3041 | 2018-09-20 12:10:22 -0700 | [diff] [blame] | 13933 | status = dsc_driver_trans_start_wait(hdd_driver->dsc_driver, |
| 13934 | "mode change"); |
| 13935 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13936 | hdd_err("Failed to start 'mode change'; status:%u", status); |
| 13937 | errno = qdf_status_to_os_return(status); |
| 13938 | goto exit; |
| 13939 | } |
| 13940 | |
| 13941 | dsc_driver_wait_for_ops(hdd_driver->dsc_driver); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13942 | |
| 13943 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Dustin Brown | 67d3041 | 2018-09-20 12:10:22 -0700 | [diff] [blame] | 13944 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 13945 | if (errno) |
| 13946 | goto trans_stop; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13947 | |
Ashish Kumar Dhanotiya | 759b327 | 2018-05-18 17:49:46 +0530 | [diff] [blame] | 13948 | if (!cds_wait_for_external_threads_completion(__func__)) { |
| 13949 | hdd_warn("External threads are still active, can not change mode"); |
Dustin Brown | 67d3041 | 2018-09-20 12:10:22 -0700 | [diff] [blame] | 13950 | errno = -EAGAIN; |
| 13951 | goto trans_stop; |
Ashish Kumar Dhanotiya | 759b327 | 2018-05-18 17:49:46 +0530 | [diff] [blame] | 13952 | } |
| 13953 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13954 | cds_ssr_protect(__func__); |
Dustin Brown | 67d3041 | 2018-09-20 12:10:22 -0700 | [diff] [blame] | 13955 | errno = __con_mode_handler(kmessage, kp, hdd_ctx); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13956 | cds_ssr_unprotect(__func__); |
| 13957 | |
Dustin Brown | 67d3041 | 2018-09-20 12:10:22 -0700 | [diff] [blame] | 13958 | trans_stop: |
| 13959 | dsc_driver_trans_stop(hdd_driver->dsc_driver); |
| 13960 | |
| 13961 | exit: |
| 13962 | hdd_exit(); |
| 13963 | |
| 13964 | return errno; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13965 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13966 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 13967 | static int con_mode_handler_ftm(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13968 | const struct kernel_param *kp) |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 13969 | { |
| 13970 | int ret; |
| 13971 | |
| 13972 | ret = param_set_int(kmessage, kp); |
| 13973 | |
| 13974 | if (con_mode_ftm != QDF_GLOBAL_FTM_MODE) { |
| 13975 | pr_err("Only FTM mode supported!"); |
| 13976 | return -ENOTSUPP; |
| 13977 | } |
| 13978 | |
| 13979 | hdd_set_conparam(con_mode_ftm); |
| 13980 | con_mode = con_mode_ftm; |
| 13981 | |
| 13982 | return ret; |
| 13983 | } |
| 13984 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 13985 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 13986 | static int con_mode_handler_monitor(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13987 | const struct kernel_param *kp) |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 13988 | { |
| 13989 | int ret; |
| 13990 | |
| 13991 | ret = param_set_int(kmessage, kp); |
| 13992 | |
| 13993 | if (con_mode_monitor != QDF_GLOBAL_MONITOR_MODE) { |
| 13994 | pr_err("Only Monitor mode supported!"); |
| 13995 | return -ENOTSUPP; |
| 13996 | } |
| 13997 | |
| 13998 | hdd_set_conparam(con_mode_monitor); |
| 13999 | con_mode = con_mode_monitor; |
| 14000 | |
| 14001 | return ret; |
| 14002 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14003 | #endif |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 14004 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14005 | /** |
| 14006 | * hdd_get_conparam() - driver exit point |
| 14007 | * |
| 14008 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 14009 | * |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 14010 | * Return: enum QDF_GLOBAL_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14011 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 14012 | enum QDF_GLOBAL_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14013 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 14014 | return (enum QDF_GLOBAL_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14015 | } |
| 14016 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 14017 | void hdd_set_conparam(int32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14018 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 14019 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14020 | } |
| 14021 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14022 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14023 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 14024 | * @hdd_ctx: HDD context |
| 14025 | * |
| 14026 | * Cleans up the pre cac interface, if it exists |
| 14027 | * |
| 14028 | * Return: None |
| 14029 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14030 | void hdd_clean_up_pre_cac_interface(struct hdd_context *hdd_ctx) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14031 | { |
| 14032 | uint8_t session_id; |
| 14033 | QDF_STATUS status; |
Jeff Johnson | 85b5c11 | 2017-08-11 15:15:23 -0700 | [diff] [blame] | 14034 | struct hdd_adapter *precac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14035 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14036 | 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] | 14037 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14038 | hdd_err("failed to get pre cac vdev id"); |
| 14039 | return; |
| 14040 | } |
| 14041 | |
| 14042 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, session_id); |
| 14043 | if (!precac_adapter) { |
Jeff Johnson | dd2f1fc | 2018-05-06 11:22:52 -0700 | [diff] [blame] | 14044 | hdd_err("invalid pre cac adapter"); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14045 | return; |
| 14046 | } |
| 14047 | |
| 14048 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 14049 | wlan_hdd_sap_pre_cac_failure, |
| 14050 | (void *)precac_adapter); |
| 14051 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 14052 | |
| 14053 | } |
| 14054 | |
| 14055 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14056 | * hdd_update_ol_config - API to update ol configuration parameters |
| 14057 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14058 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14059 | * Return: void |
| 14060 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14061 | static void hdd_update_ol_config(struct hdd_context *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14062 | { |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14063 | struct ol_config_info cfg = {0}; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 14064 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14065 | bool self_recovery = false; |
| 14066 | QDF_STATUS status; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14067 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14068 | if (!ol_ctx) |
| 14069 | return; |
| 14070 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14071 | status = ucfg_mlme_get_self_recovery(hdd_ctx->psoc, &self_recovery); |
| 14072 | if (QDF_IS_STATUS_ERROR(status)) |
| 14073 | hdd_err("Failed to get self recovery ini config"); |
| 14074 | |
| 14075 | cfg.enable_self_recovery = self_recovery; |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14076 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 14077 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 14078 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 14079 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14080 | |
| 14081 | ol_init_ini_config(ol_ctx, &cfg); |
| 14082 | } |
| 14083 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14084 | #ifdef FEATURE_RUNTIME_PM |
| 14085 | /** |
| 14086 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 14087 | * @hdd_ctx: hdd context |
| 14088 | * @cfg: pointer to the configuration memory being populated |
| 14089 | * |
| 14090 | * Return: void |
| 14091 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14092 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14093 | struct hif_config_info *cfg) |
| 14094 | { |
| 14095 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14096 | cfg->runtime_pm_delay = |
| 14097 | ucfg_pmo_get_runtime_pm_delay(hdd_ctx->psoc); |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14098 | } |
| 14099 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14100 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14101 | struct hif_config_info *cfg) |
| 14102 | { |
| 14103 | } |
| 14104 | #endif |
| 14105 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14106 | /** |
| 14107 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 14108 | * @hdd_ctx: HDD Context |
| 14109 | * |
| 14110 | * Return: void |
| 14111 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14112 | static void hdd_update_hif_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14113 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 14114 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14115 | struct hif_config_info cfg = {0}; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14116 | bool prevent_link_down = false; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14117 | bool self_recovery = false; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14118 | QDF_STATUS status; |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14119 | |
| 14120 | if (!scn) |
| 14121 | return; |
| 14122 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14123 | status = ucfg_mlme_get_prevent_link_down(hdd_ctx->psoc, |
| 14124 | &prevent_link_down); |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14125 | if (QDF_IS_STATUS_ERROR(status)) |
| 14126 | hdd_err("Failed to get prevent_link_down config"); |
| 14127 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14128 | status = ucfg_mlme_get_self_recovery(hdd_ctx->psoc, &self_recovery); |
| 14129 | if (QDF_IS_STATUS_ERROR(status)) |
| 14130 | hdd_err("Failed to get self recovery ini config"); |
| 14131 | |
| 14132 | cfg.enable_self_recovery = self_recovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14133 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14134 | hif_init_ini_config(scn, &cfg); |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 14135 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14136 | if (prevent_link_down) |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 14137 | hif_vote_link_up(scn); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14138 | } |
| 14139 | |
| 14140 | /** |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14141 | * hdd_update_dp_config() - Propagate config parameters to Lithium |
| 14142 | * datapath |
| 14143 | * @hdd_ctx: HDD Context |
| 14144 | * |
| 14145 | * Return: 0 for success/errno for failure |
| 14146 | */ |
| 14147 | static int hdd_update_dp_config(struct hdd_context *hdd_ctx) |
| 14148 | { |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14149 | struct cdp_config_params params = {0}; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14150 | QDF_STATUS status; |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14151 | void *soc; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14152 | |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14153 | soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 14154 | params.tso_enable = cfg_get(hdd_ctx->psoc, CFG_DP_TSO); |
| 14155 | params.lro_enable = cfg_get(hdd_ctx->psoc, CFG_DP_LRO); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14156 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 14157 | params.tx_flow_stop_queue_threshold = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 14158 | cfg_get(hdd_ctx->psoc, CFG_DP_TX_FLOW_STOP_QUEUE_TH); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14159 | params.tx_flow_start_queue_offset = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 14160 | cfg_get(hdd_ctx->psoc, |
| 14161 | CFG_DP_TX_FLOW_START_QUEUE_OFFSET); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14162 | #endif |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14163 | params.flow_steering_enable = |
| 14164 | cfg_get(hdd_ctx->psoc, CFG_DP_FLOW_STEERING_ENABLED); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14165 | params.napi_enable = hdd_ctx->napi_enable; |
| 14166 | params.tcp_udp_checksumoffload = |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14167 | cfg_get(hdd_ctx->psoc, |
| 14168 | CFG_DP_TCP_UDP_CKSUM_OFFLOAD); |
Sravan Kumar Kairam | 0af1ee5 | 2018-12-12 20:37:51 +0530 | [diff] [blame] | 14169 | params.ipa_enable = ucfg_ipa_is_enabled(); |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 14170 | params.gro_enable = cfg_get(hdd_ctx->psoc, CFG_DP_GRO); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14171 | |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14172 | status = cdp_update_config_parameters(soc, ¶ms); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14173 | if (status) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 14174 | hdd_err("Failed to attach config parameters"); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14175 | return status; |
| 14176 | } |
| 14177 | |
| 14178 | return 0; |
| 14179 | } |
| 14180 | |
| 14181 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14182 | * hdd_update_config() - Initialize driver per module ini parameters |
| 14183 | * @hdd_ctx: HDD Context |
| 14184 | * |
| 14185 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14186 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14187 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14188 | int hdd_update_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14189 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14190 | int ret; |
| 14191 | |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14192 | if (ucfg_pmo_is_ns_offloaded(hdd_ctx->psoc)) |
| 14193 | hdd_ctx->ns_offload_enable = true; |
| 14194 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14195 | hdd_update_ol_config(hdd_ctx); |
| 14196 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14197 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 14198 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 14199 | else |
| 14200 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 14201 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14202 | |
| 14203 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14204 | } |
| 14205 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14206 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 14207 | /** |
| 14208 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 14209 | * @psoc_cfg: pmo psoc Configuration |
| 14210 | * @hdd_ctx: Pointer to hdd context |
| 14211 | * |
| 14212 | * Return: none |
| 14213 | */ |
| 14214 | static inline void hdd_ra_populate_pmo_config( |
| 14215 | struct pmo_psoc_cfg *psoc_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14216 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14217 | { |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 14218 | bool is_rate_limit_enabled; |
| 14219 | QDF_STATUS status; |
| 14220 | |
| 14221 | status = ucfg_fwol_get_is_rate_limit_enabled(hdd_ctx->psoc, |
| 14222 | &is_rate_limit_enabled); |
| 14223 | if (QDF_IS_STATUS_ERROR(status)) |
| 14224 | return; |
| 14225 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14226 | psoc_cfg->ra_ratelimit_interval = |
| 14227 | hdd_ctx->config->RArateLimitInterval; |
| 14228 | psoc_cfg->ra_ratelimit_enable = |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 14229 | is_rate_limit_enabled; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14230 | } |
| 14231 | #else |
| 14232 | static inline void hdd_ra_populate_pmo_config( |
| 14233 | struct cds_config_info *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14234 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14235 | { |
| 14236 | } |
| 14237 | #endif |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 14238 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14239 | /** |
| 14240 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 14241 | * @hdd_ctx: HDD context |
| 14242 | * |
| 14243 | * Return: void |
| 14244 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14245 | static int hdd_update_pmo_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14246 | { |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14247 | struct pmo_psoc_cfg psoc_cfg = {0}; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14248 | QDF_STATUS status; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14249 | enum pmo_wow_enable_type wow_enable; |
| 14250 | |
| 14251 | ucfg_pmo_get_psoc_config(hdd_ctx->psoc, &psoc_cfg); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14252 | |
| 14253 | /* |
| 14254 | * Value of hdd_ctx->wowEnable can be, |
| 14255 | * 0 - Disable both magic pattern match and pattern byte match. |
| 14256 | * 1 - Enable magic pattern match on all interfaces. |
| 14257 | * 2 - Enable pattern byte match on all interfaces. |
| 14258 | * 3 - Enable both magic patter and pattern byte match on |
| 14259 | * all interfaces. |
| 14260 | */ |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14261 | wow_enable = ucfg_pmo_get_wow_enable(hdd_ctx->psoc); |
| 14262 | psoc_cfg.magic_ptrn_enable = (wow_enable & 0x01) ? true : false; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14263 | psoc_cfg.ptrn_match_enable_all_vdev = |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14264 | (wow_enable & 0x02) ? true : false; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 14265 | psoc_cfg.packet_filter_enabled = !hdd_ctx->config->disablePacketFilter; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14266 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 14267 | psoc_cfg.d0_wow_supported = wma_d0_wow_is_supported(); |
Bala Venkatesh | 46e2903 | 2018-11-14 18:24:55 +0530 | [diff] [blame] | 14268 | ucfg_mlme_get_sap_max_modulated_dtim(hdd_ctx->psoc, |
| 14269 | &psoc_cfg.sta_max_li_mod_dtim); |
| 14270 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14271 | |
| 14272 | hdd_ra_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 14273 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14274 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14275 | status = ucfg_pmo_update_psoc_config(hdd_ctx->psoc, &psoc_cfg); |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 14276 | if (QDF_IS_STATUS_ERROR(status)) |
| 14277 | hdd_err("failed pmo psoc configuration; status:%d", status); |
| 14278 | |
| 14279 | return qdf_status_to_os_return(status); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14280 | } |
| 14281 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 14282 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 14283 | static inline void hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 14284 | struct hdd_context *hdd_ctx) |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 14285 | { |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 14286 | struct nlo_mawc_params *mawc_cfg = &pno_cfg->mawc_params; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 14287 | struct hdd_config *cfg = hdd_ctx->config; |
| 14288 | bool mawc_enabled; |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 14289 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 14290 | pno_cfg->channel_prediction = cfg->pno_channel_prediction; |
| 14291 | pno_cfg->top_k_num_of_channels = cfg->top_k_num_of_channels; |
| 14292 | pno_cfg->stationary_thresh = cfg->stationary_thresh; |
Abhishek Singh | cfc4e23 | 2018-12-20 11:04:57 +0530 | [diff] [blame] | 14293 | pno_cfg->adaptive_dwell_mode = cfg->pnoscan_adaptive_dwell_mode; |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 14294 | pno_cfg->channel_prediction_full_scan = |
| 14295 | cfg->channel_prediction_full_scan; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 14296 | |
| 14297 | ucfg_mlme_is_mawc_enabled(hdd_ctx->psoc, &mawc_enabled); |
| 14298 | mawc_cfg->enable = mawc_enabled && cfg->mawc_nlo_enabled; |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 14299 | mawc_cfg->exp_backoff_ratio = cfg->mawc_nlo_exp_backoff_ratio; |
| 14300 | mawc_cfg->init_scan_interval = cfg->mawc_nlo_init_scan_interval; |
| 14301 | mawc_cfg->max_scan_interval = cfg->mawc_nlo_max_scan_interval; |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 14302 | } |
| 14303 | #else |
| 14304 | static inline void |
| 14305 | hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 14306 | struct hdd_context *hdd_ctx) |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 14307 | { |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 14308 | } |
| 14309 | #endif |
| 14310 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14311 | 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] | 14312 | struct hdd_context *hdd_ctx) |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14313 | { |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14314 | struct wlan_fwol_ie_whitelist whitelist = {0}; |
| 14315 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14316 | QDF_STATUS status; |
| 14317 | bool is_ie_whitelist_enable = false; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14318 | uint8_t i = 0; |
| 14319 | |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14320 | status = ucfg_fwol_get_ie_whitelist(psoc, &is_ie_whitelist_enable); |
| 14321 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14322 | hdd_err("Unable to get IE whitelist param"); |
| 14323 | return; |
| 14324 | } |
| 14325 | |
| 14326 | ie_whitelist->white_list = is_ie_whitelist_enable; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14327 | if (!ie_whitelist->white_list) |
| 14328 | return; |
| 14329 | |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14330 | status = ucfg_fwol_get_all_whitelist_params(psoc, &whitelist); |
| 14331 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14332 | hdd_err("Unable to get all whitelist params"); |
| 14333 | return; |
| 14334 | } |
| 14335 | |
| 14336 | ie_whitelist->ie_bitmap[0] = whitelist.ie_bitmap_0; |
| 14337 | ie_whitelist->ie_bitmap[1] = whitelist.ie_bitmap_1; |
| 14338 | ie_whitelist->ie_bitmap[2] = whitelist.ie_bitmap_2; |
| 14339 | ie_whitelist->ie_bitmap[3] = whitelist.ie_bitmap_3; |
| 14340 | ie_whitelist->ie_bitmap[4] = whitelist.ie_bitmap_4; |
| 14341 | ie_whitelist->ie_bitmap[5] = whitelist.ie_bitmap_5; |
| 14342 | ie_whitelist->ie_bitmap[6] = whitelist.ie_bitmap_6; |
| 14343 | ie_whitelist->ie_bitmap[7] = whitelist.ie_bitmap_7; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14344 | |
Dundi Raviteja | 9ab4e7b | 2018-09-28 14:18:28 +0530 | [diff] [blame] | 14345 | ie_whitelist->num_vendor_oui = whitelist.no_of_probe_req_ouis; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14346 | for (i = 0; i < ie_whitelist->num_vendor_oui; i++) |
Dundi Raviteja | 9ab4e7b | 2018-09-28 14:18:28 +0530 | [diff] [blame] | 14347 | ie_whitelist->voui[i] = whitelist.probe_req_voui[i]; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14348 | } |
| 14349 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14350 | uint32_t hdd_limit_max_per_index_score(uint32_t per_index_score) |
| 14351 | { |
| 14352 | uint8_t i, score; |
| 14353 | |
| 14354 | for (i = 0; i < MAX_INDEX_PER_INI; i++) { |
| 14355 | score = WLAN_GET_SCORE_PERCENTAGE(per_index_score, i); |
| 14356 | if (score > MAX_INDEX_SCORE) |
| 14357 | WLAN_SET_SCORE_PERCENTAGE(per_index_score, |
| 14358 | MAX_INDEX_SCORE, i); |
| 14359 | } |
| 14360 | |
| 14361 | return per_index_score; |
| 14362 | } |
| 14363 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14364 | QDF_STATUS hdd_update_score_config( |
| 14365 | struct scoring_config *score_config, struct hdd_context *hdd_ctx) |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14366 | { |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14367 | struct hdd_config *cfg = hdd_ctx->config; |
gaurank kathpalia | ae52c98 | 2018-10-04 01:35:18 +0530 | [diff] [blame] | 14368 | QDF_STATUS status; |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 14369 | struct wlan_mlme_nss_chains vdev_ini_cfg; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14370 | bool bval = false; |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14371 | |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14372 | qdf_mem_zero(&vdev_ini_cfg, sizeof(struct wlan_mlme_nss_chains)); |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 14373 | /* Populate the nss chain params from ini for this vdev type */ |
| 14374 | sme_populate_nss_chain_params(hdd_ctx->mac_handle, &vdev_ini_cfg, |
| 14375 | QDF_STA_MODE, |
| 14376 | hdd_ctx->num_rf_chains); |
| 14377 | |
| 14378 | score_config->vdev_nss_24g = vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_2GHZ]; |
| 14379 | score_config->vdev_nss_24g = vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_5GHZ]; |
| 14380 | |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14381 | sme_update_score_config(hdd_ctx->mac_handle, score_config); |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14382 | |
| 14383 | score_config->cb_mode_24G = cfg->nChannelBondingMode24GHz; |
| 14384 | score_config->cb_mode_5G = cfg->nChannelBondingMode5GHz; |
gaurank kathpalia | ae52c98 | 2018-10-04 01:35:18 +0530 | [diff] [blame] | 14385 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14386 | if (cfg->dot11Mode == eHDD_DOT11_MODE_AUTO || |
| 14387 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 14388 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) |
| 14389 | score_config->he_cap = 1; |
| 14390 | |
| 14391 | if (score_config->he_cap || |
| 14392 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 14393 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) |
| 14394 | score_config->vht_cap = 1; |
| 14395 | |
| 14396 | if (score_config->vht_cap || cfg->dot11Mode == eHDD_DOT11_MODE_11n || |
| 14397 | cfg->dot11Mode == eHDD_DOT11_MODE_11n_ONLY) |
| 14398 | score_config->ht_cap = 1; |
| 14399 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14400 | status = ucfg_mlme_get_vht_for_24ghz(hdd_ctx->psoc, &bval); |
| 14401 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 14402 | hdd_err("Failed to get vht_for_24ghz"); |
| 14403 | if (score_config->vht_cap && bval) |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14404 | score_config->vht_24G_cap = 1; |
| 14405 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14406 | status = ucfg_mlme_get_vht_enable_tx_bf(hdd_ctx->psoc, |
| 14407 | &bval); |
| 14408 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 14409 | hdd_err("unable to get vht_enable_tx_bf"); |
| 14410 | |
| 14411 | if (bval) |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14412 | score_config->beamformee_cap = 1; |
| 14413 | |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14414 | return QDF_STATUS_SUCCESS; |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14415 | } |
| 14416 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14417 | /** |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14418 | * hdd_update_dfs_config() - API to update dfs configuration parameters. |
| 14419 | * @hdd_ctx: HDD context |
| 14420 | * |
| 14421 | * Return: 0 if success else err |
| 14422 | */ |
| 14423 | static int hdd_update_dfs_config(struct hdd_context *hdd_ctx) |
| 14424 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14425 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14426 | struct dfs_user_config dfs_cfg = {0}; |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14427 | QDF_STATUS status; |
| 14428 | |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 14429 | ucfg_mlme_get_dfs_filter_offload(hdd_ctx->psoc, |
| 14430 | &dfs_cfg.dfs_is_phyerr_filter_offload); |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14431 | status = ucfg_dfs_update_config(psoc, &dfs_cfg); |
| 14432 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14433 | hdd_err("failed dfs psoc configuration"); |
| 14434 | return -EINVAL; |
| 14435 | } |
| 14436 | |
| 14437 | return 0; |
| 14438 | } |
| 14439 | |
| 14440 | /** |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14441 | * hdd_update_scan_config - API to update scan configuration parameters |
| 14442 | * @hdd_ctx: HDD context |
| 14443 | * |
| 14444 | * Return: 0 if success else err |
| 14445 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14446 | static int hdd_update_scan_config(struct hdd_context *hdd_ctx) |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14447 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14448 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14449 | struct scan_user_cfg scan_cfg = {0}; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14450 | struct hdd_config *cfg = hdd_ctx->config; |
| 14451 | QDF_STATUS status; |
Krunal Soni | d2c33e1 | 2018-12-06 15:02:37 -0800 | [diff] [blame] | 14452 | uint32_t mcast_mcc_rest_time = 0; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14453 | |
Abhishek Singh | 158fe25 | 2017-03-23 11:09:34 +0530 | [diff] [blame] | 14454 | /* convert to ms */ |
| 14455 | scan_cfg.scan_cache_aging_time = |
| 14456 | cfg->scanAgingTimeout * 1000; |
Kapil Gupta | fa9a8c6 | 2017-04-10 15:25:40 +0530 | [diff] [blame] | 14457 | scan_cfg.is_snr_monitoring_enabled = cfg->fEnableSNRMonitoring; |
Kiran Kumar Lokere | d547fdd | 2017-09-13 17:20:55 -0700 | [diff] [blame] | 14458 | scan_cfg.enable_mac_spoofing = cfg->enable_mac_spoofing; |
Krunal Soni | d2c33e1 | 2018-12-06 15:02:37 -0800 | [diff] [blame] | 14459 | status = ucfg_mlme_get_sta_miracast_mcc_rest_time(hdd_ctx->psoc, |
| 14460 | &mcast_mcc_rest_time); |
| 14461 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 14462 | hdd_err("ucfg_mlme_get_sta_miracast_mcc_rest_time, use def"); |
| 14463 | return -EIO; |
| 14464 | } |
| 14465 | scan_cfg.sta_miracast_mcc_rest_time = mcast_mcc_rest_time; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 14466 | hdd_update_pno_config(&scan_cfg.pno_cfg, hdd_ctx); |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14467 | hdd_update_ie_whitelist_attr(&scan_cfg.ie_whitelist, hdd_ctx); |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14468 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14469 | status = hdd_update_score_config(&scan_cfg.score_config, hdd_ctx); |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14470 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14471 | hdd_err("Failed to update scoring config"); |
| 14472 | return -EINVAL; |
| 14473 | } |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 14474 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14475 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 14476 | if (status != QDF_STATUS_SUCCESS) { |
| 14477 | hdd_err("failed pmo psoc configuration"); |
| 14478 | return -EINVAL; |
| 14479 | } |
| 14480 | |
| 14481 | return 0; |
| 14482 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14483 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14484 | int hdd_update_components_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14485 | { |
| 14486 | int ret; |
| 14487 | |
| 14488 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14489 | if (ret) |
| 14490 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14491 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14492 | ret = hdd_update_scan_config(hdd_ctx); |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 14493 | if (ret) |
| 14494 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14495 | |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 14496 | ret = hdd_update_tdls_config(hdd_ctx); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14497 | if (ret) |
| 14498 | return ret; |
| 14499 | |
| 14500 | ret = hdd_update_dp_config(hdd_ctx); |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14501 | if (ret) |
| 14502 | return ret; |
| 14503 | |
| 14504 | ret = hdd_update_dfs_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14505 | |
| 14506 | return ret; |
| 14507 | } |
| 14508 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14509 | /** |
| 14510 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 14511 | * @mode : cfg80211 DFS mode |
| 14512 | * |
| 14513 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 14514 | */ |
| 14515 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 14516 | { |
| 14517 | switch (mode) { |
| 14518 | case DFS_MODE_ENABLE: |
| 14519 | return ACS_DFS_MODE_ENABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14520 | case DFS_MODE_DISABLE: |
| 14521 | return ACS_DFS_MODE_DISABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14522 | case DFS_MODE_DEPRIORITIZE: |
| 14523 | return ACS_DFS_MODE_DEPRIORITIZE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14524 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 14525 | hdd_debug("ACS dfs mode is NONE"); |
| 14526 | return ACS_DFS_MODE_NONE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14527 | } |
| 14528 | } |
| 14529 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14530 | /** |
| 14531 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 14532 | * @hddctx: pointer to hdd context |
| 14533 | * @set_value: enable/disable |
| 14534 | * |
| 14535 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 14536 | * Host(even though it is duplicate). When Host send vendor command |
| 14537 | * disable,FW doesn't perform any action. Whenever any change in |
| 14538 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 14539 | * |
| 14540 | * return - 0 on success, appropriate error values on failure. |
| 14541 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14542 | 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] | 14543 | { |
| 14544 | QDF_STATUS status; |
| 14545 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14546 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14547 | return -EAGAIN; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14548 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14549 | status = sme_enable_disable_chanavoidind_event(hdd_ctx->mac_handle, |
| 14550 | set_value); |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14551 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 14552 | hdd_err("Failed to send chan avoid command to SME"); |
| 14553 | return -EINVAL; |
| 14554 | } |
| 14555 | return 0; |
| 14556 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14557 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14558 | /** |
| 14559 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 14560 | * @value: value to set |
| 14561 | * |
| 14562 | * This function will set the passed value to roaming in progress flag. |
| 14563 | * |
| 14564 | * Return: None |
| 14565 | */ |
| 14566 | void hdd_set_roaming_in_progress(bool value) |
| 14567 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14568 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14569 | |
| 14570 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14571 | if (!hdd_ctx) { |
| 14572 | hdd_err("HDD context is NULL"); |
| 14573 | return; |
| 14574 | } |
| 14575 | |
| 14576 | hdd_ctx->roaming_in_progress = value; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 14577 | hdd_debug("Roaming in Progress set to %d", value); |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14578 | } |
| 14579 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14580 | bool hdd_is_roaming_in_progress(struct hdd_context *hdd_ctx) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14581 | { |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14582 | if (!hdd_ctx) { |
| 14583 | hdd_err("HDD context is NULL"); |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14584 | return false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14585 | } |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 14586 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14587 | hdd_debug("roaming_in_progress = %d", hdd_ctx->roaming_in_progress); |
| 14588 | |
| 14589 | return hdd_ctx->roaming_in_progress; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14590 | } |
| 14591 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14592 | /** |
| 14593 | * hdd_is_connection_in_progress() - check if connection is in |
| 14594 | * progress |
| 14595 | * @session_id: session id |
| 14596 | * @reason: scan reject reason |
| 14597 | * |
| 14598 | * Go through each adapter and check if Connection is in progress |
| 14599 | * |
| 14600 | * Return: true if connection is in progress else false |
| 14601 | */ |
| 14602 | bool hdd_is_connection_in_progress(uint8_t *session_id, |
| 14603 | enum scan_reject_states *reason) |
| 14604 | { |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 14605 | struct hdd_station_ctx *hdd_sta_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14606 | struct hdd_adapter *adapter = NULL; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14607 | uint8_t sta_id = 0; |
| 14608 | uint8_t *sta_mac = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14609 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14610 | mac_handle_t mac_handle; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14611 | |
| 14612 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14613 | if (!hdd_ctx) { |
| 14614 | hdd_err("HDD context is NULL"); |
| 14615 | return false; |
| 14616 | } |
| 14617 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14618 | mac_handle = hdd_ctx->mac_handle; |
| 14619 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 14620 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Tushnim Bhattacharyya | 929afa4 | 2018-06-01 15:04:44 -0700 | [diff] [blame] | 14621 | hdd_debug("Adapter with device mode %s(%d) exists", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 14622 | qdf_opmode_str(adapter->device_mode), |
| 14623 | adapter->device_mode); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14624 | if (((QDF_STA_MODE == adapter->device_mode) |
| 14625 | || (QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 14626 | || (QDF_P2P_DEVICE_MODE == adapter->device_mode)) |
| 14627 | && (eConnectionState_Connecting == |
| 14628 | (WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> |
| 14629 | conn_info.connState)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14630 | hdd_debug("%pK(%d) Connection is in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14631 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14632 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14633 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14634 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14635 | *reason = CONNECTION_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14636 | } |
| 14637 | return true; |
| 14638 | } |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 14639 | /* |
| 14640 | * sme_neighbor_middle_of_roaming is for LFR2 |
| 14641 | * hdd_is_roaming_in_progress is for LFR3 |
| 14642 | */ |
| 14643 | if (((QDF_STA_MODE == adapter->device_mode) && |
| 14644 | sme_neighbor_middle_of_roaming( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14645 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14646 | adapter->session_id)) || |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14647 | hdd_is_roaming_in_progress(hdd_ctx)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14648 | hdd_debug("%pK(%d) Reassociation in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14649 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14650 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14651 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14652 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14653 | *reason = REASSOC_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14654 | } |
| 14655 | return true; |
| 14656 | } |
| 14657 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 14658 | (QDF_P2P_CLIENT_MODE == adapter->device_mode) || |
| 14659 | (QDF_P2P_DEVICE_MODE == adapter->device_mode)) { |
| 14660 | hdd_sta_ctx = |
| 14661 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 14662 | if ((eConnectionState_Associated == |
Vignesh Viswanathan | 0a56929 | 2018-02-14 15:34:47 +0530 | [diff] [blame] | 14663 | hdd_sta_ctx->conn_info.connState) |
| 14664 | && sme_is_sta_key_exchange_in_progress( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14665 | mac_handle, adapter->session_id)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14666 | sta_mac = (uint8_t *) |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 14667 | &(adapter->mac_addr.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14668 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14669 | " is in middle of WPS/EAPOL exchange.", |
| 14670 | MAC_ADDR_ARRAY(sta_mac)); |
| 14671 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14672 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14673 | *reason = EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14674 | } |
| 14675 | return true; |
| 14676 | } |
| 14677 | } else if ((QDF_SAP_MODE == adapter->device_mode) || |
| 14678 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
| 14679 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; |
| 14680 | sta_id++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 14681 | if (!((adapter->sta_info[sta_id].in_use) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14682 | && (OL_TXRX_PEER_STATE_CONN == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 14683 | adapter->sta_info[sta_id].peer_state))) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14684 | continue; |
| 14685 | |
| 14686 | sta_mac = (uint8_t *) |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 14687 | &(adapter->sta_info[sta_id]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 14688 | sta_mac.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14689 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14690 | " of SAP/GO is in middle of WPS/EAPOL exchange", |
| 14691 | MAC_ADDR_ARRAY(sta_mac)); |
| 14692 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14693 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14694 | *reason = SAP_EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14695 | } |
| 14696 | return true; |
| 14697 | } |
| 14698 | if (hdd_ctx->connection_in_progress) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14699 | hdd_debug("AP/GO: connection is in progress"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14700 | return true; |
| 14701 | } |
| 14702 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14703 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 14704 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14705 | return false; |
| 14706 | } |
| 14707 | |
| 14708 | /** |
| 14709 | * hdd_restart_sap() - to restart SAP in driver internally |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14710 | * @ap_adapter: Pointer to SAP struct hdd_adapter structure |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14711 | * |
| 14712 | * Return: None |
| 14713 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14714 | void hdd_restart_sap(struct hdd_adapter *ap_adapter) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14715 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 14716 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 14717 | struct hdd_hostapd_state *hostapd_state; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14718 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14719 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 14720 | tsap_config_t *sap_config; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14721 | void *sap_ctx; |
| 14722 | |
| 14723 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 14724 | sap_config = &hdd_ap_ctx->sap_config; |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 14725 | sap_ctx = hdd_ap_ctx->sap_context; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14726 | |
| 14727 | mutex_lock(&hdd_ctx->sap_lock); |
| 14728 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
| 14729 | wlan_hdd_del_station(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14730 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 14731 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
| 14732 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(sap_ctx)) { |
| 14733 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 14734 | qdf_wait_for_event_completion(&hostapd_state-> |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14735 | qdf_stop_bss_event, |
Vignesh Viswanathan | 865daaa | 2018-10-11 19:30:44 +0530 | [diff] [blame] | 14736 | SME_CMD_START_STOP_BSS_TIMEOUT); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14737 | |
| 14738 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14739 | hdd_err("SAP Stop Failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14740 | goto end; |
| 14741 | } |
| 14742 | } |
| 14743 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14744 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14745 | ap_adapter->device_mode, ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 14746 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14747 | false); |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14748 | hdd_err("SAP Stop Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14749 | |
| 14750 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14751 | hdd_err("SAP Not able to set AP IEs"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14752 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14753 | eUPDATE_IE_ALL); |
| 14754 | goto end; |
| 14755 | } |
| 14756 | |
| 14757 | qdf_event_reset(&hostapd_state->qdf_event); |
| 14758 | if (wlansap_start_bss(sap_ctx, hdd_hostapd_sap_event_cb, |
| 14759 | sap_config, |
| 14760 | ap_adapter->dev) != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14761 | hdd_err("SAP Start Bss fail"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14762 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14763 | eUPDATE_IE_ALL); |
| 14764 | goto end; |
| 14765 | } |
| 14766 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14767 | hdd_info("Waiting for SAP to start"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14768 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 14769 | qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Vignesh Viswanathan | 865daaa | 2018-10-11 19:30:44 +0530 | [diff] [blame] | 14770 | SME_CMD_START_STOP_BSS_TIMEOUT); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14771 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14772 | eUPDATE_IE_ALL); |
| 14773 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14774 | hdd_err("SAP Start failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14775 | goto end; |
| 14776 | } |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14777 | hdd_err("SAP Start Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14778 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14779 | if (hostapd_state->bss_state == BSS_START) { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14780 | policy_mgr_incr_active_session(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14781 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14782 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 14783 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14784 | ap_adapter->device_mode, |
| 14785 | true); |
| 14786 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14787 | } |
| 14788 | end: |
| 14789 | mutex_unlock(&hdd_ctx->sap_lock); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14790 | } |
| 14791 | |
| 14792 | /** |
| 14793 | * hdd_check_and_restart_sap_with_non_dfs_acs() - Restart SAP |
| 14794 | * with non dfs acs |
| 14795 | * |
| 14796 | * Restarts SAP in non-DFS ACS mode when STA-AP mode DFS is not supported |
| 14797 | * |
| 14798 | * Return: None |
| 14799 | */ |
| 14800 | void hdd_check_and_restart_sap_with_non_dfs_acs(void) |
| 14801 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14802 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14803 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 14804 | struct cds_context *cds_ctx; |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14805 | uint8_t restart_chan; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14806 | |
| 14807 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14808 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14809 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14810 | return; |
| 14811 | } |
| 14812 | |
| 14813 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 14814 | if (!cds_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14815 | hdd_err("Invalid CDS Context"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14816 | return; |
| 14817 | } |
| 14818 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14819 | if (policy_mgr_get_concurrency_mode(hdd_ctx->psoc) |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14820 | != (QDF_STA_MASK | QDF_SAP_MASK)) { |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 14821 | hdd_debug("Concurrency mode is not SAP"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14822 | return; |
| 14823 | } |
| 14824 | |
| 14825 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 14826 | if (ap_adapter && |
| 14827 | test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags) && |
| 14828 | wlan_reg_is_dfs_ch(hdd_ctx->pdev, |
| 14829 | ap_adapter->session.ap.operating_channel)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14830 | |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14831 | 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] | 14832 | |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14833 | restart_chan = |
| 14834 | hdd_get_safe_channel_from_pcl_and_acs_range(ap_adapter); |
| 14835 | if (!restart_chan || |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 14836 | wlan_reg_is_dfs_ch(hdd_ctx->pdev, restart_chan)) |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14837 | restart_chan = SAP_DEFAULT_5GHZ_CHANNEL; |
| 14838 | |
| 14839 | hdd_switch_sap_channel(ap_adapter, restart_chan, true); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14840 | } |
| 14841 | } |
| 14842 | |
| 14843 | /** |
| 14844 | * hdd_set_connection_in_progress() - to set the connection in |
| 14845 | * progress flag |
| 14846 | * @value: value to set |
| 14847 | * |
| 14848 | * This function will set the passed value to connection in progress flag. |
| 14849 | * If value is previously being set to true then no need to set it again. |
| 14850 | * |
| 14851 | * Return: true if value is being set correctly and false otherwise. |
| 14852 | */ |
| 14853 | bool hdd_set_connection_in_progress(bool value) |
| 14854 | { |
| 14855 | bool status = true; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14856 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14857 | |
| 14858 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14859 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14860 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14861 | return false; |
| 14862 | } |
| 14863 | |
| 14864 | qdf_spin_lock(&hdd_ctx->connection_status_lock); |
| 14865 | /* |
| 14866 | * if the value is set to true previously and if someone is |
| 14867 | * trying to make it true again then it could be some race |
| 14868 | * condition being triggered. Avoid this situation by returning |
| 14869 | * false |
| 14870 | */ |
| 14871 | if (hdd_ctx->connection_in_progress && value) |
| 14872 | status = false; |
| 14873 | else |
| 14874 | hdd_ctx->connection_in_progress = value; |
| 14875 | qdf_spin_unlock(&hdd_ctx->connection_status_lock); |
| 14876 | return status; |
| 14877 | } |
| 14878 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14879 | 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] | 14880 | { |
| 14881 | if (!adapter) { |
| 14882 | hdd_err("Invalid adapter"); |
| 14883 | return -EINVAL; |
| 14884 | } |
| 14885 | hdd_info("Send MCC P2P QUOTA to WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14886 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 14887 | WMA_VDEV_MCC_SET_TIME_QUOTA, |
| 14888 | set_value, VDEV_CMD); |
| 14889 | return 0; |
| 14890 | |
| 14891 | } |
| 14892 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14893 | 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] | 14894 | { |
| 14895 | if (!adapter) { |
| 14896 | hdd_err("Invalid adapter"); |
| 14897 | return -EINVAL; |
| 14898 | } |
| 14899 | |
| 14900 | hdd_info("Send MCC latency WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14901 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 14902 | WMA_VDEV_MCC_SET_TIME_LATENCY, |
| 14903 | set_value, VDEV_CMD); |
| 14904 | return 0; |
| 14905 | } |
| 14906 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14907 | 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] | 14908 | *psoc, uint8_t vdev_id) |
| 14909 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14910 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14911 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 14912 | |
| 14913 | /* |
| 14914 | * Currently PSOC is not being used. But this logic will |
| 14915 | * change once we have the converged implementation of |
| 14916 | * HDD context per PSOC in place. This would break if |
| 14917 | * multiple vdev objects reuse the vdev id. |
| 14918 | */ |
| 14919 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 14920 | if (!adapter) |
| 14921 | hdd_err("Get adapter by vdev id failed"); |
| 14922 | |
| 14923 | return adapter; |
| 14924 | } |
| 14925 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14926 | 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] | 14927 | int8_t *rssi, int8_t *snr) |
| 14928 | { |
| 14929 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14930 | mac_handle_t mac_handle; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 14931 | struct csr_roam_profile *roam_profile; |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 14932 | |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 14933 | roam_profile = hdd_roam_profile(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14934 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 14935 | status = sme_get_rssi_snr_by_bssid(mac_handle, |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 14936 | roam_profile, bssid, rssi, snr); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 14937 | if (QDF_STATUS_SUCCESS != status) { |
| 14938 | hdd_warn("sme_get_rssi_snr_by_bssid failed"); |
| 14939 | return -EINVAL; |
| 14940 | } |
| 14941 | |
| 14942 | return 0; |
| 14943 | } |
| 14944 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 14945 | /** |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14946 | * hdd_reset_limit_off_chan() - reset limit off-channel command parameters |
| 14947 | * @adapter - HDD adapter |
| 14948 | * |
| 14949 | * Return: 0 on success and non zero value on failure |
| 14950 | */ |
| 14951 | int hdd_reset_limit_off_chan(struct hdd_adapter *adapter) |
| 14952 | { |
| 14953 | struct hdd_context *hdd_ctx; |
| 14954 | int ret; |
| 14955 | QDF_STATUS status; |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 14956 | uint8_t sys_pref = 0; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14957 | |
| 14958 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 14959 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 14960 | if (ret < 0) |
| 14961 | return ret; |
| 14962 | |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 14963 | ucfg_policy_mgr_get_sys_pref(hdd_ctx->psoc, |
| 14964 | &sys_pref); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14965 | /* set the system preferece to default */ |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 14966 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->psoc, sys_pref); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14967 | |
| 14968 | /* clear the bitmap */ |
| 14969 | adapter->active_ac = 0; |
| 14970 | |
| 14971 | hdd_debug("reset ac_bitmap for session %hu active_ac %0x", |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14972 | adapter->session_id, adapter->active_ac); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14973 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14974 | status = sme_send_limit_off_channel_params(hdd_ctx->mac_handle, |
| 14975 | adapter->session_id, |
| 14976 | false, 0, 0, false); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14977 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 14978 | hdd_err("failed to reset limit off chan params"); |
| 14979 | ret = -EINVAL; |
| 14980 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 14981 | |
| 14982 | return ret; |
| 14983 | } |
| 14984 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14985 | /** |
| 14986 | * hdd_start_driver_ops_timer() - Starts driver ops inactivity timer |
| 14987 | * @drv_op: Enum indicating driver op |
| 14988 | * |
| 14989 | * Return: none |
| 14990 | */ |
| 14991 | void hdd_start_driver_ops_timer(int drv_op) |
| 14992 | { |
| 14993 | memset(drv_ops_string, 0, MAX_OPS_NAME_STRING_SIZE); |
| 14994 | switch (drv_op) { |
Jeff Johnson | 5794d4f | 2018-12-04 11:57:09 -0800 | [diff] [blame] | 14995 | case HDD_DRV_OP_PROBE: |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14996 | memcpy(drv_ops_string, "probe", sizeof("probe")); |
| 14997 | break; |
Jeff Johnson | 5794d4f | 2018-12-04 11:57:09 -0800 | [diff] [blame] | 14998 | case HDD_DRV_OP_REMOVE: |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14999 | memcpy(drv_ops_string, "remove", sizeof("remove")); |
| 15000 | break; |
Jeff Johnson | 5794d4f | 2018-12-04 11:57:09 -0800 | [diff] [blame] | 15001 | case HDD_DRV_OP_SHUTDOWN: |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 15002 | memcpy(drv_ops_string, "shutdown", sizeof("shutdown")); |
| 15003 | break; |
Jeff Johnson | 5794d4f | 2018-12-04 11:57:09 -0800 | [diff] [blame] | 15004 | case HDD_DRV_OP_REINIT: |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 15005 | memcpy(drv_ops_string, "reinit", sizeof("reinit")); |
| 15006 | break; |
Jeff Johnson | 5794d4f | 2018-12-04 11:57:09 -0800 | [diff] [blame] | 15007 | case HDD_DRV_OP_IFF_UP: |
Arunk Khandavalli | e9ef42a | 2017-10-04 14:49:51 +0530 | [diff] [blame] | 15008 | memcpy(drv_ops_string, "iff_up", sizeof("iff_up")); |
| 15009 | break; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 15010 | } |
| 15011 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 15012 | hdd_drv_ops_task = current; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 15013 | qdf_timer_start(&hdd_drv_ops_inactivity_timer, |
Dustin Brown | cfc54fe | 2018-06-18 16:17:41 -0700 | [diff] [blame] | 15014 | HDD_OPS_INACTIVITY_TIMEOUT * qdf_timer_get_multiplier()); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 15015 | } |
| 15016 | |
| 15017 | /** |
| 15018 | * hdd_stop_driver_ops_timer() - Stops driver ops inactivity timer |
| 15019 | * |
| 15020 | * Return: none |
| 15021 | */ |
| 15022 | void hdd_stop_driver_ops_timer(void) |
| 15023 | { |
| 15024 | qdf_timer_sync_cancel(&hdd_drv_ops_inactivity_timer); |
| 15025 | } |
| 15026 | |
| 15027 | /** |
| 15028 | * hdd_drv_ops_inactivity_handler() - Timeout handler for driver ops |
| 15029 | * inactivity timer |
| 15030 | * |
| 15031 | * Return: None |
| 15032 | */ |
| 15033 | void hdd_drv_ops_inactivity_handler(void) |
| 15034 | { |
Rajeev Kumar | 4471f1b | 2018-06-08 14:18:28 -0700 | [diff] [blame] | 15035 | 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] | 15036 | __func__, HDD_OPS_INACTIVITY_TIMEOUT/1000, drv_ops_string); |
| 15037 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 15038 | if (hdd_drv_ops_task) { |
| 15039 | printk("Call stack for \"%s\"\n", hdd_drv_ops_task->comm); |
| 15040 | qdf_print_thread_trace(hdd_drv_ops_task); |
| 15041 | } else { |
| 15042 | hdd_err("hdd_drv_ops_task is null"); |
| 15043 | } |
| 15044 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 15045 | /* Driver shutdown is stuck, no recovery possible at this point */ |
| 15046 | if (0 == qdf_mem_cmp(&drv_ops_string[0], "shutdown", |
| 15047 | sizeof("shutdown"))) |
| 15048 | QDF_BUG(0); |
| 15049 | |
Rajeev Kumar | 1e57b9c | 2018-01-04 16:17:10 -0800 | [diff] [blame] | 15050 | if (cds_is_fw_down()) { |
| 15051 | hdd_err("FW is down"); |
| 15052 | return; |
| 15053 | } |
| 15054 | |
Dustin Brown | 83044c2 | 2018-08-13 15:00:44 -0700 | [diff] [blame] | 15055 | cds_trigger_recovery(QDF_REASON_UNSPECIFIED); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 15056 | } |
| 15057 | |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 15058 | /** |
| 15059 | * hdd_set_rx_mode_rps() - Enable/disable RPS in SAP mode |
| 15060 | * @struct hdd_context *hdd_ctx |
| 15061 | * @struct hdd_adapter *padapter |
| 15062 | * @bool enble |
| 15063 | * |
| 15064 | * Return: none |
| 15065 | */ |
| 15066 | void hdd_set_rx_mode_rps(bool enable) |
| 15067 | { |
| 15068 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 15069 | struct hdd_context *hdd_ctx; |
| 15070 | struct hdd_adapter *adapter; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 15071 | |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 15072 | if (!cds_cfg) |
| 15073 | return; |
| 15074 | |
| 15075 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 15076 | if (!hdd_ctx) |
| 15077 | return; |
| 15078 | |
| 15079 | adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 15080 | if (!adapter) |
| 15081 | return; |
| 15082 | |
| 15083 | if (!hdd_ctx->rps && cds_cfg->uc_offload_enabled) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 15084 | if (enable && !cds_cfg->rps_enabled) |
| 15085 | hdd_send_rps_ind(adapter); |
| 15086 | else if (!enable && cds_cfg->rps_enabled) |
| 15087 | hdd_send_rps_disable_ind(adapter); |
| 15088 | } |
| 15089 | } |
| 15090 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15091 | /* Register the module init/exit functions */ |
| 15092 | module_init(hdd_module_init); |
| 15093 | module_exit(hdd_module_exit); |
| 15094 | |
| 15095 | MODULE_LICENSE("Dual BSD/GPL"); |
| 15096 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 15097 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 15098 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15099 | static const struct kernel_param_ops con_mode_ops = { |
| 15100 | .set = con_mode_handler, |
| 15101 | .get = param_get_int, |
| 15102 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15103 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15104 | static const struct kernel_param_ops con_mode_ftm_ops = { |
| 15105 | .set = con_mode_handler_ftm, |
| 15106 | .get = param_get_int, |
| 15107 | }; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 15108 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15109 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15110 | static const struct kernel_param_ops con_mode_monitor_ops = { |
| 15111 | .set = con_mode_handler_monitor, |
| 15112 | .get = param_get_int, |
| 15113 | }; |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15114 | #endif |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 15115 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15116 | static const struct kernel_param_ops fwpath_ops = { |
| 15117 | .set = fwpath_changed_handler, |
| 15118 | .get = param_get_string, |
| 15119 | }; |
| 15120 | |
| 15121 | module_param_cb(con_mode, &con_mode_ops, &con_mode, |
| 15122 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 15123 | |
| 15124 | module_param_cb(con_mode_ftm, &con_mode_ftm_ops, &con_mode_ftm, |
| 15125 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 15126 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15127 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15128 | module_param_cb(con_mode_monitor, &con_mode_monitor_ops, &con_mode_monitor, |
| 15129 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15130 | #endif |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15131 | |
| 15132 | module_param_cb(fwpath, &fwpath_ops, &fwpath, |
| 15133 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15134 | |
| 15135 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 15136 | |
| 15137 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 15138 | |
| 15139 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |