Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4 | * Permission to use, copy, modify, and/or distribute this software for |
| 5 | * any purpose with or without fee is hereby granted, provided that the |
| 6 | * above copyright notice and this permission notice appear in all |
| 7 | * copies. |
| 8 | * |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 10 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 11 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 12 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 13 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 14 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 15 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 16 | * PERFORMANCE OF THIS SOFTWARE. |
| 17 | */ |
| 18 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19 | /** |
| 20 | * DOC: wlan_hdd_main.c |
| 21 | * |
| 22 | * WLAN Host Device Driver implementation |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | /* Include Files */ |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 27 | #include "cfg_ucfg_api.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 28 | #include <wlan_hdd_includes.h> |
| 29 | #include <cds_api.h> |
| 30 | #include <cds_sched.h> |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 31 | #include <linux/cpu.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 32 | #include <linux/etherdevice.h> |
| 33 | #include <linux/firmware.h> |
| 34 | #include <wlan_hdd_tx_rx.h> |
| 35 | #include <wni_api.h> |
| 36 | #include <wlan_hdd_cfg.h> |
| 37 | #include <wlan_ptt_sock_svc.h> |
| 38 | #include <dbglog_host.h> |
| 39 | #include <wlan_logging_sock_svc.h> |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 40 | #include <wlan_roam_debug.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 41 | #include <wlan_hdd_wowl.h> |
| 42 | #include <wlan_hdd_misc.h> |
| 43 | #include <wlan_hdd_wext.h> |
| 44 | #include "wlan_hdd_trace.h" |
| 45 | #include "wlan_hdd_ioctl.h" |
| 46 | #include "wlan_hdd_ftm.h" |
| 47 | #include "wlan_hdd_power.h" |
| 48 | #include "wlan_hdd_stats.h" |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 49 | #include "wlan_hdd_scan.h" |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 50 | #include <wlan_osif_request_manager.h> |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 51 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 52 | #include "qdf_debug_domain.h" |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 53 | #endif |
Dustin Brown | d424194 | 2018-02-26 12:51:37 -0800 | [diff] [blame] | 54 | #include "qdf_str.h" |
| 55 | #include "qdf_trace.h" |
| 56 | #include "qdf_types.h" |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 57 | #include <cdp_txrx_peer_ops.h> |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 58 | #include <cdp_txrx_misc.h> |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 59 | #include <cdp_txrx_stats.h> |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 60 | #include "cdp_txrx_flow_ctrl_legacy.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 61 | |
| 62 | #include <net/addrconf.h> |
| 63 | #include <linux/wireless.h> |
| 64 | #include <net/cfg80211.h> |
| 65 | #include <linux/inetdevice.h> |
| 66 | #include <net/addrconf.h> |
| 67 | #include "wlan_hdd_cfg80211.h" |
| 68 | #include "wlan_hdd_ext_scan.h" |
| 69 | #include "wlan_hdd_p2p.h" |
| 70 | #include <linux/rtnetlink.h> |
| 71 | #include "sap_api.h" |
| 72 | #include <linux/semaphore.h> |
| 73 | #include <linux/ctype.h> |
| 74 | #include <linux/compat.h> |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 75 | #include <linux/reboot.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 76 | #ifdef MSM_PLATFORM |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 77 | #include <soc/qcom/subsystem_restart.h> |
| 78 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 79 | #include <wlan_hdd_hostapd.h> |
| 80 | #include <wlan_hdd_softap_tx_rx.h> |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 81 | #include <wlan_hdd_green_ap.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 82 | #include "cfg_api.h" |
| 83 | #include "qwlan_version.h" |
| 84 | #include "wma_types.h" |
| 85 | #include "wlan_hdd_tdls.h" |
| 86 | #ifdef FEATURE_WLAN_CH_AVOID |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 87 | #include "cds_regdomain.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 88 | #endif /* FEATURE_WLAN_CH_AVOID */ |
Dustin Brown | ce46d1d | 2017-08-15 13:34:24 -0700 | [diff] [blame] | 89 | #include "cdp_txrx_flow_ctrl_v2.h" |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 90 | #include "pld_common.h" |
Tushnim Bhattacharyya | 15596cf | 2016-02-12 11:57:02 -0800 | [diff] [blame] | 91 | #include "wlan_hdd_ocb.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 92 | #include "wlan_hdd_nan.h" |
| 93 | #include "wlan_hdd_debugfs.h" |
| 94 | #include "wlan_hdd_driver_ops.h" |
| 95 | #include "epping_main.h" |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 96 | #include "wlan_hdd_data_stall_detection.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 97 | |
| 98 | #include <wlan_hdd_ipa.h> |
| 99 | #include "hif.h" |
| 100 | #include "wma.h" |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 101 | #include "wlan_policy_mgr_api.h" |
Manikandan Mohan | dcc21ba | 2016-03-15 14:31:56 -0700 | [diff] [blame] | 102 | #include "wlan_hdd_tsf.h" |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 103 | #include "bmi.h" |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 104 | #include <wlan_hdd_regulatory.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 105 | #include "wlan_hdd_lpass.h" |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 106 | #include "nan_api.h" |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 107 | #include <wlan_hdd_napi.h> |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 108 | #include "wlan_hdd_disa.h" |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 109 | #include <dispatcher_init_deinit.h> |
Rajeev Kumar | 699debf | 2017-01-06 14:17:00 -0800 | [diff] [blame] | 110 | #include "wlan_hdd_object_manager.h" |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 111 | #include "cds_utils.h" |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 112 | #include <cdp_txrx_handle.h> |
Sandeep Puligilla | fdd201e | 2017-02-02 18:43:46 -0800 | [diff] [blame] | 113 | #include <qca_vendor.h> |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 114 | #include "wlan_pmo_ucfg_api.h" |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 115 | #include "sir_api.h" |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 116 | #include "os_if_wifi_pos.h" |
| 117 | #include "wifi_pos_api.h" |
| 118 | #include "wlan_hdd_oemdata.h" |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 119 | #include "wlan_hdd_he.h" |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 120 | #include "os_if_nan.h" |
| 121 | #include "nan_public_structs.h" |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 122 | #include "wlan_reg_ucfg_api.h" |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 123 | #include "wlan_dfs_ucfg_api.h" |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 124 | #include "wlan_hdd_rx_monitor.h" |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 125 | #include "sme_power_save_api.h" |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 126 | #include "enet.h" |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 127 | #include <cdp_txrx_cmn_struct.h> |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 128 | #include <dp_txrx.h> |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 129 | #include "wlan_hdd_sysfs.h" |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 130 | #include "wlan_disa_ucfg_api.h" |
Wu Gao | 52084c1 | 2018-05-17 20:47:11 +0800 | [diff] [blame] | 131 | #include "wlan_disa_obj_mgmt_api.h" |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 132 | #include "wlan_action_oui_ucfg_api.h" |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 133 | #include "wlan_ipa_ucfg_api.h" |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 134 | #include <target_if.h> |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 135 | #include "wlan_hdd_nud_tracking.h" |
Nachiket Kukade | d0dd62e | 2018-05-21 18:39:22 +0530 | [diff] [blame] | 136 | #include "wlan_hdd_apf.h" |
Varun Reddy Yeturu | e93d246 | 2018-05-22 13:54:52 -0700 | [diff] [blame] | 137 | #include "wlan_hdd_twt.h" |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 138 | #include "qc_sap_ioctl.h" |
Sandeep Puligilla | c5609d5 | 2018-05-17 19:23:41 -0700 | [diff] [blame] | 139 | #include "wlan_mlme_main.h" |
Wu Gao | e568979 | 2018-07-05 19:20:13 +0800 | [diff] [blame] | 140 | #include "wlan_p2p_cfg_api.h" |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 141 | #include "wlan_tdls_cfg_api.h" |
Qiwei Cai | e689a26 | 2018-07-26 15:50:22 +0800 | [diff] [blame] | 142 | #include <wlan_hdd_rssi_monitor.h> |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 143 | #include "wlan_mlme_ucfg_api.h" |
| 144 | #include "wlan_mlme_public_struct.h" |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 145 | #ifdef CNSS_GENL |
| 146 | #include <net/cnss_nl.h> |
| 147 | #endif |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 148 | #include "wlan_reg_ucfg_api.h" |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 149 | #include "wlan_ocb_ucfg_api.h" |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 150 | #include <wlan_hdd_spectralscan.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 151 | #ifdef MODULE |
| 152 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 153 | #else |
| 154 | #define WLAN_MODULE_NAME "wlan" |
| 155 | #endif |
| 156 | |
| 157 | #ifdef TIMER_MANAGER |
| 158 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 159 | #else |
| 160 | #define TIMER_MANAGER_STR "" |
| 161 | #endif |
| 162 | |
| 163 | #ifdef MEMORY_DEBUG |
| 164 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 165 | #else |
| 166 | #define MEMORY_DEBUG_STR "" |
| 167 | #endif |
| 168 | |
Dustin Brown | c1034df | 2018-02-07 14:51:32 -0800 | [diff] [blame] | 169 | #ifdef PANIC_ON_BUG |
| 170 | #define PANIC_ON_BUG_STR " +PANIC_ON_BUG" |
| 171 | #else |
| 172 | #define PANIC_ON_BUG_STR "" |
| 173 | #endif |
| 174 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 175 | bool g_is_system_reboot_triggered; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 176 | int wlan_start_ret_val; |
| 177 | static DECLARE_COMPLETION(wlan_start_comp); |
| 178 | static unsigned int dev_num = 1; |
| 179 | static struct cdev wlan_hdd_state_cdev; |
| 180 | static struct class *class; |
| 181 | static dev_t device; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 182 | #ifndef MODULE |
| 183 | static struct gwlan_loader *wlan_loader; |
| 184 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 185 | struct kobj_attribute *attr, |
| 186 | const char *buf, size_t count); |
| 187 | struct gwlan_loader { |
| 188 | bool loaded_state; |
| 189 | struct kobject *boot_wlan_obj; |
| 190 | struct attribute_group *attr_group; |
| 191 | }; |
| 192 | |
| 193 | static struct kobj_attribute wlan_boot_attribute = |
| 194 | __ATTR(boot_wlan, 0220, NULL, wlan_boot_cb); |
| 195 | |
| 196 | static struct attribute *attrs[] = { |
| 197 | &wlan_boot_attribute.attr, |
| 198 | NULL, |
| 199 | }; |
| 200 | |
| 201 | #define MODULE_INITIALIZED 1 |
| 202 | #endif |
| 203 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 204 | #define HDD_OPS_INACTIVITY_TIMEOUT (120000) |
| 205 | #define MAX_OPS_NAME_STRING_SIZE 20 |
Rajeev Kumar | 6d0b2ea | 2017-12-26 17:55:33 -0800 | [diff] [blame] | 206 | #define RATE_LIMIT_ERROR_LOG (256) |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 207 | |
| 208 | static qdf_timer_t hdd_drv_ops_inactivity_timer; |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 209 | static struct task_struct *hdd_drv_ops_task; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 210 | static char drv_ops_string[MAX_OPS_NAME_STRING_SIZE]; |
| 211 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 212 | /* the Android framework expects this param even though we don't use it */ |
| 213 | #define BUF_LEN 20 |
| 214 | static char fwpath_buffer[BUF_LEN]; |
| 215 | static struct kparam_string fwpath = { |
| 216 | .string = fwpath_buffer, |
| 217 | .maxlen = BUF_LEN, |
| 218 | }; |
| 219 | |
| 220 | static char *country_code; |
| 221 | static int enable_11d = -1; |
| 222 | static int enable_dfs_chan_scan = -1; |
| 223 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 224 | /* |
| 225 | * spinlock for synchronizing asynchronous request/response |
| 226 | * (full description of use in wlan_hdd_main.h) |
| 227 | */ |
| 228 | DEFINE_SPINLOCK(hdd_context_lock); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 229 | DEFINE_MUTEX(hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 230 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 231 | #define WLAN_NLINK_CESIUM 30 |
| 232 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 233 | static qdf_wake_lock_t wlan_wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 234 | |
| 235 | #define WOW_MAX_FILTER_LISTS 1 |
| 236 | #define WOW_MAX_FILTERS_PER_LIST 4 |
| 237 | #define WOW_MIN_PATTERN_SIZE 6 |
| 238 | #define WOW_MAX_PATTERN_SIZE 64 |
| 239 | |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 240 | /* max peer can be tdls peers + self peer + bss peer */ |
| 241 | #define HDD_MAX_VDEV_PEER_COUNT (HDD_MAX_NUM_TDLS_STA + 2) |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 242 | #define IS_IDLE_STOP (!cds_is_driver_unloading() && \ |
| 243 | !cds_is_driver_recovering() && !cds_is_driver_loading()) |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 244 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 245 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 246 | static const struct wiphy_wowlan_support wowlan_support_reg_init = { |
| 247 | .flags = WIPHY_WOWLAN_ANY | |
| 248 | WIPHY_WOWLAN_MAGIC_PKT | |
| 249 | WIPHY_WOWLAN_DISCONNECT | |
| 250 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 251 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 252 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 253 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 254 | WIPHY_WOWLAN_RFKILL_RELEASE, |
| 255 | .n_patterns = WOW_MAX_FILTER_LISTS * WOW_MAX_FILTERS_PER_LIST, |
| 256 | .pattern_min_len = WOW_MIN_PATTERN_SIZE, |
| 257 | .pattern_max_len = WOW_MAX_PATTERN_SIZE, |
| 258 | }; |
| 259 | #endif |
| 260 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 261 | static const struct category_info cinfo[MAX_SUPPORTED_CATEGORY] = { |
| 262 | [QDF_MODULE_ID_TLSHIM] = {QDF_TRACE_LEVEL_ALL}, |
| 263 | [QDF_MODULE_ID_WMI] = {QDF_TRACE_LEVEL_ALL}, |
| 264 | [QDF_MODULE_ID_HTT] = {QDF_TRACE_LEVEL_ALL}, |
| 265 | [QDF_MODULE_ID_HDD] = {QDF_TRACE_LEVEL_ALL}, |
| 266 | [QDF_MODULE_ID_SME] = {QDF_TRACE_LEVEL_ALL}, |
| 267 | [QDF_MODULE_ID_PE] = {QDF_TRACE_LEVEL_ALL}, |
| 268 | [QDF_MODULE_ID_WMA] = {QDF_TRACE_LEVEL_ALL}, |
| 269 | [QDF_MODULE_ID_SYS] = {QDF_TRACE_LEVEL_ALL}, |
| 270 | [QDF_MODULE_ID_QDF] = {QDF_TRACE_LEVEL_ALL}, |
| 271 | [QDF_MODULE_ID_SAP] = {QDF_TRACE_LEVEL_ALL}, |
| 272 | [QDF_MODULE_ID_HDD_SOFTAP] = {QDF_TRACE_LEVEL_ALL}, |
| 273 | [QDF_MODULE_ID_HDD_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 274 | [QDF_MODULE_ID_HDD_SAP_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 275 | [QDF_MODULE_ID_HIF] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 276 | [QDF_MODULE_ID_HTC] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 277 | [QDF_MODULE_ID_TXRX] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 278 | [QDF_MODULE_ID_QDF_DEVICE] = {QDF_TRACE_LEVEL_ALL}, |
| 279 | [QDF_MODULE_ID_CFG] = {QDF_TRACE_LEVEL_ALL}, |
| 280 | [QDF_MODULE_ID_BMI] = {QDF_TRACE_LEVEL_ALL}, |
| 281 | [QDF_MODULE_ID_EPPING] = {QDF_TRACE_LEVEL_ALL}, |
| 282 | [QDF_MODULE_ID_QVIT] = {QDF_TRACE_LEVEL_ALL}, |
| 283 | [QDF_MODULE_ID_DP] = {QDF_TRACE_LEVEL_ALL}, |
| 284 | [QDF_MODULE_ID_SOC] = {QDF_TRACE_LEVEL_ALL}, |
| 285 | [QDF_MODULE_ID_OS_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 286 | [QDF_MODULE_ID_TARGET_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 287 | [QDF_MODULE_ID_SCHEDULER] = {QDF_TRACE_LEVEL_ALL}, |
| 288 | [QDF_MODULE_ID_MGMT_TXRX] = {QDF_TRACE_LEVEL_ALL}, |
| 289 | [QDF_MODULE_ID_PMO] = {QDF_TRACE_LEVEL_ALL}, |
| 290 | [QDF_MODULE_ID_SCAN] = {QDF_TRACE_LEVEL_ALL}, |
| 291 | [QDF_MODULE_ID_POLICY_MGR] = {QDF_TRACE_LEVEL_ALL}, |
| 292 | [QDF_MODULE_ID_P2P] = {QDF_TRACE_LEVEL_ALL}, |
| 293 | [QDF_MODULE_ID_TDLS] = {QDF_TRACE_LEVEL_ALL}, |
| 294 | [QDF_MODULE_ID_REGULATORY] = {QDF_TRACE_LEVEL_ALL}, |
| 295 | [QDF_MODULE_ID_SERIALIZATION] = {QDF_TRACE_LEVEL_ALL}, |
Arif Hussain | fde76e7 | 2017-09-05 16:58:23 -0700 | [diff] [blame] | 296 | [QDF_MODULE_ID_DFS] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar | ca8ef9d | 2017-10-06 10:43:21 -0700 | [diff] [blame] | 297 | [QDF_MODULE_ID_OBJ_MGR] = {QDF_TRACE_LEVEL_ALL}, |
Deepak Dhamdhere | f918d42 | 2017-07-06 12:56:29 -0700 | [diff] [blame] | 298 | [QDF_MODULE_ID_ROAM_DEBUG] = {QDF_TRACE_LEVEL_ALL}, |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 299 | [QDF_MODULE_ID_GREEN_AP] = {QDF_TRACE_LEVEL_ALL}, |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 300 | [QDF_MODULE_ID_OCB] = {QDF_TRACE_LEVEL_ALL}, |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 301 | [QDF_MODULE_ID_IPA] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 302 | [QDF_MODULE_ID_ACTION_OUI] = {QDF_TRACE_LEVEL_ALL}, |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 303 | [QDF_MODULE_ID_CONFIG] = {QDF_TRACE_LEVEL_ALL}, |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 304 | [QDF_MODULE_ID_MLME] = {QDF_TRACE_LEVEL_ALL}, |
Ashish Kumar Dhanotiya | 8d039c8 | 2018-07-11 20:41:14 +0530 | [diff] [blame] | 305 | [QDF_MODULE_ID_TARGET] = {QDF_TRACE_LEVEL_ALL}, |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 306 | }; |
| 307 | |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 308 | struct notifier_block hdd_netdev_notifier; |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 309 | struct notifier_block system_reboot_notifier; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 310 | |
| 311 | struct sock *cesium_nl_srv_sock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 312 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 313 | static void wlan_hdd_auto_shutdown_cb(void); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 314 | #endif |
| 315 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 316 | void hdd_start_complete(int ret) |
| 317 | { |
| 318 | wlan_start_ret_val = ret; |
| 319 | |
| 320 | complete(&wlan_start_comp); |
| 321 | } |
| 322 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 323 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 324 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 325 | * @hdd_ctx: pointer to struct hdd_context |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 326 | * |
| 327 | * Return: none |
| 328 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 329 | static void hdd_set_rps_cpu_mask(struct hdd_context *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 330 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 331 | struct hdd_adapter *adapter; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 332 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 333 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 334 | hdd_send_rps_ind(adapter); |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 335 | } |
| 336 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 337 | #ifdef QCA_HL_NETDEV_FLOW_CONTROL |
| 338 | void wlan_hdd_mod_fc_timer(struct hdd_adapter *adapter, |
| 339 | enum netif_action_type action) |
| 340 | { |
| 341 | if (!adapter->tx_flow_timer_initialized) |
| 342 | return; |
| 343 | |
| 344 | if (action == WLAN_WAKE_NON_PRIORITY_QUEUE) { |
| 345 | qdf_mc_timer_stop(&adapter->tx_flow_control_timer); |
| 346 | } else if (action == WLAN_STOP_NON_PRIORITY_QUEUE) { |
| 347 | QDF_STATUS status = |
| 348 | qdf_mc_timer_start(&adapter->tx_flow_control_timer, |
| 349 | WLAN_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME); |
| 350 | |
| 351 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 352 | hdd_err("Failed to start tx_flow_control_timer"); |
| 353 | else |
| 354 | adapter-> |
| 355 | hdd_stats.tx_rx_stats.txflow_timer_cnt++; |
| 356 | |
| 357 | adapter->hdd_stats.tx_rx_stats.txflow_pause_cnt++; |
| 358 | adapter->hdd_stats.tx_rx_stats.is_txflow_paused = true; |
| 359 | } |
| 360 | } |
| 361 | #endif /* QCA_HL_NETDEV_FLOW_CONTROL */ |
| 362 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 363 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 364 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 365 | * @vdev_id: vdev_id |
| 366 | * @action: action type |
| 367 | * @reason: reason type |
| 368 | * |
| 369 | * Return: none |
| 370 | */ |
| 371 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 372 | enum netif_action_type action, enum netif_reason_type reason) |
| 373 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 374 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 375 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 376 | |
| 377 | if (!hdd_ctx) { |
| 378 | hdd_err("hdd ctx is NULL"); |
| 379 | return; |
| 380 | } |
| 381 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 382 | wlan_hdd_mod_fc_timer(adapter, action); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 383 | wlan_hdd_netif_queue_control(adapter, action, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | /* |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 387 | * Store WLAN driver version and timestamp info in global variables such that |
| 388 | * crash debugger can extract them from driver debug symbol and crashdump for |
| 389 | * post processing |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 390 | */ |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 391 | #ifdef BUILD_TAG |
| 392 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR "; " BUILD_TAG; |
| 393 | #else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 394 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR; |
Naveen Rawat | 9383625 | 2017-06-20 16:30:59 -0700 | [diff] [blame] | 395 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 396 | |
| 397 | /** |
| 398 | * hdd_device_mode_to_string() - return string conversion of device mode |
| 399 | * @device_mode: device mode |
| 400 | * |
| 401 | * This utility function helps log string conversion of device mode. |
| 402 | * |
| 403 | * Return: string conversion of device mode, if match found; |
| 404 | * "Unknown" otherwise. |
| 405 | */ |
| 406 | const char *hdd_device_mode_to_string(uint8_t device_mode) |
| 407 | { |
| 408 | switch (device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 409 | CASE_RETURN_STRING(QDF_STA_MODE); |
| 410 | CASE_RETURN_STRING(QDF_SAP_MODE); |
| 411 | CASE_RETURN_STRING(QDF_P2P_CLIENT_MODE); |
| 412 | CASE_RETURN_STRING(QDF_P2P_GO_MODE); |
| 413 | CASE_RETURN_STRING(QDF_FTM_MODE); |
| 414 | CASE_RETURN_STRING(QDF_IBSS_MODE); |
| 415 | CASE_RETURN_STRING(QDF_P2P_DEVICE_MODE); |
| 416 | CASE_RETURN_STRING(QDF_OCB_MODE); |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 417 | CASE_RETURN_STRING(QDF_NDI_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 418 | default: |
| 419 | return "Unknown"; |
| 420 | } |
| 421 | } |
| 422 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 423 | /** |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 424 | * hdd_get_valid_chan() - return current chan list from regulatory. |
| 425 | * @hdd_ctx: HDD context |
| 426 | * @chan_list: buf hold returned chan list |
| 427 | * @chan_num: input buf size and output returned chan num |
| 428 | * |
| 429 | * This function helps get current available chan list from regulatory |
| 430 | * module. It excludes the "disabled" and "invalid" channels. |
| 431 | * |
| 432 | * Return: 0 for success. |
| 433 | */ |
| 434 | static int hdd_get_valid_chan(struct hdd_context *hdd_ctx, |
| 435 | uint8_t *chan_list, |
| 436 | uint32_t *chan_num) |
| 437 | { |
| 438 | int i = 0, j = 0; |
| 439 | struct regulatory_channel *cur_chan_list; |
| 440 | struct wlan_objmgr_pdev *pdev; |
| 441 | |
| 442 | if (!hdd_ctx || !hdd_ctx->hdd_pdev || !chan_list || !chan_num) |
| 443 | return -EINVAL; |
| 444 | |
| 445 | pdev = hdd_ctx->hdd_pdev; |
| 446 | cur_chan_list = qdf_mem_malloc(NUM_CHANNELS * |
| 447 | sizeof(struct regulatory_channel)); |
| 448 | if (!cur_chan_list) |
| 449 | return -ENOMEM; |
| 450 | |
| 451 | if (wlan_reg_get_current_chan_list(pdev, cur_chan_list) != |
| 452 | QDF_STATUS_SUCCESS) { |
| 453 | qdf_mem_free(cur_chan_list); |
| 454 | return -EINVAL; |
| 455 | } |
| 456 | |
| 457 | for (i = 0; i < NUM_CHANNELS; i++) { |
| 458 | uint32_t ch = cur_chan_list[i].chan_num; |
| 459 | enum channel_state state = wlan_reg_get_channel_state(pdev, |
| 460 | ch); |
| 461 | |
| 462 | if (state != CHANNEL_STATE_DISABLE && |
| 463 | state != CHANNEL_STATE_INVALID && |
| 464 | j < *chan_num) { |
| 465 | chan_list[j] = (uint8_t)ch; |
| 466 | j++; |
| 467 | } |
| 468 | } |
| 469 | *chan_num = j; |
| 470 | qdf_mem_free(cur_chan_list); |
| 471 | return 0; |
| 472 | } |
| 473 | |
| 474 | /** |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 475 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 476 | * @adapter: HDD adapter |
| 477 | * @chan_number: Channel number |
| 478 | * @chan_bw: Bandwidth |
| 479 | * |
| 480 | * Checks if the given bandwidth is valid for the given channel number. |
| 481 | * |
| 482 | * Return: 0 for success, non-zero for failure |
| 483 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 484 | int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 485 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 486 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 487 | { |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 488 | uint8_t chan[NUM_CHANNELS]; |
| 489 | uint32_t len = NUM_CHANNELS, i; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 490 | bool found = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 491 | mac_handle_t mac_handle; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 492 | int ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 493 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 494 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 495 | if (!mac_handle) { |
| 496 | hdd_err("Invalid MAC handle"); |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 497 | return -EINVAL; |
| 498 | } |
| 499 | |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 500 | ret = hdd_get_valid_chan(adapter->hdd_ctx, chan, |
| 501 | &len); |
| 502 | if (ret) { |
| 503 | hdd_err("error %d in getting valid channel list", ret); |
| 504 | return ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 505 | } |
| 506 | |
| 507 | for (i = 0; i < len; i++) { |
| 508 | if (chan[i] == chan_number) { |
| 509 | found = true; |
| 510 | break; |
| 511 | } |
| 512 | } |
| 513 | |
| 514 | if (found == false) { |
| 515 | hdd_err("Channel not in driver's valid channel list"); |
| 516 | return -EOPNOTSUPP; |
| 517 | } |
| 518 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 519 | if ((!WLAN_REG_IS_24GHZ_CH(chan_number)) && |
| 520 | (!WLAN_REG_IS_5GHZ_CH(chan_number))) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 521 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 522 | return -EINVAL; |
| 523 | } |
| 524 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 525 | if (WLAN_REG_IS_24GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 526 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 527 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 528 | return -EINVAL; |
| 529 | } |
| 530 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 531 | (chan_bw != CH_WIDTH_MAX)) { |
| 532 | hdd_err("Only BW20 possible on channel 14"); |
| 533 | return -EINVAL; |
| 534 | } |
| 535 | } |
| 536 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 537 | if (WLAN_REG_IS_5GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 538 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 539 | (chan_bw != CH_WIDTH_MAX)) { |
| 540 | hdd_err("Only BW20 possible on channel 165"); |
| 541 | return -EINVAL; |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | return 0; |
| 546 | } |
| 547 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 548 | /** |
| 549 | * hdd_wait_for_recovery_completion() - Wait for cds recovery completion |
| 550 | * |
| 551 | * Block the unloading of the driver (or) interface up until the |
| 552 | * cds recovery is completed |
| 553 | * |
| 554 | * Return: true for recovery completion else false |
| 555 | */ |
| 556 | static bool hdd_wait_for_recovery_completion(void) |
| 557 | { |
| 558 | int retry = 0; |
| 559 | |
| 560 | /* Wait for recovery to complete */ |
| 561 | while (cds_is_driver_recovering()) { |
| 562 | if (retry == HDD_MOD_EXIT_SSR_MAX_RETRIES/2) |
| 563 | hdd_err("Recovery in progress; wait here!!!"); |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 564 | |
| 565 | if (g_is_system_reboot_triggered) { |
| 566 | hdd_info("System Reboot happening ignore unload!!"); |
| 567 | return false; |
| 568 | } |
| 569 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 570 | msleep(1000); |
| 571 | if (retry++ == HDD_MOD_EXIT_SSR_MAX_RETRIES) { |
| 572 | hdd_err("SSR never completed, error"); |
| 573 | /* |
| 574 | * Trigger the bug_on in the internal builds, in the |
| 575 | * customer builds self-recovery will be enabled |
| 576 | * in those cases just return error. |
| 577 | */ |
| 578 | if (cds_is_self_recovery_enabled()) |
| 579 | return false; |
| 580 | QDF_BUG(0); |
| 581 | } |
| 582 | } |
| 583 | |
| 584 | hdd_info("Recovery completed successfully!"); |
| 585 | return true; |
| 586 | } |
| 587 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 588 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 589 | static int __hdd_netdev_notifier_call(struct notifier_block *nb, |
| 590 | unsigned long state, void *data) |
| 591 | { |
| 592 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 593 | struct netdev_notifier_info *dev_notif_info = data; |
| 594 | struct net_device *dev = dev_notif_info->dev; |
| 595 | #else |
| 596 | struct net_device *dev = data; |
| 597 | #endif |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 598 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 599 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 600 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 601 | hdd_enter_dev(dev); |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 602 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 603 | if (!dev->ieee80211_ptr) { |
Dustin Brown | aeb5564 | 2018-07-30 17:20:32 -0700 | [diff] [blame] | 604 | hdd_debug("ieee80211_ptr is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 605 | return NOTIFY_DONE; |
| 606 | } |
| 607 | |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 608 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 609 | if (!hdd_ctx) { |
| 610 | hdd_err("HDD Context is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 611 | return NOTIFY_DONE; |
| 612 | } |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 613 | |
| 614 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 615 | hdd_debug("%s: Driver module is closed", __func__); |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 616 | return NOTIFY_DONE; |
| 617 | } |
| 618 | |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 619 | /* Make sure that this callback corresponds to our device. */ |
| 620 | adapter = hdd_get_adapter_by_iface_name(hdd_ctx, dev->name); |
| 621 | if (!adapter) { |
Dustin Brown | aeb5564 | 2018-07-30 17:20:32 -0700 | [diff] [blame] | 622 | hdd_debug("failed to look up adapter for '%s'", dev->name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 623 | return NOTIFY_DONE; |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 624 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 625 | |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 626 | if (adapter != WLAN_HDD_GET_PRIV_PTR(dev)) { |
| 627 | hdd_err("HDD adapter mismatch!"); |
| 628 | return NOTIFY_DONE; |
| 629 | } |
| 630 | |
Dustin Brown | aeb5564 | 2018-07-30 17:20:32 -0700 | [diff] [blame] | 631 | if (cds_is_driver_recovering()) { |
| 632 | hdd_debug("Driver is recovering"); |
| 633 | return NOTIFY_DONE; |
| 634 | } |
| 635 | |
| 636 | if (cds_is_driver_in_bad_state()) { |
| 637 | hdd_debug("Driver is in failed recovery state"); |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 638 | return NOTIFY_DONE; |
| 639 | } |
| 640 | |
| 641 | hdd_debug("%s New Net Device State = %lu", dev->name, state); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 642 | |
| 643 | switch (state) { |
| 644 | case NETDEV_REGISTER: |
| 645 | break; |
| 646 | |
| 647 | case NETDEV_UNREGISTER: |
| 648 | break; |
| 649 | |
| 650 | case NETDEV_UP: |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 651 | sme_ch_avoid_update_req(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 652 | break; |
| 653 | |
| 654 | case NETDEV_DOWN: |
| 655 | break; |
| 656 | |
| 657 | case NETDEV_CHANGE: |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 658 | if (adapter->is_link_up_service_needed) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 659 | complete(&adapter->linkup_event_var); |
| 660 | break; |
| 661 | |
| 662 | case NETDEV_GOING_DOWN: |
Sandeep Puligilla | 5f86d99 | 2017-10-29 14:58:53 -0700 | [diff] [blame] | 663 | if (ucfg_scan_get_vdev_status(adapter->hdd_vdev) != |
| 664 | SCAN_NOT_IN_PROGRESS) { |
Abhishek Singh | 69ccb51 | 2017-04-25 11:58:16 +0530 | [diff] [blame] | 665 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 666 | adapter->session_id, INVALID_SCAN_ID, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 667 | } |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 668 | cds_flush_work(&adapter->scan_block_work); |
| 669 | /* Need to clean up blocked scan request */ |
| 670 | wlan_hdd_cfg80211_scan_block_cb(&adapter->scan_block_work); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 671 | hdd_debug("Scan is not Pending from user"); |
Arunk Khandavalli | f0c0d76 | 2017-12-07 10:18:50 +0530 | [diff] [blame] | 672 | /* |
| 673 | * After NETDEV_GOING_DOWN, kernel calls hdd_stop.Irrespective |
| 674 | * of return status of hdd_stop call, kernel resets the IFF_UP |
| 675 | * flag after which driver does not send the cfg80211_scan_done. |
| 676 | * Ensure to cleanup the scan queue in NETDEV_GOING_DOWN |
| 677 | */ |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 678 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 679 | break; |
| 680 | |
| 681 | default: |
| 682 | break; |
| 683 | } |
| 684 | |
| 685 | return NOTIFY_DONE; |
| 686 | } |
| 687 | |
| 688 | /** |
| 689 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 690 | * @nb: pointer to notifier block |
| 691 | * @state: state |
| 692 | * @ndev: ndev pointer |
| 693 | * |
| 694 | * Return: 0 on success, error number otherwise. |
| 695 | */ |
| 696 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 697 | unsigned long state, |
| 698 | void *ndev) |
| 699 | { |
| 700 | int ret; |
| 701 | |
| 702 | cds_ssr_protect(__func__); |
| 703 | ret = __hdd_netdev_notifier_call(nb, state, ndev); |
| 704 | cds_ssr_unprotect(__func__); |
| 705 | |
| 706 | return ret; |
| 707 | } |
| 708 | |
| 709 | struct notifier_block hdd_netdev_notifier = { |
| 710 | .notifier_call = hdd_netdev_notifier_call, |
| 711 | }; |
| 712 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 713 | static int system_reboot_notifier_call(struct notifier_block *nb, |
| 714 | unsigned long msg_type, void *_unused) |
| 715 | { |
| 716 | switch (msg_type) { |
| 717 | case SYS_DOWN: |
| 718 | case SYS_HALT: |
| 719 | case SYS_POWER_OFF: |
| 720 | g_is_system_reboot_triggered = true; |
| 721 | hdd_info("reboot, reason: %ld", msg_type); |
| 722 | break; |
| 723 | default: |
| 724 | break; |
| 725 | } |
| 726 | |
| 727 | return NOTIFY_OK; |
| 728 | } |
| 729 | |
| 730 | struct notifier_block system_reboot_notifier = { |
| 731 | .notifier_call = system_reboot_notifier_call, |
| 732 | }; |
| 733 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 734 | /* variable to hold the insmod parameters */ |
| 735 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 736 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 737 | static int con_mode_ftm; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 738 | int con_mode_monitor; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 739 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 740 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 741 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 742 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 743 | /** |
| 744 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 745 | * @ch_width: NL channel width |
| 746 | * |
| 747 | * Converts the NL channel width to the driver's internal representation |
| 748 | * |
| 749 | * Return: Converted channel width. In case of non matching NL channel width, |
| 750 | * CH_WIDTH_MAX will be returned. |
| 751 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 752 | 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] | 753 | { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 754 | uint8_t fw_ch_bw; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 755 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 756 | fw_ch_bw = wma_get_vht_ch_width(); |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 757 | switch (ch_width) { |
| 758 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 759 | case NL80211_CHAN_WIDTH_20: |
| 760 | return CH_WIDTH_20MHZ; |
| 761 | case NL80211_CHAN_WIDTH_40: |
| 762 | return CH_WIDTH_40MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 763 | case NL80211_CHAN_WIDTH_80: |
| 764 | return CH_WIDTH_80MHZ; |
| 765 | case NL80211_CHAN_WIDTH_80P80: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 766 | if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ) |
| 767 | return CH_WIDTH_80P80MHZ; |
| 768 | else if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 769 | return CH_WIDTH_160MHZ; |
| 770 | else |
| 771 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 772 | case NL80211_CHAN_WIDTH_160: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 773 | if (fw_ch_bw >= WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 774 | return CH_WIDTH_160MHZ; |
| 775 | else |
| 776 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 777 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 778 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 779 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 780 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 781 | default: |
| 782 | hdd_err("Invalid channel width %d, setting to default", |
| 783 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 784 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 785 | } |
| 786 | } |
| 787 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 788 | uint8_t wlan_hdd_find_opclass(mac_handle_t mac_handle, uint8_t channel, |
| 789 | uint8_t bw_offset) |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 790 | { |
| 791 | uint8_t opclass = 0; |
| 792 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 793 | sme_get_opclass(mac_handle, channel, bw_offset, &opclass); |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 794 | return opclass; |
| 795 | } |
| 796 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 797 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 798 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 799 | * @module_id: Module whose trace level is being configured |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 800 | * @bitmask: Bitmask of log levels to be enabled |
| 801 | * |
| 802 | * Called immediately after the cfg.ini is read in order to configure |
| 803 | * the desired trace levels. |
| 804 | * |
| 805 | * Return: None |
| 806 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 807 | 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] | 808 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 809 | QDF_TRACE_LEVEL level; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 810 | int qdf_print_idx = -1; |
| 811 | int status = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 812 | /* |
| 813 | * if the bitmask is the default value, then a bitmask was not |
| 814 | * specified in cfg.ini, so leave the logging level alone (it |
| 815 | * will remain at the "compiled in" default value) |
| 816 | */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 817 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 818 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 819 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 820 | qdf_print_idx = qdf_get_pidx(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 821 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 822 | /* a mask was specified. start by disabling all logging */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 823 | status = qdf_print_set_category_verbose(qdf_print_idx, module_id, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 824 | QDF_TRACE_LEVEL_NONE, 0); |
| 825 | |
| 826 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 827 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 828 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Ashish Kumar Dhanotiya | 83f286b | 2017-09-15 19:52:58 +0530 | [diff] [blame] | 829 | level = QDF_TRACE_LEVEL_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 830 | while (0 != bitmask) { |
| 831 | if (bitmask & 1) { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 832 | status = qdf_print_set_category_verbose(qdf_print_idx, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 833 | module_id, level, 1); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 834 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 835 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 836 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 837 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 838 | level++; |
| 839 | bitmask >>= 1; |
| 840 | } |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 841 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 842 | } |
| 843 | |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 844 | 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] | 845 | { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 846 | if (!hdd_ctx) { |
| 847 | hdd_err("HDD context is null (via %s)", func); |
| 848 | return -ENODEV; |
| 849 | } |
| 850 | |
| 851 | if (!hdd_ctx->config) { |
| 852 | hdd_err("HDD config is null (via %s)", func); |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 853 | return -ENODEV; |
| 854 | } |
| 855 | |
| 856 | if (cds_is_driver_recovering()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 857 | hdd_debug("Recovery in progress (via %s); state:0x%x", |
| 858 | func, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 859 | return -EAGAIN; |
| 860 | } |
| 861 | |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 862 | if (cds_is_load_or_unload_in_progress()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 863 | hdd_debug("Load/unload in progress (via %s); state:0x%x", |
| 864 | func, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 865 | return -EAGAIN; |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 866 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 867 | |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 868 | if (hdd_ctx->start_modules_in_progress) { |
| 869 | hdd_debug("Start modules in progress (via %s)", func); |
| 870 | return -EAGAIN; |
| 871 | } |
| 872 | |
| 873 | if (hdd_ctx->stop_modules_in_progress) { |
| 874 | hdd_debug("Stop modules in progress (via %s)", func); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 875 | return -EAGAIN; |
| 876 | } |
| 877 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 878 | if (cds_is_driver_in_bad_state()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 879 | hdd_debug("Driver in bad state (via %s); state:0x%x", |
| 880 | func, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 881 | return -EAGAIN; |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 882 | } |
| 883 | |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 884 | if (cds_is_fw_down()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 885 | hdd_debug("FW is down (via %s); state:0x%x", |
| 886 | func, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 887 | return -EAGAIN; |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 888 | } |
| 889 | |
Liangwei Dong | 858feb1 | 2018-05-21 01:52:46 -0400 | [diff] [blame] | 890 | if (qdf_atomic_read(&hdd_ctx->con_mode_flag)) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 891 | hdd_debug("Driver mode change in progress (via %s)", func); |
Liangwei Dong | 858feb1 | 2018-05-21 01:52:46 -0400 | [diff] [blame] | 892 | return -EAGAIN; |
| 893 | } |
| 894 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 895 | return 0; |
| 896 | } |
| 897 | |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 898 | int __hdd_validate_adapter(struct hdd_adapter *adapter, const char *func) |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 899 | { |
| 900 | if (!adapter) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 901 | hdd_err("adapter is null (via %s)", func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 902 | return -EINVAL; |
| 903 | } |
| 904 | |
| 905 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 906 | hdd_err("bad adapter magic (via %s)", func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 907 | return -EINVAL; |
| 908 | } |
| 909 | |
| 910 | if (!adapter->dev) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 911 | hdd_err("adapter net_device is null (via %s)", func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 912 | return -EINVAL; |
| 913 | } |
| 914 | |
| 915 | if (!(adapter->dev->flags & IFF_UP)) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 916 | hdd_debug_rl("adapter '%s' is not up (via %s)", |
| 917 | adapter->dev->name, func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 918 | return -EAGAIN; |
| 919 | } |
| 920 | |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 921 | return __wlan_hdd_validate_session_id(adapter->session_id, func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 922 | } |
| 923 | |
Dustin Brown | 6350061 | 2018-08-07 11:36:09 -0700 | [diff] [blame] | 924 | int __wlan_hdd_validate_session_id(uint8_t session_id, const char *func) |
| 925 | { |
| 926 | if (session_id == CSR_SESSION_ID_INVALID) { |
| 927 | hdd_debug_rl("adapter is not up (via %s)", func); |
| 928 | return -EINVAL; |
| 929 | } |
| 930 | |
| 931 | if (session_id >= CSR_ROAM_SESSION_MAX) { |
| 932 | hdd_err("bad session Id:%u (via %s)", session_id, func); |
| 933 | return -EINVAL; |
| 934 | } |
| 935 | |
| 936 | return 0; |
| 937 | } |
| 938 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 939 | /** |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 940 | * wlan_hdd_validate_modules_state() - Check modules status |
| 941 | * @hdd_ctx: HDD context pointer |
| 942 | * |
| 943 | * Check's the driver module's state and returns true if the |
| 944 | * modules are enabled returns false if modules are closed. |
| 945 | * |
| 946 | * Return: True if modules are enabled or false. |
| 947 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 948 | bool wlan_hdd_validate_modules_state(struct hdd_context *hdd_ctx) |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 949 | { |
| 950 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 951 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 952 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 953 | hdd_info("Modules not enabled, Present status: %d", |
| 954 | hdd_ctx->driver_status); |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 955 | return false; |
| 956 | } |
| 957 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 958 | return true; |
| 959 | } |
| 960 | |
| 961 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 962 | * 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] | 963 | * @struct hdd_adapter Hdd adapter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 964 | * |
| 965 | * This function sets the IBSS power save config parameters to WMA |
| 966 | * which will send it to firmware if FW supports IBSS power save |
| 967 | * before vdev start. |
| 968 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 969 | * 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] | 970 | * on failure. |
| 971 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 972 | QDF_STATUS hdd_set_ibss_power_save_params(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 973 | { |
| 974 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 975 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 976 | |
| 977 | if (hdd_ctx == NULL) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 978 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 979 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 980 | } |
| 981 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 982 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 983 | WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE, |
| 984 | hdd_ctx->config->ibssATIMWinSize, |
| 985 | VDEV_CMD); |
| 986 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 987 | hdd_err("atim window set failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 988 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 989 | } |
| 990 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 991 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 992 | WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED, |
| 993 | hdd_ctx->config->isIbssPowerSaveAllowed, |
| 994 | VDEV_CMD); |
| 995 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 996 | hdd_err("power save allow failed %d", |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 997 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 998 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 999 | } |
| 1000 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1001 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1002 | WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED, |
| 1003 | hdd_ctx->config-> |
| 1004 | isIbssPowerCollapseAllowed, VDEV_CMD); |
| 1005 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1006 | hdd_err("power collapse allow failed %d", |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1007 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1008 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1009 | } |
| 1010 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1011 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1012 | WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX, |
| 1013 | hdd_ctx->config->isIbssAwakeOnTxRx, |
| 1014 | VDEV_CMD); |
| 1015 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1016 | hdd_err("set awake on tx/rx failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1017 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1018 | } |
| 1019 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1020 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1021 | WMA_VDEV_IBSS_SET_INACTIVITY_TIME, |
| 1022 | hdd_ctx->config->ibssInactivityCount, |
| 1023 | VDEV_CMD); |
| 1024 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1025 | hdd_err("set inactivity time failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1026 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1027 | } |
| 1028 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1029 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1030 | WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME, |
| 1031 | hdd_ctx->config->ibssTxSpEndInactivityTime, |
| 1032 | VDEV_CMD); |
| 1033 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1034 | hdd_err("set txsp end failed %d", |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1035 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1036 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1037 | } |
| 1038 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1039 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1040 | WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS, |
| 1041 | hdd_ctx->config->ibssPsWarmupTime, |
| 1042 | VDEV_CMD); |
| 1043 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1044 | hdd_err("set ps warmup failed %d", |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1045 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1046 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1047 | } |
| 1048 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1049 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1050 | WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW, |
| 1051 | hdd_ctx->config->ibssPs1RxChainInAtimEnable, |
| 1052 | VDEV_CMD); |
| 1053 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1054 | hdd_err("set 1rx chain atim failed %d", |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1055 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1056 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1057 | } |
| 1058 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1059 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1060 | } |
| 1061 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1062 | #ifdef FEATURE_RUNTIME_PM |
| 1063 | /** |
| 1064 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 1065 | * @hdd_ctx: HDD context |
| 1066 | * |
| 1067 | * Return: None |
| 1068 | */ |
| 1069 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) |
| 1070 | { |
| 1071 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1072 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1073 | qdf_runtime_lock_init(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1074 | qdf_runtime_lock_init(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1075 | |
| 1076 | wlan_scan_runtime_pm_init(hdd_ctx->hdd_pdev); |
| 1077 | } |
| 1078 | |
| 1079 | /** |
| 1080 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 1081 | * @hdd_ctx: HDD Context |
| 1082 | * |
| 1083 | * Return: None |
| 1084 | */ |
| 1085 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) |
| 1086 | { |
| 1087 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1088 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1089 | qdf_runtime_lock_deinit(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1090 | qdf_runtime_lock_deinit(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1091 | |
| 1092 | wlan_scan_runtime_pm_deinit(hdd_ctx->hdd_pdev); |
| 1093 | } |
| 1094 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1095 | #else /* FEATURE_RUNTIME_PM */ |
| 1096 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) {} |
| 1097 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) {} |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1098 | #endif /* FEATURE_RUNTIME_PM */ |
| 1099 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1100 | #define INTF_MACADDR_MASK 0x7 |
| 1101 | |
| 1102 | /** |
| 1103 | * hdd_update_macaddr() - update mac address |
| 1104 | * @config: hdd configuration |
| 1105 | * @hw_macaddr: mac address |
| 1106 | * |
| 1107 | * Mac address for multiple virtual interface is found as following |
| 1108 | * i) The mac address of the first interface is just the actual hw mac address. |
| 1109 | * ii) MSM 3 or 4 bits of byte5 of the actual mac address are used to |
| 1110 | * define the mac address for the remaining interfaces and locally |
| 1111 | * admistered bit is set. INTF_MACADDR_MASK is based on the number of |
| 1112 | * supported virtual interfaces, right now this is 0x07 (meaning 8 |
| 1113 | * interface). |
| 1114 | * Byte[3] of second interface will be hw_macaddr[3](bit5..7) + 1, |
| 1115 | * for third interface it will be hw_macaddr[3](bit5..7) + 2, etc. |
| 1116 | * |
| 1117 | * Return: None |
| 1118 | */ |
| 1119 | void hdd_update_macaddr(struct hdd_config *config, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1120 | struct qdf_mac_addr hw_macaddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1121 | { |
| 1122 | int8_t i; |
| 1123 | uint8_t macaddr_b3, tmp_br3; |
| 1124 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1125 | qdf_mem_copy(config->intfMacAddr[0].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1126 | QDF_MAC_ADDR_SIZE); |
| 1127 | for (i = 1; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1128 | qdf_mem_copy(config->intfMacAddr[i].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1129 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1130 | macaddr_b3 = config->intfMacAddr[i].bytes[3]; |
| 1131 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 1132 | INTF_MACADDR_MASK; |
| 1133 | macaddr_b3 += tmp_br3; |
| 1134 | |
| 1135 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 1136 | * mac address range before collision |
| 1137 | */ |
| 1138 | macaddr_b3 ^= (1 << 7); |
| 1139 | |
| 1140 | /* Set locally administered bit */ |
| 1141 | config->intfMacAddr[i].bytes[0] |= 0x02; |
| 1142 | config->intfMacAddr[i].bytes[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1143 | hdd_debug("config->intfMacAddr[%d]: " |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1144 | MAC_ADDRESS_STR, i, |
| 1145 | MAC_ADDR_ARRAY(config->intfMacAddr[i].bytes)); |
| 1146 | } |
| 1147 | } |
| 1148 | |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1149 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
| 1150 | { |
| 1151 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 1152 | struct tdls_start_params tdls_cfg; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1153 | struct hdd_config *cfg = hdd_ctx->config; |
| 1154 | QDF_STATUS status; |
| 1155 | |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1156 | cfg_tdls_set_vdev_nss_2g(hdd_ctx->hdd_psoc, |
| 1157 | CFG_TDLS_NSS(cfg->vdev_type_nss_2g)); |
| 1158 | cfg_tdls_set_vdev_nss_5g(hdd_ctx->hdd_psoc, |
| 1159 | CFG_TDLS_NSS(cfg->vdev_type_nss_5g)); |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1160 | tdls_cfg.tdls_send_mgmt_req = eWNI_SME_TDLS_SEND_MGMT_REQ; |
| 1161 | tdls_cfg.tdls_add_sta_req = eWNI_SME_TDLS_ADD_STA_REQ; |
| 1162 | tdls_cfg.tdls_del_sta_req = eWNI_SME_TDLS_DEL_STA_REQ; |
| 1163 | tdls_cfg.tdls_update_peer_state = WMA_UPDATE_TDLS_PEER_STATE; |
| 1164 | tdls_cfg.tdls_del_all_peers = eWNI_SME_DEL_ALL_TDLS_PEERS; |
| 1165 | tdls_cfg.tdls_update_dp_vdev_flags = CDP_UPDATE_TDLS_FLAGS; |
| 1166 | tdls_cfg.tdls_event_cb = wlan_cfg80211_tdls_event_callback; |
| 1167 | tdls_cfg.tdls_evt_cb_data = psoc; |
Jeff Johnson | 1d40f5b | 2018-03-02 08:35:53 -0800 | [diff] [blame] | 1168 | tdls_cfg.tdls_peer_context = hdd_ctx; |
| 1169 | tdls_cfg.tdls_reg_peer = hdd_tdls_register_peer; |
| 1170 | tdls_cfg.tdls_dereg_peer = hdd_tdls_deregister_peer; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1171 | tdls_cfg.tdls_wmm_cb = hdd_wmm_is_acm_allowed; |
| 1172 | tdls_cfg.tdls_wmm_cb_data = psoc; |
| 1173 | tdls_cfg.tdls_rx_cb = wlan_cfg80211_tdls_rx_callback; |
| 1174 | tdls_cfg.tdls_rx_cb_data = psoc; |
| 1175 | tdls_cfg.tdls_dp_vdev_update = hdd_update_dp_vdev_flags; |
| 1176 | |
| 1177 | status = ucfg_tdls_update_config(psoc, &tdls_cfg); |
| 1178 | if (status != QDF_STATUS_SUCCESS) { |
| 1179 | hdd_err("failed pmo psoc configuration"); |
| 1180 | return -EINVAL; |
| 1181 | } |
| 1182 | |
| 1183 | hdd_ctx->tdls_umac_comp_active = true; |
| 1184 | /* enable napier specific tdls data path */ |
| 1185 | hdd_ctx->tdls_nap_active = true; |
| 1186 | |
| 1187 | return 0; |
| 1188 | } |
| 1189 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1190 | static void hdd_update_tgt_services(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1191 | struct wma_tgt_services *cfg) |
| 1192 | { |
| 1193 | struct hdd_config *config = hdd_ctx->config; |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1194 | #ifdef FEATURE_WLAN_TDLS |
| 1195 | bool tdls_support; |
| 1196 | bool tdls_off_channel; |
| 1197 | bool tdls_buffer_sta; |
| 1198 | uint32_t tdls_uapsd_mask; |
| 1199 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1200 | /* Set up UAPSD */ |
| 1201 | config->apUapsdEnabled &= cfg->uapsd; |
| 1202 | |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 1203 | /* 11AX mode support */ |
| 1204 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 1205 | config->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) && !cfg->en_11ax) |
| 1206 | config->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 1207 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1208 | /* 11AC mode support */ |
| 1209 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 1210 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 1211 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1212 | |
| 1213 | /* ARP offload: override user setting if invalid */ |
| 1214 | config->fhostArpOffload &= cfg->arp_offload; |
| 1215 | |
| 1216 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 1217 | /* PNO offload */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1218 | hdd_debug("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1219 | if (cfg->pno_offload) |
| 1220 | config->PnoOffload = true; |
| 1221 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1222 | #ifdef FEATURE_WLAN_TDLS |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1223 | cfg_tdls_get_support_enable(hdd_ctx->hdd_psoc, &tdls_support); |
| 1224 | cfg_tdls_set_support_enable(hdd_ctx->hdd_psoc, |
| 1225 | tdls_support & cfg->en_tdls); |
| 1226 | |
| 1227 | cfg_tdls_get_off_channel_enable(hdd_ctx->hdd_psoc, &tdls_off_channel); |
| 1228 | cfg_tdls_set_off_channel_enable(hdd_ctx->hdd_psoc, |
| 1229 | tdls_off_channel && |
| 1230 | cfg->en_tdls_offchan); |
| 1231 | |
| 1232 | cfg_tdls_get_buffer_sta_enable(hdd_ctx->hdd_psoc, &tdls_buffer_sta); |
| 1233 | cfg_tdls_set_buffer_sta_enable(hdd_ctx->hdd_psoc, |
| 1234 | tdls_buffer_sta && |
| 1235 | cfg->en_tdls_uapsd_buf_sta); |
| 1236 | |
| 1237 | cfg_tdls_get_uapsd_mask(hdd_ctx->hdd_psoc, &tdls_uapsd_mask); |
| 1238 | if (tdls_uapsd_mask && cfg->en_tdls_uapsd_sleep_sta) |
| 1239 | cfg_tdls_set_sleep_sta_enable(hdd_ctx->hdd_psoc, true); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1240 | else |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1241 | cfg_tdls_set_sleep_sta_enable(hdd_ctx->hdd_psoc, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1242 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1243 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1244 | config->isRoamOffloadEnabled &= cfg->en_roam_offload; |
| 1245 | #endif |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 1246 | config->sap_get_peer_info &= cfg->get_peer_info_enabled; |
Varun Reddy Yeturu | 62c3265 | 2017-10-26 15:32:35 -0700 | [diff] [blame] | 1247 | config->MAWCEnabled &= cfg->is_fw_mawc_capable; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1248 | hdd_update_tdls_config(hdd_ctx); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1249 | sme_update_tgt_services(hdd_ctx->mac_handle, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1250 | |
| 1251 | } |
| 1252 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1253 | /** |
| 1254 | * hdd_update_vdev_nss() - sets the vdev nss |
| 1255 | * @hdd_ctx: HDD context |
| 1256 | * |
| 1257 | * Sets the Nss per vdev type based on INI |
| 1258 | * |
| 1259 | * Return: None |
| 1260 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1261 | static void hdd_update_vdev_nss(struct hdd_context *hdd_ctx) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1262 | { |
| 1263 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1264 | uint8_t max_supp_nss = 1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1265 | mac_handle_t mac_handle; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1266 | |
Naveen Rawat | 10b1c15 | 2017-01-18 11:16:06 -0800 | [diff] [blame] | 1267 | if (cfg_ini->enable2x2 && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1268 | max_supp_nss = 2; |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 1269 | hdd_debug("max nss %d vdev_type_nss_2g %x vdev_type_nss_5g %x", |
| 1270 | max_supp_nss, cfg_ini->vdev_type_nss_2g, |
| 1271 | cfg_ini->vdev_type_nss_5g); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1272 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1273 | mac_handle = hdd_ctx->mac_handle; |
| 1274 | sme_update_vdev_type_nss(mac_handle, max_supp_nss, |
| 1275 | cfg_ini->vdev_type_nss_2g, BAND_2G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1276 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1277 | sme_update_vdev_type_nss(mac_handle, max_supp_nss, |
| 1278 | cfg_ini->vdev_type_nss_5g, BAND_5G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1279 | } |
| 1280 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1281 | /** |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1282 | * hdd_update_wiphy_vhtcap() - Updates wiphy vhtcap fields |
| 1283 | * @hdd_ctx: HDD context |
| 1284 | * |
| 1285 | * Updates wiphy vhtcap fields |
| 1286 | * |
| 1287 | * Return: None |
| 1288 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1289 | static void hdd_update_wiphy_vhtcap(struct hdd_context *hdd_ctx) |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1290 | { |
| 1291 | struct ieee80211_supported_band *band_5g = |
| 1292 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]; |
| 1293 | uint32_t val; |
| 1294 | |
| 1295 | if (!band_5g) { |
| 1296 | hdd_debug("5GHz band disabled, skipping capability population"); |
| 1297 | return; |
| 1298 | } |
| 1299 | |
| 1300 | val = hdd_ctx->config->txBFCsnValue; |
| 1301 | band_5g->vht_cap.cap |= (val << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT); |
| 1302 | |
| 1303 | val = NUM_OF_SOUNDING_DIMENSIONS; |
| 1304 | band_5g->vht_cap.cap |= |
| 1305 | (val << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT); |
| 1306 | |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 1307 | hdd_debug("Updated wiphy vhtcap:0x%x, CSNAntSupp:%d, NumSoundDim:%d", |
| 1308 | band_5g->vht_cap.cap, hdd_ctx->config->txBFCsnValue, val); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1309 | } |
| 1310 | |
| 1311 | /** |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1312 | * hdd_update_hw_dbs_capable() - sets the dbs capability of the device |
| 1313 | * @hdd_ctx: HDD context |
| 1314 | * |
| 1315 | * Sets the DBS capability as per INI and firmware capability |
| 1316 | * |
| 1317 | * Return: None |
| 1318 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1319 | static void hdd_update_hw_dbs_capable(struct hdd_context *hdd_ctx) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1320 | { |
| 1321 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1322 | uint8_t hw_dbs_capable = 0; |
| 1323 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 1324 | if (policy_mgr_is_hw_dbs_capable(hdd_ctx->hdd_psoc) && |
| 1325 | ((cfg_ini->dual_mac_feature_disable == |
| 1326 | ENABLE_DBS_CXN_AND_SCAN) || |
| 1327 | (cfg_ini->dual_mac_feature_disable == |
Tushnim Bhattacharyya | aececb2 | 2018-08-06 14:27:46 -0700 | [diff] [blame] | 1328 | ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF) || |
| 1329 | (cfg_ini->dual_mac_feature_disable == |
| 1330 | ENABLE_DBS_CXN_AND_DISABLE_SIMULTANEOUS_SCAN))) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1331 | hw_dbs_capable = 1; |
| 1332 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1333 | sme_update_hw_dbs_capable(hdd_ctx->mac_handle, hw_dbs_capable); |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1334 | } |
| 1335 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1336 | static void hdd_update_tgt_ht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1337 | struct wma_tgt_ht_cap *cfg) |
| 1338 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1339 | QDF_STATUS status; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1340 | uint32_t value; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1341 | struct hdd_config *pconfig = hdd_ctx->config; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1342 | struct mlme_ht_capabilities_info ht_cap_info; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1343 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1344 | mac_handle_t mac_handle = hdd_ctx->mac_handle; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1345 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1346 | /* get the MPDU density */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1347 | status = sme_cfg_get_int(mac_handle, WNI_CFG_MPDU_DENSITY, &value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1348 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1349 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1350 | hdd_err("could not get MPDU DENSITY"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1351 | value = 0; |
| 1352 | } |
| 1353 | |
| 1354 | /* |
| 1355 | * MPDU density: |
| 1356 | * override user's setting if value is larger |
| 1357 | * than the one supported by target |
| 1358 | */ |
| 1359 | if (value > cfg->mpdu_density) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1360 | status = sme_cfg_set_int(mac_handle, WNI_CFG_MPDU_DENSITY, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1361 | cfg->mpdu_density); |
| 1362 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1363 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1364 | hdd_err("could not set MPDU DENSITY to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1365 | } |
| 1366 | |
| 1367 | /* get the HT capability info */ |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1368 | status = ucfg_mlme_get_ht_cap_info(hdd_ctx->hdd_psoc, &ht_cap_info); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1369 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1370 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1371 | return; |
| 1372 | } |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1373 | |
| 1374 | /* check and update RX STBC */ |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1375 | if (ht_cap_info.rx_stbc && !cfg->ht_rx_stbc) |
| 1376 | ht_cap_info.rx_stbc = cfg->ht_rx_stbc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1377 | |
| 1378 | /* Set the LDPC capability */ |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1379 | ht_cap_info.adv_coding_cap = cfg->ht_rx_ldpc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1380 | |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1381 | if (ht_cap_info.short_gi_20_mhz && !cfg->ht_sgi_20) |
| 1382 | ht_cap_info.short_gi_20_mhz = cfg->ht_sgi_20; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1383 | |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1384 | if (ht_cap_info.short_gi_40_mhz && !cfg->ht_sgi_40) |
| 1385 | ht_cap_info.short_gi_40_mhz = cfg->ht_sgi_40; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1386 | |
| 1387 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 1388 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 1389 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1390 | if (pconfig->enable2x2 && (cfg->num_rf_chains == 2)) { |
| 1391 | pconfig->enable2x2 = 1; |
| 1392 | } else { |
| 1393 | pconfig->enable2x2 = 0; |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1394 | ht_cap_info.tx_stbc = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1395 | |
| 1396 | /* 1x1 */ |
| 1397 | /* Update Rx Highest Long GI data Rate */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1398 | if (sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1399 | WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1400 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1401 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1402 | hdd_err("Could not pass on WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1403 | } |
| 1404 | |
| 1405 | /* Update Tx Highest Long GI data Rate */ |
| 1406 | if (sme_cfg_set_int |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1407 | (mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1408 | WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1409 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1410 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1411 | hdd_err("VHT_TX_HIGHEST_SUPP_RATE_1_1 to CCM fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1412 | } |
| 1413 | } |
| 1414 | if (!(cfg->ht_tx_stbc && pconfig->enable2x2)) |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1415 | ht_cap_info.tx_stbc = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1416 | |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1417 | status = ucfg_mlme_set_ht_cap_info(hdd_ctx->hdd_psoc, ht_cap_info); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1418 | if (status != QDF_STATUS_SUCCESS) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1419 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1420 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
| 1421 | value = SIZE_OF_SUPPORTED_MCS_SET; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1422 | if (sme_cfg_get_str(mac_handle, WNI_CFG_SUPPORTED_MCS_SET, mcs_set, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1423 | &value) == QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1424 | hdd_debug("Read MCS rate set"); |
gaurank kathpalia | 18b4936 | 2018-04-15 23:12:03 +0530 | [diff] [blame] | 1425 | if (cfg->num_rf_chains > SIZE_OF_SUPPORTED_MCS_SET) |
| 1426 | cfg->num_rf_chains = SIZE_OF_SUPPORTED_MCS_SET; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1427 | if (pconfig->enable2x2) { |
| 1428 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 1429 | mcs_set[value] = |
| 1430 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 1431 | |
| 1432 | status = |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1433 | sme_cfg_set_str(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1434 | WNI_CFG_SUPPORTED_MCS_SET, |
| 1435 | mcs_set, |
| 1436 | SIZE_OF_SUPPORTED_MCS_SET); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1437 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1438 | hdd_err("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1439 | } |
| 1440 | } |
| 1441 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 1442 | } |
| 1443 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1444 | static void hdd_update_tgt_vht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1445 | struct wma_tgt_vht_cap *cfg) |
| 1446 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1447 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1448 | uint32_t value = 0; |
| 1449 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1450 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 1451 | struct ieee80211_supported_band *band_5g = |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 1452 | wiphy->bands[HDD_NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1453 | uint32_t temp = 0; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1454 | uint32_t ch_width = eHT_CHANNEL_WIDTH_80MHZ; |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1455 | uint32_t hw_rx_ldpc_enabled; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1456 | struct wma_caps_per_phy caps_per_phy; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1457 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1458 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1459 | if (!band_5g) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1460 | hdd_debug("5GHz band disabled, skipping capability population"); |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1461 | return; |
| 1462 | } |
| 1463 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1464 | mac_handle = hdd_ctx->mac_handle; |
| 1465 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1466 | /* Get the current MPDU length */ |
| 1467 | status = |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1468 | sme_cfg_get_int(mac_handle, WNI_CFG_VHT_MAX_MPDU_LENGTH, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1469 | &value); |
| 1470 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1471 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1472 | hdd_err("could not get MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1473 | value = 0; |
| 1474 | } |
| 1475 | |
| 1476 | /* |
| 1477 | * VHT max MPDU length: |
| 1478 | * override if user configured value is too high |
| 1479 | * that the target cannot support |
| 1480 | */ |
| 1481 | if (value > cfg->vht_max_mpdu) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1482 | status = sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1483 | WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1484 | cfg->vht_max_mpdu); |
| 1485 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1486 | if (status == QDF_STATUS_E_FAILURE) |
| 1487 | hdd_err("could not set VHT MAX MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1488 | } |
| 1489 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1490 | sme_cfg_get_int(mac_handle, WNI_CFG_VHT_BASIC_MCS_SET, &temp); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1491 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1492 | |
| 1493 | if (pconfig->enable2x2) |
| 1494 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1495 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1496 | if (sme_cfg_set_int(mac_handle, WNI_CFG_VHT_BASIC_MCS_SET, temp) == |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1497 | QDF_STATUS_E_FAILURE) { |
| 1498 | hdd_err("Could not pass VHT_BASIC_MCS_SET to CCM"); |
| 1499 | } |
| 1500 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1501 | sme_cfg_get_int(mac_handle, WNI_CFG_VHT_RX_MCS_MAP, &temp); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1502 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1503 | if (pconfig->enable2x2) |
| 1504 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1505 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1506 | if (sme_cfg_set_int(mac_handle, WNI_CFG_VHT_RX_MCS_MAP, temp) == |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1507 | QDF_STATUS_E_FAILURE) { |
| 1508 | hdd_err("Could not pass WNI_CFG_VHT_RX_MCS_MAP to CCM"); |
| 1509 | } |
| 1510 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1511 | sme_cfg_get_int(mac_handle, WNI_CFG_VHT_TX_MCS_MAP, &temp); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1512 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtTxMCS; |
| 1513 | if (pconfig->enable2x2) |
| 1514 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtTxMCS2x2 << 2); |
| 1515 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1516 | hdd_debug("vhtRxMCS2x2 - %x temp - %u enable2x2 %d", |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1517 | pconfig->vhtRxMCS2x2, temp, pconfig->enable2x2); |
| 1518 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1519 | if (sme_cfg_set_int(mac_handle, WNI_CFG_VHT_TX_MCS_MAP, temp) == |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1520 | QDF_STATUS_E_FAILURE) { |
| 1521 | hdd_err("Could not pass WNI_CFG_VHT_TX_MCS_MAP to CCM"); |
| 1522 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1523 | /* Get the current RX LDPC setting */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1524 | status = sme_cfg_get_int(mac_handle, WNI_CFG_VHT_LDPC_CODING_CAP, |
| 1525 | &value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1526 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1527 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1528 | hdd_err("could not get VHT LDPC CODING CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1529 | value = 0; |
| 1530 | } |
| 1531 | |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1532 | /* Set HW RX LDPC capability */ |
| 1533 | hw_rx_ldpc_enabled = !!cfg->vht_rx_ldpc; |
| 1534 | if (hw_rx_ldpc_enabled != value) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1535 | status = sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1536 | WNI_CFG_VHT_LDPC_CODING_CAP, |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1537 | hw_rx_ldpc_enabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1538 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1539 | if (status == QDF_STATUS_E_FAILURE) |
| 1540 | hdd_err("could not set VHT LDPC CODING CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1541 | } |
| 1542 | |
| 1543 | /* Get current GI 80 value */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1544 | status = sme_cfg_get_int(mac_handle, WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1545 | &value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1546 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1547 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1548 | hdd_err("could not get SHORT GI 80MHZ"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1549 | value = 0; |
| 1550 | } |
| 1551 | |
| 1552 | /* set the Guard interval 80MHz */ |
| 1553 | if (value && !cfg->vht_short_gi_80) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1554 | status = sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1555 | WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1556 | cfg->vht_short_gi_80); |
| 1557 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1558 | if (status == QDF_STATUS_E_FAILURE) |
| 1559 | hdd_err("could not set SHORT GI 80MHZ to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1560 | } |
| 1561 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1562 | /* Get VHT TX STBC cap */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1563 | status = sme_cfg_get_int(mac_handle, WNI_CFG_VHT_TXSTBC, &value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1564 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1565 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1566 | hdd_err("could not get VHT TX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1567 | value = 0; |
| 1568 | } |
| 1569 | |
| 1570 | /* VHT TX STBC cap */ |
| 1571 | if (value && !cfg->vht_tx_stbc) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1572 | status = sme_cfg_set_int(mac_handle, WNI_CFG_VHT_TXSTBC, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1573 | cfg->vht_tx_stbc); |
| 1574 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1575 | if (status == QDF_STATUS_E_FAILURE) |
| 1576 | hdd_err("could not set the VHT TX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1577 | } |
| 1578 | |
| 1579 | /* Get VHT RX STBC cap */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1580 | status = sme_cfg_get_int(mac_handle, WNI_CFG_VHT_RXSTBC, &value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1581 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1582 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1583 | hdd_err("could not get VHT RX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1584 | value = 0; |
| 1585 | } |
| 1586 | |
| 1587 | /* VHT RX STBC cap */ |
| 1588 | if (value && !cfg->vht_rx_stbc) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1589 | status = sme_cfg_set_int(mac_handle, WNI_CFG_VHT_RXSTBC, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1590 | cfg->vht_rx_stbc); |
| 1591 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1592 | if (status == QDF_STATUS_E_FAILURE) |
| 1593 | hdd_err("could not set the VHT RX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1594 | } |
| 1595 | |
| 1596 | /* Get VHT SU Beamformer cap */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1597 | status = sme_cfg_get_int(mac_handle, WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1598 | &value); |
| 1599 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1600 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1601 | hdd_err("could not get VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1602 | value = 0; |
| 1603 | } |
| 1604 | |
| 1605 | /* set VHT SU Beamformer cap */ |
| 1606 | if (value && !cfg->vht_su_bformer) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1607 | status = sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1608 | WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1609 | cfg->vht_su_bformer); |
| 1610 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1611 | if (status == QDF_STATUS_E_FAILURE) |
| 1612 | hdd_err("could not set VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1613 | } |
| 1614 | |
| 1615 | /* check and update SU BEAMFORMEE capabality */ |
| 1616 | if (pconfig->enableTxBF && !cfg->vht_su_bformee) |
| 1617 | pconfig->enableTxBF = cfg->vht_su_bformee; |
| 1618 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1619 | status = sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1620 | WNI_CFG_VHT_SU_BEAMFORMEE_CAP, |
| 1621 | pconfig->enableTxBF); |
| 1622 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1623 | if (status == QDF_STATUS_E_FAILURE) |
| 1624 | hdd_err("could not set VHT SU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1625 | |
| 1626 | /* Get VHT MU Beamformer cap */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1627 | status = sme_cfg_get_int(mac_handle, WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1628 | &value); |
| 1629 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1630 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1631 | hdd_err("could not get VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1632 | value = 0; |
| 1633 | } |
| 1634 | |
| 1635 | /* set VHT MU Beamformer cap */ |
| 1636 | if (value && !cfg->vht_mu_bformer) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1637 | status = sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1638 | WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1639 | cfg->vht_mu_bformer); |
| 1640 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1641 | if (status == QDF_STATUS_E_FAILURE) |
| 1642 | hdd_err("could not set the VHT MU BEAMFORMER CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1643 | } |
| 1644 | |
| 1645 | /* Get VHT MU Beamformee cap */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1646 | status = sme_cfg_get_int(mac_handle, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1647 | &value); |
| 1648 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1649 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1650 | hdd_err("could not get VHT MU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1651 | value = 0; |
| 1652 | } |
| 1653 | |
| 1654 | /* set VHT MU Beamformee cap */ |
| 1655 | if (value && !cfg->vht_mu_bformee) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1656 | status = sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1657 | WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1658 | cfg->vht_mu_bformee); |
| 1659 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1660 | if (status == QDF_STATUS_E_FAILURE) |
| 1661 | hdd_err("could not set VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1662 | } |
| 1663 | |
| 1664 | /* Get VHT MAX AMPDU Len exp */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1665 | status = sme_cfg_get_int(mac_handle, WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1666 | &value); |
| 1667 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1668 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1669 | hdd_err("could not get VHT AMPDU LEN"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1670 | value = 0; |
| 1671 | } |
| 1672 | |
| 1673 | /* |
| 1674 | * VHT max AMPDU len exp: |
| 1675 | * override if user configured value is too high |
| 1676 | * that the target cannot support. |
| 1677 | * Even though Rome publish ampdu_len=7, it can |
| 1678 | * only support 4 because of some h/w bug. |
| 1679 | */ |
| 1680 | |
| 1681 | if (value > cfg->vht_max_ampdu_len_exp) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1682 | status = sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1683 | WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1684 | cfg->vht_max_ampdu_len_exp); |
| 1685 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1686 | if (status == QDF_STATUS_E_FAILURE) |
| 1687 | hdd_err("could not set the VHT AMPDU LEN EXP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1688 | } |
| 1689 | |
| 1690 | /* Get VHT TXOP PS CAP */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1691 | status = sme_cfg_get_int(mac_handle, WNI_CFG_VHT_TXOP_PS, &value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1692 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1693 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1694 | hdd_err("could not get VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1695 | value = 0; |
| 1696 | } |
| 1697 | |
| 1698 | /* set VHT TXOP PS cap */ |
| 1699 | if (value && !cfg->vht_txop_ps) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1700 | status = sme_cfg_set_int(mac_handle, WNI_CFG_VHT_TXOP_PS, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1701 | cfg->vht_txop_ps); |
| 1702 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1703 | if (status == QDF_STATUS_E_FAILURE) |
| 1704 | hdd_err("could not set the VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1705 | } |
| 1706 | |
| 1707 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1708 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1709 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1710 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1711 | else |
| 1712 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1713 | |
| 1714 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1715 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1716 | status = sme_cfg_set_int(mac_handle, |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1717 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1718 | VHT_CAP_160_AND_80P80_SUPP); |
| 1719 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1720 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1721 | band_5g->vht_cap.cap |= |
| 1722 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1723 | ch_width = eHT_CHANNEL_WIDTH_80P80MHZ; |
| 1724 | } else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1725 | status = sme_cfg_set_int(mac_handle, |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1726 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1727 | VHT_CAP_160_SUPP); |
| 1728 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1729 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1730 | band_5g->vht_cap.cap |= |
| 1731 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1732 | ch_width = eHT_CHANNEL_WIDTH_160MHZ; |
| 1733 | } |
| 1734 | pconfig->vhtChannelWidth = QDF_MIN(pconfig->vhtChannelWidth, |
| 1735 | ch_width); |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1736 | /* Get the current GI 160 value */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1737 | status = sme_cfg_get_int(mac_handle, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1738 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1739 | &value); |
| 1740 | if (status != QDF_STATUS_SUCCESS) { |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1741 | hdd_err("could not get GI 80 & 160"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1742 | value = 0; |
| 1743 | } |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1744 | /* set the Guard interval 160MHz */ |
| 1745 | if (value && !cfg->vht_short_gi_160) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1746 | status = sme_cfg_set_int(mac_handle, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1747 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
| 1748 | cfg->vht_short_gi_160); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1749 | |
| 1750 | if (status == QDF_STATUS_E_FAILURE) |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1751 | hdd_err("failed to set SHORT GI 160MHZ"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1752 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1753 | |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1754 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1755 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1756 | hdd_debug("VHT RxLDPC capability is set"); |
| 1757 | } else { |
| 1758 | /* |
| 1759 | * Get the RX LDPC capability for the NON DBS |
| 1760 | * hardware mode for 5G band |
| 1761 | */ |
| 1762 | status = wma_get_caps_for_phyidx_hwmode(&caps_per_phy, |
| 1763 | HW_MODE_DBS_NONE, CDS_BAND_5GHZ); |
| 1764 | if ((QDF_IS_STATUS_SUCCESS(status)) && |
| 1765 | (caps_per_phy.vht_5g & WMI_VHT_CAP_RX_LDPC)) { |
| 1766 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1767 | hdd_debug("VHT RX LDPC capability is set"); |
| 1768 | } |
| 1769 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1770 | |
| 1771 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1772 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1773 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1774 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1775 | |
| 1776 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1777 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1778 | |
| 1779 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1780 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1781 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1782 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1783 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1784 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1785 | |
| 1786 | band_5g->vht_cap.cap |= |
| 1787 | (cfg->vht_max_ampdu_len_exp << |
| 1788 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1789 | |
| 1790 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1791 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1792 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1793 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1794 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1795 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1796 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1797 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1798 | |
| 1799 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1800 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1801 | |
| 1802 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1803 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1804 | /** |
| 1805 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1806 | * @hdd_ctx: Pointer to the HDD context |
| 1807 | * |
| 1808 | * Auto-generate mac address using device serial number. |
| 1809 | * Keep the first 3 bytes of OUI as before and replace |
| 1810 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1811 | * |
| 1812 | * Return: 0 for success |
| 1813 | * Non zero failure code for errors |
| 1814 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1815 | static int hdd_generate_macaddr_auto(struct hdd_context *hdd_ctx) |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1816 | { |
| 1817 | unsigned int serialno = 0; |
| 1818 | struct qdf_mac_addr mac_addr = { |
| 1819 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1820 | }; |
| 1821 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1822 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1823 | if (serialno == 0) |
| 1824 | return -EINVAL; |
| 1825 | |
| 1826 | serialno &= 0x00ffffff; |
| 1827 | |
| 1828 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1829 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1830 | mac_addr.bytes[5] = serialno & 0xff; |
| 1831 | |
| 1832 | hdd_update_macaddr(hdd_ctx->config, mac_addr); |
| 1833 | return 0; |
| 1834 | } |
| 1835 | |
Nachiket Kukade | 5f0ce4f | 2018-06-15 19:47:37 +0530 | [diff] [blame] | 1836 | #ifdef FEATURE_WLAN_APF |
| 1837 | /** |
| 1838 | * hdd_update_apf_support() - Update APF supported flag in hdd context |
| 1839 | * @hdd_ctx: Pointer to hdd_ctx |
| 1840 | * @cfg: target configuration |
| 1841 | * |
| 1842 | * Update the APF support flag in HDD Context using INI and target config. |
| 1843 | * |
| 1844 | * Return: None |
| 1845 | */ |
| 1846 | static void hdd_update_apf_support(struct hdd_context *hdd_ctx, |
| 1847 | struct wma_tgt_cfg *cfg) |
| 1848 | { |
| 1849 | hdd_ctx->apf_supported = (cfg->apf_enabled && |
| 1850 | hdd_ctx->config->apf_packet_filter_enable); |
| 1851 | } |
| 1852 | #else |
| 1853 | static void hdd_update_apf_support(struct hdd_context *hdd_ctx, |
| 1854 | struct wma_tgt_cfg *cfg) |
| 1855 | { |
| 1856 | } |
| 1857 | #endif |
| 1858 | |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1859 | /** |
| 1860 | * hdd_update_ra_rate_limit() - Update RA rate limit from target |
| 1861 | * configuration to cfg_ini in HDD |
| 1862 | * @hdd_ctx: Pointer to hdd_ctx |
| 1863 | * @cfg: target configuration |
| 1864 | * |
| 1865 | * Return: None |
| 1866 | */ |
| 1867 | #ifdef FEATURE_WLAN_RA_FILTERING |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1868 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1869 | struct wma_tgt_cfg *cfg) |
| 1870 | { |
| 1871 | hdd_ctx->config->IsRArateLimitEnabled = cfg->is_ra_rate_limit_enabled; |
| 1872 | } |
| 1873 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1874 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1875 | struct wma_tgt_cfg *cfg) |
| 1876 | { |
| 1877 | } |
| 1878 | #endif |
| 1879 | |
Jeff Johnson | f917638 | 2018-07-17 19:15:58 -0700 | [diff] [blame] | 1880 | static void hdd_sar_target_config(struct hdd_context *hdd_ctx, |
| 1881 | struct wma_tgt_cfg *cfg) |
| 1882 | { |
| 1883 | hdd_ctx->sar_version = cfg->sar_version; |
| 1884 | } |
| 1885 | |
Jeff Johnson | 8abc593 | 2018-06-02 22:51:37 -0700 | [diff] [blame] | 1886 | 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] | 1887 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1888 | int ret; |
Jeff Johnson | ea70b94 | 2018-07-02 09:42:31 -0700 | [diff] [blame] | 1889 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1890 | uint8_t temp_band_cap; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1891 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1892 | uint8_t antenna_mode; |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1893 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1894 | mac_handle_t mac_handle; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1895 | |
gaurank kathpalia | 843f7c3 | 2018-07-02 18:04:14 +0530 | [diff] [blame] | 1896 | if (!hdd_ctx) { |
| 1897 | hdd_err("HDD context is NULL"); |
| 1898 | return; |
| 1899 | } |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1900 | ret = hdd_objmgr_create_and_store_pdev(hdd_ctx); |
| 1901 | if (ret) { |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1902 | QDF_DEBUG_PANIC("Failed to create pdev; errno:%d", ret); |
| 1903 | return; |
| 1904 | } |
| 1905 | |
| 1906 | hdd_debug("New pdev has been created with pdev_id = %u", |
| 1907 | hdd_ctx->hdd_pdev->pdev_objmgr.wlan_pdev_id); |
| 1908 | |
| 1909 | status = dispatcher_pdev_open(hdd_ctx->hdd_pdev); |
| 1910 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1911 | QDF_DEBUG_PANIC("dispatcher pdev open failed; status:%d", |
| 1912 | status); |
| 1913 | return; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1914 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1915 | |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1916 | cdp_pdev_set_ctrl_pdev(cds_get_context(QDF_MODULE_ID_SOC), |
| 1917 | cds_get_context(QDF_MODULE_ID_TXRX), |
| 1918 | (struct cdp_ctrl_objmgr_pdev *)hdd_ctx->hdd_pdev); |
| 1919 | |
| 1920 | wlan_pdev_set_dp_handle(hdd_ctx->hdd_pdev, |
| 1921 | cds_get_context(QDF_MODULE_ID_TXRX)); |
| 1922 | |
Will Huang | 0724417 | 2018-05-14 14:23:30 +0800 | [diff] [blame] | 1923 | hdd_objmgr_update_tgt_max_vdev_psoc(hdd_ctx, cfg->max_intf_count); |
| 1924 | |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 1925 | ret = hdd_green_ap_update_config(hdd_ctx); |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 1926 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1927 | ucfg_ipa_set_dp_handle(hdd_ctx->hdd_psoc, |
| 1928 | cds_get_context(QDF_MODULE_ID_SOC)); |
| 1929 | ucfg_ipa_set_txrx_handle(hdd_ctx->hdd_psoc, |
| 1930 | cds_get_context(QDF_MODULE_ID_TXRX)); |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 1931 | ucfg_ipa_reg_sap_xmit_cb(hdd_ctx->hdd_pdev, |
| 1932 | hdd_softap_hard_start_xmit); |
| 1933 | ucfg_ipa_reg_send_to_nw_cb(hdd_ctx->hdd_pdev, |
| 1934 | hdd_ipa_send_skb_to_network); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1935 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1936 | if (cds_cfg) { |
| 1937 | if (hdd_ctx->config->enable_sub_20_channel_width != |
| 1938 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
| 1939 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1940 | cds_cfg->sub_20_channel_width = |
| 1941 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1942 | } else { |
| 1943 | cds_cfg->sub_20_channel_width = |
| 1944 | hdd_ctx->config->enable_sub_20_channel_width; |
| 1945 | } |
| 1946 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1947 | |
| 1948 | /* first store the INI band capability */ |
| 1949 | temp_band_cap = hdd_ctx->config->nBandCapability; |
| 1950 | |
| 1951 | hdd_ctx->config->nBandCapability = cfg->band_cap; |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 1952 | hdd_ctx->is_fils_roaming_supported = |
| 1953 | cfg->services.is_fils_roaming_supported; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1954 | |
Vignesh Viswanathan | 694e28e | 2018-01-18 20:53:57 +0530 | [diff] [blame] | 1955 | hdd_ctx->config->is_11k_offload_supported = |
| 1956 | cfg->services.is_11k_offload_supported; |
| 1957 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 1958 | /* |
| 1959 | * now overwrite the target band capability with INI |
| 1960 | * setting if INI setting is a subset |
| 1961 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1962 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1963 | if ((hdd_ctx->config->nBandCapability == BAND_ALL) && |
| 1964 | (temp_band_cap != BAND_ALL)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1965 | hdd_ctx->config->nBandCapability = temp_band_cap; |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1966 | else if ((hdd_ctx->config->nBandCapability != BAND_ALL) && |
| 1967 | (temp_band_cap != BAND_ALL) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1968 | (hdd_ctx->config->nBandCapability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1969 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1970 | } |
| 1971 | |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 1972 | hdd_ctx->curr_band = hdd_ctx->config->nBandCapability; |
| 1973 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1974 | if (!cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1975 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 1976 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 1977 | } |
| 1978 | |
| 1979 | /* This can be extended to other configurations like ht, vht cap... */ |
| 1980 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 1981 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1982 | hdd_update_macaddr(hdd_ctx->config, cfg->hw_macaddr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1983 | hdd_ctx->update_mac_addr_to_fw = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1984 | } else { |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1985 | static struct qdf_mac_addr default_mac_addr = { |
| 1986 | {0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF} |
| 1987 | }; |
| 1988 | if (qdf_is_macaddr_equal(&hdd_ctx->config->intfMacAddr[0], |
| 1989 | &default_mac_addr)) { |
| 1990 | if (hdd_generate_macaddr_auto(hdd_ctx) != 0) |
| 1991 | hdd_err("Fail to auto-generate MAC, using MAC from ini file " |
| 1992 | MAC_ADDRESS_STR, |
| 1993 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1994 | intfMacAddr[0].bytes)); |
| 1995 | } else { |
| 1996 | hdd_err("Invalid MAC passed from target, using MAC from ini file " |
| 1997 | MAC_ADDRESS_STR, |
| 1998 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1999 | intfMacAddr[0].bytes)); |
| 2000 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 2001 | hdd_ctx->update_mac_addr_to_fw = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2002 | } |
| 2003 | |
| 2004 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 2005 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2006 | |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2007 | hdd_ctx->hw_bd_id = cfg->hw_bd_id; |
| 2008 | qdf_mem_copy(&hdd_ctx->hw_bd_info, &cfg->hw_bd_info, |
| 2009 | sizeof(cfg->hw_bd_info)); |
| 2010 | |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 2011 | if (cfg->max_intf_count > CSR_ROAM_SESSION_MAX) { |
| 2012 | hdd_err("fw max vdevs (%u) > host max vdevs (%u); using %u", |
| 2013 | cfg->max_intf_count, CSR_ROAM_SESSION_MAX, |
| 2014 | CSR_ROAM_SESSION_MAX); |
| 2015 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 2016 | } else { |
| 2017 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 2018 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2019 | |
Jeff Johnson | f917638 | 2018-07-17 19:15:58 -0700 | [diff] [blame] | 2020 | hdd_sar_target_config(hdd_ctx, cfg); |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 2021 | hdd_lpass_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 2022 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2023 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 2024 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 2025 | |
| 2026 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 2027 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2028 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame] | 2029 | if (cfg->services.en_11ax) { |
| 2030 | hdd_info("11AX: 11ax is enabled - update HDD config"); |
| 2031 | hdd_update_tgt_he_cap(hdd_ctx, cfg); |
| 2032 | } |
Varun Reddy Yeturu | e93d246 | 2018-05-22 13:54:52 -0700 | [diff] [blame] | 2033 | hdd_update_tgt_twt_cap(hdd_ctx, cfg); |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 2034 | |
| 2035 | hdd_update_vdev_nss(hdd_ctx); |
| 2036 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 2037 | hdd_update_hw_dbs_capable(hdd_ctx); |
| 2038 | |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 2039 | hdd_ctx->config->fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 2040 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2041 | hdd_debug("fine_time_meas_cap: 0x%x", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2042 | hdd_ctx->config->fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 2043 | |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 2044 | antenna_mode = (hdd_ctx->config->enable2x2 == 0x01) ? |
| 2045 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 2046 | hdd_update_smps_antenna_mode(hdd_ctx, antenna_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2047 | hdd_debug("Init current antenna mode: %d", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2048 | hdd_ctx->current_antenna_mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 2049 | |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 2050 | hdd_ctx->rcpi_enabled = cfg->rcpi_enabled; |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 2051 | hdd_update_ra_rate_limit(hdd_ctx, cfg); |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 2052 | |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2053 | if ((hdd_ctx->config->txBFCsnValue > |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2054 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF) && |
| 2055 | !cfg->tx_bfee_8ss_enabled) |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2056 | hdd_ctx->config->txBFCsnValue = |
| 2057 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF; |
| 2058 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 2059 | mac_handle = hdd_ctx->mac_handle; |
| 2060 | status = sme_cfg_set_int(mac_handle, |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2061 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED, |
| 2062 | hdd_ctx->config->txBFCsnValue); |
| 2063 | if (QDF_IS_STATUS_ERROR(status)) |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2064 | hdd_err("fw update WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED to CFG fails"); |
| 2065 | |
Nachiket Kukade | 5f0ce4f | 2018-06-15 19:47:37 +0530 | [diff] [blame] | 2066 | hdd_update_apf_support(hdd_ctx, cfg); |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2067 | |
Nachiket Kukade | e547a48 | 2018-05-22 16:43:30 +0530 | [diff] [blame] | 2068 | hdd_debug("Target APF %d Host APF %d 8ss fw support %d txBFCsnValue %d", |
| 2069 | cfg->apf_enabled, hdd_ctx->config->apf_packet_filter_enable, |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2070 | cfg->tx_bfee_8ss_enabled, hdd_ctx->config->txBFCsnValue); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 2071 | |
| 2072 | /* |
| 2073 | * Update txBFCsnValue and NumSoundingDim values to vhtcap in wiphy |
| 2074 | */ |
| 2075 | hdd_update_wiphy_vhtcap(hdd_ctx); |
Manjeet Singh | 70d3d93 | 2016-12-20 20:41:10 +0530 | [diff] [blame] | 2076 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 2077 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 2078 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 2079 | /* |
| 2080 | * This needs to be done after HDD pdev is created and stored since |
| 2081 | * it will access the HDD pdev object lock. |
| 2082 | */ |
| 2083 | hdd_runtime_suspend_context_init(hdd_ctx); |
| 2084 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 2085 | /* Configure NAN datapath features */ |
| 2086 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Arif Hussain | 759a023 | 2017-03-20 13:17:18 -0700 | [diff] [blame] | 2087 | hdd_ctx->dfs_cac_offload = cfg->dfs_cac_offload; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 2088 | hdd_ctx->lte_coex_ant_share = cfg->services.lte_coex_ant_share; |
Liangwei Dong | 0da1426 | 2018-07-03 03:30:23 -0400 | [diff] [blame] | 2089 | hdd_ctx->obss_scan_offload = cfg->services.obss_scan_offload; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 2090 | status = sme_cfg_set_int(mac_handle, WNI_CFG_OBSS_DETECTION_OFFLOAD, |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2091 | cfg->obss_detection_offloaded); |
| 2092 | if (QDF_IS_STATUS_ERROR(status)) |
| 2093 | hdd_err("Couldn't pass WNI_CFG_OBSS_DETECTION_OFFLOAD to CFG"); |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2094 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 2095 | status = sme_cfg_set_int(mac_handle, |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2096 | WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD, |
| 2097 | cfg->obss_color_collision_offloaded); |
| 2098 | if (QDF_IS_STATUS_ERROR(status)) |
| 2099 | hdd_err("Failed to set WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2100 | } |
| 2101 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2102 | bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2103 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2104 | struct hdd_adapter *adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 2105 | struct hdd_ap_ctx *ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2106 | |
Jiachao Wu | f610d91 | 2018-01-23 17:47:32 +0800 | [diff] [blame] | 2107 | if (!hdd_ctx) { |
| 2108 | hdd_info("Couldn't get hdd_ctx"); |
| 2109 | return true; |
| 2110 | } |
| 2111 | |
| 2112 | if (hdd_ctx->config->disableDFSChSwitch) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 2113 | hdd_info("skip tx block hdd_ctx=%pK, disableDFSChSwitch=%d", |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2114 | hdd_ctx, hdd_ctx->config->disableDFSChSwitch); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2115 | return true; |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2116 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2117 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 2118 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2119 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 2120 | |
| 2121 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 2122 | QDF_P2P_GO_MODE == adapter->device_mode) && |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 2123 | (wlan_reg_is_passive_or_disable_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 2124 | ap_ctx->operating_channel))) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2125 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->dfs_cac_block_tx = |
| 2126 | true; |
| 2127 | hdd_info("tx blocked for session: %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2128 | adapter->session_id); |
bings | 6fb9bf6 | 2018-07-05 14:01:53 +0800 | [diff] [blame] | 2129 | if (adapter->txrx_vdev) |
| 2130 | cdp_fc_vdev_flush( |
| 2131 | cds_get_context(QDF_MODULE_ID_SOC), |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 2132 | adapter->txrx_vdev); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2133 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2134 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2135 | |
| 2136 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2137 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2138 | |
| 2139 | /** |
| 2140 | * hdd_is_valid_mac_address() - validate MAC address |
| 2141 | * @pMacAddr: Pointer to the input MAC address |
| 2142 | * |
| 2143 | * This function validates whether the given MAC address is valid or not |
| 2144 | * Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 2145 | * where X is the hexa decimal digit character and separated by ':' |
| 2146 | * This algorithm works even if MAC address is not separated by ':' |
| 2147 | * |
| 2148 | * This code checks given input string mac contains exactly 12 hexadecimal |
| 2149 | * digits and a separator colon : appears in the input string only after |
| 2150 | * an even number of hex digits. |
| 2151 | * |
| 2152 | * Return: 1 for valid and 0 for invalid |
| 2153 | */ |
| 2154 | bool hdd_is_valid_mac_address(const uint8_t *pMacAddr) |
| 2155 | { |
| 2156 | int xdigit = 0; |
| 2157 | int separator = 0; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2158 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2159 | while (*pMacAddr) { |
| 2160 | if (isxdigit(*pMacAddr)) { |
| 2161 | xdigit++; |
| 2162 | } else if (':' == *pMacAddr) { |
| 2163 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 2164 | break; |
| 2165 | |
| 2166 | ++separator; |
| 2167 | } else { |
| 2168 | /* Invalid MAC found */ |
| 2169 | return 0; |
| 2170 | } |
| 2171 | ++pMacAddr; |
| 2172 | } |
| 2173 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 2174 | } |
| 2175 | |
| 2176 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2177 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 2178 | * @dev: Handle to struct net_device to be updated. |
| 2179 | * |
| 2180 | * Return: None |
| 2181 | */ |
| 2182 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 2183 | { |
| 2184 | dev->header_ops = NULL; |
| 2185 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 2186 | dev->hard_header_len = ETH_HLEN; |
| 2187 | dev->mtu = ETH_DATA_LEN; |
| 2188 | dev->addr_len = ETH_ALEN; |
| 2189 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 2190 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 2191 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 2192 | |
| 2193 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 2194 | } |
| 2195 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 2196 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2197 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2198 | * __hdd__mon_open() - HDD Open function |
| 2199 | * @dev: Pointer to net_device structure |
| 2200 | * |
| 2201 | * This is called in response to ifconfig up |
| 2202 | * |
| 2203 | * Return: 0 for success; non-zero for failure |
| 2204 | */ |
| 2205 | static int __hdd_mon_open(struct net_device *dev) |
| 2206 | { |
| 2207 | int ret; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2208 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2209 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2210 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2211 | hdd_enter_dev(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2212 | |
| 2213 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2214 | if (ret) |
| 2215 | return ret; |
| 2216 | |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2217 | hdd_mon_mode_ether_setup(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2218 | |
| 2219 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2220 | ret = hdd_wlan_start_modules(hdd_ctx, false); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2221 | if (ret) { |
| 2222 | hdd_err("Failed to start WLAN modules return"); |
| 2223 | return ret; |
| 2224 | } |
| 2225 | hdd_err("hdd_wlan_start_modules() successful !"); |
| 2226 | |
| 2227 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2228 | ret = hdd_start_adapter(adapter); |
| 2229 | if (ret) { |
| 2230 | hdd_err("Failed to start adapter :%d", |
| 2231 | adapter->device_mode); |
| 2232 | return ret; |
| 2233 | } |
| 2234 | hdd_err("hdd_start_adapters() successful !"); |
| 2235 | } |
| 2236 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2237 | } |
| 2238 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2239 | ret = hdd_set_mon_rx_cb(dev); |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 2240 | |
| 2241 | if (!ret) |
| 2242 | ret = hdd_enable_monitor_mode(dev); |
| 2243 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2244 | return ret; |
| 2245 | } |
| 2246 | |
| 2247 | /** |
| 2248 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 2249 | * @dev: Pointer to net_device structure |
| 2250 | * |
| 2251 | * This is called in response to ifconfig up |
| 2252 | * |
| 2253 | * Return: 0 for success; non-zero for failure |
| 2254 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2255 | static int hdd_mon_open(struct net_device *dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2256 | { |
| 2257 | int ret; |
| 2258 | |
| 2259 | cds_ssr_protect(__func__); |
| 2260 | ret = __hdd_mon_open(dev); |
| 2261 | cds_ssr_unprotect(__func__); |
| 2262 | |
| 2263 | return ret; |
| 2264 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 2265 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2266 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2267 | static QDF_STATUS |
| 2268 | wlan_hdd_update_dbs_scan_and_fw_mode_config(void) |
| 2269 | { |
| 2270 | struct policy_mgr_dual_mac_config cfg = {0}; |
| 2271 | QDF_STATUS status; |
| 2272 | uint32_t channel_select_logic_conc; |
| 2273 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 2274 | |
| 2275 | if (!hdd_ctx) { |
| 2276 | hdd_err("HDD context is NULL"); |
| 2277 | return QDF_STATUS_E_FAILURE; |
| 2278 | } |
| 2279 | |
| 2280 | |
| 2281 | if (!policy_mgr_is_hw_dbs_capable(hdd_ctx->hdd_psoc)) |
| 2282 | return QDF_STATUS_SUCCESS; |
| 2283 | |
| 2284 | cfg.scan_config = 0; |
| 2285 | cfg.fw_mode_config = 0; |
| 2286 | cfg.set_dual_mac_cb = policy_mgr_soc_set_dual_mac_cfg_cb; |
| 2287 | |
| 2288 | channel_select_logic_conc = hdd_ctx->config-> |
| 2289 | channel_select_logic_conc; |
| 2290 | |
| 2291 | if (hdd_ctx->config->dual_mac_feature_disable != |
| 2292 | DISABLE_DBS_CXN_AND_SCAN) { |
| 2293 | status = policy_mgr_get_updated_scan_and_fw_mode_config( |
| 2294 | hdd_ctx->hdd_psoc, &cfg.scan_config, |
| 2295 | &cfg.fw_mode_config, |
| 2296 | hdd_ctx->config->dual_mac_feature_disable, |
| 2297 | channel_select_logic_conc); |
| 2298 | |
| 2299 | if (status != QDF_STATUS_SUCCESS) { |
| 2300 | hdd_err("wma_get_updated_scan_and_fw_mode_config failed %d", |
| 2301 | status); |
| 2302 | return status; |
| 2303 | } |
| 2304 | } |
| 2305 | |
| 2306 | hdd_debug("send scan_cfg: 0x%x fw_mode_cfg: 0x%x to fw", |
| 2307 | cfg.scan_config, cfg.fw_mode_config); |
| 2308 | |
| 2309 | status = sme_soc_set_dual_mac_config(cfg); |
| 2310 | if (status != QDF_STATUS_SUCCESS) { |
| 2311 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 2312 | return status; |
| 2313 | } |
| 2314 | |
| 2315 | return QDF_STATUS_SUCCESS; |
| 2316 | } |
| 2317 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2318 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2319 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 2320 | * @adapter: pointer to HDD adapter |
| 2321 | * |
| 2322 | * This function is called to start the device specific adapter for |
| 2323 | * the mode passed in the adapter's device_mode. |
| 2324 | * |
| 2325 | * Return: 0 for success; non-zero for failure |
| 2326 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2327 | int hdd_start_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2328 | { |
| 2329 | |
| 2330 | int ret; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 2331 | enum QDF_OPMODE device_mode = adapter->device_mode; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2332 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2333 | hdd_enter_dev(adapter->dev); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2334 | hdd_debug("Start_adapter for mode : %d", adapter->device_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2335 | |
| 2336 | switch (device_mode) { |
| 2337 | case QDF_P2P_CLIENT_MODE: |
| 2338 | case QDF_P2P_DEVICE_MODE: |
| 2339 | case QDF_OCB_MODE: |
| 2340 | case QDF_STA_MODE: |
| 2341 | case QDF_MONITOR_MODE: |
| 2342 | ret = hdd_start_station_adapter(adapter); |
| 2343 | if (ret) |
| 2344 | goto err_start_adapter; |
Alok Kumar | 81e1d73 | 2018-09-04 11:10:36 +0530 | [diff] [blame] | 2345 | |
| 2346 | hdd_nud_ignore_tracking(adapter, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2347 | break; |
| 2348 | case QDF_P2P_GO_MODE: |
| 2349 | case QDF_SAP_MODE: |
| 2350 | ret = hdd_start_ap_adapter(adapter); |
| 2351 | if (ret) |
| 2352 | goto err_start_adapter; |
| 2353 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 2354 | case QDF_IBSS_MODE: |
| 2355 | /* |
| 2356 | * For IBSS interface is initialized as part of |
| 2357 | * hdd_init_station_mode() |
| 2358 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2359 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2360 | case QDF_FTM_MODE: |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2361 | /* vdevs are dynamically managed by firmware in FTM */ |
| 2362 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2363 | default: |
| 2364 | hdd_err("Invalid session type %d", device_mode); |
| 2365 | QDF_ASSERT(0); |
| 2366 | goto err_start_adapter; |
| 2367 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2368 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2369 | if (hdd_set_fw_params(adapter)) |
| 2370 | hdd_err("Failed to set the FW params for the adapter!"); |
| 2371 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2372 | if (adapter->session_id != HDD_SESSION_ID_INVALID) { |
| 2373 | ret = wlan_hdd_cfg80211_register_frames(adapter); |
| 2374 | if (ret < 0) { |
| 2375 | hdd_err("Failed to register frames - ret %d", ret); |
| 2376 | goto err_start_adapter; |
| 2377 | } |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2378 | } |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2379 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2380 | wlan_hdd_update_dbs_scan_and_fw_mode_config(); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2381 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2382 | exit_with_success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2383 | hdd_exit(); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2384 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2385 | return 0; |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2386 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2387 | err_start_adapter: |
| 2388 | return -EINVAL; |
| 2389 | } |
| 2390 | |
| 2391 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2392 | * hdd_enable_power_management() - API to Enable Power Management |
| 2393 | * |
| 2394 | * API invokes Bus Interface Layer power management functionality |
| 2395 | * |
| 2396 | * Return: None |
| 2397 | */ |
| 2398 | static void hdd_enable_power_management(void) |
| 2399 | { |
| 2400 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2401 | |
| 2402 | if (!hif_ctx) { |
| 2403 | hdd_err("Bus Interface Context is Invalid"); |
| 2404 | return; |
| 2405 | } |
| 2406 | |
| 2407 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 2408 | } |
| 2409 | |
| 2410 | /** |
| 2411 | * hdd_disable_power_management() - API to disable Power Management |
| 2412 | * |
| 2413 | * API disable Bus Interface Layer Power management functionality |
| 2414 | * |
| 2415 | * Return: None |
| 2416 | */ |
| 2417 | static void hdd_disable_power_management(void) |
| 2418 | { |
| 2419 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2420 | |
| 2421 | if (!hif_ctx) { |
| 2422 | hdd_err("Bus Interface Context is Invalid"); |
| 2423 | return; |
| 2424 | } |
| 2425 | |
| 2426 | hif_disable_power_management(hif_ctx); |
| 2427 | } |
| 2428 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2429 | void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2430 | { |
| 2431 | void *hif_sc; |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2432 | size_t target_hw_name_len; |
| 2433 | const char *target_hw_name; |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2434 | uint8_t *buf; |
| 2435 | uint32_t buf_len; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2436 | |
| 2437 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
| 2438 | if (!hif_sc) { |
| 2439 | hdd_err("HIF context is NULL"); |
| 2440 | return; |
| 2441 | } |
| 2442 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2443 | hif_get_hw_info(hif_sc, &hdd_ctx->target_hw_version, |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2444 | &hdd_ctx->target_hw_revision, |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2445 | &target_hw_name); |
| 2446 | |
| 2447 | if (hdd_ctx->target_hw_name) |
| 2448 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2449 | |
| 2450 | target_hw_name_len = strlen(target_hw_name) + 1; |
| 2451 | hdd_ctx->target_hw_name = qdf_mem_malloc(target_hw_name_len); |
| 2452 | if (hdd_ctx->target_hw_name) |
| 2453 | qdf_mem_copy(hdd_ctx->target_hw_name, target_hw_name, |
| 2454 | target_hw_name_len); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2455 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2456 | buf = qdf_mem_malloc(WE_MAX_STR_LEN); |
| 2457 | if (buf) { |
| 2458 | buf_len = hdd_wlan_get_version(hdd_ctx, WE_MAX_STR_LEN, buf); |
| 2459 | hdd_info("%s", buf); |
| 2460 | qdf_mem_free(buf); |
| 2461 | } |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2462 | } |
| 2463 | |
| 2464 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2465 | * hdd_update_cds_ac_specs_params() - update cds ac_specs params |
| 2466 | * @hdd_ctx: Pointer to hdd context |
| 2467 | * |
| 2468 | * Return: none |
| 2469 | */ |
| 2470 | static void |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2471 | hdd_update_cds_ac_specs_params(struct hdd_context *hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2472 | { |
| 2473 | uint8_t num_entries = 0; |
| 2474 | uint8_t tx_sched_wrr_param[TX_SCHED_WRR_PARAMS_NUM]; |
| 2475 | uint8_t *tx_sched_wrr_ac; |
| 2476 | int i; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2477 | struct cds_context *cds_ctx; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2478 | |
| 2479 | if (NULL == hdd_ctx) |
| 2480 | return; |
| 2481 | |
| 2482 | if (NULL == hdd_ctx->config) { |
| 2483 | /* Do nothing if hdd_ctx is invalid */ |
| 2484 | hdd_err("%s: Warning: hdd_ctx->cfg_ini is NULL", __func__); |
| 2485 | return; |
| 2486 | } |
| 2487 | |
| 2488 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2489 | |
| 2490 | if (!cds_ctx) { |
| 2491 | hdd_err("Invalid CDS Context"); |
| 2492 | return; |
| 2493 | } |
| 2494 | |
| 2495 | for (i = 0; i < OL_TX_NUM_WMM_AC; i++) { |
| 2496 | switch (i) { |
| 2497 | case OL_TX_WMM_AC_BE: |
| 2498 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_be; |
| 2499 | break; |
| 2500 | case OL_TX_WMM_AC_BK: |
| 2501 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_bk; |
| 2502 | break; |
| 2503 | case OL_TX_WMM_AC_VI: |
| 2504 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vi; |
| 2505 | break; |
| 2506 | case OL_TX_WMM_AC_VO: |
| 2507 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vo; |
| 2508 | break; |
| 2509 | default: |
| 2510 | tx_sched_wrr_ac = NULL; |
| 2511 | break; |
| 2512 | } |
| 2513 | |
| 2514 | hdd_string_to_u8_array(tx_sched_wrr_ac, |
| 2515 | tx_sched_wrr_param, |
| 2516 | &num_entries, |
| 2517 | sizeof(tx_sched_wrr_param)); |
| 2518 | |
| 2519 | if (num_entries == TX_SCHED_WRR_PARAMS_NUM) { |
| 2520 | cds_ctx->ac_specs[i].wrr_skip_weight = |
| 2521 | tx_sched_wrr_param[0]; |
| 2522 | cds_ctx->ac_specs[i].credit_threshold = |
| 2523 | tx_sched_wrr_param[1]; |
| 2524 | cds_ctx->ac_specs[i].send_limit = |
| 2525 | tx_sched_wrr_param[2]; |
| 2526 | cds_ctx->ac_specs[i].credit_reserve = |
| 2527 | tx_sched_wrr_param[3]; |
| 2528 | cds_ctx->ac_specs[i].discard_weight = |
| 2529 | tx_sched_wrr_param[4]; |
| 2530 | } |
| 2531 | |
| 2532 | num_entries = 0; |
| 2533 | } |
| 2534 | } |
| 2535 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2536 | uint32_t hdd_wlan_get_version(struct hdd_context *hdd_ctx, |
| 2537 | const size_t version_len, uint8_t *version) |
| 2538 | { |
| 2539 | uint32_t size; |
| 2540 | uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0; |
| 2541 | |
| 2542 | if (!hdd_ctx) { |
| 2543 | hdd_err("Invalid context, HDD context is null"); |
| 2544 | return 0; |
| 2545 | } |
| 2546 | |
Ashish Kumar Dhanotiya | 7353f88 | 2018-05-15 12:50:19 +0530 | [diff] [blame] | 2547 | if (!version || version_len == 0) { |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2548 | hdd_err("Invalid buffer pointr or buffer len\n"); |
| 2549 | return 0; |
| 2550 | } |
| 2551 | |
| 2552 | msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 2553 | mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 2554 | siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 2555 | crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 2556 | sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28; |
| 2557 | |
| 2558 | size = scnprintf(version, version_len, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2559 | "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] | 2560 | QWLAN_VERSIONSTR, |
| 2561 | msp_id, mspid, siid, crmid, sub_id, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2562 | hdd_ctx->target_hw_name, |
| 2563 | hdd_ctx->hw_bd_info.bdf_version, |
| 2564 | hdd_ctx->hw_bd_info.ref_design_id, |
| 2565 | hdd_ctx->hw_bd_info.customer_id, |
| 2566 | hdd_ctx->hw_bd_info.project_id, |
| 2567 | hdd_ctx->hw_bd_info.board_data_rev); |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2568 | |
| 2569 | return size; |
| 2570 | } |
| 2571 | |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 2572 | int hdd_set_11ax_rate(struct hdd_adapter *adapter, int set_value, |
| 2573 | struct sap_config *sap_config) |
| 2574 | { |
| 2575 | uint8_t preamble = 0, nss = 0, rix = 0; |
| 2576 | int ret; |
| 2577 | mac_handle_t mac_handle = adapter->hdd_ctx->mac_handle; |
| 2578 | |
| 2579 | if (!sap_config) { |
| 2580 | if (!sme_is_feature_supported_by_fw(DOT11AX)) { |
| 2581 | hdd_err("Target does not support 11ax"); |
| 2582 | return -EIO; |
| 2583 | } |
| 2584 | } else if (sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax && |
| 2585 | sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax_ONLY) { |
| 2586 | hdd_err("Invalid hw mode, SAP hw_mode= 0x%x, ch = %d", |
| 2587 | sap_config->SapHw_mode, sap_config->channel); |
| 2588 | return -EIO; |
| 2589 | } |
| 2590 | |
| 2591 | if (set_value != 0xff) { |
| 2592 | rix = RC_2_RATE_IDX_11AX(set_value); |
| 2593 | preamble = WMI_RATE_PREAMBLE_HE; |
| 2594 | nss = HT_RC_2_STREAMS_11AX(set_value); |
| 2595 | |
| 2596 | set_value = hdd_assemble_rate_code(preamble, nss, rix); |
| 2597 | } else { |
| 2598 | ret = sme_set_auto_rate_he_ltf(mac_handle, adapter->session_id, |
| 2599 | QCA_WLAN_HE_LTF_AUTO); |
| 2600 | } |
| 2601 | |
| 2602 | hdd_info("SET_11AX_RATE val %d rix %d preamble %x nss %d", |
| 2603 | set_value, rix, preamble, nss); |
| 2604 | |
| 2605 | ret = wma_cli_set_command(adapter->session_id, |
| 2606 | WMI_VDEV_PARAM_FIXED_RATE, |
| 2607 | set_value, VDEV_CMD); |
| 2608 | |
| 2609 | return ret; |
| 2610 | } |
| 2611 | |
| 2612 | int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate) |
| 2613 | { |
| 2614 | int set_value; |
| 2615 | |
| 2616 | if (sme_is_feature_supported_by_fw(DOT11AX)) |
| 2617 | set_value = WMI_ASSEMBLE_RATECODE_V1(rate, nss, preamble); |
| 2618 | else |
| 2619 | set_value = (preamble << 6) | (nss << 4) | rate; |
| 2620 | |
| 2621 | return set_value; |
| 2622 | } |
| 2623 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2624 | #ifdef IPA_OFFLOAD |
| 2625 | /** |
| 2626 | * hdd_update_ipa_component_config() - update ipa config |
| 2627 | * @hdd_ctx: Pointer to hdd context |
| 2628 | * |
| 2629 | * Return: none |
| 2630 | */ |
| 2631 | static void hdd_update_ipa_component_config(struct hdd_context *hdd_ctx) |
| 2632 | { |
| 2633 | struct hdd_config *cfg = hdd_ctx->config; |
| 2634 | struct wlan_ipa_config ipa_cfg; |
| 2635 | |
| 2636 | ipa_cfg.ipa_config = cfg->IpaConfig; |
| 2637 | ipa_cfg.desc_size = cfg->IpaDescSize; |
| 2638 | ipa_cfg.txbuf_count = cfg->IpaUcTxBufCount; |
| 2639 | ipa_cfg.bus_bw_high = cfg->busBandwidthHighThreshold; |
| 2640 | ipa_cfg.bus_bw_medium = cfg->busBandwidthMediumThreshold; |
| 2641 | ipa_cfg.bus_bw_low = cfg->busBandwidthLowThreshold; |
| 2642 | ipa_cfg.ipa_bw_high = cfg->IpaHighBandwidthMbps; |
| 2643 | ipa_cfg.ipa_bw_medium = cfg->IpaMediumBandwidthMbps; |
| 2644 | ipa_cfg.ipa_bw_low = cfg->IpaLowBandwidthMbps; |
| 2645 | |
| 2646 | ucfg_ipa_update_config(&ipa_cfg); |
| 2647 | } |
| 2648 | #else |
| 2649 | static void hdd_update_ipa_component_config(struct hdd_context *hdd_ctx) |
| 2650 | { |
| 2651 | } |
| 2652 | #endif |
| 2653 | |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2654 | #ifdef FEATURE_WLAN_WAPI |
| 2655 | /** |
| 2656 | * hdd_wapi_security_sta_exist() - return wapi security sta exist or not |
| 2657 | * |
| 2658 | * This API returns the wapi security station exist or not |
| 2659 | * |
| 2660 | * Return: true - wapi security station exist |
| 2661 | */ |
| 2662 | static bool hdd_wapi_security_sta_exist(void) |
| 2663 | { |
| 2664 | struct hdd_adapter *adapter = NULL; |
| 2665 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 2666 | |
| 2667 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 2668 | if ((adapter->device_mode == QDF_STA_MODE) && |
| 2669 | adapter->wapi_info.wapi_mode && |
| 2670 | (adapter->wapi_info.wapi_auth_mode != WAPI_AUTH_MODE_OPEN)) |
| 2671 | return true; |
| 2672 | } |
| 2673 | return false; |
| 2674 | } |
| 2675 | #else |
| 2676 | static bool hdd_wapi_security_sta_exist(void) |
| 2677 | { |
| 2678 | return false; |
| 2679 | } |
| 2680 | #endif |
| 2681 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2682 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2683 | static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev( |
| 2684 | struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) |
| 2685 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2686 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2687 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2688 | |
| 2689 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 2690 | if (!adapter) { |
| 2691 | hdd_err("Adapter is NULL"); |
| 2692 | return PM_MAX_NUM_OF_MODE; |
| 2693 | } |
| 2694 | |
| 2695 | return policy_mgr_convert_device_mode_to_qdf_type( |
| 2696 | adapter->device_mode); |
| 2697 | } |
| 2698 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2699 | static void hdd_register_policy_manager_callback( |
| 2700 | struct wlan_objmgr_psoc *psoc) |
| 2701 | { |
| 2702 | struct policy_mgr_hdd_cbacks hdd_cbacks; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 2703 | |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2704 | qdf_mem_zero(&hdd_cbacks, sizeof(hdd_cbacks)); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2705 | hdd_cbacks.sap_restart_chan_switch_cb = |
Jeff Johnson | 2381294 | 2017-10-06 11:33:55 -0700 | [diff] [blame] | 2706 | hdd_sap_restart_chan_switch_cb; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2707 | hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = |
| 2708 | wlan_hdd_get_channel_for_sap_restart; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2709 | hdd_cbacks.get_mode_for_non_connected_vdev = |
| 2710 | wlan_hdd_get_mode_for_non_connected_vdev; |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 2711 | hdd_cbacks.hdd_get_device_mode = hdd_get_device_mode; |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2712 | hdd_cbacks.hdd_wapi_security_sta_exist = |
| 2713 | hdd_wapi_security_sta_exist; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2714 | if (QDF_STATUS_SUCCESS != |
| 2715 | policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { |
| 2716 | hdd_err("HDD callback registration with policy manager failed"); |
| 2717 | } |
| 2718 | } |
| 2719 | #else |
| 2720 | static void hdd_register_policy_manager_callback( |
| 2721 | struct wlan_objmgr_psoc *psoc) |
| 2722 | { |
| 2723 | } |
| 2724 | #endif |
| 2725 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2726 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2727 | { |
| 2728 | struct nan_callbacks cb_obj = {0}; |
| 2729 | |
| 2730 | cb_obj.ndi_open = hdd_ndi_open; |
| 2731 | cb_obj.ndi_close = hdd_ndi_close; |
| 2732 | cb_obj.ndi_start = hdd_ndi_start; |
| 2733 | cb_obj.ndi_delete = hdd_ndi_delete; |
| 2734 | cb_obj.drv_ndi_create_rsp_handler = hdd_ndi_drv_ndi_create_rsp_handler; |
| 2735 | cb_obj.drv_ndi_delete_rsp_handler = hdd_ndi_drv_ndi_delete_rsp_handler; |
| 2736 | |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2737 | cb_obj.new_peer_ind = hdd_ndp_new_peer_handler; |
| 2738 | cb_obj.get_peer_idx = hdd_ndp_get_peer_idx; |
Naveen Rawat | b3143ea | 2017-03-26 22:25:46 -0700 | [diff] [blame] | 2739 | cb_obj.peer_departed_ind = hdd_ndp_peer_departed_handler; |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2740 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2741 | os_if_nan_register_hdd_callbacks(hdd_ctx->hdd_psoc, &cb_obj); |
| 2742 | } |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2743 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2744 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2745 | /** |
| 2746 | * hdd_check_for_leaks() - Perform runtime memory leak checks |
Dustin Brown | a6246dd | 2018-05-24 14:35:58 -0700 | [diff] [blame] | 2747 | * @hdd_ctx: the global HDD context |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2748 | * @is_ssr: true if SSR is in progress |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2749 | * |
| 2750 | * This API triggers runtime memory leak detection. This feature enforces the |
| 2751 | * policy that any memory allocated at runtime must also be released at runtime. |
| 2752 | * |
| 2753 | * Allocating memory at runtime and releasing it at unload is effectively a |
| 2754 | * memory leak for configurations which never unload (e.g. LONU, statically |
| 2755 | * compiled driver). Such memory leaks are NOT false positives, and must be |
| 2756 | * fixed. |
| 2757 | * |
| 2758 | * Return: None |
| 2759 | */ |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2760 | 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] | 2761 | { |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2762 | /* DO NOT REMOVE these checks; for false positives, read above first */ |
| 2763 | |
Dustin Brown | 3cfe0d4 | 2018-07-25 14:13:47 -0700 | [diff] [blame] | 2764 | wlan_objmgr_psoc_check_for_peer_leaks(hdd_ctx->hdd_psoc); |
Dustin Brown | a6246dd | 2018-05-24 14:35:58 -0700 | [diff] [blame] | 2765 | wlan_objmgr_psoc_check_for_vdev_leaks(hdd_ctx->hdd_psoc); |
Dustin Brown | 2946296 | 2018-06-18 14:02:00 -0700 | [diff] [blame] | 2766 | wlan_objmgr_psoc_check_for_pdev_leaks(hdd_ctx->hdd_psoc); |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2767 | |
| 2768 | /* many adapter resources are not freed by design during SSR */ |
| 2769 | if (is_ssr) |
| 2770 | return; |
| 2771 | |
Dustin Brown | 677e086 | 2017-10-10 16:30:09 -0700 | [diff] [blame] | 2772 | qdf_mc_timer_check_for_leaks(); |
Dustin Brown | 8e71150 | 2017-12-07 16:49:11 -0800 | [diff] [blame] | 2773 | qdf_nbuf_map_check_for_leaks(); |
Dustin Brown | e6b9d5a | 2017-12-14 15:18:49 -0800 | [diff] [blame] | 2774 | qdf_mem_check_for_leaks(); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2775 | } |
| 2776 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2777 | #define hdd_debug_domain_set(domain) qdf_debug_domain_set(domain) |
| 2778 | #else |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2779 | static inline void hdd_check_for_leaks(struct hdd_context *hdd_ctx, bool is_ssr) |
| 2780 | { } |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2781 | |
| 2782 | #define hdd_debug_domain_set(domain) |
| 2783 | #endif /* CONFIG_LEAK_DETECTION */ |
| 2784 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2785 | /** |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2786 | * hdd_update_country_code - Update country code |
| 2787 | * @hdd_ctx: HDD context |
| 2788 | * |
| 2789 | * Update country code based on module parameter country_code |
| 2790 | * |
| 2791 | * Return: 0 on success and errno on failure |
| 2792 | */ |
| 2793 | static int hdd_update_country_code(struct hdd_context *hdd_ctx) |
| 2794 | { |
| 2795 | if (!country_code) |
| 2796 | return 0; |
| 2797 | |
| 2798 | return hdd_reg_set_country(hdd_ctx, country_code); |
| 2799 | } |
| 2800 | |
| 2801 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2802 | * hdd_wlan_start_modules() - Single driver state machine for starting modules |
| 2803 | * @hdd_ctx: HDD context |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2804 | * @reinit: flag to indicate from SSR or normal path |
| 2805 | * |
| 2806 | * This function maintains the driver state machine it will be invoked from |
| 2807 | * startup, reinit and change interface. Depending on the driver state shall |
| 2808 | * perform the opening of the modules. |
| 2809 | * |
| 2810 | * Return: 0 for success; non-zero for failure |
| 2811 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2812 | int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, bool reinit) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2813 | { |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2814 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2815 | qdf_device_t qdf_dev; |
| 2816 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2817 | bool unint = false; |
| 2818 | void *hif_ctx; |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2819 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2820 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2821 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2822 | if (!qdf_dev) { |
| 2823 | hdd_err("QDF Device Context is Invalid return"); |
| 2824 | return -EINVAL; |
| 2825 | } |
| 2826 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 2827 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2828 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2829 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2830 | if (hdd_ctx->driver_status == DRIVER_MODULES_ENABLED) { |
| 2831 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2832 | hdd_debug("Driver modules already Enabled"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2833 | hdd_exit(); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2834 | return 0; |
| 2835 | } |
| 2836 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2837 | hdd_ctx->start_modules_in_progress = true; |
| 2838 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2839 | switch (hdd_ctx->driver_status) { |
| 2840 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2841 | hdd_info("Wlan transitioning (UNINITIALIZED -> CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2842 | unint = true; |
| 2843 | /* Fall through dont add break here */ |
| 2844 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2845 | hdd_info("Wlan transitioning (CLOSED -> OPENED)"); |
| 2846 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2847 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2848 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2849 | if (!reinit && !unint) { |
| 2850 | ret = pld_power_on(qdf_dev->dev); |
| 2851 | if (ret) { |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2852 | hdd_err("Failed to power up device; errno:%d", |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2853 | ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2854 | goto release_lock; |
| 2855 | } |
| 2856 | } |
Yuanyuan Liu | f8fe4bc | 2017-06-07 16:55:58 -0700 | [diff] [blame] | 2857 | |
| 2858 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 2859 | hdd_ctx->config->enable_fw_log); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2860 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 2861 | qdf_dev->bus_type, |
| 2862 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 2863 | HIF_ENABLE_TYPE_PROBE); |
| 2864 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2865 | hdd_err("Failed to open hif; errno: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2866 | goto power_down; |
| 2867 | } |
| 2868 | |
| 2869 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2870 | if (!hif_ctx) { |
| 2871 | hdd_err("hif context is null!!"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2872 | ret = -EINVAL; |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2873 | goto power_down; |
| 2874 | } |
| 2875 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2876 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 2877 | if (status != QDF_STATUS_SUCCESS) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2878 | hdd_err("No Memory to Create BMI Context; status: %d", |
| 2879 | status); |
| 2880 | ret = qdf_status_to_os_return(status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2881 | goto hif_close; |
| 2882 | } |
| 2883 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2884 | hdd_update_ipa_component_config(hdd_ctx); |
| 2885 | |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2886 | ret = hdd_update_config(hdd_ctx); |
| 2887 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2888 | hdd_err("Failed to update configuration; errno: %d", |
| 2889 | ret); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2890 | goto cds_free; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2891 | } |
| 2892 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2893 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 2894 | |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 2895 | status = hdd_component_psoc_open(hdd_ctx->hdd_psoc); |
| 2896 | if (QDF_IS_STATUS_ERROR(status)) { |
| 2897 | hdd_err("Failed to Open legacy components; status: %d", |
| 2898 | status); |
| 2899 | ret = qdf_status_to_os_return(status); |
| 2900 | goto deinit_config; |
| 2901 | } |
| 2902 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2903 | status = cds_open(hdd_ctx->hdd_psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2904 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2905 | hdd_err("Failed to Open CDS; status: %d", status); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2906 | ret = qdf_status_to_os_return(status); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 2907 | goto hdd_psoc_close; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2908 | } |
| 2909 | |
Manjunathappa Prakash | b6b4ff1 | 2018-06-04 12:32:33 -0700 | [diff] [blame] | 2910 | if (hdd_ctx->config->rx_thread_affinity_mask) |
| 2911 | cds_set_rx_thread_cpu_mask( |
| 2912 | hdd_ctx->config->rx_thread_affinity_mask); |
| 2913 | |
| 2914 | /* initialize components configurations after psoc open */ |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2915 | ret = hdd_update_components_config(hdd_ctx); |
| 2916 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2917 | hdd_err("Failed to update component configs; errno: %d", |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2918 | ret); |
| 2919 | goto close; |
| 2920 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2921 | status = cds_dp_open(hdd_ctx->hdd_psoc); |
| 2922 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2923 | hdd_err("Failed to Open cds post open; status: %d", |
| 2924 | status); |
| 2925 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2926 | goto close; |
| 2927 | } |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2928 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2929 | /* |
| 2930 | * NAN compoenet requires certian operations like, open adapter, |
| 2931 | * close adapter, etc. to be initiated by HDD, for those |
| 2932 | * register HDD callbacks with UMAC's NAN componenet. |
| 2933 | */ |
| 2934 | hdd_nan_register_callbacks(hdd_ctx); |
| 2935 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 2936 | hdd_ctx->mac_handle = cds_get_context(QDF_MODULE_ID_SME); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2937 | |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 2938 | status = cds_pre_enable(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2939 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2940 | hdd_err("Failed to pre-enable CDS; status: %d", status); |
| 2941 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2942 | goto cds_txrx_free; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2943 | } |
| 2944 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2945 | hdd_register_policy_manager_callback( |
| 2946 | hdd_ctx->hdd_psoc); |
| 2947 | |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 2948 | hdd_sysfs_create_version_interface(hdd_ctx->hdd_psoc); |
| 2949 | |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2950 | hdd_update_hw_sw_info(hdd_ctx); |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 2951 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2952 | hdd_info("Wlan transitioned (now OPENED)"); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2953 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2954 | if (unint) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2955 | hdd_debug("In phase-1 initialization don't enable modules"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2956 | break; |
| 2957 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2958 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2959 | /* Fall through dont add break here */ |
| 2960 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2961 | hdd_info("Wlan transitioning (OPENED -> ENABLED)"); |
| 2962 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2963 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2964 | hdd_err("in ftm mode, no need to configure cds modules"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2965 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2966 | break; |
| 2967 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2968 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2969 | ret = hdd_configure_cds(hdd_ctx); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2970 | if (ret) { |
| 2971 | hdd_err("Failed to Enable cds modules; errno: %d", ret); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2972 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2973 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2974 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2975 | hdd_enable_power_management(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2976 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2977 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2978 | hdd_info("Wlan transitioned (now ENABLED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2979 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2980 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2981 | default: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2982 | QDF_DEBUG_PANIC("Unknown driver state:%d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2983 | hdd_ctx->driver_status); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2984 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2985 | goto release_lock; |
| 2986 | } |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2987 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2988 | hdd_ctx->start_modules_in_progress = false; |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2989 | if (DRIVER_MODULES_ENABLED == hdd_ctx->driver_status) { |
| 2990 | ret = hdd_update_country_code(hdd_ctx); |
| 2991 | if (ret) |
| 2992 | hdd_err("Failed to update command line country code!"); |
| 2993 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2994 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2995 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2996 | hdd_exit(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2997 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2998 | return 0; |
| 2999 | |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 3000 | post_disable: |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 3001 | cds_post_disable(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 3002 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 3003 | cds_txrx_free: |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 3004 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->hdd_psoc); |
| 3005 | |
| 3006 | if (tgt_hdl && target_psoc_get_wmi_ready(tgt_hdl)) { |
| 3007 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
| 3008 | dispatcher_pdev_close(hdd_ctx->hdd_pdev); |
| 3009 | hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 3010 | } |
| 3011 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 3012 | cds_dp_close(hdd_ctx->hdd_psoc); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 3013 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3014 | close: |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 3015 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 3016 | hdd_info("Wlan transition aborted (now CLOSED)"); |
| 3017 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 3018 | cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3019 | |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 3020 | hdd_psoc_close: |
| 3021 | hdd_component_psoc_close(hdd_ctx->hdd_psoc); |
| 3022 | |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 3023 | deinit_config: |
| 3024 | cds_deinit_ini_config(); |
| 3025 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 3026 | cds_free: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3027 | ol_cds_free(); |
| 3028 | |
| 3029 | hif_close: |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 3030 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 3031 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3032 | power_down: |
| 3033 | if (!reinit && !unint) |
| 3034 | pld_power_off(qdf_dev->dev); |
| 3035 | release_lock: |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 3036 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3037 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Abhinav Kumar | 7ae9b7b | 2017-12-19 15:11:54 +0530 | [diff] [blame] | 3038 | if (hdd_ctx->target_hw_name) { |
| 3039 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 3040 | hdd_ctx->target_hw_name = NULL; |
| 3041 | } |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 3042 | |
| 3043 | hdd_check_for_leaks(hdd_ctx, reinit); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 3044 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 3045 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3046 | hdd_exit(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 3047 | |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 3048 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3049 | } |
| 3050 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3051 | #ifdef WIFI_POS_CONVERGED |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3052 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3053 | { |
| 3054 | int ret = os_if_wifi_pos_register_nl(); |
| 3055 | |
| 3056 | if (ret) |
| 3057 | hdd_err("os_if_wifi_pos_register_nl failed"); |
| 3058 | |
| 3059 | return ret; |
| 3060 | } |
| 3061 | |
| 3062 | static int hdd_deactivate_wifi_pos(void) |
| 3063 | { |
| 3064 | int ret = os_if_wifi_pos_deregister_nl(); |
| 3065 | |
| 3066 | if (ret) |
| 3067 | hdd_err("os_if_wifi_pos_deregister_nl failed"); |
| 3068 | |
| 3069 | return ret; |
| 3070 | } |
| 3071 | |
| 3072 | /** |
| 3073 | * hdd_populate_wifi_pos_cfg - populates wifi_pos parameters |
| 3074 | * @hdd_ctx: hdd context |
| 3075 | * |
| 3076 | * Return: status of operation |
| 3077 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3078 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3079 | { |
| 3080 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 3081 | struct hdd_config *cfg = hdd_ctx->config; |
| 3082 | |
| 3083 | wifi_pos_set_oem_target_type(psoc, hdd_ctx->target_type); |
| 3084 | wifi_pos_set_oem_fw_version(psoc, hdd_ctx->target_fw_version); |
| 3085 | wifi_pos_set_drv_ver_major(psoc, QWLAN_VERSION_MAJOR); |
| 3086 | wifi_pos_set_drv_ver_minor(psoc, QWLAN_VERSION_MINOR); |
| 3087 | wifi_pos_set_drv_ver_patch(psoc, QWLAN_VERSION_PATCH); |
| 3088 | wifi_pos_set_drv_ver_build(psoc, QWLAN_VERSION_BUILD); |
| 3089 | wifi_pos_set_dwell_time_min(psoc, cfg->nNeighborScanMinChanTime); |
| 3090 | wifi_pos_set_dwell_time_max(psoc, cfg->nNeighborScanMaxChanTime); |
| 3091 | } |
| 3092 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3093 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3094 | { |
| 3095 | return oem_activate_service(hdd_ctx); |
| 3096 | } |
| 3097 | |
| 3098 | static int hdd_deactivate_wifi_pos(void) |
| 3099 | { |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 3100 | return oem_deactivate_service(); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3101 | } |
| 3102 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3103 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3104 | { |
| 3105 | } |
| 3106 | #endif |
| 3107 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3108 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3109 | * __hdd_open() - HDD Open function |
| 3110 | * @dev: Pointer to net_device structure |
| 3111 | * |
| 3112 | * This is called in response to ifconfig up |
| 3113 | * |
| 3114 | * Return: 0 for success; non-zero for failure |
| 3115 | */ |
| 3116 | static int __hdd_open(struct net_device *dev) |
| 3117 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3118 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3119 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3120 | int ret; |
| 3121 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3122 | hdd_enter_dev(dev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3123 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3124 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3125 | |
Ashish Kumar Dhanotiya | 15a7db5 | 2017-08-03 10:27:34 +0530 | [diff] [blame] | 3126 | /* Nothing to be done if device is unloading */ |
| 3127 | if (cds_is_driver_unloading()) { |
| 3128 | hdd_err("Driver is unloading can not open the hdd"); |
| 3129 | return -EBUSY; |
| 3130 | } |
| 3131 | |
Dustin Brown | 0184775 | 2017-10-25 13:56:27 -0700 | [diff] [blame] | 3132 | if (cds_is_driver_recovering()) { |
| 3133 | hdd_err("WLAN is currently recovering; Please try again."); |
| 3134 | return -EBUSY; |
| 3135 | } |
| 3136 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 3137 | if (qdf_atomic_read(&hdd_ctx->con_mode_flag)) { |
| 3138 | hdd_err("con_mode_handler is in progress; Please try again."); |
| 3139 | return -EBUSY; |
| 3140 | } |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3141 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 3142 | mutex_lock(&hdd_init_deinit_lock); |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 3143 | hdd_start_driver_ops_timer(eHDD_DRV_OP_IFF_UP); |
| 3144 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3145 | /* |
| 3146 | * This scenario can be hit in cases where in the wlan driver after |
| 3147 | * registering the netdevices and there is a failure in driver |
| 3148 | * initialization. So return error gracefully because the netdevices |
| 3149 | * will be de-registered as part of the load failure. |
| 3150 | */ |
| 3151 | |
| 3152 | if (!cds_is_driver_loaded()) { |
| 3153 | hdd_err("Failed to start the wlan driver!!"); |
| 3154 | ret = -EIO; |
| 3155 | goto err_hdd_hdd_init_deinit_lock; |
| 3156 | } |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 3157 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3158 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 3159 | ret = hdd_wlan_start_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3160 | if (ret) { |
| 3161 | hdd_err("Failed to start WLAN modules return"); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3162 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3163 | } |
| 3164 | |
| 3165 | |
| 3166 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 3167 | ret = hdd_start_adapter(adapter); |
| 3168 | if (ret) { |
| 3169 | hdd_err("Failed to start adapter :%d", |
| 3170 | adapter->device_mode); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3171 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3172 | } |
| 3173 | } |
| 3174 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3175 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 3176 | 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] | 3177 | hdd_debug("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3178 | /* Enable TX queues only when we are connected */ |
| 3179 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3180 | WLAN_START_ALL_NETIF_QUEUE, |
| 3181 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3182 | } |
| 3183 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3184 | /* Enable carrier and transmit queues for NDI */ |
| 3185 | if (WLAN_HDD_IS_NDI(adapter)) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 3186 | hdd_debug("Enabling Tx Queues"); |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3187 | wlan_hdd_netif_queue_control(adapter, |
| 3188 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 3189 | WLAN_CONTROL_PATH); |
| 3190 | } |
| 3191 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3192 | hdd_populate_wifi_pos_cfg(hdd_ctx); |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 3193 | hdd_lpass_notify_start(hdd_ctx, adapter); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3194 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3195 | err_hdd_hdd_init_deinit_lock: |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 3196 | hdd_stop_driver_ops_timer(); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3197 | mutex_unlock(&hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3198 | return ret; |
| 3199 | } |
| 3200 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3201 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3202 | /** |
| 3203 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 3204 | * @dev: Pointer to net_device structure |
| 3205 | * |
| 3206 | * This is called in response to ifconfig up |
| 3207 | * |
| 3208 | * Return: 0 for success; non-zero for failure |
| 3209 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3210 | static int hdd_open(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3211 | { |
| 3212 | int ret; |
| 3213 | |
| 3214 | cds_ssr_protect(__func__); |
| 3215 | ret = __hdd_open(dev); |
| 3216 | cds_ssr_unprotect(__func__); |
| 3217 | |
| 3218 | return ret; |
| 3219 | } |
| 3220 | |
| 3221 | /** |
| 3222 | * __hdd_stop() - HDD stop function |
| 3223 | * @dev: Pointer to net_device structure |
| 3224 | * |
| 3225 | * This is called in response to ifconfig down |
| 3226 | * |
| 3227 | * Return: 0 for success; non-zero for failure |
| 3228 | */ |
| 3229 | static int __hdd_stop(struct net_device *dev) |
| 3230 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3231 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3232 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3233 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3234 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3235 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3236 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3237 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3238 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3239 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3240 | |
| 3241 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3242 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3243 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3244 | |
| 3245 | /* Nothing to be done if the interface is not opened */ |
| 3246 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3247 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3248 | return -ENODEV; |
| 3249 | } |
| 3250 | |
| 3251 | /* Make sure the interface is marked as closed */ |
| 3252 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3253 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3254 | mac_handle = hdd_ctx->mac_handle; |
| 3255 | |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3256 | hdd_debug("Disabling Auto Power save timer"); |
| 3257 | sme_ps_disable_auto_ps_timer( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3258 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3259 | adapter->session_id); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3260 | |
| 3261 | /* |
| 3262 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 3263 | * be called on that interface |
| 3264 | */ |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 3265 | hdd_debug("Disabling queues, adapter device mode: %s(%d)", |
| 3266 | hdd_device_mode_to_string(adapter->device_mode), |
| 3267 | adapter->device_mode); |
Kabilan Kannan | 8dac350 | 2017-10-30 12:40:27 -0700 | [diff] [blame] | 3268 | |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 3269 | wlan_hdd_netif_queue_control(adapter, |
| 3270 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 3271 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3272 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 3273 | if (adapter->device_mode == QDF_STA_MODE) |
| 3274 | hdd_lpass_notify_stop(hdd_ctx); |
| 3275 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3276 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3277 | * NAN data interface is different in some sense. The traffic on NDI is |
| 3278 | * bursty in nature and depends on the need to transfer. The service |
| 3279 | * layer may down the interface after the usage and up again when |
| 3280 | * required. In some sense, the NDI is expected to be available |
| 3281 | * (like SAP) iface until NDI delete request is issued by the service |
| 3282 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 3283 | * interface (NDI). |
| 3284 | */ |
| 3285 | if (WLAN_HDD_IS_NDI(adapter)) |
| 3286 | return 0; |
| 3287 | |
| 3288 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3289 | * The interface is marked as down for outside world (aka kernel) |
| 3290 | * But the driver is pretty much alive inside. The driver needs to |
| 3291 | * tear down the existing connection on the netdev (session) |
| 3292 | * cleanup the data pipes and wait until the control plane is stabilized |
| 3293 | * for this interface. The call also needs to wait until the above |
| 3294 | * mentioned actions are completed before returning to the caller. |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3295 | * Notice that hdd_stop_adapter is requested not to close the session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3296 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 3297 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 3298 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3299 | |
| 3300 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 3301 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 3302 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3303 | |
| 3304 | /* |
Hanumanth Reddy Pothula | 3862ca9 | 2018-01-12 16:44:10 +0530 | [diff] [blame] | 3305 | * Upon wifi turn off, DUT has to flush the scan results so if |
| 3306 | * this is the last cli iface, flush the scan database. |
| 3307 | */ |
| 3308 | if (!hdd_is_cli_iface_up(hdd_ctx)) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3309 | sme_scan_flush_result(mac_handle); |
Hanumanth Reddy Pothula | 3862ca9 | 2018-01-12 16:44:10 +0530 | [diff] [blame] | 3310 | |
| 3311 | /* |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3312 | * Find if any iface is up. If any iface is up then can't put device to |
| 3313 | * sleep/power save mode |
| 3314 | */ |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 3315 | if (hdd_check_for_opened_interfaces(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3316 | hdd_debug("Closing all modules from the hdd_stop"); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 3317 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 3318 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 3319 | hdd_prevent_suspend_timeout( |
| 3320 | hdd_ctx->config->iface_change_wait_time, |
| 3321 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3322 | } |
| 3323 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3324 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3325 | return 0; |
| 3326 | } |
| 3327 | |
| 3328 | /** |
| 3329 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 3330 | * @dev: pointer to net_device structure |
| 3331 | * |
| 3332 | * This is called in response to ifconfig down |
| 3333 | * |
| 3334 | * Return: 0 for success and error number for failure |
| 3335 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3336 | static int hdd_stop(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3337 | { |
| 3338 | int ret; |
| 3339 | |
| 3340 | cds_ssr_protect(__func__); |
| 3341 | ret = __hdd_stop(dev); |
| 3342 | cds_ssr_unprotect(__func__); |
| 3343 | |
| 3344 | return ret; |
| 3345 | } |
| 3346 | |
| 3347 | /** |
| 3348 | * __hdd_uninit() - HDD uninit function |
| 3349 | * @dev: Pointer to net_device structure |
| 3350 | * |
| 3351 | * This is called during the netdev unregister to uninitialize all data |
| 3352 | * associated with the device |
| 3353 | * |
| 3354 | * Return: None |
| 3355 | */ |
| 3356 | static void __hdd_uninit(struct net_device *dev) |
| 3357 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3358 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3359 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3360 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3361 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3362 | |
| 3363 | do { |
| 3364 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3365 | hdd_err("Invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3366 | break; |
| 3367 | } |
| 3368 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3369 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3370 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3371 | hdd_err("NULL hdd_ctx"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3372 | break; |
| 3373 | } |
| 3374 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3375 | if (dev != adapter->dev) |
| 3376 | hdd_err("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3377 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3378 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3379 | |
| 3380 | /* after uninit our adapter structure will no longer be valid */ |
| 3381 | adapter->dev = NULL; |
| 3382 | adapter->magic = 0; |
| 3383 | } while (0); |
| 3384 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3385 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3386 | } |
| 3387 | |
| 3388 | /** |
| 3389 | * hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 3390 | * @dev: pointer to net_device structure |
| 3391 | * |
| 3392 | * This is called during the netdev unregister to uninitialize all data |
| 3393 | * associated with the device |
| 3394 | * |
| 3395 | * Return: none |
| 3396 | */ |
| 3397 | static void hdd_uninit(struct net_device *dev) |
| 3398 | { |
| 3399 | cds_ssr_protect(__func__); |
| 3400 | __hdd_uninit(dev); |
| 3401 | cds_ssr_unprotect(__func__); |
| 3402 | } |
| 3403 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3404 | static int hdd_open_cesium_nl_sock(void) |
| 3405 | { |
| 3406 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3407 | struct netlink_kernel_cfg cfg = { |
| 3408 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 3409 | .input = NULL |
| 3410 | }; |
| 3411 | #endif |
| 3412 | int ret = 0; |
| 3413 | |
| 3414 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3415 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3416 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 3417 | THIS_MODULE, |
| 3418 | #endif |
| 3419 | &cfg); |
| 3420 | #else |
| 3421 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3422 | WLAN_NLINK_MCAST_GRP_ID, |
| 3423 | NULL, NULL, THIS_MODULE); |
| 3424 | #endif |
| 3425 | |
| 3426 | if (cesium_nl_srv_sock == NULL) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3427 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3428 | ret = -ECONNREFUSED; |
| 3429 | } |
| 3430 | |
| 3431 | return ret; |
| 3432 | } |
| 3433 | |
| 3434 | static void hdd_close_cesium_nl_sock(void) |
| 3435 | { |
| 3436 | if (NULL != cesium_nl_srv_sock) { |
| 3437 | netlink_kernel_release(cesium_nl_srv_sock); |
| 3438 | cesium_nl_srv_sock = NULL; |
| 3439 | } |
| 3440 | } |
| 3441 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3442 | /** |
| 3443 | * __hdd_set_mac_address() - set the user specified mac address |
| 3444 | * @dev: Pointer to the net device. |
| 3445 | * @addr: Pointer to the sockaddr. |
| 3446 | * |
| 3447 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3448 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3449 | * |
| 3450 | * Return: 0 for success, non zero for failure |
| 3451 | */ |
| 3452 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3453 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3454 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Ashish Kumar Dhanotiya | e533f6c | 2018-06-19 21:16:07 +0530 | [diff] [blame] | 3455 | struct hdd_adapter *adapter_temp; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3456 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3457 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3458 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3459 | int ret; |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3460 | struct qdf_mac_addr mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3461 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3462 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3463 | |
Hanumanth Reddy Pothula | 5c7a781 | 2018-03-09 12:55:32 +0530 | [diff] [blame] | 3464 | if (netif_running(dev)) { |
| 3465 | hdd_err("On iface up, set mac address change isn't supported"); |
| 3466 | return -EBUSY; |
| 3467 | } |
| 3468 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3469 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3470 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 3471 | if (0 != ret) |
| 3472 | return ret; |
| 3473 | |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3474 | 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] | 3475 | adapter_temp = hdd_get_adapter_by_macaddr(hdd_ctx, mac_addr.bytes); |
| 3476 | if (adapter_temp) { |
| 3477 | if (!qdf_str_cmp(adapter_temp->dev->name, dev->name)) |
| 3478 | return 0; |
| 3479 | hdd_err("%s adapter exist with same address " MAC_ADDRESS_STR, |
| 3480 | adapter_temp->dev->name, |
Ashish Kumar Dhanotiya | f974f33 | 2018-04-19 16:03:15 +0530 | [diff] [blame] | 3481 | MAC_ADDR_ARRAY(mac_addr.bytes)); |
| 3482 | return -EINVAL; |
| 3483 | } |
| 3484 | |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3485 | if (qdf_is_macaddr_zero(&mac_addr)) { |
| 3486 | hdd_err("MAC is all zero"); |
| 3487 | return -EINVAL; |
| 3488 | } |
| 3489 | |
| 3490 | if (qdf_is_macaddr_broadcast(&mac_addr)) { |
| 3491 | hdd_err("MAC is Broadcast"); |
| 3492 | return -EINVAL; |
| 3493 | } |
| 3494 | |
| 3495 | if (ETHER_IS_MULTICAST(psta_mac_addr->sa_data)) { |
| 3496 | hdd_err("MAC is Multicast"); |
| 3497 | return -EINVAL; |
| 3498 | } |
Ashish Kumar Dhanotiya | 8bfef12 | 2018-04-18 16:48:27 +0530 | [diff] [blame] | 3499 | hdd_info("Changing MAC to " MAC_ADDRESS_STR " of the interface %s ", |
| 3500 | MAC_ADDR_ARRAY(mac_addr.bytes), dev->name); |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3501 | |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3502 | memcpy(&adapter->mac_addr, psta_mac_addr->sa_data, ETH_ALEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3503 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 3504 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3505 | hdd_exit(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3506 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3507 | } |
| 3508 | |
| 3509 | /** |
| 3510 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
| 3511 | * function from SSR |
| 3512 | * @dev: pointer to net_device structure |
| 3513 | * @addr: Pointer to the sockaddr |
| 3514 | * |
| 3515 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3516 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3517 | * |
| 3518 | * Return: 0 for success. |
| 3519 | */ |
| 3520 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3521 | { |
| 3522 | int ret; |
| 3523 | |
| 3524 | cds_ssr_protect(__func__); |
| 3525 | ret = __hdd_set_mac_address(dev, addr); |
| 3526 | cds_ssr_unprotect(__func__); |
| 3527 | |
| 3528 | return ret; |
| 3529 | } |
| 3530 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3531 | uint8_t *wlan_hdd_get_intf_addr(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3532 | { |
| 3533 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3534 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3535 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3536 | if (0 == ((hdd_ctx->config->intfAddrMask) & (1 << i))) |
| 3537 | break; |
| 3538 | } |
| 3539 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3540 | if (QDF_MAX_CONCURRENCY_PERSONA == i) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3541 | return NULL; |
| 3542 | |
| 3543 | hdd_ctx->config->intfAddrMask |= (1 << i); |
| 3544 | return &hdd_ctx->config->intfMacAddr[i].bytes[0]; |
| 3545 | } |
| 3546 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 3547 | void wlan_hdd_release_intf_addr(struct hdd_context *hdd_ctx, |
| 3548 | uint8_t *releaseAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3549 | { |
| 3550 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3551 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3552 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3553 | if (!memcmp(releaseAddr, |
| 3554 | &hdd_ctx->config->intfMacAddr[i].bytes[0], |
| 3555 | 6)) { |
| 3556 | hdd_ctx->config->intfAddrMask &= ~(1 << i); |
| 3557 | break; |
| 3558 | } |
| 3559 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3560 | } |
| 3561 | |
| 3562 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 3563 | /** |
| 3564 | * __hdd_set_multicast_list() - set the multicast address list |
| 3565 | * @dev: Pointer to the WLAN device. |
| 3566 | * @skb: Pointer to OS packet (sk_buff). |
| 3567 | * |
| 3568 | * This funciton sets the multicast address list. |
| 3569 | * |
| 3570 | * Return: None |
| 3571 | */ |
| 3572 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 3573 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3574 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3575 | int i = 0, errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3576 | struct netdev_hw_addr *ha; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3577 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3578 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
| 3579 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 3580 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3581 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3582 | hdd_enter_dev(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3583 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3584 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 3585 | |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3586 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 3587 | if (errno) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3588 | goto out; |
| 3589 | |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3590 | errno = hdd_validate_adapter(adapter); |
| 3591 | if (errno) |
Dustin Brown | c788acb | 2017-08-01 17:43:51 -0700 | [diff] [blame] | 3592 | goto out; |
| 3593 | |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3594 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 3595 | hdd_err("%s: Driver module is closed", __func__); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3596 | goto out; |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3597 | } |
| 3598 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3599 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
| 3600 | if (!mc_list_request) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3601 | hdd_err("Cannot allocate mc_list_request"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3602 | goto out; |
| 3603 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3604 | |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3605 | /* Delete already configured multicast address list */ |
| 3606 | if (adapter->mc_addr_list.mc_cnt > 0) { |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3607 | hdd_debug("clear previously configured MC address list"); |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3608 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3609 | pmo_mc_list_change_notify); |
| 3610 | } |
| 3611 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3612 | if (dev->flags & IFF_ALLMULTI) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3613 | hdd_debug("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3614 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3615 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3616 | } else { |
| 3617 | mc_count = netdev_mc_count(dev); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3618 | if (mc_count > pmo_ucfg_max_mc_addr_supported(psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3619 | hdd_debug("Exceeded max MC filter addresses (%d). Allowing all MC frames by disabling MC address filtering", |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3620 | pmo_ucfg_max_mc_addr_supported(psoc)); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3621 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3622 | pmo_mc_list_change_notify); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3623 | goto free_req; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3624 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3625 | netdev_for_each_mc_addr(ha, dev) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3626 | hdd_debug("ha_addr[%d] "MAC_ADDRESS_STR, |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 3627 | i, MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3628 | if (i == mc_count) |
| 3629 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3630 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 3631 | 0, ETH_ALEN); |
| 3632 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 3633 | ha->addr, ETH_ALEN); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3634 | hdd_debug("mlist[%d] = %pM", i, |
| 3635 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3636 | i++; |
| 3637 | } |
| 3638 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3639 | |
| 3640 | mc_list_request->psoc = psoc; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3641 | mc_list_request->vdev_id = adapter->session_id; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3642 | mc_list_request->count = mc_count; |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3643 | |
| 3644 | errno = hdd_cache_mc_addr_list(mc_list_request); |
| 3645 | if (errno) { |
| 3646 | hdd_err("Failed to cache MC address list for vdev %u; errno:%d", |
| 3647 | adapter->session_id, errno); |
| 3648 | goto free_req; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3649 | } |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3650 | |
| 3651 | hdd_enable_mc_addr_filtering(adapter, pmo_mc_list_change_notify); |
| 3652 | |
| 3653 | free_req: |
| 3654 | qdf_mem_free(mc_list_request); |
| 3655 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3656 | out: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3657 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3658 | } |
| 3659 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3660 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3661 | /** |
| 3662 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
| 3663 | * @dev: pointer to net_device |
| 3664 | * |
| 3665 | * Return: none |
| 3666 | */ |
| 3667 | static void hdd_set_multicast_list(struct net_device *dev) |
| 3668 | { |
| 3669 | cds_ssr_protect(__func__); |
| 3670 | __hdd_set_multicast_list(dev); |
| 3671 | cds_ssr_unprotect(__func__); |
| 3672 | } |
| 3673 | #endif |
| 3674 | |
| 3675 | /** |
| 3676 | * hdd_select_queue() - used by Linux OS to decide which queue to use first |
| 3677 | * @dev: Pointer to the WLAN device. |
| 3678 | * @skb: Pointer to OS packet (sk_buff). |
| 3679 | * |
| 3680 | * This function is registered with the Linux OS for network |
| 3681 | * core to decide which queue to use first. |
| 3682 | * |
| 3683 | * Return: ac, Queue Index/access category corresponding to UP in IP header |
| 3684 | */ |
| 3685 | static uint16_t hdd_select_queue(struct net_device *dev, struct sk_buff *skb |
| 3686 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) |
| 3687 | , void *accel_priv |
| 3688 | #endif |
| 3689 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 3690 | , select_queue_fallback_t fallback |
| 3691 | #endif |
| 3692 | ) |
| 3693 | { |
| 3694 | return hdd_wmm_select_queue(dev, skb); |
| 3695 | } |
| 3696 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3697 | static const struct net_device_ops wlan_drv_ops = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3698 | .ndo_open = hdd_open, |
| 3699 | .ndo_stop = hdd_stop, |
| 3700 | .ndo_uninit = hdd_uninit, |
| 3701 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 3702 | .ndo_tx_timeout = hdd_tx_timeout, |
| 3703 | .ndo_get_stats = hdd_get_stats, |
| 3704 | .ndo_do_ioctl = hdd_ioctl, |
| 3705 | .ndo_set_mac_address = hdd_set_mac_address, |
| 3706 | .ndo_select_queue = hdd_select_queue, |
| 3707 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3708 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3709 | #endif |
| 3710 | }; |
| 3711 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 3712 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3713 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3714 | static const struct net_device_ops wlan_mon_drv_ops = { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3715 | .ndo_open = hdd_mon_open, |
| 3716 | .ndo_stop = hdd_stop, |
| 3717 | .ndo_get_stats = hdd_get_stats, |
| 3718 | }; |
| 3719 | |
| 3720 | /** |
| 3721 | * hdd_set_station_ops() - update net_device ops for monitor mode |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3722 | * @dev: Handle to struct net_device to be updated. |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3723 | * Return: None |
| 3724 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3725 | void hdd_set_station_ops(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3726 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3727 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3728 | dev->netdev_ops = &wlan_mon_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3729 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3730 | dev->netdev_ops = &wlan_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3731 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 3732 | #else |
| 3733 | void hdd_set_station_ops(struct net_device *dev) |
| 3734 | { |
| 3735 | dev->netdev_ops = &wlan_drv_ops; |
| 3736 | } |
| 3737 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3738 | |
| 3739 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3740 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 3741 | * @hdd_ctx: global hdd context |
| 3742 | * @macAddr: mac address to assign to the interface |
| 3743 | * @name: User-visible name of the interface |
| 3744 | * |
| 3745 | * hdd adapter pointer would point to the netdev->priv space, this function |
Jeff Johnson | 6201829 | 2018-05-06 16:18:35 -0700 | [diff] [blame] | 3746 | * would retrieve the pointer, and setup the hdd adapter configuration. |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3747 | * |
| 3748 | * Return: the pointer to hdd adapter, otherwise NULL |
| 3749 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3750 | static struct hdd_adapter *hdd_alloc_station_adapter(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3751 | tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3752 | unsigned char name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3753 | const char *name) |
| 3754 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3755 | struct net_device *dev = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3756 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 3757 | struct hdd_station_ctx *sta_ctx; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3758 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3759 | /* |
| 3760 | * cfg80211 initialization and registration.... |
| 3761 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3762 | dev = alloc_netdev_mq(sizeof(struct hdd_adapter), name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3763 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
| 3764 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3765 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3766 | (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam() ? |
| 3767 | hdd_mon_mode_ether_setup : ether_setup), |
| 3768 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3769 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3770 | if (dev != NULL) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3771 | |
| 3772 | /* Save the pointer to the net_device in the HDD adapter */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3773 | adapter = (struct hdd_adapter *) netdev_priv(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3774 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3775 | qdf_mem_zero(adapter, sizeof(struct hdd_adapter)); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 3776 | sta_ctx = &adapter->session.station; |
Hanumanth Reddy Pothula | 18553ae | 2017-04-28 15:03:10 +0530 | [diff] [blame] | 3777 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 3778 | sizeof(sta_ctx->conn_info.staId), |
| 3779 | HDD_WLAN_INVALID_STA_ID); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3780 | adapter->dev = dev; |
Jeff Johnson | dba0db6 | 2017-08-30 11:12:39 -0700 | [diff] [blame] | 3781 | adapter->hdd_ctx = hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3782 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3783 | adapter->session_id = HDD_SESSION_ID_INVALID; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3784 | |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3785 | qdf_status = qdf_event_create( |
| 3786 | &adapter->qdf_session_open_event); |
| 3787 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3788 | hdd_err("Session open QDF event init failed!"); |
| 3789 | free_netdev(adapter->dev); |
| 3790 | return NULL; |
| 3791 | } |
| 3792 | |
| 3793 | qdf_status = qdf_event_create( |
| 3794 | &adapter->qdf_session_close_event); |
| 3795 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3796 | hdd_err("Session close QDF event init failed!"); |
| 3797 | free_netdev(adapter->dev); |
| 3798 | return NULL; |
| 3799 | } |
| 3800 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3801 | adapter->offloads_configured = false; |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 3802 | adapter->is_link_up_service_needed = false; |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 3803 | adapter->disconnection_in_progress = false; |
Yeshwanth Sriram Guntuka | 4fe30bd | 2018-06-13 11:41:42 +0530 | [diff] [blame] | 3804 | adapter->send_mode_change = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3805 | /* Init the net_device structure */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3806 | strlcpy(dev->name, name, IFNAMSIZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3807 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3808 | qdf_mem_copy(dev->dev_addr, (void *)macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3809 | sizeof(tSirMacAddr)); |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3810 | qdf_mem_copy(adapter->mac_addr.bytes, macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3811 | sizeof(tSirMacAddr)); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3812 | dev->watchdog_timeo = HDD_TX_TIMEOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3813 | |
| 3814 | if (hdd_ctx->config->enable_ip_tcp_udp_checksum_offload) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3815 | dev->features |= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3816 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3817 | dev->features |= NETIF_F_RXCSUM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3818 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3819 | hdd_set_tso_flags(hdd_ctx, dev); |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 3820 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3821 | hdd_set_station_ops(adapter->dev); |
| 3822 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3823 | hdd_dev_setup_destructor(dev); |
| 3824 | dev->ieee80211_ptr = &adapter->wdev; |
| 3825 | dev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3826 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3827 | adapter->wdev.netdev = dev; |
| 3828 | /* set dev's parent to underlying device */ |
| 3829 | SET_NETDEV_DEV(dev, hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3830 | hdd_wmm_init(adapter); |
| 3831 | spin_lock_init(&adapter->pause_map_lock); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 3832 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3833 | } |
| 3834 | |
| 3835 | return adapter; |
| 3836 | } |
| 3837 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3838 | 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] | 3839 | { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3840 | struct net_device *dev = adapter->dev; |
| 3841 | int ret; |
| 3842 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 3843 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3844 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3845 | if (rtnl_held) { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3846 | if (strnchr(dev->name, IFNAMSIZ - 1, '%')) { |
| 3847 | |
| 3848 | ret = dev_alloc_name(dev, dev->name); |
| 3849 | if (ret < 0) { |
| 3850 | hdd_err( |
| 3851 | "unable to get dev name: %s, err = 0x%x", |
| 3852 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3853 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3854 | } |
| 3855 | } |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3856 | |
| 3857 | ret = register_netdevice(dev); |
| 3858 | if (ret) { |
| 3859 | hdd_err("register_netdevice(%s) failed, err = 0x%x", |
| 3860 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3861 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3862 | } |
| 3863 | } else { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3864 | ret = register_netdev(dev); |
| 3865 | if (ret) { |
| 3866 | hdd_err("register_netdev(%s) failed, err = 0x%x", |
| 3867 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3868 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3869 | } |
| 3870 | } |
| 3871 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 3872 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3873 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3874 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3875 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3876 | } |
| 3877 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3878 | QDF_STATUS hdd_sme_open_session_callback(uint8_t session_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3879 | { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3880 | struct hdd_adapter *adapter; |
| 3881 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3882 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3883 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3884 | if (!hdd_ctx) { |
| 3885 | hdd_err("Invalid HDD_CTX"); |
| 3886 | return QDF_STATUS_E_FAILURE; |
| 3887 | } |
| 3888 | |
| 3889 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 3890 | if (NULL == adapter) { |
Naveen Rawat | 23a3b91 | 2018-05-30 17:45:52 -0700 | [diff] [blame] | 3891 | hdd_err("NULL adapter for %d", session_id); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3892 | return QDF_STATUS_E_INVAL; |
| 3893 | } |
| 3894 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3895 | qdf_event_set(&adapter->qdf_session_open_event); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3896 | hdd_debug("session %d opened", adapter->session_id); |
| 3897 | |
| 3898 | return QDF_STATUS_SUCCESS; |
| 3899 | } |
| 3900 | |
| 3901 | QDF_STATUS hdd_sme_close_session_callback(uint8_t session_id) |
| 3902 | { |
| 3903 | struct hdd_adapter *adapter; |
| 3904 | struct hdd_context *hdd_ctx; |
| 3905 | |
| 3906 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3907 | if (!hdd_ctx) { |
| 3908 | hdd_err("Invalid HDD_CTX"); |
| 3909 | return QDF_STATUS_E_FAILURE; |
| 3910 | } |
| 3911 | |
| 3912 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3913 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3914 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3915 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3916 | } |
| 3917 | |
| 3918 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3919 | hdd_err("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3920 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3921 | } |
| 3922 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3923 | /* |
| 3924 | * For NAN Data interface, the close session results in the final |
| 3925 | * indication to the userspace |
| 3926 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 3927 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3928 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3929 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3930 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3931 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3932 | /* |
| 3933 | * We can be blocked while waiting for scheduled work to be |
| 3934 | * flushed, and the adapter structure can potentially be freed, in |
| 3935 | * which case the magic will have been reset. So make sure the |
| 3936 | * magic is still good, and hence the adapter structure is still |
| 3937 | * valid, before signaling completion |
| 3938 | */ |
| 3939 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3940 | qdf_event_set(&adapter->qdf_session_close_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3941 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3942 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3943 | } |
| 3944 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3945 | int hdd_vdev_ready(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3946 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3947 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3948 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3949 | status = pmo_vdev_ready(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3950 | if (QDF_IS_STATUS_ERROR(status)) |
| 3951 | return qdf_status_to_os_return(status); |
| 3952 | |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3953 | status = ucfg_reg_11d_vdev_created_update(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3954 | if (QDF_IS_STATUS_ERROR(status)) |
| 3955 | return qdf_status_to_os_return(status); |
| 3956 | |
| 3957 | if (wma_capability_enhanced_mcast_filter()) |
| 3958 | status = pmo_ucfg_enhanced_mc_filter_enable(adapter->hdd_vdev); |
| 3959 | else |
| 3960 | status = pmo_ucfg_enhanced_mc_filter_disable(adapter->hdd_vdev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3961 | |
| 3962 | return qdf_status_to_os_return(status); |
| 3963 | } |
| 3964 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3965 | int hdd_vdev_destroy(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3966 | { |
| 3967 | QDF_STATUS status; |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 3968 | int errno; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3969 | struct hdd_context *hdd_ctx; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3970 | uint8_t vdev_id; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3971 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3972 | vdev_id = adapter->session_id; |
| 3973 | hdd_info("destroying vdev %d", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3974 | |
| 3975 | /* vdev created sanity check */ |
| 3976 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 3977 | hdd_err("vdev %u does not exist", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3978 | return -EINVAL; |
| 3979 | } |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 3980 | |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3981 | status = ucfg_reg_11d_vdev_delete_update(adapter->hdd_vdev); |
Krunal Soni | 8a06d83 | 2018-06-20 16:41:17 -0700 | [diff] [blame] | 3982 | ucfg_scan_set_vdev_del_in_progress(adapter->hdd_vdev); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3983 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3984 | /* close sme session (destroy vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3985 | qdf_event_reset(&adapter->qdf_session_close_event); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3986 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3987 | status = sme_close_session(hdd_ctx->mac_handle, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3988 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 3989 | hdd_err("failed to close sme session; status:%d", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3990 | goto release_vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3991 | } |
| 3992 | |
| 3993 | /* block on a completion variable until sme session is closed */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3994 | status = qdf_wait_for_event_completion( |
| 3995 | &adapter->qdf_session_close_event, |
| 3996 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 3997 | |
| 3998 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3999 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 4000 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4001 | if (adapter->device_mode == QDF_NDI_MODE) |
| 4002 | hdd_ndp_session_end_handler(adapter); |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4003 | |
| 4004 | if (status == QDF_STATUS_E_TIMEOUT) |
| 4005 | hdd_err("timed out waiting for sme close session"); |
| 4006 | else if (adapter->qdf_session_close_event.force_set) |
| 4007 | hdd_info("SSR occurred during sme close session"); |
| 4008 | else |
| 4009 | hdd_err("failed to wait for sme close session; status:%u", |
| 4010 | status); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4011 | } |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 4012 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 4013 | release_vdev: |
Krunal Soni | 8a06d83 | 2018-06-20 16:41:17 -0700 | [diff] [blame] | 4014 | ucfg_scan_clear_vdev_del_in_progress(adapter->hdd_vdev); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 4015 | |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4016 | /* do vdev logical destroy via objmgr */ |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 4017 | errno = hdd_objmgr_release_and_destroy_vdev(adapter); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4018 | if (errno) { |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 4019 | hdd_err("failed to destroy objmgr vdev; errno:%d", errno); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4020 | return errno; |
| 4021 | } |
| 4022 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4023 | hdd_info("vdev %d destroyed successfully", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4024 | |
| 4025 | return 0; |
| 4026 | } |
| 4027 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4028 | static int hdd_set_sme_session_param(struct hdd_adapter *adapter, |
| 4029 | struct sme_session_params *session_param, |
Jeff Johnson | 6a18c96 | 2018-07-01 09:09:37 -0700 | [diff] [blame] | 4030 | csr_roam_complete_cb callback, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4031 | void *callback_ctx) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4032 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4033 | uint32_t type; |
| 4034 | uint32_t sub_type; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4035 | QDF_STATUS status; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4036 | |
| 4037 | /* determine vdev (sub)type */ |
| 4038 | status = cds_get_vdev_types(adapter->device_mode, &type, &sub_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4039 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4040 | hdd_err("failed to get vdev type: %d", status); |
| 4041 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4042 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4043 | session_param->sme_session_id = adapter->session_id; |
| 4044 | session_param->self_mac_addr = (uint8_t *)&adapter->mac_addr; |
| 4045 | session_param->type_of_persona = type; |
| 4046 | session_param->subtype_of_persona = sub_type; |
| 4047 | session_param->session_open_cb = hdd_sme_open_session_callback; |
| 4048 | session_param->session_close_cb = hdd_sme_close_session_callback; |
| 4049 | session_param->callback = callback; |
| 4050 | session_param->callback_ctx = callback_ctx; |
| 4051 | |
| 4052 | return 0; |
| 4053 | } |
| 4054 | |
| 4055 | int hdd_vdev_create(struct hdd_adapter *adapter, |
Jeff Johnson | 6a18c96 | 2018-07-01 09:09:37 -0700 | [diff] [blame] | 4056 | csr_roam_complete_cb callback, void *ctx) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4057 | { |
| 4058 | QDF_STATUS status; |
| 4059 | int errno; |
| 4060 | struct hdd_context *hdd_ctx; |
| 4061 | struct sme_session_params sme_session_params = {0}; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4062 | |
| 4063 | hdd_info("creating new vdev"); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4064 | |
| 4065 | /* do vdev create via objmgr */ |
| 4066 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 4067 | errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->hdd_pdev, adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4068 | if (errno) { |
| 4069 | hdd_err("failed to create objmgr vdev: %d", errno); |
| 4070 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4071 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4072 | |
| 4073 | /* Open a SME session (prepare vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4074 | status = qdf_event_reset(&adapter->qdf_session_open_event); |
| 4075 | if (QDF_STATUS_SUCCESS != status) { |
| 4076 | hdd_err("failed to reinit session open event"); |
| 4077 | return -EINVAL; |
| 4078 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4079 | errno = hdd_set_sme_session_param(adapter, &sme_session_params, |
| 4080 | callback, ctx); |
| 4081 | if (errno) { |
| 4082 | hdd_err("failed to populating SME params"); |
| 4083 | goto objmgr_vdev_destroy_procedure; |
| 4084 | } |
| 4085 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4086 | status = sme_open_session(hdd_ctx->mac_handle, &sme_session_params); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4087 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4088 | hdd_err("failed to open sme session: %d", status); |
| 4089 | errno = qdf_status_to_os_return(status); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4090 | goto objmgr_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4091 | } |
| 4092 | |
| 4093 | /* block on a completion variable until sme session is opened */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4094 | status = qdf_wait_for_event_completion(&adapter->qdf_session_open_event, |
| 4095 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 4096 | if (QDF_STATUS_SUCCESS != status) { |
| 4097 | if (adapter->qdf_session_open_event.force_set) { |
| 4098 | /* |
| 4099 | * SSR/PDR has caused shutdown, which has forcefully |
| 4100 | * set the event. Return without the closing session. |
| 4101 | */ |
| 4102 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 4103 | hdd_err("Session open event forcefully set"); |
| 4104 | return -EINVAL; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4105 | } |
Jeff Johnson | c66d310 | 2018-02-28 11:58:26 -0800 | [diff] [blame] | 4106 | |
| 4107 | if (QDF_STATUS_E_TIMEOUT == status) |
| 4108 | hdd_err("Session failed to open within timeout period"); |
| 4109 | else |
| 4110 | hdd_err("Failed to wait for session open event(status-%d)", |
| 4111 | status); |
| 4112 | errno = -ETIMEDOUT; |
| 4113 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 4114 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4115 | } |
| 4116 | |
| 4117 | /* firmware ready for component communication, raise vdev_ready event */ |
| 4118 | errno = hdd_vdev_ready(adapter); |
| 4119 | if (errno) { |
| 4120 | hdd_err("failed to dispatch vdev ready event: %d", errno); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4121 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4122 | } |
| 4123 | |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 4124 | if (adapter->device_mode == QDF_STA_MODE) { |
| 4125 | hdd_debug("setting RTT mac randomization param: %d", |
| 4126 | hdd_ctx->config->enable_rtt_mac_randomization); |
| 4127 | errno = sme_cli_set_command(adapter->session_id, |
| 4128 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_INITIATOR_RANDOM_MAC, |
| 4129 | hdd_ctx->config->enable_rtt_mac_randomization, |
| 4130 | VDEV_CMD); |
| 4131 | if (0 != errno) |
| 4132 | hdd_err("RTT mac randomization param set failed %d", |
| 4133 | errno); |
| 4134 | } |
| 4135 | |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 4136 | if (adapter->device_mode == QDF_STA_MODE || |
| 4137 | adapter->device_mode == QDF_P2P_CLIENT_MODE) |
| 4138 | wlan_vdev_set_max_peer_count(adapter->hdd_vdev, |
| 4139 | HDD_MAX_VDEV_PEER_COUNT); |
| 4140 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4141 | hdd_info("vdev %d created successfully", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4142 | |
| 4143 | return 0; |
| 4144 | |
| 4145 | /* |
| 4146 | * Due to legacy constraints, we need to destroy in the same order as |
| 4147 | * create. So, split error handling into 2 cases to accommodate. |
| 4148 | */ |
| 4149 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4150 | objmgr_vdev_destroy_procedure: |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 4151 | QDF_BUG(!hdd_objmgr_release_and_destroy_vdev(adapter)); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4152 | |
| 4153 | return errno; |
| 4154 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4155 | hdd_vdev_destroy_procedure: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4156 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
| 4157 | |
| 4158 | return errno; |
| 4159 | } |
| 4160 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4161 | QDF_STATUS hdd_init_station_mode(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4162 | { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 4163 | struct hdd_station_ctx *sta_ctx = &adapter->session.station; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4164 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4165 | QDF_STATUS status; |
| 4166 | int ret_val; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4167 | mac_handle_t mac_handle; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4168 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4169 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4170 | mac_handle = hdd_ctx->mac_handle; |
| 4171 | sme_set_curr_device_mode(mac_handle, adapter->device_mode); |
| 4172 | sme_set_pdev_ht_vht_ies(mac_handle, hdd_ctx->config->enable2x2); |
| 4173 | sme_set_vdev_ies_per_band(mac_handle, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4174 | |
Jeff Johnson | 7f2c591 | 2018-03-23 11:42:28 -0700 | [diff] [blame] | 4175 | hdd_roam_profile_init(adapter); |
| 4176 | hdd_register_wext(adapter->dev); |
| 4177 | |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 4178 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4179 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4180 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 4181 | sizeof(sta_ctx->conn_info.staId), HDD_WLAN_INVALID_STA_ID); |
Hanumanth Reddy Pothula | b2d729c | 2017-05-30 11:49:53 +0530 | [diff] [blame] | 4182 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 4183 | /* set fast roaming capability in sme session */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4184 | status = sme_config_fast_roaming(mac_handle, adapter->session_id, |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 4185 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4186 | /* Set the default operation channel */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4187 | sta_ctx->conn_info.operationChannel = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4188 | hdd_ctx->config->OperatingChannel; |
| 4189 | |
| 4190 | /* Make the default Auth Type as OPEN */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4191 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4192 | |
| 4193 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4194 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4195 | hdd_err("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4196 | status, status); |
| 4197 | goto error_init_txrx; |
| 4198 | } |
| 4199 | |
| 4200 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4201 | |
| 4202 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4203 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4204 | hdd_err("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4205 | status, status); |
| 4206 | goto error_wmm_init; |
| 4207 | } |
| 4208 | |
| 4209 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4210 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4211 | ret_val = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4212 | WMI_PDEV_PARAM_BURST_ENABLE, |
Dundi Raviteja | 3aa01be | 2018-05-21 18:58:59 +0530 | [diff] [blame] | 4213 | HDD_ENABLE_SIFS_BURST_DEFAULT, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4214 | PDEV_CMD); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4215 | if (ret_val) |
| 4216 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", ret_val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4217 | |
Poddar, Siddarth | 4b3f731 | 2017-11-02 17:00:20 +0530 | [diff] [blame] | 4218 | /* |
| 4219 | * In case of USB tethering, LRO is disabled. If SSR happened |
| 4220 | * during that time, then as part of SSR init, do not enable |
| 4221 | * the LRO again. Keep the LRO state same as before SSR. |
| 4222 | */ |
Alok Kumar | 90a7309 | 2018-08-03 13:55:09 +0530 | [diff] [blame] | 4223 | if (hdd_ctx->config->lro_enable && |
| 4224 | !(qdf_atomic_read(&hdd_ctx->vendor_disable_lro_flag))) |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 4225 | adapter->dev->features |= NETIF_F_LRO; |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 4226 | |
| 4227 | /* rcpi info initialization */ |
| 4228 | qdf_mem_zero(&adapter->rcpi, sizeof(adapter->rcpi)); |
| 4229 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4230 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4231 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4232 | error_wmm_init: |
| 4233 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4234 | hdd_deinit_tx_rx(adapter); |
| 4235 | error_init_txrx: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4236 | hdd_unregister_wext(adapter->dev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4237 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4238 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4239 | return status; |
| 4240 | } |
| 4241 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4242 | /** |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4243 | * hdd_deinit_station_mode() - De-initialize the station adapter |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4244 | * @hdd_ctx: global hdd context |
| 4245 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4246 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 4247 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4248 | * |
| 4249 | * This function De-initializes the STA/P2P/OCB adapter. |
| 4250 | * |
| 4251 | * Return: None. |
| 4252 | */ |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4253 | static void hdd_deinit_station_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4254 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4255 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4256 | { |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4257 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4258 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 4259 | if (adapter->dev) { |
| 4260 | if (rtnl_held) |
| 4261 | adapter->dev->wireless_handlers = NULL; |
| 4262 | else { |
| 4263 | rtnl_lock(); |
| 4264 | adapter->dev->wireless_handlers = NULL; |
| 4265 | rtnl_unlock(); |
| 4266 | } |
| 4267 | } |
| 4268 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4269 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 4270 | hdd_deinit_tx_rx(adapter); |
| 4271 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4272 | } |
| 4273 | |
| 4274 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 4275 | hdd_wmm_adapter_close(adapter); |
| 4276 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4277 | } |
| 4278 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4279 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4280 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4281 | } |
| 4282 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4283 | void hdd_deinit_adapter(struct hdd_context *hdd_ctx, |
| 4284 | struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4285 | bool rtnl_held) |
| 4286 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4287 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4288 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4289 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4290 | case QDF_STA_MODE: |
| 4291 | case QDF_P2P_CLIENT_MODE: |
| 4292 | case QDF_P2P_DEVICE_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4293 | case QDF_IBSS_MODE: |
| 4294 | case QDF_NDI_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4295 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4296 | hdd_deinit_station_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4297 | break; |
| 4298 | } |
| 4299 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4300 | case QDF_SAP_MODE: |
| 4301 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4302 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4303 | hdd_deinit_ap_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4304 | break; |
| 4305 | } |
| 4306 | |
| 4307 | default: |
| 4308 | break; |
| 4309 | } |
| 4310 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4311 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4312 | } |
| 4313 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4314 | static void hdd_cleanup_adapter(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4315 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4316 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4317 | struct net_device *dev = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4318 | |
| 4319 | if (adapter) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4320 | dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4321 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4322 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4323 | return; |
| 4324 | } |
| 4325 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4326 | hdd_nud_deinit_tracking(adapter); |
| 4327 | qdf_mutex_destroy(&adapter->disconnection_status_lock); |
Nachiket Kukade | 5f0ce4f | 2018-06-15 19:47:37 +0530 | [diff] [blame] | 4328 | hdd_apf_context_destroy(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4329 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4330 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 4331 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4332 | /* |
| 4333 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 4334 | * the driver is almost closed and cannot handle either control |
| 4335 | * messages or data. However, unregister_netdevice() call above will |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4336 | * eventually invoke hdd_stop(ndo_close) driver callback, which attempts |
| 4337 | * to close the active connections(basically excites control path) which |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4338 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 4339 | * the interface is closed and restricts any operations on that |
| 4340 | */ |
| 4341 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 4342 | |
| 4343 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4344 | if (rtnl_held) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4345 | unregister_netdevice(dev); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4346 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4347 | unregister_netdev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4348 | /* |
| 4349 | * Note that the adapter is no longer valid at this point |
| 4350 | * since the memory has been reclaimed |
| 4351 | */ |
| 4352 | } |
| 4353 | } |
| 4354 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4355 | 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] | 4356 | tSirMacAddr macAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4357 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4358 | struct hdd_adapter *adapter; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4359 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4360 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 4361 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 4362 | macAddr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4363 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4364 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4365 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4366 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4367 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4368 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4369 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4370 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 4371 | /** |
| 4372 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 4373 | * @hdd_ctx: HDD Context |
| 4374 | * @adapter: HDD Adapter |
| 4375 | * |
| 4376 | * This function set the FW Debug log level based on the INI. |
| 4377 | * |
| 4378 | * Return: None |
| 4379 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4380 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4381 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4382 | { |
| 4383 | uint8_t count = 0, numentries = 0, |
| 4384 | moduleloglevel[FW_MODULE_LOG_LEVEL_STRING_LENGTH]; |
| 4385 | uint32_t value = 0; |
| 4386 | int ret; |
| 4387 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4388 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 4389 | (!hdd_ctx->config->enable_fw_log)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4390 | 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] | 4391 | return; |
| 4392 | } |
| 4393 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4394 | /* Enable FW logs based on INI configuration */ |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4395 | hdd_ctx->fw_log_settings.dl_type = |
| 4396 | hdd_ctx->config->enableFwLogType; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4397 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4398 | WMI_DBGLOG_TYPE, |
| 4399 | hdd_ctx->config->enableFwLogType, |
| 4400 | DBG_CMD); |
| 4401 | if (ret != 0) |
| 4402 | hdd_err("Failed to enable FW log type ret %d", |
| 4403 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4404 | |
| 4405 | hdd_ctx->fw_log_settings.dl_loglevel = |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4406 | hdd_ctx->config->enableFwLogLevel; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4407 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4408 | WMI_DBGLOG_LOG_LEVEL, |
| 4409 | hdd_ctx->config->enableFwLogLevel, |
| 4410 | DBG_CMD); |
| 4411 | if (ret != 0) |
| 4412 | hdd_err("Failed to enable FW log level ret %d", |
| 4413 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4414 | |
| 4415 | hdd_string_to_u8_array( |
| 4416 | hdd_ctx->config->enableFwModuleLogLevel, |
| 4417 | moduleloglevel, |
| 4418 | &numentries, |
| 4419 | FW_MODULE_LOG_LEVEL_STRING_LENGTH); |
| 4420 | |
| 4421 | while (count < numentries) { |
| 4422 | /* |
| 4423 | * FW module log level input string looks like |
| 4424 | * below: |
| 4425 | * gFwDebugModuleLoglevel=<FW Module ID>, |
| 4426 | * <Log Level>,... |
| 4427 | * For example: |
| 4428 | * gFwDebugModuleLoglevel= |
| 4429 | * 1,0,2,1,3,2,4,3,5,4,6,5,7,6 |
| 4430 | * Above input string means : |
| 4431 | * For FW module ID 1 enable log level 0 |
| 4432 | * For FW module ID 2 enable log level 1 |
| 4433 | * For FW module ID 3 enable log level 2 |
| 4434 | * For FW module ID 4 enable log level 3 |
| 4435 | * For FW module ID 5 enable log level 4 |
| 4436 | * For FW module ID 6 enable log level 5 |
| 4437 | * For FW module ID 7 enable log level 6 |
| 4438 | */ |
| 4439 | |
Nishank Aggarwal | e239d96 | 2017-03-03 12:26:02 +0530 | [diff] [blame] | 4440 | if ((moduleloglevel[count] > WLAN_MODULE_ID_MAX) |
| 4441 | || (moduleloglevel[count + 1] > DBGLOG_LVL_MAX)) { |
| 4442 | hdd_err("Module id %d and dbglog level %d input length is more than max", |
| 4443 | moduleloglevel[count], |
| 4444 | moduleloglevel[count + 1]); |
| 4445 | return; |
| 4446 | } |
| 4447 | |
| 4448 | value = moduleloglevel[count] << 16; |
| 4449 | value |= moduleloglevel[count + 1]; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4450 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4451 | WMI_DBGLOG_MOD_LOG_LEVEL, |
| 4452 | value, DBG_CMD); |
| 4453 | if (ret != 0) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4454 | hdd_err("Failed to enable FW module log level %d ret %d", |
| 4455 | value, ret); |
| 4456 | |
| 4457 | count += 2; |
| 4458 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4459 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4460 | } |
| 4461 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4462 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4463 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4464 | { |
| 4465 | } |
| 4466 | |
| 4467 | #endif |
| 4468 | |
| 4469 | /** |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4470 | * hdd_configure_chain_mask() - programs chain mask to firmware |
| 4471 | * @adapter: HDD adapter |
| 4472 | * |
| 4473 | * Return: 0 on success or errno on failure |
| 4474 | */ |
| 4475 | static int hdd_configure_chain_mask(struct hdd_adapter *adapter) |
| 4476 | { |
| 4477 | int ret_val; |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4478 | QDF_STATUS status; |
| 4479 | struct wma_caps_per_phy non_dbs_phy_cap; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4480 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 4481 | |
| 4482 | hdd_debug("enable2x2: %d, lte_coex: %d, ChainMask1x1: tx: %d rx: %d", |
| 4483 | hdd_ctx->config->enable2x2, hdd_ctx->lte_coex_ant_share, |
| 4484 | hdd_ctx->config->txchainmask1x1, |
| 4485 | hdd_ctx->config->rxchainmask1x1); |
| 4486 | hdd_debug("disable_DBS: %d, tx_chain_mask_2g: %d, rx_chain_mask_2g: %d", |
| 4487 | hdd_ctx->config->dual_mac_feature_disable, |
| 4488 | hdd_ctx->config->tx_chain_mask_2g, |
| 4489 | hdd_ctx->config->rx_chain_mask_2g); |
| 4490 | hdd_debug("tx_chain_mask_5g: %d, rx_chain_mask_5g: %d", |
| 4491 | hdd_ctx->config->tx_chain_mask_5g, |
| 4492 | hdd_ctx->config->rx_chain_mask_5g); |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4493 | hdd_debug("enable_bt_chain_separation %d", |
| 4494 | hdd_ctx->config->enable_bt_chain_separation); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4495 | |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4496 | status = wma_get_caps_for_phyidx_hwmode(&non_dbs_phy_cap, |
| 4497 | HW_MODE_DBS_NONE, |
| 4498 | CDS_BAND_ALL); |
| 4499 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4500 | hdd_err("couldn't get phy caps. skip chain mask programming"); |
| 4501 | return qdf_status_to_os_return(status); |
| 4502 | } |
| 4503 | |
| 4504 | if (non_dbs_phy_cap.tx_chain_mask_2G < 3 || |
| 4505 | non_dbs_phy_cap.rx_chain_mask_2G < 3 || |
| 4506 | non_dbs_phy_cap.tx_chain_mask_5G < 3 || |
| 4507 | non_dbs_phy_cap.rx_chain_mask_5G < 3) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4508 | hdd_debug("firmware not capable. skip chain mask programming"); |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4509 | return 0; |
| 4510 | } |
| 4511 | |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4512 | if (hdd_ctx->config->enable2x2 && |
| 4513 | !hdd_ctx->config->enable_bt_chain_separation) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4514 | hdd_debug("2x2 enabled. skip chain mask programming"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4515 | return 0; |
| 4516 | } |
| 4517 | |
Naveen Rawat | b54c72b | 2018-02-05 10:39:06 -0800 | [diff] [blame] | 4518 | if (hdd_ctx->config->dual_mac_feature_disable != |
| 4519 | DISABLE_DBS_CXN_AND_SCAN) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4520 | hdd_debug("DBS enabled(%d). skip chain mask programming", |
| 4521 | hdd_ctx->config->dual_mac_feature_disable); |
Naveen Rawat | b54c72b | 2018-02-05 10:39:06 -0800 | [diff] [blame] | 4522 | return 0; |
| 4523 | } |
| 4524 | |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4525 | if (hdd_ctx->lte_coex_ant_share) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4526 | hdd_debug("lte ant sharing enabled. skip chainmask programming"); |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4527 | return 0; |
| 4528 | } |
| 4529 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4530 | if (hdd_ctx->config->txchainmask1x1) { |
| 4531 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4532 | WMI_PDEV_PARAM_TX_CHAIN_MASK, |
| 4533 | hdd_ctx->config->txchainmask1x1, |
| 4534 | PDEV_CMD); |
| 4535 | if (ret_val) |
| 4536 | goto error; |
| 4537 | } |
| 4538 | |
| 4539 | if (hdd_ctx->config->rxchainmask1x1) { |
| 4540 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4541 | WMI_PDEV_PARAM_RX_CHAIN_MASK, |
| 4542 | hdd_ctx->config->rxchainmask1x1, |
| 4543 | PDEV_CMD); |
| 4544 | if (ret_val) |
| 4545 | goto error; |
| 4546 | } |
| 4547 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4548 | if (hdd_ctx->config->txchainmask1x1 || |
| 4549 | hdd_ctx->config->rxchainmask1x1) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4550 | hdd_debug("band agnostic tx/rx chain mask set. skip per band chain mask"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4551 | return 0; |
| 4552 | } |
| 4553 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4554 | if (hdd_ctx->config->tx_chain_mask_2g) { |
| 4555 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4556 | WMI_PDEV_PARAM_TX_CHAIN_MASK_2G, |
| 4557 | hdd_ctx->config->tx_chain_mask_2g, PDEV_CMD); |
| 4558 | if (0 != ret_val) |
| 4559 | goto error; |
| 4560 | } |
| 4561 | |
| 4562 | if (hdd_ctx->config->rx_chain_mask_2g) { |
| 4563 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4564 | WMI_PDEV_PARAM_RX_CHAIN_MASK_2G, |
| 4565 | hdd_ctx->config->rx_chain_mask_2g, PDEV_CMD); |
| 4566 | if (0 != ret_val) |
| 4567 | goto error; |
| 4568 | } |
| 4569 | |
| 4570 | if (hdd_ctx->config->tx_chain_mask_5g) { |
| 4571 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4572 | WMI_PDEV_PARAM_TX_CHAIN_MASK_5G, |
| 4573 | hdd_ctx->config->tx_chain_mask_5g, PDEV_CMD); |
| 4574 | if (0 != ret_val) |
| 4575 | goto error; |
| 4576 | } |
| 4577 | |
| 4578 | if (hdd_ctx->config->rx_chain_mask_5g) { |
| 4579 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4580 | WMI_PDEV_PARAM_RX_CHAIN_MASK_5G, |
| 4581 | hdd_ctx->config->rx_chain_mask_5g, PDEV_CMD); |
| 4582 | if (0 != ret_val) |
| 4583 | goto error; |
| 4584 | } |
| 4585 | |
| 4586 | return 0; |
| 4587 | |
| 4588 | error: |
| 4589 | hdd_err("WMI PDEV set param failed %d", ret_val); |
| 4590 | return -EINVAL; |
| 4591 | } |
| 4592 | |
| 4593 | /** |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4594 | * hdd_set_fw_params() - Set parameters to firmware |
| 4595 | * @adapter: HDD adapter |
| 4596 | * |
| 4597 | * This function Sets various parameters to fw once the |
| 4598 | * adapter is started. |
| 4599 | * |
| 4600 | * Return: 0 on success or errno on failure |
| 4601 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4602 | int hdd_set_fw_params(struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4603 | { |
| 4604 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4605 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4606 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4607 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4608 | |
| 4609 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 4610 | if (!hdd_ctx) |
| 4611 | return -EINVAL; |
| 4612 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4613 | if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 4614 | hdd_debug("FTM Mode is active; nothing to do"); |
| 4615 | return 0; |
| 4616 | } |
| 4617 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4618 | ret = sme_cli_set_command(adapter->session_id, |
Ashish Kumar Dhanotiya | b8630ab | 2017-07-21 14:18:14 +0530 | [diff] [blame] | 4619 | WMI_PDEV_PARAM_DTIM_SYNTH, |
| 4620 | hdd_ctx->config->enable_lprx, PDEV_CMD); |
| 4621 | if (ret) { |
| 4622 | hdd_err("Failed to set LPRx"); |
| 4623 | goto error; |
| 4624 | } |
| 4625 | |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4626 | |
| 4627 | ret = sme_cli_set_command( |
| 4628 | adapter->session_id, |
| 4629 | WMI_PDEV_PARAM_1CH_DTIM_OPTIMIZED_CHAIN_SELECTION, |
| 4630 | hdd_ctx->config->enable_dtim_selection_diversity, |
| 4631 | PDEV_CMD); |
| 4632 | if (ret) { |
| 4633 | hdd_err("Failed to set DTIM_OPTIMIZED_CHAIN_SELECTION"); |
| 4634 | goto error; |
| 4635 | } |
| 4636 | |
Ashish Kumar Dhanotiya | 48dac7d | 2018-03-28 14:59:50 +0530 | [diff] [blame] | 4637 | ret = sme_cli_set_command( |
| 4638 | adapter->session_id, |
| 4639 | WMI_PDEV_PARAM_TX_SCH_DELAY, |
| 4640 | hdd_ctx->config->enable_tx_sch_delay, |
| 4641 | PDEV_CMD); |
| 4642 | if (ret) { |
| 4643 | hdd_err("Failed to set WMI_PDEV_PARAM_TX_SCH_DELAY"); |
| 4644 | goto error; |
| 4645 | } |
| 4646 | |
Ashish Kumar Dhanotiya | 959b38c | 2018-04-06 21:07:57 +0530 | [diff] [blame] | 4647 | ret = sme_cli_set_command( |
| 4648 | adapter->session_id, |
| 4649 | WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE, |
| 4650 | hdd_ctx->config->enable_secondary_rate, |
| 4651 | PDEV_CMD); |
| 4652 | if (ret) { |
| 4653 | hdd_err("Failed to set WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE"); |
| 4654 | goto error; |
| 4655 | } |
| 4656 | |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4657 | if (adapter->device_mode == QDF_STA_MODE) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4658 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4659 | HDD_STA_SMPS_PARAM_UPPER_BRSSI_THRESH, |
| 4660 | hdd_ctx->config->upper_brssi_thresh); |
| 4661 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4662 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4663 | HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH, |
| 4664 | hdd_ctx->config->lower_brssi_thresh); |
| 4665 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4666 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4667 | HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE, |
| 4668 | hdd_ctx->config->enable_dtim_1chrx); |
| 4669 | } |
| 4670 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4671 | if (hdd_ctx->config->enable2x2) { |
| 4672 | hdd_debug("configuring 2x2 mode fw params"); |
| 4673 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4674 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4675 | WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE, |
| 4676 | hdd_ctx->config->enable_cck_tx_fir_override, |
| 4677 | PDEV_CMD); |
| 4678 | if (ret) { |
| 4679 | hdd_err("WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE set failed %d", |
| 4680 | ret); |
| 4681 | goto error; |
| 4682 | } |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4683 | |
| 4684 | if (hdd_configure_chain_mask(adapter)) |
| 4685 | goto error; |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4686 | } else { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4687 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 4688 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4689 | hdd_debug("configuring 1x1 mode fw params"); |
| 4690 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4691 | /* |
| 4692 | * Disable DTIM 1 chain Rx when in 1x1, |
| 4693 | * we are passing two value |
| 4694 | * as param_id << 29 | param_value. |
| 4695 | * Below param_value = 0(disable) |
| 4696 | */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4697 | ret = sme_cli_set_command(adapter->session_id, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4698 | WMI_STA_SMPS_PARAM_CMDID, |
| 4699 | HDD_DTIM_1CHAIN_RX_ID << |
| 4700 | HDD_SMPS_PARAM_VALUE_S, |
| 4701 | VDEV_CMD); |
| 4702 | if (ret) { |
| 4703 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 4704 | goto error; |
| 4705 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4706 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4707 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 4708 | #undef HDD_SMPS_PARAM_VALUE_S |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4709 | |
| 4710 | if (hdd_configure_chain_mask(adapter)) |
| 4711 | goto error; |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4712 | } |
| 4713 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4714 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4715 | WMI_PDEV_PARAM_HYST_EN, |
| 4716 | hdd_ctx->config->enableMemDeepSleep, |
| 4717 | PDEV_CMD); |
| 4718 | if (ret) { |
| 4719 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", ret); |
| 4720 | goto error; |
| 4721 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4722 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4723 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4724 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
| 4725 | hdd_ctx->config->rts_profile, |
| 4726 | VDEV_CMD); |
| 4727 | if (ret) { |
| 4728 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 4729 | goto error; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4730 | } |
| 4731 | |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4732 | hdd_debug("SET AMSDU num %d", hdd_ctx->config->max_amsdu_num); |
| 4733 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4734 | ret = wma_cli_set_command(adapter->session_id, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4735 | GEN_VDEV_PARAM_AMSDU, |
| 4736 | hdd_ctx->config->max_amsdu_num, |
| 4737 | GEN_CMD); |
| 4738 | if (ret != 0) { |
| 4739 | hdd_err("GEN_VDEV_PARAM_AMSDU set failed %d", ret); |
| 4740 | goto error; |
| 4741 | } |
| 4742 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4743 | hdd_set_fw_log_params(hdd_ctx, adapter); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4744 | hdd_exit(); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4745 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4746 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4747 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4748 | error: |
| 4749 | return -EINVAL; |
| 4750 | } |
| 4751 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4752 | /** |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 4753 | * hdd_init_completion() - Initialize Completion Variables |
| 4754 | * @adapter: HDD adapter |
| 4755 | * |
| 4756 | * This function Initialize the completion variables for |
| 4757 | * a particular adapter |
| 4758 | * |
| 4759 | * Return: None |
| 4760 | */ |
| 4761 | static void hdd_init_completion(struct hdd_adapter *adapter) |
| 4762 | { |
| 4763 | init_completion(&adapter->disconnect_comp_var); |
| 4764 | init_completion(&adapter->roaming_comp_var); |
| 4765 | init_completion(&adapter->linkup_event_var); |
| 4766 | init_completion(&adapter->cancel_rem_on_chan_var); |
| 4767 | init_completion(&adapter->rem_on_chan_ready_event); |
| 4768 | init_completion(&adapter->sta_authorized_event); |
| 4769 | init_completion(&adapter->offchannel_tx_event); |
| 4770 | init_completion(&adapter->tx_action_cnf_event); |
| 4771 | init_completion(&adapter->ibss_peer_info_comp); |
| 4772 | init_completion(&adapter->lfr_fw_status.disable_lfr_event); |
| 4773 | } |
| 4774 | |
| 4775 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4776 | * hdd_open_adapter() - open and setup the hdd adatper |
| 4777 | * @hdd_ctx: global hdd context |
| 4778 | * @session_type: type of the interface to be created |
| 4779 | * @iface_name: User-visible name of the interface |
| 4780 | * @macAddr: MAC address to assign to the interface |
| 4781 | * @name_assign_type: the name of assign type of the netdev |
| 4782 | * @rtnl_held: the rtnl lock hold flag |
| 4783 | * |
| 4784 | * This function open and setup the hdd adpater according to the device |
| 4785 | * type request, assign the name, the mac address assigned, and then prepared |
| 4786 | * the hdd related parameters, queue, lock and ready to start. |
| 4787 | * |
| 4788 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 4789 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4790 | 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] | 4791 | const char *iface_name, tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4792 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4793 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4794 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4795 | struct hdd_adapter *adapter = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4796 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4797 | |
| 4798 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 4799 | /* |
| 4800 | * Max limit reached on the number of vdevs configured by the |
| 4801 | * host. Return error |
| 4802 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4803 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 4804 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4805 | return NULL; |
| 4806 | } |
| 4807 | |
| 4808 | if (macAddr == NULL) { |
| 4809 | /* Not received valid macAddr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4810 | 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] | 4811 | return NULL; |
| 4812 | } |
| 4813 | status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4814 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4815 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 4816 | " already exists", |
| 4817 | MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4818 | return NULL; |
| 4819 | } |
| 4820 | |
| 4821 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4822 | case QDF_STA_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4823 | /* Reset locally administered bit if the device mode is STA */ |
| 4824 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr); |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 4825 | hdd_debug("locally administered bit reset in sta mode: " |
| 4826 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4827 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4828 | case QDF_P2P_CLIENT_MODE: |
| 4829 | case QDF_P2P_DEVICE_MODE: |
| 4830 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 4831 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4832 | case QDF_MONITOR_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4833 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4834 | name_assign_type, |
| 4835 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4836 | |
| 4837 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4838 | hdd_err("failed to allocate adapter for session %d", |
| 4839 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4840 | return NULL; |
| 4841 | } |
| 4842 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4843 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4844 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4845 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4846 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4847 | else if (QDF_MONITOR_MODE == session_type) |
| 4848 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4849 | else |
| 4850 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4851 | |
| 4852 | adapter->device_mode = session_type; |
| 4853 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4854 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4855 | /* |
| 4856 | * Workqueue which gets scheduled in IPv4 notification |
| 4857 | * callback |
| 4858 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4859 | INIT_WORK(&adapter->ipv4_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4860 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4861 | |
| 4862 | #ifdef WLAN_NS_OFFLOAD |
| 4863 | /* |
| 4864 | * Workqueue which gets scheduled in IPv6 |
| 4865 | * notification callback. |
| 4866 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4867 | INIT_WORK(&adapter->ipv6_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4868 | hdd_ipv6_notifier_work_queue); |
| 4869 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4870 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4871 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4872 | goto err_free_netdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4873 | |
| 4874 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4875 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4876 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4877 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4878 | WLAN_CONTROL_PATH); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4879 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4880 | hdd_nud_init_tracking(adapter); |
| 4881 | |
| 4882 | qdf_mutex_create(&adapter->disconnection_status_lock); |
| 4883 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4884 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4885 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4886 | case QDF_P2P_GO_MODE: |
| 4887 | case QDF_SAP_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4888 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr, |
| 4889 | name_assign_type, |
| 4890 | (uint8_t *) iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4891 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4892 | hdd_err("failed to allocate adapter for session %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4893 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4894 | return NULL; |
| 4895 | } |
| 4896 | |
| 4897 | adapter->wdev.iftype = |
| 4898 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4899 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4900 | NL80211_IFTYPE_P2P_GO; |
| 4901 | adapter->device_mode = session_type; |
| 4902 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 4903 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4904 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4905 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4906 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4907 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4908 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4909 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4910 | WLAN_CONTROL_PATH); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4911 | |
| 4912 | /* |
| 4913 | * Workqueue which gets scheduled in IPv4 notification |
| 4914 | * callback |
| 4915 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4916 | INIT_WORK(&adapter->ipv4_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4917 | hdd_ipv4_notifier_work_queue); |
| 4918 | |
| 4919 | #ifdef WLAN_NS_OFFLOAD |
| 4920 | /* |
| 4921 | * Workqueue which gets scheduled in IPv6 |
| 4922 | * notification callback. |
| 4923 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4924 | INIT_WORK(&adapter->ipv6_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4925 | hdd_ipv6_notifier_work_queue); |
| 4926 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4927 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4928 | case QDF_FTM_MODE: |
| 4929 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4930 | name_assign_type, |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 4931 | iface_name); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4932 | if (NULL == adapter) { |
| 4933 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 4934 | return NULL; |
| 4935 | } |
| 4936 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4937 | adapter->device_mode = session_type; |
| 4938 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4939 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4940 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4941 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4942 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4943 | hdd_debug("Disabling queues"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4944 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4945 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4946 | WLAN_CONTROL_PATH); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4947 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4948 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4949 | hdd_err("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4950 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4951 | return NULL; |
| 4952 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4953 | |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 4954 | hdd_init_completion(adapter); |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 4955 | INIT_WORK(&adapter->scan_block_work, wlan_hdd_cfg80211_scan_block_cb); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 4956 | qdf_list_create(&adapter->blocked_scan_request_q, WLAN_MAX_SCAN_COUNT); |
| 4957 | qdf_mutex_create(&adapter->blocked_scan_request_q_lock); |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 4958 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4959 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4960 | /* Add it to the hdd's session list. */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4961 | status = hdd_add_adapter_back(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4962 | } |
| 4963 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4964 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4965 | if (NULL != adapter) { |
| 4966 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4967 | adapter = NULL; |
| 4968 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4969 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4970 | return NULL; |
| 4971 | } |
Nachiket Kukade | 5f0ce4f | 2018-06-15 19:47:37 +0530 | [diff] [blame] | 4972 | hdd_apf_context_init(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4973 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4974 | if (QDF_STATUS_SUCCESS == status) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4975 | policy_mgr_set_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4976 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4977 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4978 | /* Adapter successfully added. Increment the vdev count */ |
| 4979 | hdd_ctx->current_intf_count++; |
| 4980 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4981 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4982 | hdd_ctx->current_intf_count); |
| 4983 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 4984 | hdd_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4985 | } |
| 4986 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4987 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 4988 | hdd_err("Interface %s wow debug_fs init failed", |
| 4989 | netdev_name(adapter->dev)); |
| 4990 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 4991 | hdd_register_hl_netdev_fc_timer(adapter, |
| 4992 | hdd_tx_resume_timer_expired_handler); |
| 4993 | |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 4994 | hdd_info("%s interface created. iftype: %d", netdev_name(adapter->dev), |
| 4995 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4996 | |
| 4997 | return adapter; |
| 4998 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4999 | err_free_netdev: |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5000 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 5001 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5002 | |
| 5003 | return NULL; |
| 5004 | } |
| 5005 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5006 | QDF_STATUS hdd_close_adapter(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 5007 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5008 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5009 | /* |
| 5010 | * Here we are stopping global bus_bw timer & work per adapter. |
| 5011 | * |
| 5012 | * The reason is to fix one race condition between |
| 5013 | * bus bandwidth work and cleaning up an adapter. |
| 5014 | * Under some conditions, it is possible for the bus bandwidth |
| 5015 | * work to access a particularly destroyed adapter, leading to |
| 5016 | * use-after-free. |
| 5017 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5018 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5019 | |
Min Liu | ef92ef5 | 2018-06-25 18:08:54 +0800 | [diff] [blame] | 5020 | qdf_list_destroy(&adapter->blocked_scan_request_q); |
| 5021 | qdf_mutex_destroy(&adapter->blocked_scan_request_q_lock); |
| 5022 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5023 | /* cleanup adapter */ |
| 5024 | policy_mgr_clear_concurrency_mode(hdd_ctx->hdd_psoc, |
| 5025 | adapter->device_mode); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5026 | hdd_remove_adapter(hdd_ctx, adapter); |
Liangwei Dong | ad89c76 | 2018-06-01 01:56:23 -0400 | [diff] [blame] | 5027 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5028 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5029 | /* conditionally restart the bw timer */ |
| 5030 | hdd_bus_bw_compute_timer_try_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5031 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5032 | /* Adapter removed. Decrement vdev count */ |
| 5033 | if (hdd_ctx->current_intf_count != 0) |
| 5034 | hdd_ctx->current_intf_count--; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 5035 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5036 | /* Fw will take care incase of concurrency */ |
| 5037 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5038 | } |
| 5039 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 5040 | /** |
| 5041 | * hdd_close_all_adapters - Close all open adapters |
| 5042 | * @hdd_ctx: Hdd context |
| 5043 | * rtnl_held: True if RTNL lock held |
| 5044 | * |
| 5045 | * Close all open adapters. |
| 5046 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5047 | * Return: QDF status code |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 5048 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5049 | QDF_STATUS hdd_close_all_adapters(struct hdd_context *hdd_ctx, bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5050 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5051 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5052 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5053 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5054 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5055 | |
| 5056 | do { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5057 | status = hdd_remove_front_adapter(hdd_ctx, &adapter); |
| 5058 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5059 | wlan_hdd_release_intf_addr(hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5060 | adapter->mac_addr.bytes); |
| 5061 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 5062 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5063 | /* Adapter removed. Decrement vdev count */ |
| 5064 | if (hdd_ctx->current_intf_count != 0) |
| 5065 | hdd_ctx->current_intf_count--; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5066 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5067 | } while (QDF_IS_STATUS_SUCCESS(status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5068 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5069 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5070 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5071 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5072 | } |
| 5073 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5074 | void wlan_hdd_reset_prob_rspies(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5075 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5076 | struct qdf_mac_addr *bssid = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5077 | tSirUpdateIE updateIE; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5078 | mac_handle_t mac_handle; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5079 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5080 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5081 | case QDF_STA_MODE: |
| 5082 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5083 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5084 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5085 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5086 | bssid = &sta_ctx->conn_info.bssId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5087 | break; |
| 5088 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5089 | case QDF_SAP_MODE: |
| 5090 | case QDF_P2P_GO_MODE: |
| 5091 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5092 | { |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5093 | bssid = &adapter->mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5094 | break; |
| 5095 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5096 | case QDF_FTM_MODE: |
| 5097 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5098 | default: |
| 5099 | /* |
| 5100 | * wlan_hdd_reset_prob_rspies should not have been called |
| 5101 | * for these kind of devices |
| 5102 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5103 | hdd_err("Unexpected request for the current device type %d", |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5104 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5105 | return; |
| 5106 | } |
| 5107 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 5108 | qdf_copy_macaddr(&updateIE.bssid, bssid); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5109 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5110 | updateIE.ieBufferlength = 0; |
| 5111 | updateIE.pAdditionIEBuffer = NULL; |
| 5112 | updateIE.append = true; |
| 5113 | updateIE.notify = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5114 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 5115 | if (sme_update_add_ie(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5116 | &updateIE, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5117 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5118 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5119 | } |
| 5120 | } |
| 5121 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5122 | QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx, |
| 5123 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5124 | { |
Liangwei Dong | ad89c76 | 2018-06-01 01:56:23 -0400 | [diff] [blame] | 5125 | return hdd_stop_adapter_ext(hdd_ctx, adapter, 0); |
| 5126 | } |
| 5127 | |
| 5128 | QDF_STATUS hdd_stop_adapter_ext(struct hdd_context *hdd_ctx, |
| 5129 | struct hdd_adapter *adapter, |
| 5130 | enum hdd_adapter_stop_flag_t flag) |
| 5131 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5132 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5133 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5134 | union iwreq_data wrqu; |
| 5135 | tSirUpdateIE updateIE; |
| 5136 | unsigned long rc; |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 5137 | tsap_config_t *sap_config; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5138 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5139 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5140 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5141 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 5142 | if (adapter->session_id != HDD_SESSION_ID_INVALID) |
| 5143 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 5144 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5145 | hdd_nud_ignore_tracking(adapter, true); |
| 5146 | hdd_nud_reset_tracking(adapter); |
| 5147 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5148 | hdd_debug("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5149 | wlan_hdd_netif_queue_control(adapter, |
| 5150 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5151 | WLAN_CONTROL_PATH); |
Tushnim Bhattacharyya | 9bd058f | 2017-12-27 14:01:31 -0800 | [diff] [blame] | 5152 | /* |
| 5153 | * if this is the last active connection check & stop the |
| 5154 | * opportunistic timer first |
| 5155 | */ |
| 5156 | if (((policy_mgr_get_connection_count(hdd_ctx->hdd_psoc) == 1) && |
| 5157 | (policy_mgr_mode_specific_connection_count(hdd_ctx->hdd_psoc, |
| 5158 | policy_mgr_convert_device_mode_to_qdf_type( |
| 5159 | adapter->device_mode), NULL) == 1)) || |
| 5160 | !policy_mgr_get_connection_count(hdd_ctx->hdd_psoc)) |
| 5161 | policy_mgr_check_and_stop_opportunistic_timer( |
| 5162 | hdd_ctx->hdd_psoc, adapter->session_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5163 | |
| 5164 | mac_handle = hdd_ctx->mac_handle; |
| 5165 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5166 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5167 | case QDF_STA_MODE: |
| 5168 | case QDF_P2P_CLIENT_MODE: |
| 5169 | case QDF_IBSS_MODE: |
| 5170 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5171 | case QDF_NDI_MODE: |
| 5172 | if ((QDF_NDI_MODE == adapter->device_mode) || |
| 5173 | hdd_conn_is_connected( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5174 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)) || |
| 5175 | hdd_is_connecting( |
| 5176 | WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5177 | INIT_COMPLETION(adapter->disconnect_comp_var); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5178 | roam_profile = hdd_roam_profile(adapter); |
| 5179 | /* For NDI do not use roam_profile */ |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5180 | if (QDF_NDI_MODE == adapter->device_mode) |
| 5181 | qdf_ret_status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5182 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5183 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5184 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5185 | else if (roam_profile->BSSType == |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5186 | eCSR_BSS_TYPE_START_IBSS) |
| 5187 | qdf_ret_status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5188 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5189 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5190 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Abhinav Kumar | 19a7a40 | 2018-07-12 17:36:57 +0530 | [diff] [blame] | 5191 | else if (adapter->device_mode == QDF_STA_MODE) |
| 5192 | wlan_hdd_disconnect(adapter, |
| 5193 | eCSR_DISCONNECT_REASON_DEAUTH); |
| 5194 | else |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5195 | qdf_ret_status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5196 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5197 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5198 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5199 | /* success implies disconnect command got |
| 5200 | * queued up successfully |
| 5201 | */ |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5202 | if (qdf_ret_status == QDF_STATUS_SUCCESS && |
| 5203 | QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5204 | rc = wait_for_completion_timeout( |
| 5205 | &adapter->disconnect_comp_var, |
| 5206 | msecs_to_jiffies |
| 5207 | (WLAN_WAIT_TIME_DISCONNECT)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5208 | if (!rc) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5209 | hdd_warn("disconn_comp_var wait fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5210 | } |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5211 | if (qdf_ret_status != QDF_STATUS_SUCCESS) |
| 5212 | hdd_warn("failed to post disconnect"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5213 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5214 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5215 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5216 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 5217 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 5218 | } |
Wu Gao | aceec6c | 2017-08-30 16:08:21 +0800 | [diff] [blame] | 5219 | wlan_hdd_scan_abort(adapter); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5220 | |
Wu Gao | 4a1ec8c | 2018-07-23 19:18:40 +0800 | [diff] [blame] | 5221 | wlan_hdd_cleanup_actionframe(adapter); |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 5222 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 5223 | hdd_clear_fils_connection_info(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5224 | |
| 5225 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5226 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5227 | #endif |
| 5228 | |
| 5229 | hdd_deregister_tx_flow_control(adapter); |
| 5230 | |
| 5231 | #ifdef WLAN_NS_OFFLOAD |
| 5232 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5233 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5234 | #endif |
| 5235 | #endif |
| 5236 | |
Hanumanth Reddy Pothula | 0586014 | 2017-07-26 18:45:27 +0530 | [diff] [blame] | 5237 | if (adapter->device_mode == QDF_STA_MODE) |
| 5238 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 5239 | adapter->dev); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5240 | |
| 5241 | if (wlan_hdd_try_disconnect(adapter)) { |
| 5242 | hdd_err("Error: Can't disconnect adapter"); |
| 5243 | return QDF_STATUS_E_FAILURE; |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 5244 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5245 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 5246 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5247 | break; |
| 5248 | |
Rajeev Kumar | 3b90620 | 2018-02-01 10:55:14 -0800 | [diff] [blame] | 5249 | case QDF_MONITOR_MODE: |
| 5250 | wlan_hdd_scan_abort(adapter); |
| 5251 | hdd_deregister_tx_flow_control(adapter); |
| 5252 | hdd_vdev_destroy(adapter); |
| 5253 | break; |
| 5254 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5255 | case QDF_SAP_MODE: |
Will Huang | 7049bae | 2018-08-13 17:25:02 +0800 | [diff] [blame] | 5256 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 5257 | cds_flush_delayed_work(&adapter->acs_pending_work); |
| 5258 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 5259 | } |
wadesong | f9b15ed | 2017-12-14 14:12:32 +0800 | [diff] [blame] | 5260 | wlan_hdd_scan_abort(adapter); |
Govind Singh | 1dab23b | 2017-08-12 13:31:00 +0530 | [diff] [blame] | 5261 | /* Flush IPA exception path packets */ |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 5262 | sap_config = &adapter->session.ap.sap_config; |
| 5263 | if (sap_config) |
| 5264 | wlansap_reset_sap_config_add_ie(sap_config, |
| 5265 | eUPDATE_IE_ALL); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 5266 | ucfg_ipa_flush(hdd_ctx->hdd_pdev); |
Liangwei Dong | ad89c76 | 2018-06-01 01:56:23 -0400 | [diff] [blame] | 5267 | if (!(flag & HDD_IN_CAC_WORK_TH_CONTEXT)) |
| 5268 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
Jeff Johnson | 46807cd | 2018-04-29 21:32:22 -0700 | [diff] [blame] | 5269 | /* fallthrough */ |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5270 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5271 | case QDF_P2P_GO_MODE: |
Krunal Soni | 2220839 | 2017-09-29 18:10:34 -0700 | [diff] [blame] | 5272 | cds_flush_work(&adapter->sap_stop_bss_work); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5273 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5274 | /* Any softap specific cleanup here... */ |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5275 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5276 | wlan_hdd_undo_acs(adapter); |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5277 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5278 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5279 | |
| 5280 | hdd_deregister_tx_flow_control(adapter); |
| 5281 | |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 5282 | hdd_destroy_acs_timer(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5283 | mutex_lock(&hdd_ctx->sap_lock); |
| 5284 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5285 | QDF_STATUS status; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5286 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5287 | |
| 5288 | /* Stop Bss. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5289 | status = wlansap_stop_bss( |
| 5290 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5291 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5292 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 5293 | struct hdd_hostapd_state *hostapd_state = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5294 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5295 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5296 | qdf_stop_bss_event); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5297 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 5298 | qdf_wait_for_event_completion( |
| 5299 | &hostapd_state->qdf_stop_bss_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 5300 | SME_CMD_TIMEOUT_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5301 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5302 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5303 | hdd_err("failure waiting for wlansap_stop_bss %d", |
| 5304 | qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5305 | } |
| 5306 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5307 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5308 | } |
| 5309 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5310 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 5311 | adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5312 | adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5313 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5314 | adapter->device_mode, |
| 5315 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5316 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 5317 | qdf_copy_macaddr(&updateIE.bssid, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5318 | &adapter->mac_addr); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5319 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5320 | updateIE.ieBufferlength = 0; |
| 5321 | updateIE.pAdditionIEBuffer = NULL; |
| 5322 | updateIE.append = false; |
| 5323 | updateIE.notify = false; |
| 5324 | /* Probe bcn reset */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5325 | if (sme_update_add_ie(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5326 | &updateIE, eUPDATE_IE_PROBE_BCN) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5327 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5328 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5329 | } |
| 5330 | /* Assoc resp reset */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5331 | if (sme_update_add_ie(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5332 | &updateIE, |
| 5333 | eUPDATE_IE_ASSOC_RESP) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5334 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5335 | hdd_err("Could not pass on ASSOC_RSP data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5336 | } |
| 5337 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 5338 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5339 | } |
Jiachao Wu | b1e1ddd | 2018-05-21 12:04:15 +0800 | [diff] [blame] | 5340 | clear_bit(SOFTAP_INIT_DONE, &adapter->event_flags); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5341 | qdf_mem_free(adapter->session.ap.beacon); |
| 5342 | adapter->session.ap.beacon = NULL; |
Jiachao Wu | b1e1ddd | 2018-05-21 12:04:15 +0800 | [diff] [blame] | 5343 | |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5344 | /* |
| 5345 | * If Do_Not_Break_Stream was enabled clear avoid channel list. |
| 5346 | */ |
| 5347 | if (policy_mgr_is_dnsc_set(adapter->hdd_vdev)) |
| 5348 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0); |
| 5349 | |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5350 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5351 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5352 | #endif |
| 5353 | |
| 5354 | #ifdef WLAN_NS_OFFLOAD |
| 5355 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5356 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5357 | #endif |
| 5358 | #endif |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5359 | |
| 5360 | hdd_vdev_destroy(adapter); |
| 5361 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5362 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5363 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5364 | case QDF_OCB_MODE: |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 5365 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5366 | (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX), |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 5367 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.staId[0]); |
Zhang Qian | 79d0d13 | 2018-02-05 13:40:16 +0800 | [diff] [blame] | 5368 | hdd_deregister_tx_flow_control(adapter); |
| 5369 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5370 | break; |
| 5371 | default: |
| 5372 | break; |
| 5373 | } |
| 5374 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 5375 | hdd_deregister_hl_netdev_fc_timer(adapter); |
| 5376 | |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5377 | if (adapter->scan_info.default_scan_ies) { |
| 5378 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 5379 | adapter->scan_info.default_scan_ies = NULL; |
| 5380 | } |
| 5381 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5382 | hdd_exit(); |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5383 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5384 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5385 | } |
| 5386 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5387 | /** |
| 5388 | * hdd_deinit_all_adapters - deinit all adapters |
| 5389 | * @hdd_ctx: HDD context |
| 5390 | * @rtnl_held: True if RTNL lock held |
| 5391 | * |
| 5392 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5393 | 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] | 5394 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5395 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5396 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5397 | hdd_enter(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5398 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5399 | hdd_for_each_adapter(hdd_ctx, adapter) |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5400 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5401 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5402 | hdd_exit(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5403 | } |
| 5404 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5405 | QDF_STATUS hdd_stop_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5406 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5407 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5408 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5409 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5410 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5411 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5412 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5413 | hdd_for_each_adapter(hdd_ctx, adapter) |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5414 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5415 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5416 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5417 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5418 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5419 | } |
| 5420 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5421 | static void hdd_reset_scan_operation(struct hdd_context *hdd_ctx, |
| 5422 | struct hdd_adapter *adapter) |
| 5423 | { |
| 5424 | switch (adapter->device_mode) { |
| 5425 | case QDF_STA_MODE: |
| 5426 | case QDF_P2P_CLIENT_MODE: |
| 5427 | case QDF_IBSS_MODE: |
| 5428 | case QDF_P2P_DEVICE_MODE: |
| 5429 | case QDF_NDI_MODE: |
| 5430 | wlan_hdd_scan_abort(adapter); |
| 5431 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5432 | if (adapter->device_mode == QDF_STA_MODE) |
| 5433 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 5434 | adapter->dev); |
| 5435 | break; |
| 5436 | case QDF_P2P_GO_MODE: |
| 5437 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5438 | break; |
| 5439 | case QDF_SAP_MODE: |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5440 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5441 | wlan_hdd_undo_acs(adapter); |
| 5442 | break; |
| 5443 | default: |
| 5444 | break; |
| 5445 | } |
| 5446 | } |
| 5447 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5448 | QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5449 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5450 | struct hdd_adapter *adapter; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5451 | struct hdd_station_ctx *sta_ctx; |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5452 | struct qdf_mac_addr peerMacAddr; |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5453 | int sta_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5454 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5455 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5456 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5457 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5458 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5459 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 5460 | hdd_info("[SSR] reset adapter with device mode %s(%d)", |
| 5461 | hdd_device_mode_to_string(adapter->device_mode), |
| 5462 | adapter->device_mode); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5463 | |
| 5464 | if ((adapter->device_mode == QDF_STA_MODE) || |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5465 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5466 | /* Stop tdls timers */ |
Kabilan Kannan | 00d2041 | 2017-06-04 14:20:32 -0700 | [diff] [blame] | 5467 | hdd_notify_tdls_reset_adapter(adapter->hdd_vdev); |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5468 | adapter->session.station.hdd_reassoc_scenario = false; |
| 5469 | } |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5470 | |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5471 | if (hdd_ctx->config->sap_internal_restart && |
| 5472 | adapter->device_mode == QDF_SAP_MODE) { |
| 5473 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5474 | WLAN_STOP_ALL_NETIF_QUEUE, |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5475 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5476 | if (test_bit(SOFTAP_BSS_STARTED, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5477 | &adapter->event_flags)) |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5478 | hdd_sap_indicate_disconnect_for_sta(adapter); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5479 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
| 5480 | } else { |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5481 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5482 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5483 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5484 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5485 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5486 | hdd_reset_scan_operation(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5487 | |
| 5488 | hdd_deinit_tx_rx(adapter); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5489 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5490 | adapter->device_mode, adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5491 | hdd_green_ap_start_state_mc(hdd_ctx, adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5492 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5493 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 5494 | hdd_wmm_adapter_close(adapter); |
| 5495 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 5496 | } |
| 5497 | |
Vignesh Viswanathan | 2eb1874 | 2017-09-08 11:18:59 +0530 | [diff] [blame] | 5498 | if (adapter->device_mode == QDF_STA_MODE) |
| 5499 | hdd_clear_fils_connection_info(adapter); |
| 5500 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5501 | if (adapter->device_mode == QDF_SAP_MODE) { |
Jingxiang Ge | ec11359 | 2018-08-09 15:40:39 +0800 | [diff] [blame] | 5502 | wlansap_cleanup_cac_timer( |
| 5503 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5504 | /* |
| 5505 | * If adapter is SAP, set session ID to invalid |
| 5506 | * since SAP session will be cleanup during SSR. |
| 5507 | */ |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 5508 | wlansap_set_invalid_session( |
| 5509 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5510 | } |
| 5511 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5512 | /* Delete connection peers if any to avoid peer object leaks */ |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5513 | if (adapter->device_mode == QDF_STA_MODE || |
| 5514 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5515 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5516 | qdf_copy_macaddr(&peerMacAddr, |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5517 | &sta_ctx->conn_info.bssId); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5518 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5519 | } else if (adapter->device_mode == QDF_P2P_GO_MODE) { |
Wu Gao | 6b81fc5 | 2018-05-24 19:27:27 +0800 | [diff] [blame] | 5520 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5521 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) { |
| 5522 | if (adapter->sta_info[sta_id].in_use) { |
| 5523 | hdd_debug("[SSR] deregister STA with ID %d", |
| 5524 | sta_id); |
| 5525 | hdd_softap_deregister_sta(adapter, |
| 5526 | sta_id); |
| 5527 | adapter->sta_info[sta_id].in_use = 0; |
| 5528 | } |
| 5529 | } |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5530 | } |
| 5531 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5532 | hdd_nud_reset_tracking(adapter); |
| 5533 | hdd_nud_ignore_tracking(adapter, true); |
| 5534 | hdd_set_disconnect_status(adapter, false); |
| 5535 | |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5536 | hdd_softap_deinit_tx_rx(adapter); |
Tiger Yu | 8c38770 | 2018-07-06 16:56:42 +0800 | [diff] [blame] | 5537 | hdd_deregister_tx_flow_control(adapter); |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5538 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 5539 | /* Destroy vdev which will be recreated during reinit. */ |
| 5540 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5541 | } |
| 5542 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5543 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5544 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5545 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5546 | } |
| 5547 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5548 | bool hdd_check_for_opened_interfaces(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5549 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5550 | struct hdd_adapter *adapter; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5551 | bool close_modules = true; |
| 5552 | |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5553 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 5554 | hdd_info("FTM mode, don't close the module"); |
| 5555 | return false; |
| 5556 | } |
| 5557 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5558 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5559 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags) || |
| 5560 | test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5561 | hdd_debug("Still other ifaces are up cannot close modules"); |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5562 | close_modules = false; |
| 5563 | break; |
| 5564 | } |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5565 | } |
| 5566 | |
| 5567 | return close_modules; |
| 5568 | } |
| 5569 | |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 5570 | bool hdd_is_interface_up(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5571 | { |
| 5572 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 5573 | return true; |
| 5574 | else |
| 5575 | return false; |
| 5576 | } |
| 5577 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5578 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
bings | bdcd4a2 | 2017-06-20 09:27:00 +0800 | [diff] [blame] | 5579 | && !defined(WITH_BACKPORTS) && !defined(IEEE80211_PRIVACY) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5580 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5581 | struct ieee80211_channel *channel, |
| 5582 | const u8 *bssid, const u8 *ssid, |
| 5583 | size_t ssid_len) |
| 5584 | { |
| 5585 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5586 | ssid, ssid_len, |
| 5587 | WLAN_CAPABILITY_ESS, |
| 5588 | WLAN_CAPABILITY_ESS); |
| 5589 | } |
| 5590 | #else |
| 5591 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5592 | struct ieee80211_channel *channel, |
| 5593 | const u8 *bssid, const u8 *ssid, |
| 5594 | size_t ssid_len) |
| 5595 | { |
| 5596 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5597 | ssid, ssid_len, |
| 5598 | IEEE80211_BSS_TYPE_ESS, |
| 5599 | IEEE80211_PRIVACY_ANY); |
| 5600 | } |
| 5601 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5602 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5603 | #if defined CFG80211_CONNECT_BSS || \ |
| 5604 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5605 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5606 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5607 | /** |
| 5608 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 5609 | * @timeout_reason: reason for connect timeout |
| 5610 | * |
| 5611 | * This function is used to convert host timeout |
| 5612 | * reason enum to kernel specific enum. |
| 5613 | * |
| 5614 | * Return: nl timeout enum |
| 5615 | */ |
| 5616 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 5617 | tSirResultCodes timeout_reason) |
| 5618 | { |
| 5619 | switch (timeout_reason) { |
| 5620 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 5621 | return NL80211_TIMEOUT_SCAN; |
| 5622 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 5623 | return NL80211_TIMEOUT_AUTH; |
| 5624 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 5625 | return NL80211_TIMEOUT_ASSOC; |
| 5626 | default: |
| 5627 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 5628 | } |
| 5629 | } |
| 5630 | |
| 5631 | /** |
| 5632 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 5633 | * @dev: network device |
| 5634 | * @bssid: bssid to which we want to associate |
| 5635 | * @timeout_reason: reason for connect timeout |
| 5636 | * |
| 5637 | * This API is used to send connection timeout reason to supplicant |
| 5638 | * |
| 5639 | * Return: void |
| 5640 | */ |
| 5641 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5642 | const u8 *bssid, |
| 5643 | tSirResultCodes timeout_reason) |
| 5644 | { |
| 5645 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5646 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5647 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5648 | |
| 5649 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 5650 | nl_timeout_reason); |
| 5651 | } |
| 5652 | |
| 5653 | /** |
| 5654 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 5655 | * @dev: network device |
| 5656 | * @bssid: bssid to which we want to associate |
| 5657 | * @req_ie: Request Information Element |
| 5658 | * @req_ie_len: len of the req IE |
| 5659 | * @resp_ie: Response IE |
| 5660 | * @resp_ie_len: len of ht response IE |
| 5661 | * @status: status |
| 5662 | * @gfp: Kernel Flag |
| 5663 | * @timeout_reason: reason for connect timeout |
| 5664 | * |
| 5665 | * Return: void |
| 5666 | */ |
| 5667 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5668 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5669 | size_t req_ie_len, const u8 *resp_ie, |
| 5670 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5671 | tSirResultCodes timeout_reason) |
| 5672 | { |
| 5673 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5674 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5675 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5676 | |
| 5677 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5678 | resp_ie, resp_ie_len, status, gfp, |
| 5679 | nl_timeout_reason); |
| 5680 | } |
| 5681 | #else |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5682 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5683 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5684 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5685 | const u8 *bssid, |
| 5686 | tSirResultCodes timeout_reason) |
| 5687 | { |
| 5688 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 5689 | } |
| 5690 | #endif |
| 5691 | |
| 5692 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5693 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5694 | size_t req_ie_len, const u8 *resp_ie, |
| 5695 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5696 | tSirResultCodes timeout_reason) |
| 5697 | { |
| 5698 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5699 | resp_ie, resp_ie_len, status, gfp); |
| 5700 | } |
| 5701 | #endif |
| 5702 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5703 | /** |
| 5704 | * hdd_connect_bss() - API to send connection status to supplicant |
| 5705 | * @dev: network device |
| 5706 | * @bssid: bssid to which we want to associate |
| 5707 | * @req_ie: Request Information Element |
| 5708 | * @req_ie_len: len of the req IE |
| 5709 | * @resp_ie: Response IE |
| 5710 | * @resp_ie_len: len of ht response IE |
| 5711 | * @status: status |
| 5712 | * @gfp: Kernel Flag |
| 5713 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5714 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5715 | * |
| 5716 | * The API is a wrapper to send connection status to supplicant |
| 5717 | * |
| 5718 | * Return: Void |
| 5719 | */ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5720 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5721 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5722 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5723 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5724 | size_t req_ie_len, const u8 *resp_ie, |
| 5725 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5726 | bool connect_timeout, |
| 5727 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5728 | { |
| 5729 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5730 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5731 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5732 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5733 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5734 | } |
| 5735 | #else |
| 5736 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5737 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5738 | size_t req_ie_len, const u8 *resp_ie, |
| 5739 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5740 | bool connect_timeout, |
| 5741 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5742 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5743 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5744 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5745 | } |
| 5746 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5747 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5748 | #if defined(WLAN_FEATURE_FILS_SK) |
| 5749 | #if defined(CFG80211_CONNECT_DONE) || \ |
| 5750 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
| 5751 | #if defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 5752 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5753 | /** |
| 5754 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 5755 | * @fils_params: connect response to supplicant |
| 5756 | * @fils_kek: FILS kek |
| 5757 | * @fils_kek_len: FILS kek length |
| 5758 | * @pmk: FILS PMK |
| 5759 | * @pmk_len: FILS PMK length |
| 5760 | * @pmkid: PMKID |
| 5761 | * @fils_seq_num: FILS Seq number |
| 5762 | * |
| 5763 | * Return: None |
| 5764 | */ |
| 5765 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5766 | *fils_params, const uint8_t *fils_kek, |
| 5767 | size_t fils_kek_len, const uint8_t *pmk, |
| 5768 | size_t pmk_len, const uint8_t *pmkid, |
| 5769 | uint16_t fils_seq_num) |
| 5770 | { |
| 5771 | /* Increament seq number to be used for next FILS */ |
| 5772 | fils_params->fils_erp_next_seq_num = fils_seq_num + 1; |
| 5773 | fils_params->update_erp_next_seq_num = true; |
| 5774 | fils_params->fils_kek = fils_kek; |
| 5775 | fils_params->fils_kek_len = fils_kek_len; |
| 5776 | fils_params->pmk = pmk; |
| 5777 | fils_params->pmk_len = pmk_len; |
| 5778 | fils_params->pmkid = pmkid; |
| 5779 | } |
| 5780 | #else |
| 5781 | static inline void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5782 | *fils_params, const uint8_t |
| 5783 | *fils_kek, size_t fils_kek_len, |
| 5784 | const uint8_t *pmk, size_t pmk_len, |
| 5785 | const uint8_t *pmkid, |
| 5786 | uint16_t fils_seq_num) |
| 5787 | { } |
| 5788 | #endif |
| 5789 | |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5790 | void hdd_update_hlp_info(struct net_device *dev, |
| 5791 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5792 | { |
| 5793 | struct sk_buff *skb; |
| 5794 | uint16_t skb_len; |
| 5795 | struct llc_snap_hdr_t *llc_hdr; |
| 5796 | QDF_STATUS status; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5797 | uint8_t *hlp_data; |
| 5798 | uint16_t hlp_data_len; |
| 5799 | struct fils_join_rsp_params *roam_fils_params |
| 5800 | = roam_info->fils_join_rsp; |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5801 | struct hdd_adapter *padapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5802 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5803 | if (!roam_fils_params) { |
| 5804 | hdd_err("FILS Roam Param NULL"); |
| 5805 | return; |
| 5806 | } |
| 5807 | |
Srinivas Girigowda | 3cc8e91 | 2017-11-28 18:11:57 -0800 | [diff] [blame] | 5808 | if (!roam_fils_params->hlp_data_len) { |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5809 | hdd_err("FILS HLP Data NULL, len %d", |
| 5810 | roam_fils_params->hlp_data_len); |
| 5811 | return; |
| 5812 | } |
| 5813 | |
| 5814 | hlp_data = roam_fils_params->hlp_data; |
| 5815 | hlp_data_len = roam_fils_params->hlp_data_len; |
| 5816 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5817 | /* Calculate skb length */ |
| 5818 | skb_len = (2 * ETH_ALEN) + hlp_data_len; |
| 5819 | skb = qdf_nbuf_alloc(NULL, skb_len, 0, 4, false); |
| 5820 | if (skb == NULL) { |
| 5821 | hdd_err("HLP packet nbuf alloc fails"); |
| 5822 | return; |
| 5823 | } |
| 5824 | |
| 5825 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->dst_mac.bytes, |
| 5826 | QDF_MAC_ADDR_SIZE); |
| 5827 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->src_mac.bytes, |
| 5828 | QDF_MAC_ADDR_SIZE); |
| 5829 | |
| 5830 | llc_hdr = (struct llc_snap_hdr_t *) hlp_data; |
| 5831 | if (IS_SNAP(llc_hdr)) { |
| 5832 | hlp_data += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5833 | hlp_data_len += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5834 | } |
| 5835 | |
| 5836 | qdf_mem_copy(skb_put(skb, hlp_data_len), hlp_data, hlp_data_len); |
| 5837 | |
| 5838 | /* |
| 5839 | * This HLP packet is formed from HLP info encapsulated |
| 5840 | * in assoc response frame which is AEAD encrypted. |
| 5841 | * Hence, this checksum validation can be set unnecessary. |
| 5842 | * i.e. network layer need not worry about checksum. |
| 5843 | */ |
| 5844 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 5845 | |
| 5846 | status = hdd_rx_packet_cbk(padapter, skb); |
| 5847 | if (QDF_IS_STATUS_ERROR(status)) { |
| 5848 | hdd_err("Sending HLP packet fails"); |
| 5849 | return; |
| 5850 | } |
| 5851 | hdd_debug("send HLP packet to netif successfully"); |
| 5852 | } |
| 5853 | |
| 5854 | /** |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5855 | * hdd_connect_done() - Wrapper API to call cfg80211_connect_done |
| 5856 | * @dev: network device |
| 5857 | * @bssid: bssid to which we want to associate |
| 5858 | * @bss: cfg80211 bss info |
| 5859 | * @roam_info: information about connected bss |
| 5860 | * @req_ie: Request Information Element |
| 5861 | * @req_ie_len: len of the req IE |
| 5862 | * @resp_ie: Response IE |
| 5863 | * @resp_ie_len: len of ht response IE |
| 5864 | * @status: status |
| 5865 | * @gfp: allocation flags |
| 5866 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5867 | * @timeout_reason: reason for connect timeout |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5868 | * |
| 5869 | * This API is used as wrapper to send FILS key/sequence number |
| 5870 | * params etc. to supplicant in case of FILS connection |
| 5871 | * |
| 5872 | * Return: None |
| 5873 | */ |
| 5874 | static void hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5875 | struct cfg80211_bss *bss, |
| 5876 | struct csr_roam_info *roam_info, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5877 | const u8 *req_ie, size_t req_ie_len, |
| 5878 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5879 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5880 | tSirResultCodes timeout_reason) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5881 | { |
| 5882 | struct cfg80211_connect_resp_params fils_params; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5883 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5884 | struct fils_join_rsp_params *roam_fils_params = |
| 5885 | roam_info->fils_join_rsp; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5886 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5887 | qdf_mem_zero(&fils_params, sizeof(fils_params)); |
| 5888 | |
| 5889 | if (!roam_fils_params) { |
| 5890 | fils_params.status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 5891 | } else { |
| 5892 | fils_params.status = status; |
| 5893 | fils_params.bssid = bssid; |
Srinivas Girigowda | e975f53 | 2018-01-05 14:03:05 -0800 | [diff] [blame] | 5894 | fils_params.timeout_reason = |
| 5895 | hdd_convert_timeout_reason(timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5896 | fils_params.req_ie = req_ie; |
| 5897 | fils_params.req_ie_len = req_ie_len; |
| 5898 | fils_params.resp_ie = resp_ie; |
| 5899 | fils_params.resp_ie_len = resp_ie_len; |
| 5900 | fils_params.bss = bss; |
| 5901 | hdd_populate_fils_params(&fils_params, roam_fils_params->kek, |
| 5902 | roam_fils_params->kek_len, |
| 5903 | roam_fils_params->fils_pmk, |
| 5904 | roam_fils_params->fils_pmk_len, |
| 5905 | roam_fils_params->fils_pmkid, |
| 5906 | roam_info->fils_seq_num); |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 5907 | hdd_save_gtk_params(adapter, roam_info, false); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5908 | } |
| 5909 | hdd_debug("FILS indicate connect status %d seq no %d", |
| 5910 | fils_params.status, |
| 5911 | fils_params.fils_erp_next_seq_num); |
| 5912 | |
| 5913 | cfg80211_connect_done(dev, &fils_params, gfp); |
| 5914 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5915 | if (roam_fils_params && roam_fils_params->hlp_data_len) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5916 | hdd_update_hlp_info(dev, roam_info); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5917 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5918 | /* Clear all the FILS key info */ |
| 5919 | if (roam_fils_params && roam_fils_params->fils_pmk) |
| 5920 | qdf_mem_free(roam_fils_params->fils_pmk); |
| 5921 | if (roam_fils_params) |
| 5922 | qdf_mem_free(roam_fils_params); |
| 5923 | roam_info->fils_join_rsp = NULL; |
| 5924 | } |
| 5925 | #else |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5926 | static inline void |
| 5927 | hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5928 | struct cfg80211_bss *bss, struct csr_roam_info *roam_info, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5929 | const u8 *req_ie, size_t req_ie_len, |
| 5930 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
| 5931 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5932 | tSirResultCodes timeout_reason) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5933 | { } |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5934 | #endif |
| 5935 | #endif |
| 5936 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5937 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 5938 | (defined(CFG80211_CONNECT_DONE) || \ |
| 5939 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5940 | /** |
| 5941 | * hdd_fils_update_connect_results() - API to send fils connection status to |
| 5942 | * supplicant. |
| 5943 | * @dev: network device |
| 5944 | * @bssid: bssid to which we want to associate |
| 5945 | * @bss: cfg80211 bss info |
| 5946 | * @roam_info: information about connected bss |
| 5947 | * @req_ie: Request Information Element |
| 5948 | * @req_ie_len: len of the req IE |
| 5949 | * @resp_ie: Response IE |
| 5950 | * @resp_ie_len: len of ht response IE |
| 5951 | * @status: status |
| 5952 | * @gfp: allocation flags |
| 5953 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5954 | * @timeout_reason: reason for connect timeout |
| 5955 | * |
| 5956 | * The API is a wrapper to send connection status to supplicant |
| 5957 | * |
| 5958 | * Return: 0 if success else failure |
| 5959 | */ |
| 5960 | static int hdd_fils_update_connect_results(struct net_device *dev, |
| 5961 | const u8 *bssid, |
| 5962 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5963 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5964 | size_t req_ie_len, const u8 *resp_ie, |
| 5965 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5966 | bool connect_timeout, |
| 5967 | tSirResultCodes timeout_reason) |
| 5968 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5969 | hdd_enter(); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5970 | if (!roam_info || !roam_info->is_fils_connection) |
| 5971 | return -EINVAL; |
| 5972 | |
| 5973 | hdd_connect_done(dev, bssid, bss, roam_info, req_ie, req_ie_len, |
| 5974 | resp_ie, resp_ie_len, status, gfp, connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5975 | timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5976 | return 0; |
| 5977 | } |
| 5978 | #else |
| 5979 | static inline int hdd_fils_update_connect_results(struct net_device *dev, |
| 5980 | const u8 *bssid, |
| 5981 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5982 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5983 | size_t req_ie_len, const u8 *resp_ie, |
| 5984 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5985 | bool connect_timeout, |
| 5986 | tSirResultCodes timeout_reason) |
| 5987 | { |
| 5988 | return -EINVAL; |
| 5989 | } |
| 5990 | #endif |
| 5991 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5992 | /** |
| 5993 | * hdd_connect_result() - API to send connection status to supplicant |
| 5994 | * @dev: network device |
| 5995 | * @bssid: bssid to which we want to associate |
| 5996 | * @roam_info: information about connected bss |
| 5997 | * @req_ie: Request Information Element |
| 5998 | * @req_ie_len: len of the req IE |
| 5999 | * @resp_ie: Response IE |
| 6000 | * @resp_ie_len: len of ht response IE |
| 6001 | * @status: status |
| 6002 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6003 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6004 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6005 | * |
| 6006 | * The API is a wrapper to send connection status to supplicant |
| 6007 | * and allow runtime suspend |
| 6008 | * |
| 6009 | * Return: Void |
| 6010 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6011 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6012 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6013 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6014 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6015 | bool connect_timeout, |
| 6016 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6017 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6018 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6019 | struct cfg80211_bss *bss = NULL; |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 6020 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6021 | |
| 6022 | if (WLAN_STATUS_SUCCESS == status) { |
| 6023 | struct ieee80211_channel *chan; |
| 6024 | int freq; |
| 6025 | int chan_no = roam_info->pBssDesc->channelId; |
| 6026 | |
| 6027 | if (chan_no <= 14) |
| 6028 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 6029 | HDD_NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6030 | else |
| 6031 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 6032 | HDD_NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6033 | |
| 6034 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
| 6035 | bss = hdd_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
| 6036 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 6037 | roam_info->u.pConnectedProfile->SSID.length); |
| 6038 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6039 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6040 | if (hdd_fils_update_connect_results(dev, bssid, bss, |
| 6041 | roam_info, req_ie, req_ie_len, resp_ie, |
| 6042 | resp_ie_len, status, gfp, connect_timeout, |
| 6043 | timeout_reason) != 0) { |
| 6044 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 6045 | req_ie_len, resp_ie, resp_ie_len, |
| 6046 | status, gfp, connect_timeout, timeout_reason); |
| 6047 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6048 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 6049 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 6050 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6051 | } |
| 6052 | #else |
| 6053 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6054 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6055 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6056 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6057 | bool connect_timeout, |
| 6058 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6059 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6060 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 6061 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6062 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6063 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 6064 | resp_ie, resp_ie_len, status, gfp); |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 6065 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 6066 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 6067 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6068 | } |
| 6069 | #endif |
| 6070 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 6071 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6072 | int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan, |
| 6073 | uint32_t bandwidth) |
| 6074 | { |
| 6075 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6076 | struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 6077 | struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info; |
| 6078 | QDF_STATUS status; |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6079 | tHalHandle hal_hdl = hdd_ctx->mac_handle; |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6080 | struct qdf_mac_addr bssid; |
| 6081 | struct csr_roam_profile roam_profile; |
| 6082 | struct ch_params ch_params; |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6083 | eConnectionState connstate; |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6084 | |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6085 | if (hdd_get_conparam() != QDF_GLOBAL_MONITOR_MODE && |
| 6086 | adapter->device_mode != QDF_STA_MODE) { |
| 6087 | 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] | 6088 | return -EINVAL; |
| 6089 | } |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6090 | if (adapter->device_mode == QDF_STA_MODE && |
| 6091 | hdd_ctx->config->enable_change_channel_bandwidth) { |
| 6092 | connstate = sta_ctx->conn_info.connState; |
| 6093 | if (eConnectionState_Associated == connstate || |
| 6094 | eConnectionState_Connecting == connstate) { |
| 6095 | return -EINVAL; |
| 6096 | } |
| 6097 | } |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6098 | |
Visweswara Tanuku | 006313a | 2018-04-12 12:26:34 +0530 | [diff] [blame] | 6099 | /* Validate Channel */ |
| 6100 | if (!WLAN_REG_IS_24GHZ_CH(chan) && !WLAN_REG_IS_5GHZ_CH(chan)) { |
| 6101 | hdd_err("Channel %d Not supported", chan); |
| 6102 | return -EINVAL; |
| 6103 | } |
| 6104 | |
| 6105 | if (WLAN_REG_IS_24GHZ_CH(chan)) { |
| 6106 | if (bandwidth == CH_WIDTH_80MHZ) { |
| 6107 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 6108 | return -EINVAL; |
| 6109 | } |
| 6110 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 14) && |
| 6111 | (bandwidth != CH_WIDTH_MAX)) { |
| 6112 | hdd_err("Only BW20 possible on channel 14"); |
| 6113 | return -EINVAL; |
| 6114 | } |
| 6115 | } |
| 6116 | |
| 6117 | if (WLAN_REG_IS_5GHZ_CH(chan)) { |
| 6118 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 165) && |
| 6119 | (bandwidth != CH_WIDTH_MAX)) { |
| 6120 | hdd_err("Only BW20 possible on channel 165"); |
| 6121 | return -EINVAL; |
| 6122 | } |
| 6123 | } |
| 6124 | |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6125 | hdd_debug("Set monitor mode Channel %d", chan); |
| 6126 | qdf_mem_zero(&roam_profile, sizeof(roam_profile)); |
| 6127 | roam_profile.ChannelInfo.ChannelList = &ch_info->channel; |
| 6128 | roam_profile.ChannelInfo.numOfChannels = 1; |
| 6129 | roam_profile.phyMode = ch_info->phy_mode; |
| 6130 | roam_profile.ch_params.ch_width = bandwidth; |
| 6131 | hdd_select_cbmode(adapter, chan, &roam_profile.ch_params); |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6132 | if (hdd_ctx->config->enable_change_channel_bandwidth && |
| 6133 | (!sme_find_session_by_bssid(hal_hdl, adapter->mac_addr.bytes))) { |
| 6134 | status = sme_create_mon_session(hal_hdl, |
| 6135 | adapter->mac_addr.bytes); |
| 6136 | if (status != QDF_STATUS_SUCCESS) { |
| 6137 | hdd_err("Status: %d Failed to create session.", |
| 6138 | status); |
| 6139 | return qdf_status_to_os_return(status); |
| 6140 | } |
| 6141 | } |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6142 | qdf_mem_copy(bssid.bytes, adapter->mac_addr.bytes, |
| 6143 | QDF_MAC_ADDR_SIZE); |
| 6144 | |
| 6145 | ch_params.ch_width = bandwidth; |
| 6146 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, chan, 0, &ch_params); |
| 6147 | if (ch_params.ch_width == CH_WIDTH_INVALID) { |
| 6148 | hdd_err("Invalid capture channel or bandwidth for a country"); |
| 6149 | return -EINVAL; |
| 6150 | } |
| 6151 | if (wlan_hdd_change_hw_mode_for_given_chnl(adapter, chan, |
| 6152 | POLICY_MGR_UPDATE_REASON_SET_OPER_CHAN)) { |
| 6153 | hdd_err("Failed to change hw mode"); |
| 6154 | return -EINVAL; |
| 6155 | } |
| 6156 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 6157 | status = sme_roam_channel_change_req(hdd_ctx->mac_handle, |
| 6158 | bssid, &ch_params, |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6159 | &roam_profile); |
| 6160 | if (status) { |
| 6161 | hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode", |
| 6162 | status); |
| 6163 | } |
| 6164 | |
| 6165 | adapter->mon_chan = chan; |
| 6166 | adapter->mon_bandwidth = bandwidth; |
| 6167 | return qdf_status_to_os_return(status); |
| 6168 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 6169 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6170 | |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6171 | #ifdef MSM_PLATFORM |
| 6172 | /** |
| 6173 | * hdd_stop_p2p_go() - call cfg80211 API to stop P2P GO |
| 6174 | * @adapter: pointer to adapter |
| 6175 | * |
| 6176 | * This function calls cfg80211 API to stop P2P GO |
| 6177 | * |
| 6178 | * Return: None |
| 6179 | */ |
| 6180 | static void hdd_stop_p2p_go(struct hdd_adapter *adapter) |
| 6181 | { |
| 6182 | hdd_debug("[SSR] send stop ap to supplicant"); |
| 6183 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 6184 | } |
| 6185 | |
| 6186 | static inline void hdd_delete_sta(struct hdd_adapter *adapter) |
| 6187 | { |
| 6188 | } |
| 6189 | #else |
| 6190 | static inline void hdd_stop_p2p_go(struct hdd_adapter *adapter) |
| 6191 | { |
| 6192 | } |
| 6193 | |
| 6194 | /** |
| 6195 | * hdd_delete_sta() - call cfg80211 API to delete STA |
| 6196 | * @adapter: pointer to adapter |
| 6197 | * |
| 6198 | * This function calls cfg80211 API to delete STA |
| 6199 | * |
| 6200 | * Return: None |
| 6201 | */ |
| 6202 | static void hdd_delete_sta(struct hdd_adapter *adapter) |
| 6203 | { |
| 6204 | struct qdf_mac_addr bcast_mac = QDF_MAC_ADDR_BCAST_INIT; |
| 6205 | |
| 6206 | hdd_debug("[SSR] send restart supplicant"); |
| 6207 | /* event supplicant to restart */ |
| 6208 | cfg80211_del_sta(adapter->dev, |
| 6209 | (const u8 *)&bcast_mac.bytes[0], |
| 6210 | GFP_KERNEL); |
| 6211 | } |
| 6212 | #endif |
| 6213 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6214 | QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6215 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6216 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6217 | eConnectionState connState; |
| 6218 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6219 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6220 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6221 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6222 | if (!hdd_is_interface_up(adapter)) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6223 | continue; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6224 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 6225 | hdd_debug("[SSR] start adapter with device mode %s(%d)", |
| 6226 | hdd_device_mode_to_string(adapter->device_mode), |
| 6227 | adapter->device_mode); |
| 6228 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6229 | hdd_wmm_init(adapter); |
| 6230 | |
| 6231 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6232 | case QDF_STA_MODE: |
| 6233 | case QDF_P2P_CLIENT_MODE: |
| 6234 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6235 | |
| 6236 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 6237 | ->conn_info.connState; |
| 6238 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6239 | hdd_start_station_adapter(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6240 | /* Open the gates for HDD to receive Wext commands */ |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 6241 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6242 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6243 | /* Indicate disconnect event to supplicant |
| 6244 | * if associated previously |
| 6245 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6246 | if (eConnectionState_Associated == connState || |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 6247 | eConnectionState_IbssConnected == connState || |
| 6248 | eConnectionState_NotConnected == connState || |
| 6249 | eConnectionState_IbssDisconnected == connState || |
| 6250 | eConnectionState_Disconnecting == connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6251 | union iwreq_data wrqu; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6252 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6253 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 6254 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 6255 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 6256 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 6257 | &wrqu, NULL); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 6258 | adapter->session.station. |
Jeff Johnson | 690fe95 | 2017-10-25 11:48:39 -0700 | [diff] [blame] | 6259 | hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6260 | |
| 6261 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 6262 | wlan_hdd_cfg80211_indicate_disconnect( |
| 6263 | adapter->dev, false, |
| 6264 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6265 | } else if (eConnectionState_Connecting == connState) { |
| 6266 | /* |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6267 | * Indicate connect failure to supplicant if we |
| 6268 | * were in the process of connecting |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6269 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6270 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6271 | NULL, 0, NULL, 0, |
| 6272 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6273 | GFP_KERNEL, false, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6274 | } |
| 6275 | |
| 6276 | hdd_register_tx_flow_control(adapter, |
| 6277 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 6278 | hdd_tx_resume_cb, |
| 6279 | hdd_tx_flow_control_is_pause); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6280 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 6281 | hdd_lpass_notify_start(hdd_ctx, adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6282 | hdd_nud_ignore_tracking(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6283 | break; |
| 6284 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6285 | case QDF_SAP_MODE: |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6286 | if (hdd_ctx->config->sap_internal_restart) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6287 | hdd_start_ap_adapter(adapter); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 6288 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6289 | break; |
| 6290 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6291 | case QDF_P2P_GO_MODE: |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6292 | hdd_delete_sta(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6293 | break; |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6294 | case QDF_MONITOR_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6295 | hdd_start_station_adapter(adapter); |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6296 | hdd_set_mon_rx_cb(adapter->dev); |
| 6297 | wlan_hdd_set_mon_chan(adapter, adapter->mon_chan, |
| 6298 | adapter->mon_bandwidth); |
| 6299 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6300 | default: |
| 6301 | break; |
| 6302 | } |
Krunal Soni | 9c2ee03 | 2017-07-18 13:49:54 -0700 | [diff] [blame] | 6303 | /* |
| 6304 | * Action frame registered in one adapter which will |
| 6305 | * applicable to all interfaces |
| 6306 | */ |
| 6307 | wlan_hdd_cfg80211_register_frames(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6308 | } |
| 6309 | |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6310 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6311 | if (!hdd_is_interface_up(adapter)) |
| 6312 | continue; |
| 6313 | |
| 6314 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
| 6315 | hdd_stop_p2p_go(adapter); |
| 6316 | } |
| 6317 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6318 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6319 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6320 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6321 | } |
| 6322 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6323 | QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6324 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6325 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6326 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6327 | qdf_list_node_t *node; |
| 6328 | |
| 6329 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6330 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6331 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6332 | status = qdf_list_peek_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6333 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6334 | |
| 6335 | if (QDF_IS_STATUS_ERROR(status)) |
| 6336 | return status; |
| 6337 | |
| 6338 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6339 | |
| 6340 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6341 | } |
| 6342 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6343 | QDF_STATUS hdd_get_next_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6344 | struct hdd_adapter *current_adapter, |
| 6345 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6346 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6347 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6348 | qdf_list_node_t *node; |
| 6349 | |
| 6350 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6351 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6352 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6353 | status = qdf_list_peek_next(&hdd_ctx->hdd_adapters, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6354 | ¤t_adapter->node, |
| 6355 | &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6356 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6357 | |
| 6358 | if (QDF_IS_STATUS_ERROR(status)) |
| 6359 | return status; |
| 6360 | |
| 6361 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6362 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6363 | return status; |
| 6364 | } |
| 6365 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6366 | QDF_STATUS hdd_remove_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6367 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6368 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6369 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6370 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6371 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6372 | status = qdf_list_remove_node(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6373 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6374 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6375 | return status; |
| 6376 | } |
| 6377 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6378 | QDF_STATUS hdd_remove_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6379 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6380 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6381 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6382 | qdf_list_node_t *node; |
| 6383 | |
| 6384 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6385 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6386 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6387 | status = qdf_list_remove_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6388 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6389 | |
| 6390 | if (QDF_IS_STATUS_ERROR(status)) |
| 6391 | return status; |
| 6392 | |
| 6393 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6394 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6395 | return status; |
| 6396 | } |
| 6397 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6398 | QDF_STATUS hdd_add_adapter_back(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6399 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6400 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6401 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6402 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6403 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6404 | status = qdf_list_insert_back(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6405 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6406 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6407 | return status; |
| 6408 | } |
| 6409 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6410 | QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6411 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6412 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6413 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6414 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6415 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6416 | status = qdf_list_insert_front(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6417 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6418 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6419 | return status; |
| 6420 | } |
| 6421 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6422 | 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] | 6423 | tSirMacAddr macAddr) |
| 6424 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6425 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6426 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6427 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6428 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 6429 | macAddr, sizeof(tSirMacAddr))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6430 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6431 | } |
| 6432 | |
| 6433 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6434 | } |
| 6435 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6436 | 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] | 6437 | uint32_t vdev_id) |
| 6438 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6439 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6440 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6441 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6442 | if (adapter->session_id == vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6443 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6444 | } |
| 6445 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6446 | return NULL; |
| 6447 | } |
| 6448 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6449 | /** |
| 6450 | * hdd_get_adapter_by_sme_session_id() - Return adapter with |
| 6451 | * the sessionid |
| 6452 | * @hdd_ctx: hdd context. |
| 6453 | * @sme_session_id: sme session is for the adapter to get. |
| 6454 | * |
| 6455 | * This function is used to get the adapter with provided session id |
| 6456 | * |
| 6457 | * Return: adapter pointer if found |
| 6458 | * |
| 6459 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 6460 | struct hdd_adapter * |
| 6461 | hdd_get_adapter_by_sme_session_id(struct hdd_context *hdd_ctx, |
| 6462 | uint32_t sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6463 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6464 | struct hdd_adapter *adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6465 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6466 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6467 | if (adapter->session_id == sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6468 | return adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6469 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6470 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6471 | return NULL; |
| 6472 | } |
| 6473 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6474 | 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] | 6475 | const char *iface_name) |
| 6476 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6477 | struct hdd_adapter *adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6478 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6479 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6480 | if (!qdf_str_cmp(adapter->dev->name, iface_name)) |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6481 | return adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6482 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6483 | |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6484 | return NULL; |
| 6485 | } |
| 6486 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6487 | /** |
| 6488 | * hdd_get_adapter() - to get adapter matching the mode |
| 6489 | * @hdd_ctx: hdd context |
| 6490 | * @mode: adapter mode |
| 6491 | * |
| 6492 | * This routine will return the pointer to adapter matching |
| 6493 | * with the passed mode. |
| 6494 | * |
| 6495 | * Return: pointer to adapter or null |
| 6496 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6497 | struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6498 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6499 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6500 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6501 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6502 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6503 | if (adapter->device_mode == mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6504 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6505 | } |
| 6506 | |
| 6507 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6508 | } |
| 6509 | |
Jeff Johnson | 36a0abf | 2018-05-20 11:24:25 -0700 | [diff] [blame] | 6510 | enum QDF_OPMODE hdd_get_device_mode(uint32_t session_id) |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 6511 | { |
| 6512 | struct hdd_context *hdd_ctx; |
| 6513 | struct hdd_adapter *adapter; |
| 6514 | |
| 6515 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 6516 | if (!hdd_ctx) { |
| 6517 | hdd_err("Invalid HDD context"); |
| 6518 | return QDF_MAX_NO_OF_MODE; |
| 6519 | } |
| 6520 | |
| 6521 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 6522 | if (!adapter) { |
| 6523 | hdd_err("Invalid HDD adapter"); |
| 6524 | return QDF_MAX_NO_OF_MODE; |
| 6525 | } |
| 6526 | |
| 6527 | return adapter->device_mode; |
| 6528 | } |
| 6529 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6530 | /** |
| 6531 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 6532 | * @hdd_ctx: Pointer to the HDD context. |
| 6533 | * @mode: Device mode for which operating channel is required. |
Jeff Johnson | 77f89bb | 2018-05-06 16:21:36 -0700 | [diff] [blame] | 6534 | * Supported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6535 | * QDF_STA_MODE, |
| 6536 | * QDF_P2P_CLIENT_MODE, |
| 6537 | * QDF_SAP_MODE, |
| 6538 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6539 | * |
| 6540 | * This API returns the operating channel of the requested device mode |
| 6541 | * |
| 6542 | * Return: channel number. "0" id the requested device is not found OR it is |
| 6543 | * not connected. |
| 6544 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6545 | uint8_t hdd_get_operating_channel(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6546 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6547 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6548 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6549 | uint8_t operatingChannel = 0; |
| 6550 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6551 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6552 | if (mode == adapter->device_mode) { |
| 6553 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6554 | case QDF_STA_MODE: |
| 6555 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6556 | if (hdd_conn_is_connected |
| 6557 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6558 | (adapter))) { |
| 6559 | operatingChannel = |
| 6560 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6561 | (adapter))->conn_info. |
| 6562 | operationChannel; |
| 6563 | } |
| 6564 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6565 | case QDF_SAP_MODE: |
| 6566 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6567 | /* softap connection info */ |
| 6568 | if (test_bit |
| 6569 | (SOFTAP_BSS_STARTED, |
| 6570 | &adapter->event_flags)) |
| 6571 | operatingChannel = |
| 6572 | (WLAN_HDD_GET_AP_CTX_PTR |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 6573 | (adapter))->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6574 | break; |
| 6575 | default: |
| 6576 | break; |
| 6577 | } |
| 6578 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6579 | /* Found the device of interest. break the loop */ |
| 6580 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6581 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6582 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6583 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6584 | return operatingChannel; |
| 6585 | } |
| 6586 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6587 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6588 | hdd_ctx) |
| 6589 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6590 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6591 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6592 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6593 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6594 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6595 | if (adapter->device_mode == QDF_STA_MODE || |
| 6596 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6597 | adapter->device_mode == QDF_IBSS_MODE || |
| 6598 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6599 | adapter->device_mode == QDF_SAP_MODE || |
| 6600 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6601 | hdd_unregister_wext(adapter->dev); |
| 6602 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6603 | } |
| 6604 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6605 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6606 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6607 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6608 | } |
| 6609 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6610 | 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] | 6611 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6612 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6613 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6614 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6615 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6616 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6617 | if (adapter->device_mode == QDF_STA_MODE || |
| 6618 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6619 | adapter->device_mode == QDF_IBSS_MODE || |
| 6620 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6621 | adapter->device_mode == QDF_SAP_MODE || |
| 6622 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 6623 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6624 | adapter->session_id, INVALID_SCAN_ID, |
Vignesh Viswanathan | 19611c8 | 2018-01-16 16:20:40 +0530 | [diff] [blame] | 6625 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6626 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6627 | } |
| 6628 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6629 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6630 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6631 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6632 | } |
| 6633 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6634 | /** |
| 6635 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 6636 | * adapters |
| 6637 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 6638 | * |
| 6639 | * return: QDF_STATUS_SUCCESS |
| 6640 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6641 | 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] | 6642 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6643 | struct hdd_adapter *adapter; |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6644 | int err; |
| 6645 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6646 | hdd_enter(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6647 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6648 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6649 | if (adapter->device_mode == QDF_STA_MODE || |
| 6650 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6651 | adapter->device_mode == QDF_IBSS_MODE || |
| 6652 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6653 | adapter->device_mode == QDF_SAP_MODE || |
| 6654 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6655 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 6656 | if (err) |
| 6657 | hdd_err("Unable to stop scheduled scan"); |
| 6658 | } |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6659 | } |
| 6660 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6661 | hdd_exit(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6662 | |
| 6663 | return QDF_STATUS_SUCCESS; |
| 6664 | } |
| 6665 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6666 | #ifdef WLAN_NS_OFFLOAD |
| 6667 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6668 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6669 | * @hdd_ctx: Pointer to hdd context |
| 6670 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6671 | * Unregister for IPv6 address change notifications. |
| 6672 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6673 | * Return: None |
| 6674 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6675 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6676 | { |
| 6677 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6678 | } |
| 6679 | |
| 6680 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6681 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6682 | * @hdd_ctx: Pointer to hdd context |
| 6683 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6684 | * Register for IPv6 address change notifications. |
| 6685 | * |
| 6686 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6687 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6688 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6689 | { |
| 6690 | int ret; |
| 6691 | |
| 6692 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 6693 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6694 | if (ret) { |
| 6695 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 6696 | goto out; |
| 6697 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6698 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6699 | hdd_debug("Registered IPv6 notifier"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6700 | out: |
| 6701 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6702 | } |
| 6703 | #else |
| 6704 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6705 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6706 | * @hdd_ctx: Pointer to hdd context |
| 6707 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6708 | * Unregister for IPv6 address change notifications. |
| 6709 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6710 | * Return: None |
| 6711 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6712 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6713 | { |
| 6714 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6715 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6716 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6717 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6718 | * @hdd_ctx: Pointer to hdd context |
| 6719 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6720 | * Register for IPv6 address change notifications. |
| 6721 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6722 | * Return: None |
| 6723 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6724 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6725 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6726 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6727 | } |
| 6728 | #endif |
| 6729 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6730 | void hdd_set_disconnect_status(struct hdd_adapter *adapter, bool status) |
| 6731 | { |
| 6732 | qdf_mutex_acquire(&adapter->disconnection_status_lock); |
| 6733 | adapter->disconnection_in_progress = status; |
| 6734 | qdf_mutex_release(&adapter->disconnection_status_lock); |
| 6735 | hdd_debug("setting disconnection status: %d", status); |
| 6736 | } |
| 6737 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6738 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6739 | * hdd_register_notifiers - Register netdev notifiers. |
| 6740 | * @hdd_ctx: HDD context |
| 6741 | * |
| 6742 | * Register netdev notifiers like IPv4 and IPv6. |
| 6743 | * |
| 6744 | * Return: 0 on success and errno on failure |
| 6745 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6746 | static int hdd_register_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6747 | { |
| 6748 | int ret; |
| 6749 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6750 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 6751 | if (ret) |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6752 | goto out; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6753 | |
| 6754 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 6755 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 6756 | if (ret) { |
| 6757 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 6758 | goto unregister_ip6_notifier; |
| 6759 | } |
| 6760 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6761 | ret = hdd_nud_register_netevent_notifier(hdd_ctx); |
| 6762 | if (ret) { |
| 6763 | hdd_err("Failed to register netevent notifier: %d", |
| 6764 | ret); |
| 6765 | goto unregister_inetaddr_notifier; |
| 6766 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6767 | return 0; |
| 6768 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6769 | unregister_inetaddr_notifier: |
| 6770 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6771 | unregister_ip6_notifier: |
| 6772 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6773 | out: |
| 6774 | return ret; |
| 6775 | |
| 6776 | } |
| 6777 | |
| 6778 | /** |
| 6779 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 6780 | * @hdd_ctx: HDD context |
| 6781 | * |
| 6782 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 6783 | * |
| 6784 | * Return: None. |
| 6785 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6786 | void hdd_unregister_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6787 | { |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6788 | hdd_nud_unregister_netevent_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6789 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 6790 | |
| 6791 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6792 | } |
| 6793 | |
| 6794 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6795 | * hdd_exit_netlink_services - Exit netlink services |
| 6796 | * @hdd_ctx: HDD context |
| 6797 | * |
| 6798 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6799 | * nl service. |
| 6800 | * |
| 6801 | * Return: None. |
| 6802 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6803 | static void hdd_exit_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6804 | { |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 6805 | spectral_scan_deactivate_service(); |
| 6806 | cnss_diag_deactivate_service(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6807 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6808 | ptt_sock_deactivate_svc(); |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 6809 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6810 | |
| 6811 | nl_srv_exit(); |
| 6812 | } |
| 6813 | |
| 6814 | /** |
| 6815 | * hdd_init_netlink_services- Init netlink services |
| 6816 | * @hdd_ctx: HDD context |
| 6817 | * |
| 6818 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6819 | * nl service. |
| 6820 | * |
| 6821 | * Return: 0 on success and errno on failure. |
| 6822 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6823 | static int hdd_init_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6824 | { |
| 6825 | int ret; |
| 6826 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6827 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6828 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6829 | hdd_err("nl_srv_init failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6830 | goto out; |
| 6831 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6832 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6833 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 6834 | ret = hdd_activate_wifi_pos(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6835 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6836 | hdd_err("hdd_activate_wifi_pos failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6837 | goto err_nl_srv; |
| 6838 | } |
| 6839 | |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 6840 | ptt_sock_activate_svc(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6841 | |
| 6842 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 6843 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6844 | hdd_err("hdd_open_cesium_nl_sock failed ret: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6845 | |
| 6846 | ret = cnss_diag_activate_service(); |
| 6847 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6848 | hdd_err("cnss_diag_activate_service failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6849 | goto err_close_cesium; |
| 6850 | } |
| 6851 | |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 6852 | spectral_scan_activate_service(); |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 6853 | |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6854 | return 0; |
| 6855 | |
| 6856 | err_close_cesium: |
| 6857 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6858 | ptt_sock_deactivate_svc(); |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 6859 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6860 | err_nl_srv: |
| 6861 | nl_srv_exit(); |
| 6862 | out: |
| 6863 | return ret; |
| 6864 | } |
| 6865 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6866 | /** |
| 6867 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 6868 | * @hdd_ctx: HDD context. |
| 6869 | * |
| 6870 | * Destroy RX wakelock. |
| 6871 | * |
| 6872 | * Return: None. |
| 6873 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6874 | static void hdd_rx_wake_lock_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6875 | { |
| 6876 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 6877 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6878 | |
| 6879 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6880 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 6881 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6882 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6883 | * Create RX wakelock. |
| 6884 | * |
| 6885 | * Return: None. |
| 6886 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6887 | static void hdd_rx_wake_lock_create(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6888 | { |
| 6889 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 6890 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6891 | |
| 6892 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6893 | * hdd_context_deinit() - Deinitialize HDD context |
| 6894 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6895 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6896 | * Deinitialize HDD context along with all the feature specific contexts but |
| 6897 | * do not free hdd context itself. Caller of this API is supposed to free |
| 6898 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6899 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6900 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6901 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6902 | static int hdd_context_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6903 | { |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6904 | qdf_wake_lock_destroy(&hdd_ctx->monitor_mode_wakelock); |
| 6905 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6906 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6907 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6908 | hdd_sap_context_destroy(hdd_ctx); |
| 6909 | |
| 6910 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 6911 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6912 | hdd_scan_context_destroy(hdd_ctx); |
| 6913 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6914 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6915 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6916 | return 0; |
| 6917 | } |
| 6918 | |
| 6919 | /** |
| 6920 | * hdd_context_destroy() - Destroy HDD context |
| 6921 | * @hdd_ctx: HDD context to be destroyed. |
| 6922 | * |
| 6923 | * Free config and HDD context as well as destroy all the resources. |
| 6924 | * |
| 6925 | * Return: None |
| 6926 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6927 | static void hdd_context_destroy(struct hdd_context *hdd_ctx) |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6928 | { |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 6929 | cds_set_context(QDF_MODULE_ID_HDD, NULL); |
Arunk Khandavalli | 3d267b4 | 2017-05-02 18:58:59 +0530 | [diff] [blame] | 6930 | |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 6931 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 6932 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6933 | hdd_context_deinit(hdd_ctx); |
| 6934 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6935 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6936 | hdd_ctx->config = NULL; |
| 6937 | |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 6938 | cfg_release(); |
| 6939 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6940 | wiphy_free(hdd_ctx->wiphy); |
| 6941 | } |
| 6942 | |
| 6943 | /** |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 6944 | * wlan_destroy_bug_report_lock() - Destroy bug report lock |
| 6945 | * |
| 6946 | * This function is used to destroy bug report lock |
| 6947 | * |
| 6948 | * Return: None |
| 6949 | */ |
| 6950 | static void wlan_destroy_bug_report_lock(void) |
| 6951 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 6952 | struct cds_context *p_cds_context; |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 6953 | |
| 6954 | p_cds_context = cds_get_global_context(); |
| 6955 | if (!p_cds_context) { |
| 6956 | hdd_err("cds context is NULL"); |
| 6957 | return; |
| 6958 | } |
| 6959 | |
| 6960 | qdf_spinlock_destroy(&p_cds_context->bug_report_lock); |
| 6961 | } |
| 6962 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 6963 | #ifdef DISABLE_CHANNEL_LIST |
| 6964 | static void wlan_hdd_cache_chann_mutex_destroy(struct hdd_context *hdd_ctx) |
| 6965 | { |
| 6966 | qdf_mutex_destroy(&hdd_ctx->cache_channel_lock); |
| 6967 | } |
| 6968 | #else |
| 6969 | static void wlan_hdd_cache_chann_mutex_destroy(struct hdd_context *hdd_ctx) |
| 6970 | { |
| 6971 | } |
| 6972 | #endif |
| 6973 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 6974 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6975 | * hdd_wlan_exit() - HDD WLAN exit function |
| 6976 | * @hdd_ctx: Pointer to the HDD Context |
| 6977 | * |
| 6978 | * This is the driver exit point (invoked during rmmod) |
| 6979 | * |
| 6980 | * Return: None |
| 6981 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6982 | static void hdd_wlan_exit(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6983 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6984 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6985 | int driver_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6986 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6987 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6988 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6989 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6990 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6991 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6992 | if (QDF_TIMER_STATE_RUNNING == |
| 6993 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 6994 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6995 | } |
| 6996 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6997 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6998 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 6999 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7000 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7001 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 7002 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 7003 | hdd_ctx->last_acs_channel_list = NULL; |
| 7004 | hdd_ctx->num_of_channels = 0; |
| 7005 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7006 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7007 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7008 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 7009 | driver_status = hdd_ctx->driver_status; |
| 7010 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 7011 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7012 | /* |
| 7013 | * Powersave Offload Case |
| 7014 | * Disable Idle Power Save Mode |
| 7015 | */ |
| 7016 | hdd_set_idle_ps_config(hdd_ctx, false); |
Sandeep Puligilla | 8fa28fd | 2017-11-02 12:19:33 -0700 | [diff] [blame] | 7017 | /* clear the scan queue in all the scenarios */ |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 7018 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7019 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7020 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 7021 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 7022 | /* |
| 7023 | * Cancel any outstanding scan requests. We are about to close |
| 7024 | * all of our adapters, but an adapter structure is what SME |
| 7025 | * passes back to our callback function. Hence if there |
| 7026 | * are any outstanding scan requests then there is a |
| 7027 | * race condition between when the adapter is closed and |
| 7028 | * when the callback is invoked. We try to resolve that |
| 7029 | * race condition here by canceling any outstanding scans |
| 7030 | * before we close the adapters. |
| 7031 | * Note that the scans may be cancelled in an asynchronous |
| 7032 | * manner, so ideally there needs to be some kind of |
| 7033 | * synchronization. Rather than introduce a new |
| 7034 | * synchronization here, we will utilize the fact that we are |
| 7035 | * about to Request Full Power, and since that is synchronized, |
| 7036 | * the expectation is that by the time Request Full Power has |
| 7037 | * completed, all scans will be cancelled |
| 7038 | */ |
| 7039 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7040 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 7041 | hdd_stop_all_adapters(hdd_ctx); |
bings | 29c9986 | 2017-11-01 13:54:13 +0800 | [diff] [blame] | 7042 | hdd_deinit_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7043 | } |
| 7044 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 7045 | unregister_reboot_notifier(&system_reboot_notifier); |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 7046 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 7047 | |
Rachit Kankane | 3080733 | 2018-06-27 18:39:36 +0530 | [diff] [blame] | 7048 | qdf_dp_trace_deinit(); |
| 7049 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 7050 | hdd_wlan_stop_modules(hdd_ctx, false); |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 7051 | |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 7052 | hdd_bus_bandwidth_deinit(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 7053 | hdd_driver_memdump_deinit(); |
| 7054 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 7055 | qdf_nbuf_deinit_replenish_timer(); |
| 7056 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 7057 | if (QDF_GLOBAL_MONITOR_MODE == hdd_get_conparam()) { |
| 7058 | hdd_info("Release wakelock for monitor mode!"); |
| 7059 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 7060 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 7061 | } |
| 7062 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7063 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
| 7064 | qdf_spinlock_destroy(&hdd_ctx->sta_update_info_lock); |
| 7065 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7066 | wlan_hdd_cache_chann_mutex_destroy(hdd_ctx); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7067 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 7068 | osif_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7069 | |
Dustin Brown | d005ad8 | 2018-01-19 10:32:13 -0800 | [diff] [blame] | 7070 | hdd_close_all_adapters(hdd_ctx, false); |
| 7071 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 7072 | wlansap_global_deinit(); |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7073 | /* |
| 7074 | * If there is re_init failure wiphy would have already de-registered |
| 7075 | * check the wiphy status before un-registering again |
| 7076 | */ |
Ashish Kumar Dhanotiya | e16feb7 | 2017-03-31 19:39:37 +0530 | [diff] [blame] | 7077 | if (wiphy && wiphy->registered) { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7078 | wiphy_unregister(wiphy); |
| 7079 | wlan_hdd_cfg80211_deinit(wiphy); |
| 7080 | hdd_lpass_notify_stop(hdd_ctx); |
| 7081 | } |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 7082 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7083 | hdd_exit_netlink_services(hdd_ctx); |
| 7084 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 7085 | #ifdef FEATURE_WLAN_CH_AVOID |
| 7086 | mutex_destroy(&hdd_ctx->avoid_freq_lock); |
| 7087 | #endif |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 7088 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 7089 | driver_status = hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 7090 | if (driver_status) |
| 7091 | hdd_err("Psoc delete failed"); |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 7092 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7093 | hdd_context_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7094 | } |
| 7095 | |
| 7096 | void __hdd_wlan_exit(void) |
| 7097 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7098 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7099 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7100 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7101 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7102 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7103 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7104 | hdd_err("Invalid HDD Context"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7105 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7106 | return; |
| 7107 | } |
| 7108 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7109 | /* Do all the cleanup before deregistering the driver */ |
| 7110 | hdd_wlan_exit(hdd_ctx); |
Mohit Khanna | ebf8a86 | 2016-04-28 17:53:59 -0700 | [diff] [blame] | 7111 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7112 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7113 | } |
| 7114 | |
| 7115 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7116 | /** |
| 7117 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7118 | * @data: pointer to struct hdd_context |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7119 | * |
| 7120 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 7121 | * Then new ACS request will do a fresh scan without reusing the cached |
| 7122 | * scan information. |
| 7123 | * |
| 7124 | * Return: void |
| 7125 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 7126 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7127 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7128 | struct hdd_context *hdd_ctx = (struct hdd_context *) data; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7129 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7130 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7131 | hdd_debug("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7132 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7133 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 7134 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 7135 | hdd_ctx->last_acs_channel_list = NULL; |
| 7136 | hdd_ctx->num_of_channels = 0; |
| 7137 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7138 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7139 | mac_handle = hdd_ctx->mac_handle; |
| 7140 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7141 | return; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7142 | sme_scan_flush_result(mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7143 | } |
| 7144 | #endif |
| 7145 | |
| 7146 | #ifdef QCA_HT_2040_COEX |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 7147 | int hdd_wlan_set_ht2040_mode(struct hdd_adapter *adapter, uint16_t sta_id, |
| 7148 | struct qdf_mac_addr sta_mac, int channel_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7149 | { |
| 7150 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7151 | QDF_STATUS qdf_status; |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 7152 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7153 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7154 | |
| 7155 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7156 | |
| 7157 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7158 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7159 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7160 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7161 | mac_handle = hdd_ctx->mac_handle; |
| 7162 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7163 | return -EINVAL; |
| 7164 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7165 | qdf_status = sme_notify_ht2040_mode(mac_handle, sta_id, sta_mac, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7166 | adapter->session_id, channel_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7167 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7168 | hdd_err("Fail to send notification with ht2040 mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7169 | return -EINVAL; |
| 7170 | } |
| 7171 | |
| 7172 | return 0; |
| 7173 | } |
| 7174 | #endif |
| 7175 | |
| 7176 | /** |
| 7177 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 7178 | * @state: state |
| 7179 | * |
| 7180 | * This function notifies FW with modem power status |
| 7181 | * |
| 7182 | * Return: 0 if successful, error number otherwise |
| 7183 | */ |
| 7184 | int hdd_wlan_notify_modem_power_state(int state) |
| 7185 | { |
| 7186 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7187 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7188 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7189 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7190 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7191 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7192 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7193 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7194 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7195 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7196 | mac_handle = hdd_ctx->mac_handle; |
| 7197 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7198 | return -EINVAL; |
| 7199 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7200 | qdf_status = sme_notify_modem_power_state(mac_handle, state); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7201 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7202 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7203 | state); |
| 7204 | return -EINVAL; |
| 7205 | } |
| 7206 | return 0; |
| 7207 | } |
| 7208 | |
| 7209 | /** |
| 7210 | * |
| 7211 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 7212 | * @adapter - Pointer to the HDD |
| 7213 | * |
| 7214 | * Return: None |
| 7215 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7216 | QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7217 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7218 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7219 | |
| 7220 | /* |
| 7221 | * Send ready indication to the HDD. This will kick off the MAC |
| 7222 | * into a 'running' state and should kick off an initial scan. |
| 7223 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7224 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->mac_handle); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7225 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7226 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 7227 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7228 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7229 | } |
| 7230 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7231 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7232 | } |
| 7233 | |
Sourav Mohapatra | 92ea8d6 | 2018-02-05 10:03:10 +0530 | [diff] [blame] | 7234 | struct hdd_adapter *hdd_get_first_valid_adapter(struct hdd_context *hdd_ctx) |
| 7235 | { |
| 7236 | struct hdd_adapter *adapter; |
| 7237 | |
| 7238 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 7239 | if (adapter && adapter->magic == WLAN_HDD_ADAPTER_MAGIC) |
| 7240 | return adapter; |
| 7241 | } |
| 7242 | |
| 7243 | return NULL; |
| 7244 | } |
| 7245 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7246 | /* wake lock APIs for HDD */ |
| 7247 | void hdd_prevent_suspend(uint32_t reason) |
| 7248 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 7249 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7250 | } |
| 7251 | |
| 7252 | void hdd_allow_suspend(uint32_t reason) |
| 7253 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 7254 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7255 | } |
| 7256 | |
| 7257 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 7258 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 7259 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 7260 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7261 | } |
| 7262 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7263 | /* Initialize channel list in sme based on the country code */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7264 | QDF_STATUS hdd_set_sme_chan_list(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7265 | { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7266 | return sme_init_chan_list(hdd_ctx->mac_handle, |
Amar Singhal | 6f8592b | 2017-04-26 14:31:58 -0700 | [diff] [blame] | 7267 | hdd_ctx->reg.alpha2, |
| 7268 | hdd_ctx->reg.cc_src); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7269 | } |
| 7270 | |
| 7271 | /** |
| 7272 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 7273 | * @hdd_ctx: Pointer to the hdd context |
| 7274 | * |
| 7275 | * HDD function to know if hardware supports 5GHz |
| 7276 | * |
| 7277 | * Return: true if hardware supports 5GHz |
| 7278 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7279 | bool hdd_is_5g_supported(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7280 | { |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 7281 | if (!hdd_ctx) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7282 | return true; |
| 7283 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 7284 | if (hdd_ctx->curr_band != BAND_2G) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7285 | return true; |
| 7286 | else |
| 7287 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7288 | } |
| 7289 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7290 | static int hdd_wiphy_init(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7291 | { |
| 7292 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7293 | int ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7294 | |
| 7295 | wiphy = hdd_ctx->wiphy; |
| 7296 | |
| 7297 | /* |
| 7298 | * The channel information in |
| 7299 | * wiphy needs to be initialized before wiphy registration |
| 7300 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7301 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 7302 | if (ret_val) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7303 | hdd_err("regulatory init failed"); |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7304 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7305 | } |
| 7306 | |
| 7307 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 7308 | wiphy->wowlan = &wowlan_support_reg_init; |
| 7309 | #else |
| 7310 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 7311 | WIPHY_WOWLAN_MAGIC_PKT | |
| 7312 | WIPHY_WOWLAN_DISCONNECT | |
| 7313 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 7314 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 7315 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 7316 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 7317 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 7318 | |
| 7319 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 7320 | WOW_MAX_FILTERS_PER_LIST); |
| 7321 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 7322 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 7323 | #endif |
Liangwei Dong | 0da1426 | 2018-07-03 03:30:23 -0400 | [diff] [blame] | 7324 | if (hdd_ctx->obss_scan_offload) { |
| 7325 | hdd_debug("wmi_service_obss_scan supported"); |
| 7326 | } else if (hdd_ctx->config->nChannelBondingMode24GHz) { |
| 7327 | hdd_debug("enable wpa_supp obss_scan"); |
| 7328 | wiphy->features |= NL80211_FEATURE_NEED_OBSS_SCAN; |
| 7329 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7330 | |
| 7331 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7332 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7333 | if (0 > ret_val) { |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7334 | hdd_err("wiphy registration failed"); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7335 | return ret_val; |
| 7336 | } |
Amar Singhal | ac26de2 | 2018-06-22 12:53:06 -0700 | [diff] [blame] | 7337 | |
Kiran Kumar Lokere | 0508af9 | 2018-04-23 18:38:32 -0700 | [diff] [blame] | 7338 | /* Check the kernel version for upstream commit aced43ce780dc5 that |
| 7339 | * has support for processing user cell_base hints when wiphy is |
| 7340 | * self managed or check the backport flag for the same. |
| 7341 | */ |
Amar Singhal | ac26de2 | 2018-06-22 12:53:06 -0700 | [diff] [blame] | 7342 | #if defined CFG80211_USER_HINT_CELL_BASE_SELF_MANAGED || \ |
| 7343 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)) |
Kiran Kumar Lokere | 0508af9 | 2018-04-23 18:38:32 -0700 | [diff] [blame] | 7344 | hdd_send_wiphy_regd_sync_event(hdd_ctx); |
| 7345 | #endif |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7346 | |
Amar Singhal | 2d81201 | 2018-02-03 15:06:47 +0800 | [diff] [blame] | 7347 | pld_increment_driver_load_cnt(hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7348 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7349 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7350 | } |
| 7351 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7352 | #ifdef MSM_PLATFORM |
| 7353 | /** |
| 7354 | * hdd_display_periodic_stats() - Function to display periodic stats |
| 7355 | * @hdd_ctx - handle to hdd context |
| 7356 | * @bool data_in_interval - true, if data detected in bw time interval |
| 7357 | * |
| 7358 | * The periodicity is determined by hdd_ctx->config->periodic_stats_disp_time. |
| 7359 | * Stats show up in wlan driver logs. |
| 7360 | * |
| 7361 | * Returns: None |
| 7362 | */ |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7363 | static void hdd_display_periodic_stats(struct hdd_context *hdd_ctx, |
| 7364 | bool data_in_interval) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7365 | { |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7366 | static uint32_t counter; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7367 | static bool data_in_time_period; |
| 7368 | ol_txrx_pdev_handle pdev; |
| 7369 | |
| 7370 | if (hdd_ctx->config->periodic_stats_disp_time == 0) |
| 7371 | return; |
| 7372 | |
| 7373 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 7374 | if (!pdev) { |
| 7375 | hdd_err("pdev is NULL"); |
| 7376 | return; |
| 7377 | } |
| 7378 | |
| 7379 | counter++; |
| 7380 | if (data_in_interval) |
| 7381 | data_in_time_period = data_in_interval; |
| 7382 | |
| 7383 | if (counter * hdd_ctx->config->busBandwidthComputeInterval >= |
| 7384 | hdd_ctx->config->periodic_stats_disp_time * 1000) { |
| 7385 | if (data_in_time_period) { |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7386 | wlan_hdd_display_txrx_stats(hdd_ctx); |
| 7387 | dp_txrx_dump_stats(cds_get_context(QDF_MODULE_ID_SOC)); |
| 7388 | cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC), |
| 7389 | CDP_RX_RING_STATS, |
| 7390 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7391 | cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC), |
| 7392 | CDP_TXRX_PATH_STATS, |
| 7393 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7394 | wlan_hdd_display_netif_queue_history |
| 7395 | (hdd_ctx, QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7396 | qdf_dp_trace_dump_stats(); |
| 7397 | } |
| 7398 | counter = 0; |
| 7399 | data_in_time_period = false; |
| 7400 | } |
| 7401 | } |
| 7402 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7403 | /** |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7404 | * hdd_clear_rps_cpu_mask - clear RPS CPU mask for interfaces |
| 7405 | * @hdd_ctx: pointer to struct hdd_context |
| 7406 | * |
| 7407 | * Return: none |
| 7408 | */ |
| 7409 | static void hdd_clear_rps_cpu_mask(struct hdd_context *hdd_ctx) |
| 7410 | { |
| 7411 | struct hdd_adapter *adapter; |
| 7412 | |
| 7413 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 7414 | hdd_send_rps_disable_ind(adapter); |
| 7415 | } |
| 7416 | |
| 7417 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7418 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7419 | * @hdd_ctx - handle to hdd context |
| 7420 | * @tx_packets - transmit packet count |
| 7421 | * @rx_packets - receive packet count |
| 7422 | * |
| 7423 | * The function controls the bus bandwidth and dynamic control of |
| 7424 | * tcp delayed ack configuration |
| 7425 | * |
| 7426 | * Returns: None |
| 7427 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7428 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7429 | static void hdd_pld_request_bus_bandwidth(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 7430 | const uint64_t tx_packets, |
| 7431 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7432 | { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7433 | u64 total_pkts = tx_packets + rx_packets; |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7434 | uint64_t temp_tx = 0, avg_rx = 0; |
| 7435 | uint64_t no_rx_offload_pkts = 0, avg_no_rx_offload_pkts = 0; |
| 7436 | uint64_t rx_offload_pkts = 0, avg_rx_offload_pkts = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7437 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7438 | static enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7439 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7440 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7441 | uint16_t index = 0; |
| 7442 | bool vote_level_change = false; |
| 7443 | bool rx_level_change = false; |
| 7444 | bool tx_level_change = false; |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7445 | bool rxthread_high_tput_req = false; |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7446 | bool dptrace_high_tput_req; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7447 | if (total_pkts > hdd_ctx->config->busBandwidthHighThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7448 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7449 | else if (total_pkts > hdd_ctx->config->busBandwidthMediumThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7450 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7451 | else if (total_pkts > hdd_ctx->config->busBandwidthLowThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7452 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 7453 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7454 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7455 | |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7456 | dptrace_high_tput_req = |
| 7457 | next_vote_level > PLD_BUS_WIDTH_NONE ? true : false; |
| 7458 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7459 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7460 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 7461 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7462 | hdd_ctx->cur_vote_level = next_vote_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7463 | vote_level_change = true; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7464 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7465 | if ((next_vote_level == PLD_BUS_WIDTH_LOW) || |
| 7466 | (next_vote_level == PLD_BUS_WIDTH_NONE)) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7467 | if (hdd_ctx->hbw_requested) { |
| 7468 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 7469 | hdd_ctx->hbw_requested = false; |
| 7470 | } |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7471 | if (hdd_ctx->dynamic_rps) |
| 7472 | hdd_clear_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7473 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7474 | if (!hdd_ctx->hbw_requested) { |
| 7475 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 7476 | hdd_ctx->hbw_requested = true; |
| 7477 | } |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7478 | if (hdd_ctx->dynamic_rps) |
| 7479 | hdd_set_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7480 | } |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7481 | |
Manjunathappa Prakash | cb6df76 | 2018-05-29 18:54:58 -0700 | [diff] [blame] | 7482 | if (hdd_ctx->config->napi_cpu_affinity_mask) |
| 7483 | hdd_napi_apply_throughput_policy(hdd_ctx, |
| 7484 | tx_packets, |
| 7485 | rx_packets); |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7486 | |
| 7487 | if (rx_packets < hdd_ctx->config->busBandwidthLowThreshold) |
| 7488 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, true); |
| 7489 | else |
| 7490 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7491 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7492 | |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7493 | qdf_dp_trace_apply_tput_policy(dptrace_high_tput_req); |
| 7494 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7495 | /* |
| 7496 | * Includes tcp+udp, if perf core is required for tcp, then |
| 7497 | * perf core is also required for udp. |
| 7498 | */ |
| 7499 | no_rx_offload_pkts = hdd_ctx->no_rx_offload_pkt_cnt; |
| 7500 | hdd_ctx->no_rx_offload_pkt_cnt = 0; |
| 7501 | rx_offload_pkts = rx_packets - no_rx_offload_pkts; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7502 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7503 | avg_no_rx_offload_pkts = (no_rx_offload_pkts + |
| 7504 | hdd_ctx->prev_no_rx_offload_pkts) / 2; |
| 7505 | hdd_ctx->prev_no_rx_offload_pkts = no_rx_offload_pkts; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 7506 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7507 | avg_rx_offload_pkts = (rx_offload_pkts + |
| 7508 | hdd_ctx->prev_rx_offload_pkts) / 2; |
| 7509 | hdd_ctx->prev_rx_offload_pkts = rx_offload_pkts; |
| 7510 | |
| 7511 | avg_rx = avg_no_rx_offload_pkts + avg_rx_offload_pkts; |
| 7512 | /* |
| 7513 | * Takes care to set Rx_thread affinity for below case |
| 7514 | * 1)LRO/GRO not supported ROME case |
| 7515 | * 2)when rx_ol is disabled in cases like concurrency etc |
| 7516 | * 3)For UDP cases |
| 7517 | */ |
| 7518 | if (avg_no_rx_offload_pkts > |
| 7519 | hdd_ctx->config->busBandwidthHighThreshold) |
| 7520 | rxthread_high_tput_req = true; |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7521 | else |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7522 | rxthread_high_tput_req = false; |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7523 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7524 | if (cds_sched_handle_throughput_req(rxthread_high_tput_req)) |
| 7525 | hdd_warn("Rx thread high_tput(%d) affinity request failed", |
| 7526 | rxthread_high_tput_req); |
| 7527 | |
| 7528 | /* fine-tuning parameters for RX Flows */ |
| 7529 | if (avg_rx > hdd_ctx->config->tcpDelackThresholdHigh) { |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 7530 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 7531 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 7532 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 7533 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7534 | } else { |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7535 | hdd_ctx->rx_high_ind_cnt = 0; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7536 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7537 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7538 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7539 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7540 | struct wlan_rx_tp_data rx_tp_data = {0}; |
| 7541 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7542 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Jeff Johnson | b9feee4 | 2018-07-08 10:34:48 -0700 | [diff] [blame] | 7543 | next_rx_level, avg_rx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7544 | hdd_ctx->cur_rx_level = next_rx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7545 | rx_level_change = true; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7546 | /* Send throughput indication only if it is enabled. |
| 7547 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 7548 | * to default delayed ack. Note that this will disable the |
| 7549 | * dynamic delayed ack mechanism across the system |
| 7550 | */ |
Manjunathappa Prakash | bfd1276 | 2018-04-29 22:44:52 -0700 | [diff] [blame] | 7551 | if (hdd_ctx->en_tcp_delack_no_lro) |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7552 | rx_tp_data.rx_tp_flags |= TCP_DEL_ACK_IND; |
| 7553 | |
Mohit Khanna | 6272fb68 | 2017-04-13 09:34:36 -0700 | [diff] [blame] | 7554 | if (hdd_ctx->config->enable_tcp_adv_win_scale) |
| 7555 | rx_tp_data.rx_tp_flags |= TCP_ADV_WIN_SCL; |
| 7556 | |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7557 | rx_tp_data.level = next_rx_level; |
| 7558 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7559 | WLAN_SVC_WLAN_TP_IND, &rx_tp_data, |
| 7560 | sizeof(rx_tp_data)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7561 | } |
| 7562 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7563 | /* fine-tuning parameters for TX Flows */ |
| 7564 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 7565 | hdd_ctx->prev_tx = tx_packets; |
| 7566 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 7567 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 7568 | else |
| 7569 | next_tx_level = WLAN_SVC_TP_LOW; |
| 7570 | |
Prakash Manjunathappa | e73e3b5 | 2018-02-27 18:56:22 -0800 | [diff] [blame] | 7571 | if ((hdd_ctx->config->enable_tcp_limit_output) && |
| 7572 | (hdd_ctx->cur_tx_level != next_tx_level)) { |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7573 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 7574 | next_tx_level, temp_tx); |
| 7575 | hdd_ctx->cur_tx_level = next_tx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7576 | tx_level_change = true; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 7577 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7578 | WLAN_SVC_WLAN_TP_TX_IND, |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7579 | &next_tx_level, |
| 7580 | sizeof(next_tx_level)); |
| 7581 | } |
| 7582 | |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7583 | index = hdd_ctx->hdd_txrx_hist_idx; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7584 | if (vote_level_change || tx_level_change || rx_level_change) { |
| 7585 | hdd_ctx->hdd_txrx_hist[index].next_tx_level = next_tx_level; |
| 7586 | hdd_ctx->hdd_txrx_hist[index].next_rx_level = next_rx_level; |
| 7587 | hdd_ctx->hdd_txrx_hist[index].next_vote_level = next_vote_level; |
| 7588 | hdd_ctx->hdd_txrx_hist[index].interval_rx = rx_packets; |
| 7589 | hdd_ctx->hdd_txrx_hist[index].interval_tx = tx_packets; |
| 7590 | hdd_ctx->hdd_txrx_hist[index].qtime = qdf_get_log_timestamp(); |
| 7591 | hdd_ctx->hdd_txrx_hist_idx++; |
| 7592 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
| 7593 | } |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7594 | |
| 7595 | hdd_display_periodic_stats(hdd_ctx, (total_pkts > 0) ? true : false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7596 | } |
| 7597 | |
| 7598 | #define HDD_BW_GET_DIFF(_x, _y) (unsigned long)((ULONG_MAX - (_y)) + (_x) + 1) |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7599 | static void hdd_bus_bw_work_handler(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7600 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7601 | struct hdd_context *hdd_ctx = container_of(work, struct hdd_context, |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7602 | bus_bw_work); |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7603 | struct hdd_adapter *adapter = NULL, *con_sap_adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7604 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 7605 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 7606 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7607 | uint64_t total_tx = 0, total_rx = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7608 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7609 | bool connected = false; |
| 7610 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 7611 | |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 7612 | hdd_enter(); |
| 7613 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7614 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7615 | return; |
| 7616 | |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 7617 | if (hdd_ctx->is_wiphy_suspended) |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7618 | goto restart_timer; |
| 7619 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7620 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 7621 | /* |
| 7622 | * Validate magic so we don't end up accessing |
| 7623 | * an invalid adapter. |
| 7624 | */ |
| 7625 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 7626 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7627 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7628 | if ((adapter->device_mode == QDF_STA_MODE || |
| 7629 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7630 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.connState |
| 7631 | != eConnectionState_Associated) { |
| 7632 | |
| 7633 | continue; |
| 7634 | } |
| 7635 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7636 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 7637 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 7638 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active == false) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7639 | |
| 7640 | continue; |
| 7641 | } |
| 7642 | |
| 7643 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 7644 | adapter->prev_tx_packets); |
| 7645 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 7646 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7647 | |
| 7648 | if (adapter->device_mode == QDF_SAP_MODE || |
| 7649 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 7650 | adapter->device_mode == QDF_IBSS_MODE) { |
| 7651 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 7652 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 7653 | cds_get_context(QDF_MODULE_ID_SOC), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7654 | adapter->session_id, |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7655 | &fwd_tx_packets, &fwd_rx_packets); |
| 7656 | if (ret == A_OK) { |
| 7657 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 7658 | fwd_tx_packets, |
| 7659 | adapter->prev_fwd_tx_packets); |
| 7660 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 7661 | fwd_tx_packets, |
| 7662 | adapter->prev_fwd_rx_packets); |
| 7663 | } |
| 7664 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7665 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7666 | if (adapter->device_mode == QDF_SAP_MODE) |
| 7667 | con_sap_adapter = adapter; |
| 7668 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7669 | total_rx += adapter->stats.rx_packets; |
| 7670 | total_tx += adapter->stats.tx_packets; |
| 7671 | |
| 7672 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 7673 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 7674 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7675 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 7676 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7677 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 7678 | connected = true; |
| 7679 | } |
| 7680 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7681 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7682 | hdd_err("bus bandwidth timer running in disconnected state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7683 | return; |
| 7684 | } |
| 7685 | |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7686 | /* add intra bss forwarded tx and rx packets */ |
| 7687 | tx_packets += fwd_tx_packets_diff; |
| 7688 | rx_packets += fwd_rx_packets_diff; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7689 | |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7690 | if (ucfg_ipa_is_fw_wdi_activated(hdd_ctx->hdd_pdev)) { |
| 7691 | ucfg_ipa_uc_stat_query(hdd_ctx->hdd_pdev, &ipa_tx_packets, |
| 7692 | &ipa_rx_packets); |
| 7693 | tx_packets += (uint64_t)ipa_tx_packets; |
| 7694 | rx_packets += (uint64_t)ipa_rx_packets; |
| 7695 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7696 | if (con_sap_adapter) { |
| 7697 | con_sap_adapter->stats.tx_packets += ipa_tx_packets; |
| 7698 | con_sap_adapter->stats.rx_packets += ipa_rx_packets; |
| 7699 | } |
| 7700 | |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7701 | ucfg_ipa_set_perf_level(hdd_ctx->hdd_pdev, tx_packets, rx_packets); |
| 7702 | ucfg_ipa_uc_stat_request(hdd_ctx->hdd_pdev, 2); |
| 7703 | } |
| 7704 | |
| 7705 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7706 | |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7707 | restart_timer: |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 7708 | /* ensure periodic timer should still be running before restarting it */ |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7709 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 7710 | if (hdd_ctx->bus_bw_timer_running) |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 7711 | qdf_timer_mod(&hdd_ctx->bus_bw_timer, |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7712 | hdd_ctx->config->busBandwidthComputeInterval); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7713 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 7714 | |
| 7715 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7716 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7717 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7718 | /** |
| 7719 | * __hdd_bus_bw_cbk() - Bus bandwidth data structure callback. |
| 7720 | * @arg: Argument of timer function |
| 7721 | * |
| 7722 | * Schedule a workqueue in this function where all the processing is done. |
| 7723 | * |
| 7724 | * Return: None. |
| 7725 | */ |
| 7726 | static void __hdd_bus_bw_cbk(void *arg) |
| 7727 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7728 | struct hdd_context *hdd_ctx = (struct hdd_context *) arg; |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7729 | |
| 7730 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7731 | return; |
| 7732 | |
| 7733 | schedule_work(&hdd_ctx->bus_bw_work); |
| 7734 | } |
| 7735 | |
| 7736 | /** |
| 7737 | * hdd_bus_bw_cbk() - Wrapper for bus bw callback for SSR protection. |
| 7738 | * @arg: Argument of timer function |
| 7739 | * |
| 7740 | * Return: None. |
| 7741 | */ |
| 7742 | static void hdd_bus_bw_cbk(void *arg) |
| 7743 | { |
| 7744 | cds_ssr_protect(__func__); |
| 7745 | __hdd_bus_bw_cbk(arg); |
| 7746 | cds_ssr_unprotect(__func__); |
| 7747 | } |
| 7748 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7749 | int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7750 | { |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 7751 | hdd_enter(); |
| 7752 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7753 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 7754 | INIT_WORK(&hdd_ctx->bus_bw_work, hdd_bus_bw_work_handler); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7755 | hdd_ctx->bus_bw_timer_running = false; |
| 7756 | qdf_spinlock_create(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 7757 | qdf_timer_init(NULL, &hdd_ctx->bus_bw_timer, hdd_bus_bw_cbk, |
| 7758 | (void *)hdd_ctx, QDF_TIMER_TYPE_SW); |
| 7759 | |
| 7760 | hdd_exit(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7761 | |
| 7762 | return 0; |
| 7763 | } |
| 7764 | |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 7765 | void hdd_bus_bandwidth_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7766 | { |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 7767 | hdd_enter(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7768 | |
Rajeev Kumar | c27efb6 | 2018-08-31 14:21:22 -0700 | [diff] [blame] | 7769 | QDF_BUG(!hdd_ctx->bus_bw_timer_running); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 7770 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7771 | qdf_timer_free(&hdd_ctx->bus_bw_timer); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7772 | qdf_spinlock_destroy(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 7773 | |
| 7774 | hdd_exit(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7775 | } |
Lin Bai | c5c0688 | 2017-09-21 13:58:43 +0800 | [diff] [blame] | 7776 | |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 7777 | #endif /* MSM_PLATFORM */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7778 | |
| 7779 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7780 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 7781 | * @hdd_ctx: hdd context |
| 7782 | * |
| 7783 | * Return: 0 for success or error code |
| 7784 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7785 | 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] | 7786 | { |
| 7787 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 7788 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
| 7789 | if (hdd_ctx->hdd_txrx_hist == NULL) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7790 | hdd_err("Failed malloc for hdd_txrx_hist"); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7791 | return -ENOMEM; |
| 7792 | } |
| 7793 | return 0; |
| 7794 | } |
| 7795 | |
| 7796 | /** |
| 7797 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 7798 | * @hdd_ctx: hdd context |
| 7799 | * |
| 7800 | * Return: none |
| 7801 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7802 | void wlan_hdd_deinit_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7803 | { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7804 | if (!hdd_ctx || hdd_ctx->hdd_txrx_hist == NULL) |
| 7805 | return; |
| 7806 | |
| 7807 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 7808 | hdd_ctx->hdd_txrx_hist = NULL; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7809 | } |
| 7810 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7811 | static uint8_t *convert_level_to_string(uint32_t level) |
| 7812 | { |
| 7813 | switch (level) { |
| 7814 | /* initialize the wlan sub system */ |
| 7815 | case WLAN_SVC_TP_NONE: |
| 7816 | return "NONE"; |
| 7817 | case WLAN_SVC_TP_LOW: |
| 7818 | return "LOW"; |
| 7819 | case WLAN_SVC_TP_MEDIUM: |
| 7820 | return "MED"; |
| 7821 | case WLAN_SVC_TP_HIGH: |
| 7822 | return "HIGH"; |
| 7823 | default: |
| 7824 | return "INVAL"; |
| 7825 | } |
| 7826 | } |
| 7827 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7828 | |
| 7829 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7830 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 7831 | * @hdd_ctx: hdd context |
| 7832 | * |
| 7833 | * Return: none |
| 7834 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7835 | void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7836 | { |
| 7837 | int i; |
| 7838 | |
| 7839 | #ifdef MSM_PLATFORM |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 7840 | hdd_nofl_info("BW compute Interval: %dms", |
| 7841 | hdd_ctx->config->busBandwidthComputeInterval); |
| 7842 | hdd_nofl_info("BW High TH: %d BW Med TH: %d BW Low TH: %d", |
| 7843 | hdd_ctx->config->busBandwidthHighThreshold, |
| 7844 | hdd_ctx->config->busBandwidthMediumThreshold, |
| 7845 | hdd_ctx->config->busBandwidthLowThreshold); |
| 7846 | hdd_nofl_info("Enable TCP DEL ACK: %d", |
| 7847 | hdd_ctx->en_tcp_delack_no_lro); |
| 7848 | hdd_nofl_info("TCP DEL High TH: %d TCP DEL Low TH: %d", |
| 7849 | hdd_ctx->config->tcpDelackThresholdHigh, |
| 7850 | hdd_ctx->config->tcpDelackThresholdLow); |
| 7851 | hdd_nofl_info("TCP TX HIGH TP TH: %d (Use to set tcp_output_bytes_limit)", |
| 7852 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7853 | #endif |
| 7854 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 7855 | hdd_nofl_info("Total entries: %d Current index: %d", |
| 7856 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7857 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 7858 | 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] | 7859 | |
| 7860 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7861 | /* using hdd_log to avoid printing function name */ |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7862 | if (hdd_ctx->hdd_txrx_hist[i].qtime > 0) |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 7863 | hdd_nofl_info("[%3d][%15llu]: %6llu, %6llu, %s, %s, %s", |
| 7864 | i, hdd_ctx->hdd_txrx_hist[i].qtime, |
| 7865 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
| 7866 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
| 7867 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7868 | hdd_ctx->hdd_txrx_hist[i]. |
| 7869 | next_vote_level), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 7870 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7871 | hdd_ctx->hdd_txrx_hist[i]. |
| 7872 | next_rx_level), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 7873 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7874 | hdd_ctx->hdd_txrx_hist[i]. |
| 7875 | next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7876 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7877 | } |
| 7878 | |
| 7879 | /** |
| 7880 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 7881 | * @hdd_ctx: hdd context |
| 7882 | * |
| 7883 | * Return: none |
| 7884 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7885 | void wlan_hdd_clear_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7886 | { |
| 7887 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7888 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 7889 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7890 | } |
| 7891 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7892 | /* length of the netif queue log needed per adapter */ |
| 7893 | #define ADAP_NETIFQ_LOG_LEN ((20 * WLAN_REASON_TYPE_MAX) + 50) |
| 7894 | |
| 7895 | /** |
| 7896 | * |
| 7897 | * hdd_display_netif_queue_history_compact() - display compact netifq history |
| 7898 | * @hdd_ctx: hdd context |
| 7899 | * |
| 7900 | * Return: none |
| 7901 | */ |
| 7902 | static void |
| 7903 | hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx) |
| 7904 | { |
| 7905 | int adapter_num = 0; |
| 7906 | int i; |
| 7907 | int bytes_written; |
| 7908 | u32 tbytes; |
| 7909 | qdf_time_t total, pause, unpause, curr_time, delta; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7910 | char temp_str[20 * WLAN_REASON_TYPE_MAX]; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7911 | char *comb_log_str; |
| 7912 | uint32_t comb_log_str_size; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7913 | struct hdd_adapter *adapter = NULL; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7914 | |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 7915 | comb_log_str_size = (ADAP_NETIFQ_LOG_LEN * CSR_ROAM_SESSION_MAX) + 1; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7916 | comb_log_str = qdf_mem_malloc(comb_log_str_size); |
| 7917 | if (!comb_log_str) { |
| 7918 | hdd_err("failed to alloc comb_log_str"); |
| 7919 | return; |
| 7920 | } |
| 7921 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7922 | bytes_written = 0; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7923 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7924 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7925 | curr_time = qdf_system_ticks(); |
| 7926 | total = curr_time - adapter->start_time; |
| 7927 | delta = curr_time - adapter->last_time; |
| 7928 | |
| 7929 | if (adapter->pause_map) { |
| 7930 | pause = adapter->total_pause_time + delta; |
| 7931 | unpause = adapter->total_unpause_time; |
| 7932 | } else { |
| 7933 | unpause = adapter->total_unpause_time + delta; |
| 7934 | pause = adapter->total_pause_time; |
| 7935 | } |
| 7936 | |
| 7937 | tbytes = 0; |
| 7938 | qdf_mem_set(temp_str, 0, sizeof(temp_str)); |
| 7939 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7940 | if (adapter->queue_oper_stats[i].pause_count == 0) |
| 7941 | continue; |
| 7942 | tbytes += |
| 7943 | snprintf( |
| 7944 | &temp_str[tbytes], |
| 7945 | (tbytes >= sizeof(temp_str) ? |
| 7946 | 0 : sizeof(temp_str) - tbytes), |
| 7947 | "%d(%d,%d) ", |
| 7948 | i, |
| 7949 | adapter->queue_oper_stats[i]. |
| 7950 | pause_count, |
| 7951 | adapter->queue_oper_stats[i]. |
| 7952 | unpause_count); |
| 7953 | } |
| 7954 | if (tbytes >= sizeof(temp_str)) |
| 7955 | hdd_warn("log truncated"); |
| 7956 | |
| 7957 | bytes_written += snprintf(&comb_log_str[bytes_written], |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7958 | bytes_written >= comb_log_str_size ? 0 : |
| 7959 | comb_log_str_size - bytes_written, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7960 | "[%d %d] (%d) %u/%ums %s|", |
| 7961 | adapter->session_id, adapter->device_mode, |
| 7962 | adapter->pause_map, |
| 7963 | qdf_system_ticks_to_msecs(pause), |
| 7964 | qdf_system_ticks_to_msecs(total), |
| 7965 | temp_str); |
| 7966 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7967 | adapter_num++; |
| 7968 | } |
| 7969 | |
| 7970 | /* using QDF_TRACE to avoid printing function name */ |
| 7971 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO_LOW, |
| 7972 | "STATS |%s", comb_log_str); |
| 7973 | |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7974 | if (bytes_written >= comb_log_str_size) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7975 | hdd_warn("log string truncated"); |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7976 | |
| 7977 | qdf_mem_free(comb_log_str); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7978 | } |
| 7979 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7980 | /** |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7981 | * wlan_hdd_display_netif_queue_history() - display netif queue history |
Jeff Johnson | 58adbcf | 2017-09-03 08:53:31 -0700 | [diff] [blame] | 7982 | * @hdd_ctx: hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7983 | * |
| 7984 | * Return: none |
| 7985 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7986 | void |
| 7987 | wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx, |
| 7988 | enum qdf_stats_verbosity_level verb_lvl) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7989 | { |
| 7990 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7991 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7992 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7993 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7994 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7995 | if (verb_lvl == QDF_STATS_VERBOSITY_LEVEL_LOW) { |
| 7996 | hdd_display_netif_queue_history_compact(hdd_ctx); |
| 7997 | return; |
| 7998 | } |
| 7999 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8000 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8001 | hdd_nofl_info("Netif queue operation statistics:"); |
| 8002 | hdd_nofl_info("Session_id %d device mode %d", |
| 8003 | adapter->session_id, adapter->device_mode); |
| 8004 | hdd_nofl_info("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8005 | curr_time = qdf_system_ticks(); |
| 8006 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8007 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8008 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8009 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8010 | unpause = adapter->total_unpause_time; |
| 8011 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8012 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8013 | pause = adapter->total_pause_time; |
| 8014 | } |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8015 | hdd_nofl_info("Total: %ums Pause: %ums Unpause: %ums", |
| 8016 | qdf_system_ticks_to_msecs(total), |
| 8017 | qdf_system_ticks_to_msecs(pause), |
| 8018 | qdf_system_ticks_to_msecs(unpause)); |
| 8019 | hdd_nofl_info("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8020 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8021 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 8022 | qdf_time_t pause_delta = 0; |
| 8023 | |
| 8024 | if (adapter->pause_map & (1 << i)) |
| 8025 | pause_delta = delta; |
| 8026 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8027 | /* using hdd_log to avoid printing function name */ |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8028 | hdd_nofl_info("%s: %d: %d: %ums", |
| 8029 | hdd_reason_type_to_string(i), |
| 8030 | adapter->queue_oper_stats[i].pause_count, |
| 8031 | adapter->queue_oper_stats[i]. |
| 8032 | unpause_count, |
| 8033 | qdf_system_ticks_to_msecs( |
| 8034 | adapter->queue_oper_stats[i]. |
| 8035 | total_pause_time + pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8036 | } |
| 8037 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8038 | hdd_nofl_info("Netif queue operation history:"); |
| 8039 | hdd_nofl_info("Total entries: %d current index %d", |
| 8040 | WLAN_HDD_MAX_HISTORY_ENTRY, |
| 8041 | adapter->history_index); |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8042 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8043 | hdd_nofl_info("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8044 | |
| 8045 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8046 | /* using hdd_log to avoid printing function name */ |
| 8047 | if (adapter->queue_oper_history[i].time == 0) |
| 8048 | continue; |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8049 | hdd_nofl_info("%d: %u: %s: %s: %x", |
| 8050 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8051 | adapter->queue_oper_history[i].time), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8052 | hdd_action_type_to_string( |
| 8053 | adapter->queue_oper_history[i]. |
| 8054 | netif_action), |
| 8055 | hdd_reason_type_to_string( |
| 8056 | adapter->queue_oper_history[i]. |
| 8057 | netif_reason), |
| 8058 | adapter->queue_oper_history[i].pause_map); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8059 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8060 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8061 | } |
| 8062 | |
| 8063 | /** |
| 8064 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 8065 | * @hdd_ctx: hdd context |
| 8066 | * |
| 8067 | * Return: none |
| 8068 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8069 | void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8070 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8071 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8072 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8073 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8074 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8075 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8076 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8077 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8078 | adapter->history_index = 0; |
| 8079 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 8080 | adapter->total_pause_time = 0; |
| 8081 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8082 | } |
| 8083 | } |
| 8084 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8085 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 8086 | /** |
| 8087 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 8088 | * @hdd_ctx: hdd global context |
| 8089 | * |
| 8090 | * Return: none |
| 8091 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8092 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8093 | { |
| 8094 | uint8_t i; |
| 8095 | |
| 8096 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 8097 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 8098 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 8099 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 8100 | } |
| 8101 | } |
| 8102 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8103 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8104 | { |
| 8105 | } |
| 8106 | #endif |
| 8107 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8108 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 8109 | /** |
| 8110 | * 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] | 8111 | * @phddctx: struct hdd_context structure pointer |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8112 | * @enable: enable or disable this behaviour |
| 8113 | * |
| 8114 | * Return: int |
| 8115 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8116 | 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] | 8117 | { |
| 8118 | struct hdd_config *pcfg_ini = phddctx->config; |
| 8119 | struct wow_pulse_mode wow_pulse_set_info; |
| 8120 | QDF_STATUS status; |
| 8121 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8122 | hdd_debug("wow pulse enable flag is %d", enable); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8123 | |
| 8124 | if (false == phddctx->config->wow_pulse_support) |
| 8125 | return 0; |
| 8126 | |
| 8127 | /* prepare the request to send to SME */ |
| 8128 | if (enable == true) { |
| 8129 | wow_pulse_set_info.wow_pulse_enable = true; |
| 8130 | wow_pulse_set_info.wow_pulse_pin = |
| 8131 | pcfg_ini->wow_pulse_pin; |
| 8132 | wow_pulse_set_info.wow_pulse_interval_low = |
| 8133 | pcfg_ini->wow_pulse_interval_low; |
| 8134 | wow_pulse_set_info.wow_pulse_interval_high = |
| 8135 | pcfg_ini->wow_pulse_interval_high; |
| 8136 | } else { |
| 8137 | wow_pulse_set_info.wow_pulse_enable = false; |
| 8138 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 8139 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 8140 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 8141 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8142 | hdd_debug("enable %d pin %d low %d high %d", |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8143 | wow_pulse_set_info.wow_pulse_enable, |
| 8144 | wow_pulse_set_info.wow_pulse_pin, |
| 8145 | wow_pulse_set_info.wow_pulse_interval_low, |
| 8146 | wow_pulse_set_info.wow_pulse_interval_high); |
| 8147 | |
| 8148 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 8149 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8150 | hdd_debug("sme_set_wow_pulse failure!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8151 | return -EIO; |
| 8152 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8153 | hdd_debug("sme_set_wow_pulse success!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8154 | return 0; |
| 8155 | } |
| 8156 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8157 | 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] | 8158 | { |
| 8159 | return 0; |
| 8160 | } |
| 8161 | #endif |
| 8162 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8163 | #ifdef WLAN_FEATURE_FASTPATH |
| 8164 | /** |
| 8165 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 8166 | * @hdd_cfg: hdd config |
| 8167 | * @context: lower layer context |
| 8168 | * |
| 8169 | * Return: none |
| 8170 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8171 | void hdd_enable_fastpath(struct hdd_config *hdd_cfg, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8172 | void *context) |
| 8173 | { |
| 8174 | if (hdd_cfg->fastpath_enable) |
| 8175 | hif_enable_fastpath(context); |
| 8176 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8177 | #endif |
| 8178 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8179 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8180 | /** |
| 8181 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8182 | * @hdd_handle: opaque handle for the hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8183 | * @level: thermal level |
| 8184 | * |
| 8185 | * Change IPA data path to SW path when the thermal throttle level greater |
| 8186 | * than 0, and restore the original data path when throttle level is 0 |
| 8187 | * |
| 8188 | * Return: none |
| 8189 | */ |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8190 | 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] | 8191 | { |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8192 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8193 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8194 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 8195 | if (level > THROTTLE_LEVEL_0) |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 8196 | ucfg_ipa_send_mcc_scc_msg(hdd_ctx->hdd_pdev, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8197 | else |
| 8198 | /* restore original concurrency mode */ |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 8199 | ucfg_ipa_send_mcc_scc_msg(hdd_ctx->hdd_pdev, hdd_ctx->mcc_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8200 | } |
| 8201 | |
| 8202 | /** |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8203 | * hdd_get_safe_channel() - Get safe channel from current regulatory |
| 8204 | * @hdd_ctx: pointer to hdd context |
| 8205 | * @adapter: pointer to softap adapter |
| 8206 | * |
| 8207 | * This function is used to get safe channel from current regulatory valid |
| 8208 | * channels to restart SAP if failed to get safe channel from PCL. |
| 8209 | * |
| 8210 | * Return: Channel number to restart SAP in case of success. In case of any |
| 8211 | * failure, the channel number returned is zero. |
| 8212 | */ |
| 8213 | static uint8_t |
| 8214 | hdd_get_safe_channel(struct hdd_context *hdd_ctx, |
| 8215 | struct hdd_adapter *adapter) |
| 8216 | { |
| 8217 | struct sir_pcl_list pcl = {0}; |
| 8218 | uint32_t i, j; |
| 8219 | bool found = false; |
| 8220 | int ret; |
| 8221 | |
| 8222 | /* Try for safe channel from all valid channel */ |
| 8223 | pcl.pcl_len = MAX_NUM_CHAN; |
| 8224 | ret = hdd_get_valid_chan(hdd_ctx, pcl.pcl_list, |
| 8225 | &pcl.pcl_len); |
| 8226 | if (ret) { |
| 8227 | hdd_err("error %d in getting valid channel list", ret); |
| 8228 | return INVALID_CHANNEL_ID; |
| 8229 | } |
| 8230 | |
| 8231 | for (i = 0; i < pcl.pcl_len; i++) { |
| 8232 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
| 8233 | found = false; |
| 8234 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
| 8235 | if (pcl.pcl_list[i] == |
| 8236 | hdd_ctx->unsafe_channel_list[j]) { |
| 8237 | hdd_debug("unsafe chan:%d", pcl.pcl_list[i]); |
| 8238 | found = true; |
| 8239 | break; |
| 8240 | } |
| 8241 | } |
| 8242 | |
| 8243 | if (found) |
| 8244 | continue; |
| 8245 | |
| 8246 | if ((pcl.pcl_list[i] >= |
| 8247 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
| 8248 | (pcl.pcl_list[i] <= |
| 8249 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
| 8250 | hdd_debug("found safe chan:%d", pcl.pcl_list[i]); |
| 8251 | return pcl.pcl_list[i]; |
| 8252 | } |
| 8253 | } |
| 8254 | |
| 8255 | return INVALID_CHANNEL_ID; |
| 8256 | } |
| 8257 | |
| 8258 | #else |
| 8259 | /** |
| 8260 | * hdd_set_thermal_level_cb() - set thermal level callback function |
| 8261 | * @hdd_handle: opaque handle for the hdd context |
| 8262 | * @level: thermal level |
| 8263 | * |
| 8264 | * Change IPA data path to SW path when the thermal throttle level greater |
| 8265 | * than 0, and restore the original data path when throttle level is 0 |
| 8266 | * |
| 8267 | * Return: none |
| 8268 | */ |
| 8269 | static void hdd_set_thermal_level_cb(hdd_handle_t hdd_handle, u_int8_t level) |
| 8270 | { |
| 8271 | } |
| 8272 | |
| 8273 | /** |
| 8274 | * hdd_get_safe_channel() - Get safe channel from current regulatory |
| 8275 | * @hdd_ctx: pointer to hdd context |
| 8276 | * @adapter: pointer to softap adapter |
| 8277 | * |
| 8278 | * This function is used to get safe channel from current regulatory valid |
| 8279 | * channels to restart SAP if failed to get safe channel from PCL. |
| 8280 | * |
| 8281 | * Return: Channel number to restart SAP in case of success. In case of any |
| 8282 | * failure, the channel number returned is zero. |
| 8283 | */ |
| 8284 | static uint8_t |
| 8285 | hdd_get_safe_channel(struct hdd_context *hdd_ctx, |
| 8286 | struct hdd_adapter *adapter) |
| 8287 | { |
| 8288 | return 0; |
| 8289 | } |
| 8290 | #endif |
| 8291 | |
| 8292 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8293 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 8294 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 8295 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8296 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8297 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 8298 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 8299 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8300 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8301 | * Return: Channel number to restart SAP in case of success. In case of any |
| 8302 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8303 | */ |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8304 | static uint8_t |
| 8305 | 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] | 8306 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8307 | struct sir_pcl_list pcl; |
| 8308 | QDF_STATUS status; |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8309 | uint32_t i; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8310 | mac_handle_t mac_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8311 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8312 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8313 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8314 | if (!hdd_ctx) { |
| 8315 | hdd_err("invalid HDD context"); |
| 8316 | return INVALID_CHANNEL_ID; |
| 8317 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8318 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8319 | mac_handle = hdd_ctx->mac_handle; |
| 8320 | if (!mac_handle) { |
| 8321 | hdd_err("invalid MAC handle"); |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 8322 | return INVALID_CHANNEL_ID; |
| 8323 | } |
| 8324 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8325 | status = policy_mgr_get_pcl_for_existing_conn(hdd_ctx->hdd_psoc, |
| 8326 | PM_SAP_MODE, pcl.pcl_list, &pcl.pcl_len, |
bings | 37bd58f | 2017-07-20 16:49:26 +0800 | [diff] [blame] | 8327 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list), |
| 8328 | false); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8329 | if (QDF_IS_STATUS_ERROR(status)) { |
| 8330 | hdd_err("Get PCL failed"); |
| 8331 | return INVALID_CHANNEL_ID; |
| 8332 | } |
| 8333 | |
Frank Liu | dc2cefb | 2017-06-21 15:38:18 +0800 | [diff] [blame] | 8334 | /* |
| 8335 | * In some scenarios, like hw dbs disabled, sap+sap case, if operating |
| 8336 | * channel is unsafe channel, the pcl may be empty, instead of return, |
| 8337 | * try to choose a safe channel from acs range. |
| 8338 | */ |
| 8339 | if (!pcl.pcl_len) |
| 8340 | hdd_debug("pcl length is zero!"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8341 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8342 | hdd_debug("start:%d end:%d", |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8343 | adapter->session.ap.sap_config.acs_cfg.start_ch, |
| 8344 | adapter->session.ap.sap_config.acs_cfg.end_ch); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8345 | |
| 8346 | /* PCL already takes unsafe channel into account */ |
| 8347 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8348 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8349 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8350 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8351 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8352 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8353 | hdd_debug("found PCL safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8354 | return pcl.pcl_list[i]; |
| 8355 | } |
| 8356 | } |
| 8357 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8358 | hdd_debug("no safe channel from PCL found in ACS range"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8359 | |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8360 | return hdd_get_safe_channel(hdd_ctx, adapter); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8361 | } |
| 8362 | |
| 8363 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8364 | * hdd_switch_sap_channel() - Move SAP to the given channel |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8365 | * @adapter: AP adapter |
| 8366 | * @channel: Channel |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8367 | * @forced: Force to switch channel, ignore SCC/MCC check |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8368 | * |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8369 | * Moves the SAP interface by invoking the function which |
| 8370 | * executes the callback to perform channel switch using (E)CSA. |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8371 | * |
| 8372 | * Return: None |
| 8373 | */ |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8374 | void hdd_switch_sap_channel(struct hdd_adapter *adapter, uint8_t channel, |
| 8375 | bool forced) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8376 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 8377 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8378 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8379 | mac_handle_t mac_handle; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8380 | |
| 8381 | if (!adapter) { |
| 8382 | hdd_err("invalid adapter"); |
| 8383 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8384 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8385 | |
| 8386 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 8387 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8388 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 8389 | if (!mac_handle) { |
| 8390 | hdd_err("invalid MAC handle"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8391 | return; |
| 8392 | } |
| 8393 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8394 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8395 | |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 8396 | hdd_ap_ctx->sap_config.channel = channel; |
Himanshu Agarwal | f5c5b10 | 2018-05-22 20:13:57 +0530 | [diff] [blame] | 8397 | hdd_ap_ctx->sap_config.ch_params.ch_width = CH_WIDTH_MAX; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8398 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8399 | hdd_debug("chan:%d width:%d", |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 8400 | channel, hdd_ap_ctx->sap_config.ch_width_orig); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8401 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 8402 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 8403 | hdd_ap_ctx->sap_config.channel, |
| 8404 | hdd_ap_ctx->sap_config.sec_ch, |
| 8405 | &hdd_ap_ctx->sap_config.ch_params); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8406 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8407 | policy_mgr_change_sap_channel_with_csa(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 8408 | adapter->session_id, channel, |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8409 | hdd_ap_ctx->sap_config.ch_width_orig, forced); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8410 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8411 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8412 | 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] | 8413 | { |
| 8414 | struct hdd_external_acs_timer_context *timer_context; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8415 | int status; |
| 8416 | QDF_STATUS qdf_status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8417 | |
| 8418 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 8419 | |
| 8420 | if (QDF_TIMER_STATE_RUNNING == |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8421 | qdf_mc_timer_get_current_state(&adapter->session. |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8422 | ap.vendor_acs_timer)) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8423 | qdf_mc_timer_stop(&adapter->session.ap.vendor_acs_timer); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8424 | } |
| 8425 | timer_context = (struct hdd_external_acs_timer_context *) |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8426 | adapter->session.ap.vendor_acs_timer.user_data; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8427 | timer_context->reason = reason; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8428 | qdf_status = |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8429 | qdf_mc_timer_start(&adapter->session.ap.vendor_acs_timer, |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8430 | WLAN_VENDOR_ACS_WAIT_TIME); |
| 8431 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 8432 | hdd_err("failed to start external acs timer"); |
| 8433 | return -ENOSPC; |
| 8434 | } |
| 8435 | /* Update config to application */ |
| 8436 | status = hdd_cfg80211_update_acs_config(adapter, reason); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 8437 | hdd_info("Updated ACS config to nl with reason %d", reason); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8438 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8439 | return status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8440 | } |
| 8441 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8442 | #if defined(FEATURE_WLAN_CH_AVOID) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8443 | /** |
| 8444 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 8445 | * @hdd_ctx: hdd context pointer |
| 8446 | * |
| 8447 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 8448 | * and if ACS is enabled, driver will ask userspace to restart the |
| 8449 | * sap. User space on LTE coex indication restart driver. |
| 8450 | * |
| 8451 | * Return - none |
| 8452 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8453 | void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8454 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8455 | struct hdd_adapter *adapter; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8456 | uint32_t i; |
| 8457 | bool found = false; |
| 8458 | uint8_t restart_chan; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8459 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8460 | hdd_for_each_adapter(hdd_ctxt, adapter) { |
| 8461 | if (!(adapter->device_mode == QDF_SAP_MODE && |
| 8462 | adapter->session.ap.sap_config.acs_cfg.acs_mode)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8463 | hdd_debug("skip device mode:%d acs:%d", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8464 | adapter->device_mode, |
| 8465 | adapter->session.ap.sap_config. |
| 8466 | acs_cfg.acs_mode); |
| 8467 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8468 | } |
| 8469 | |
| 8470 | found = false; |
Tushnim Bhattacharyya | d2e085d | 2018-06-18 11:58:50 -0700 | [diff] [blame] | 8471 | /* |
| 8472 | * If STA+SAP is doing SCC & g_sta_sap_scc_on_lte_coex_chan |
| 8473 | * is set, no need to move SAP. |
| 8474 | */ |
| 8475 | if (policy_mgr_is_sta_sap_scc(hdd_ctxt->hdd_psoc, |
| 8476 | adapter->session.ap.operating_channel) && |
| 8477 | hdd_ctxt->config->sta_sap_scc_on_lte_coex_chan) |
| 8478 | hdd_debug("SAP is allowed on SCC channel, no need to move SAP"); |
| 8479 | else { |
| 8480 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
| 8481 | if (adapter->session.ap.operating_channel == |
| 8482 | hdd_ctxt->unsafe_channel_list[i]) { |
| 8483 | found = true; |
| 8484 | hdd_debug("operating ch:%d is unsafe", |
| 8485 | adapter->session.ap.operating_channel); |
| 8486 | break; |
| 8487 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8488 | } |
| 8489 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8490 | if (!found) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8491 | hdd_debug("ch:%d is safe. no need to change channel", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8492 | adapter->session.ap.operating_channel); |
| 8493 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8494 | } |
| 8495 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8496 | if (hdd_ctxt->config->vendor_acs_support && |
| 8497 | hdd_ctxt->config->acs_support_for_dfs_ltecoex) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8498 | hdd_update_acs_timer_reason(adapter, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8499 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8500 | continue; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8501 | } else |
| 8502 | restart_chan = |
| 8503 | hdd_get_safe_channel_from_pcl_and_acs_range( |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8504 | adapter); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8505 | if (!restart_chan) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8506 | hdd_err("fail to restart SAP"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8507 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8508 | /* |
| 8509 | * SAP restart due to unsafe channel. While |
| 8510 | * restarting the SAP, make sure to clear |
| 8511 | * acs_channel, channel to reset to |
| 8512 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8513 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8514 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8515 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8516 | hdd_debug("sending coex indication"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8517 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 8518 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 8519 | hdd_debug("driver to start sap: %d", |
| 8520 | hdd_ctxt->config->sap_internal_restart); |
| 8521 | if (hdd_ctxt->config->sap_internal_restart) |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8522 | hdd_switch_sap_channel(adapter, restart_chan, |
| 8523 | true); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 8524 | else |
| 8525 | return; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8526 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8527 | } |
| 8528 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 8529 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8530 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8531 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 8532 | * @hdd_ctx: HDD global context |
| 8533 | * |
| 8534 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8535 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8536 | * down to the lower layers. Then subscribe to subsequent channel |
| 8537 | * avoidance events. |
| 8538 | * |
| 8539 | * Return: None |
| 8540 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8541 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8542 | { |
| 8543 | uint16_t unsafe_channel_count; |
| 8544 | int index; |
| 8545 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8546 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 8547 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8548 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8549 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8550 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8551 | hdd_debug("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8552 | hdd_ctx->unsafe_channel_count); |
| 8553 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8554 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8555 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8556 | |
| 8557 | for (index = 0; index < unsafe_channel_count; index++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8558 | hdd_debug("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8559 | hdd_ctx->unsafe_channel_list[index]); |
| 8560 | |
| 8561 | } |
| 8562 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8563 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8564 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8565 | static void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8566 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8567 | { |
| 8568 | uint8_t restart_chan; |
| 8569 | |
| 8570 | restart_chan = hdd_get_safe_channel_from_pcl_and_acs_range(adapter); |
| 8571 | if (!restart_chan) { |
| 8572 | hdd_alert("fail to restart SAP"); |
| 8573 | return; |
| 8574 | } |
| 8575 | |
| 8576 | /* SAP restart due to unsafe channel. While restarting |
| 8577 | * the SAP, make sure to clear acs_channel, channel to |
| 8578 | * reset to 0. Otherwise these settings will override |
| 8579 | * the ACS while restart. |
| 8580 | */ |
| 8581 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8582 | |
| 8583 | hdd_debug("sending coex indication"); |
| 8584 | |
| 8585 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 8586 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8587 | hdd_switch_sap_channel(adapter, restart_chan, true); |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8588 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8589 | |
| 8590 | int hdd_clone_local_unsafe_chan(struct hdd_context *hdd_ctx, |
| 8591 | uint16_t **local_unsafe_list, uint16_t *local_unsafe_list_count) |
| 8592 | { |
| 8593 | uint32_t size; |
| 8594 | uint16_t *unsafe_list; |
| 8595 | uint16_t chan_count; |
| 8596 | |
| 8597 | if (!hdd_ctx || !local_unsafe_list_count || !local_unsafe_list_count) |
| 8598 | return -EINVAL; |
| 8599 | |
| 8600 | chan_count = QDF_MIN(hdd_ctx->unsafe_channel_count, |
| 8601 | NUM_CHANNELS); |
| 8602 | if (chan_count) { |
| 8603 | size = chan_count * sizeof(hdd_ctx->unsafe_channel_list[0]); |
| 8604 | unsafe_list = qdf_mem_malloc(size); |
| 8605 | if (!unsafe_list) { |
| 8606 | hdd_err("No memory for unsafe chan list size%d", |
| 8607 | size); |
| 8608 | return -ENOMEM; |
| 8609 | } |
| 8610 | qdf_mem_copy(unsafe_list, hdd_ctx->unsafe_channel_list, size); |
| 8611 | } else { |
| 8612 | unsafe_list = NULL; |
| 8613 | } |
| 8614 | |
| 8615 | *local_unsafe_list = unsafe_list; |
| 8616 | *local_unsafe_list_count = chan_count; |
| 8617 | |
| 8618 | return 0; |
| 8619 | } |
| 8620 | |
| 8621 | bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx, |
| 8622 | uint16_t *local_unsafe_list, uint16_t local_unsafe_list_count) |
| 8623 | { |
| 8624 | int i, j; |
| 8625 | |
| 8626 | if (local_unsafe_list_count != hdd_ctx->unsafe_channel_count) |
| 8627 | return true; |
| 8628 | if (local_unsafe_list_count == 0) |
| 8629 | return false; |
| 8630 | for (i = 0; i < local_unsafe_list_count; i++) { |
| 8631 | for (j = 0; j < local_unsafe_list_count; j++) |
| 8632 | if (local_unsafe_list[i] == |
| 8633 | hdd_ctx->unsafe_channel_list[j]) |
| 8634 | break; |
| 8635 | if (j >= local_unsafe_list_count) |
| 8636 | break; |
| 8637 | } |
| 8638 | if (i >= local_unsafe_list_count) { |
| 8639 | hdd_info("unsafe chan list same"); |
| 8640 | return false; |
| 8641 | } |
| 8642 | |
| 8643 | return true; |
| 8644 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8645 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8646 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8647 | { |
| 8648 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8649 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8650 | static inline void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8651 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8652 | { |
| 8653 | hdd_debug("Channel avoidance is not enabled; Abort SAP restart"); |
| 8654 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8655 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8656 | |
| 8657 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8658 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 8659 | * user space |
| 8660 | * @frame_ind: Management frame data to be informed. |
| 8661 | * |
| 8662 | * This function is used to indicate management frame to |
| 8663 | * user space |
| 8664 | * |
| 8665 | * Return: None |
| 8666 | * |
| 8667 | */ |
| 8668 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 8669 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8670 | struct hdd_context *hdd_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8671 | struct hdd_adapter *adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8672 | int i; |
Pragaspathi Thilagaraj | 28ffc04 | 2018-07-18 15:19:36 +0530 | [diff] [blame] | 8673 | struct ieee80211_mgmt *mgmt = |
| 8674 | (struct ieee80211_mgmt *)frame_ind->frameBuf; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8675 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 8676 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 8677 | if (wlan_hdd_validate_context(hdd_ctx)) |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8678 | return; |
| 8679 | |
Pragaspathi Thilagaraj | 28ffc04 | 2018-07-18 15:19:36 +0530 | [diff] [blame] | 8680 | if (frame_ind->frame_len < ieee80211_hdrlen(mgmt->frame_control)) { |
| 8681 | hdd_err(" Invalid frame length"); |
| 8682 | return; |
| 8683 | } |
| 8684 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8685 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
| 8686 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 8687 | adapter = |
| 8688 | hdd_get_adapter_by_sme_session_id(hdd_ctx, i); |
| 8689 | if (adapter) |
| 8690 | break; |
| 8691 | } |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 8692 | } else if (SME_SESSION_ID_BROADCAST == frame_ind->sessionId) { |
| 8693 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 8694 | if ((NULL != adapter) && |
| 8695 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) { |
| 8696 | __hdd_indicate_mgmt_frame(adapter, |
| 8697 | frame_ind->frame_len, |
| 8698 | frame_ind->frameBuf, |
| 8699 | frame_ind->frameType, |
| 8700 | frame_ind->rxChan, |
| 8701 | frame_ind->rxRssi); |
| 8702 | } |
| 8703 | } |
| 8704 | adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8705 | } else { |
| 8706 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 8707 | frame_ind->sessionId); |
| 8708 | } |
| 8709 | |
| 8710 | if ((NULL != adapter) && |
| 8711 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 8712 | __hdd_indicate_mgmt_frame(adapter, |
| 8713 | frame_ind->frame_len, |
| 8714 | frame_ind->frameBuf, |
| 8715 | frame_ind->frameType, |
| 8716 | frame_ind->rxChan, |
| 8717 | frame_ind->rxRssi); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8718 | } |
| 8719 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8720 | void hdd_acs_response_timeout_handler(void *context) |
| 8721 | { |
| 8722 | struct hdd_external_acs_timer_context *timer_context = |
| 8723 | (struct hdd_external_acs_timer_context *)context; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8724 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8725 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8726 | uint8_t reason; |
| 8727 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8728 | hdd_enter(); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8729 | if (!timer_context) { |
| 8730 | hdd_err("invlaid timer context"); |
| 8731 | return; |
| 8732 | } |
| 8733 | adapter = timer_context->adapter; |
| 8734 | reason = timer_context->reason; |
| 8735 | |
| 8736 | |
| 8737 | if ((!adapter) || |
| 8738 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 8739 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 8740 | return; |
| 8741 | } |
| 8742 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8743 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 8744 | return; |
| 8745 | |
| 8746 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 8747 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 8748 | else |
| 8749 | return; |
| 8750 | |
| 8751 | hdd_err("ACS timeout happened for %s reason %d", |
| 8752 | adapter->dev->name, reason); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8753 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8754 | switch (reason) { |
| 8755 | /* SAP init case */ |
| 8756 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 8757 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 8758 | false); |
| 8759 | wlan_hdd_cfg80211_start_acs(adapter); |
| 8760 | break; |
| 8761 | /* DFS detected on current channel */ |
| 8762 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 8763 | wlan_sap_update_next_channel( |
| 8764 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8765 | sme_update_new_channel_event(hdd_ctx->mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 8766 | adapter->session_id); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8767 | break; |
| 8768 | /* LTE coex event on current channel */ |
| 8769 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 8770 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 8771 | break; |
| 8772 | default: |
| 8773 | hdd_info("invalid reason for timer invoke"); |
| 8774 | |
| 8775 | } |
| 8776 | } |
| 8777 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8778 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8779 | * hdd_override_ini_config - Override INI config |
| 8780 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8781 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8782 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8783 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8784 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8785 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8786 | static void hdd_override_ini_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8787 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8788 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8789 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
| 8790 | hdd_ctx->config->enableDFSChnlScan = enable_dfs_chan_scan; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8791 | hdd_debug("Module enable_dfs_chan_scan set to %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8792 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8793 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8794 | if (0 == enable_11d || 1 == enable_11d) { |
| 8795 | hdd_ctx->config->Is11dSupportEnabled = enable_11d; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8796 | hdd_debug("Module enable_11d set to %d", enable_11d); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8797 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 8798 | |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 8799 | if (!ucfg_ipa_is_present()) { |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 8800 | hdd_ctx->config->IpaConfig = 0; |
Jingxiang Ge | 7a040dc | 2018-02-02 11:07:59 +0800 | [diff] [blame] | 8801 | hdd_debug("IpaConfig override to %d", |
| 8802 | hdd_ctx->config->IpaConfig); |
| 8803 | } |
Yeshwanth Sriram Guntuka | 2ba6fe9 | 2017-10-04 14:40:45 +0530 | [diff] [blame] | 8804 | |
| 8805 | if (!hdd_ctx->config->rssi_assoc_reject_enabled || |
| 8806 | !hdd_ctx->config->enable_bcast_probe_rsp) { |
| 8807 | hdd_debug("OCE disabled, rssi_assoc_reject_enabled: %d enable_bcast_probe_rsp: %d", |
| 8808 | hdd_ctx->config->rssi_assoc_reject_enabled, |
| 8809 | hdd_ctx->config->enable_bcast_probe_rsp); |
| 8810 | hdd_ctx->config->oce_sta_enabled = 0; |
| 8811 | } |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 8812 | |
| 8813 | if (hdd_ctx->config->action_oui_enable && !ucfg_action_oui_enabled()) { |
| 8814 | hdd_ctx->config->action_oui_enable = 0; |
| 8815 | hdd_err("Ignore ini: %s, since no action_oui component", |
| 8816 | CFG_ENABLE_ACTION_OUI); |
| 8817 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8818 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8819 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8820 | /** |
| 8821 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 8822 | * @hdd_ctx - HDD context |
| 8823 | * |
| 8824 | * Set trace level for each module based on INI config. |
| 8825 | * |
| 8826 | * Return: None |
| 8827 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8828 | 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] | 8829 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 8830 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMI, |
| 8831 | hdd_ctx->config->qdf_trace_enable_wdi); |
| 8832 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD, |
| 8833 | hdd_ctx->config->qdf_trace_enable_hdd); |
| 8834 | hdd_qdf_trace_enable(QDF_MODULE_ID_SME, |
| 8835 | hdd_ctx->config->qdf_trace_enable_sme); |
| 8836 | hdd_qdf_trace_enable(QDF_MODULE_ID_PE, |
| 8837 | hdd_ctx->config->qdf_trace_enable_pe); |
| 8838 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMA, |
| 8839 | hdd_ctx->config->qdf_trace_enable_wma); |
| 8840 | hdd_qdf_trace_enable(QDF_MODULE_ID_SYS, |
| 8841 | hdd_ctx->config->qdf_trace_enable_sys); |
| 8842 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF, |
| 8843 | hdd_ctx->config->qdf_trace_enable_qdf); |
| 8844 | hdd_qdf_trace_enable(QDF_MODULE_ID_SAP, |
| 8845 | hdd_ctx->config->qdf_trace_enable_sap); |
| 8846 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SOFTAP, |
| 8847 | hdd_ctx->config->qdf_trace_enable_hdd_sap); |
| 8848 | hdd_qdf_trace_enable(QDF_MODULE_ID_BMI, |
| 8849 | hdd_ctx->config->qdf_trace_enable_bmi); |
| 8850 | hdd_qdf_trace_enable(QDF_MODULE_ID_CFG, |
| 8851 | hdd_ctx->config->qdf_trace_enable_cfg); |
| 8852 | hdd_qdf_trace_enable(QDF_MODULE_ID_EPPING, |
| 8853 | hdd_ctx->config->qdf_trace_enable_epping); |
| 8854 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF_DEVICE, |
| 8855 | hdd_ctx->config->qdf_trace_enable_qdf_devices); |
| 8856 | hdd_qdf_trace_enable(QDF_MODULE_ID_TXRX, |
Houston Hoffman | fbf0510 | 2017-08-28 11:37:01 -0700 | [diff] [blame] | 8857 | hdd_ctx->config->qdf_trace_enable_txrx); |
| 8858 | hdd_qdf_trace_enable(QDF_MODULE_ID_DP, |
| 8859 | hdd_ctx->config->qdf_trace_enable_dp); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 8860 | hdd_qdf_trace_enable(QDF_MODULE_ID_HTC, |
| 8861 | hdd_ctx->config->qdf_trace_enable_htc); |
| 8862 | hdd_qdf_trace_enable(QDF_MODULE_ID_HIF, |
| 8863 | hdd_ctx->config->qdf_trace_enable_hif); |
| 8864 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SAP_DATA, |
| 8865 | hdd_ctx->config->qdf_trace_enable_hdd_sap_data); |
| 8866 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_DATA, |
| 8867 | hdd_ctx->config->qdf_trace_enable_hdd_data); |
Naveen Rawat | 7df3186 | 2017-03-01 17:09:30 -0800 | [diff] [blame] | 8868 | hdd_qdf_trace_enable(QDF_MODULE_ID_WIFIPOS, |
| 8869 | hdd_ctx->config->qdf_trace_enable_wifi_pos); |
Naveen Rawat | f2b0dbd | 2017-03-27 10:00:15 -0700 | [diff] [blame] | 8870 | hdd_qdf_trace_enable(QDF_MODULE_ID_NAN, |
| 8871 | hdd_ctx->config->qdf_trace_enable_nan); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 8872 | hdd_qdf_trace_enable(QDF_MODULE_ID_REGULATORY, |
| 8873 | hdd_ctx->config->qdf_trace_enable_regulatory); |
Naveen Rawat | 3cb779e | 2018-02-16 16:36:10 -0800 | [diff] [blame] | 8874 | hdd_qdf_trace_enable(QDF_MODULE_ID_CP_STATS, |
| 8875 | hdd_ctx->config->qdf_trace_enable_cp_stats); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 8876 | hdd_qdf_trace_enable(QDF_MODULE_ID_MLME, 0xffff); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 8877 | |
Nirav Shah | 5c083da | 2018-08-03 13:46:02 +0530 | [diff] [blame] | 8878 | hdd_cfg_print_global_config(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8879 | } |
| 8880 | |
| 8881 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8882 | * hdd_context_init() - Initialize HDD context |
| 8883 | * @hdd_ctx: HDD context. |
| 8884 | * |
| 8885 | * Initialize HDD context along with all the feature specific contexts. |
| 8886 | * |
| 8887 | * return: 0 on success and errno on failure. |
| 8888 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8889 | static int hdd_context_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8890 | { |
| 8891 | int ret; |
| 8892 | |
| 8893 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 8894 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 8895 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8896 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 8897 | init_completion(&hdd_ctx->ready_to_suspend); |
| 8898 | |
| 8899 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8900 | qdf_spinlock_create(&hdd_ctx->sta_update_info_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8901 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8902 | |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 8903 | qdf_list_create(&hdd_ctx->hdd_adapters, 0); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8904 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8905 | ret = hdd_scan_context_init(hdd_ctx); |
| 8906 | if (ret) |
| 8907 | goto list_destroy; |
| 8908 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8909 | hdd_rx_wake_lock_create(hdd_ctx); |
| 8910 | |
| 8911 | ret = hdd_sap_context_init(hdd_ctx); |
| 8912 | if (ret) |
| 8913 | goto scan_destroy; |
| 8914 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8915 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 8916 | |
| 8917 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 8918 | |
| 8919 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 8920 | hdd_ctx->config); |
| 8921 | if (ret) |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 8922 | goto sap_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8923 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 8924 | qdf_wake_lock_create(&hdd_ctx->monitor_mode_wakelock, |
| 8925 | "monitor_mode_wakelock"); |
| 8926 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8927 | return 0; |
| 8928 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8929 | sap_destroy: |
| 8930 | hdd_sap_context_destroy(hdd_ctx); |
| 8931 | |
| 8932 | scan_destroy: |
| 8933 | hdd_scan_context_destroy(hdd_ctx); |
| 8934 | hdd_rx_wake_lock_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8935 | list_destroy: |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8936 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 8937 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8938 | return ret; |
| 8939 | } |
| 8940 | |
| 8941 | /** |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8942 | * ie_whitelist_attrs_init() - initialize ie whitelisting attributes |
| 8943 | * @hdd_ctx: pointer to hdd context |
| 8944 | * |
| 8945 | * Return: status of initialization |
| 8946 | * 0 - success |
| 8947 | * negative value - failure |
| 8948 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8949 | static int ie_whitelist_attrs_init(struct hdd_context *hdd_ctx) |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8950 | { |
| 8951 | int ret; |
| 8952 | |
| 8953 | if (!hdd_ctx->config->probe_req_ie_whitelist) |
| 8954 | return 0; |
| 8955 | |
| 8956 | if (!hdd_validate_prb_req_ie_bitmap(hdd_ctx)) { |
| 8957 | hdd_err("invalid ie bitmap and ouis: disable ie whitelisting"); |
| 8958 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8959 | return -EINVAL; |
| 8960 | } |
| 8961 | |
| 8962 | /* parse ini string probe req oui */ |
| 8963 | ret = hdd_parse_probe_req_ouis(hdd_ctx); |
| 8964 | if (ret) { |
| 8965 | hdd_err("parsing error: disable ie whitelisting"); |
| 8966 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8967 | } |
| 8968 | |
| 8969 | return ret; |
| 8970 | } |
| 8971 | |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8972 | /** |
| 8973 | * hdd_iface_change_callback() - Function invoked when stop modules expires |
| 8974 | * @priv: pointer to hdd context |
| 8975 | * |
| 8976 | * This function is invoked when the timer waiting for the interface change |
| 8977 | * expires, it shall cut-down the power to wlan and stop all the modules. |
| 8978 | * |
| 8979 | * Return: void |
| 8980 | */ |
| 8981 | static void hdd_iface_change_callback(void *priv) |
| 8982 | { |
| 8983 | struct hdd_context *hdd_ctx = (struct hdd_context *) priv; |
| 8984 | int ret; |
| 8985 | int status = wlan_hdd_validate_context(hdd_ctx); |
| 8986 | |
| 8987 | if (status) |
| 8988 | return; |
| 8989 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8990 | hdd_enter(); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8991 | hdd_debug("Interface change timer expired close the modules!"); |
| 8992 | ret = hdd_wlan_stop_modules(hdd_ctx, false); |
| 8993 | if (ret) |
| 8994 | hdd_err("Failed to stop modules"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8995 | hdd_exit(); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8996 | } |
| 8997 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8998 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 8999 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 9000 | { |
| 9001 | wlan_logging_set_log_to_console(hdd_ctx->config-> |
| 9002 | wlan_logging_to_console); |
| 9003 | wlan_logging_set_active(hdd_ctx->config->wlan_logging_enable); |
| 9004 | } |
| 9005 | #else |
| 9006 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 9007 | { } |
| 9008 | #endif |
| 9009 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 9010 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9011 | * hdd_context_create() - Allocate and inialize HDD context. |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9012 | * @dev: Device Pointer to the underlying device |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9013 | * |
| 9014 | * Allocate and initialize HDD context. HDD context is allocated as part of |
| 9015 | * wiphy allocation and then context is initialized. |
| 9016 | * |
| 9017 | * Return: HDD context on success and ERR_PTR on failure |
| 9018 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9019 | static struct hdd_context *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9020 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9021 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9022 | int ret = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9023 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9024 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9025 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9026 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9027 | hdd_ctx = hdd_cfg80211_wiphy_alloc(sizeof(struct hdd_context)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9028 | if (hdd_ctx == NULL) { |
| 9029 | ret = -ENOMEM; |
| 9030 | goto err_out; |
| 9031 | } |
| 9032 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 9033 | qdf_create_delayed_work(&hdd_ctx->iface_idle_work, |
| 9034 | hdd_iface_change_callback, |
| 9035 | (void *)hdd_ctx); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9036 | |
| 9037 | mutex_init(&hdd_ctx->iface_change_lock); |
| 9038 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9039 | hdd_ctx->parent_dev = dev; |
Sreelakshmi Konamki | b53c629 | 2017-03-01 13:13:23 +0530 | [diff] [blame] | 9040 | hdd_ctx->last_scan_reject_session_id = 0xFF; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9041 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9042 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9043 | if (hdd_ctx->config == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9044 | hdd_err("Failed to alloc memory for HDD config!"); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9045 | ret = -ENOMEM; |
| 9046 | goto err_free_hdd_context; |
| 9047 | } |
| 9048 | |
| 9049 | /* Read and parse the qcom_cfg.ini file */ |
| 9050 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9051 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9052 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9053 | WLAN_INI_FILE); |
| 9054 | ret = -EINVAL; |
| 9055 | goto err_free_config; |
| 9056 | } |
| 9057 | |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 9058 | status = cfg_parse(WLAN_INI_FILE); |
| 9059 | if (QDF_IS_STATUS_ERROR(status)) |
| 9060 | hdd_err("Failed to parse cfg %s; status:%d\n", |
| 9061 | WLAN_INI_FILE, status); |
| 9062 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 9063 | ie_whitelist_attrs_init(hdd_ctx); |
| 9064 | |
Dustin Brown | 7f93993 | 2017-05-18 15:02:17 -0700 | [diff] [blame] | 9065 | hdd_debug("setting timer multiplier: %u", |
| 9066 | hdd_ctx->config->timer_multiplier); |
| 9067 | qdf_timer_set_multiplier(hdd_ctx->config->timer_multiplier); |
| 9068 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9069 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 9070 | if (hdd_ctx->config->fhostNSOffload) |
| 9071 | hdd_ctx->ns_offload_enable = true; |
| 9072 | |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 9073 | cds_set_fatal_event(hdd_ctx->config->enable_fatal_event); |
| 9074 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9075 | hdd_override_ini_config(hdd_ctx); |
| 9076 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9077 | ret = hdd_context_init(hdd_ctx); |
| 9078 | |
| 9079 | if (ret) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9080 | goto err_free_config; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9081 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9082 | /* Uses to enabled logging after SSR */ |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 9083 | hdd_ctx->fw_log_settings.enable = hdd_ctx->config->enable_fw_log; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9084 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9085 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9086 | goto skip_multicast_logging; |
| 9087 | |
| 9088 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 9089 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 9090 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 9091 | if (ret) |
| 9092 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 9093 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 9094 | ret = hdd_init_netlink_services(hdd_ctx); |
| 9095 | if (ret) |
| 9096 | goto err_deinit_txrx_histogram; |
| 9097 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 9098 | hdd_set_wlan_logging(hdd_ctx); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 9099 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9100 | skip_multicast_logging: |
| 9101 | hdd_set_trace_level_for_each(hdd_ctx); |
| 9102 | |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 9103 | cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); |
| 9104 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9105 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 9106 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9107 | return hdd_ctx; |
| 9108 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 9109 | err_deinit_txrx_histogram: |
| 9110 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 9111 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 9112 | err_deinit_hdd_context: |
| 9113 | hdd_context_deinit(hdd_ctx); |
| 9114 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9115 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9116 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9117 | |
| 9118 | err_free_hdd_context: |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9119 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Rajeev Kumar | fa55a69 | 2018-01-09 14:12:41 -0800 | [diff] [blame] | 9120 | wiphy_free(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9121 | |
| 9122 | err_out: |
| 9123 | return ERR_PTR(ret); |
| 9124 | } |
| 9125 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9126 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 9127 | /** |
| 9128 | * hdd_open_p2p_interface - Open P2P interface |
| 9129 | * @hdd_ctx: HDD context |
| 9130 | * @rtnl_held: True if RTNL lock held |
| 9131 | * |
| 9132 | * Open P2P interface during probe. This function called to open the P2P |
| 9133 | * interface at probe along with STA interface. |
| 9134 | * |
| 9135 | * Return: 0 on success and errno on failure |
| 9136 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9137 | static int hdd_open_p2p_interface(struct hdd_context *hdd_ctx, bool rtnl_held) |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9138 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9139 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9140 | uint8_t *p2p_dev_addr; |
Wu Gao | e568979 | 2018-07-05 19:20:13 +0800 | [diff] [blame] | 9141 | bool p2p_dev_addr_admin = false; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9142 | |
Wu Gao | e568979 | 2018-07-05 19:20:13 +0800 | [diff] [blame] | 9143 | cfg_p2p_get_device_addr_admin(hdd_ctx->hdd_psoc, &p2p_dev_addr_admin); |
| 9144 | if (p2p_dev_addr_admin && |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9145 | !(hdd_ctx->config->intfMacAddr[0].bytes[0] & 0x02)) { |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 9146 | qdf_mem_copy(hdd_ctx->p2p_device_address.bytes, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9147 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 9148 | sizeof(tSirMacAddr)); |
| 9149 | |
| 9150 | /* |
| 9151 | * Generate the P2P Device Address. This consists of |
| 9152 | * the device's primary MAC address with the locally |
| 9153 | * administered bit set. |
| 9154 | */ |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 9155 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9156 | } else { |
| 9157 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx); |
| 9158 | if (p2p_dev_addr == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9159 | hdd_err("Failed to allocate mac_address for p2p_device"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9160 | return -ENOSPC; |
| 9161 | } |
| 9162 | |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 9163 | qdf_mem_copy(&hdd_ctx->p2p_device_address.bytes[0], |
| 9164 | p2p_dev_addr, QDF_MAC_ADDR_SIZE); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9165 | } |
| 9166 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9167 | adapter = hdd_open_adapter(hdd_ctx, QDF_P2P_DEVICE_MODE, "p2p%d", |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 9168 | &hdd_ctx->p2p_device_address.bytes[0], |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 9169 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9170 | |
| 9171 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9172 | hdd_err("Failed to do hdd_open_adapter for P2P Device Interface"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9173 | return -ENOSPC; |
| 9174 | } |
| 9175 | |
| 9176 | return 0; |
| 9177 | } |
| 9178 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9179 | static inline int hdd_open_p2p_interface(struct hdd_context *hdd_ctx, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9180 | bool rtnl_held) |
| 9181 | { |
| 9182 | return 0; |
| 9183 | } |
| 9184 | #endif |
| 9185 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9186 | static int hdd_open_ocb_interface(struct hdd_context *hdd_ctx, bool rtnl_held) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9187 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9188 | struct hdd_adapter *adapter; |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9189 | int ret = 0; |
| 9190 | |
| 9191 | adapter = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, "wlanocb%d", |
| 9192 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 9193 | NET_NAME_UNKNOWN, rtnl_held); |
| 9194 | if (adapter == NULL) { |
| 9195 | hdd_err("Failed to open 802.11p interface"); |
| 9196 | ret = -ENOSPC; |
| 9197 | } |
| 9198 | |
| 9199 | return ret; |
| 9200 | } |
| 9201 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9202 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9203 | * hdd_start_station_adapter()- Start the Station Adapter |
| 9204 | * @adapter: HDD adapter |
| 9205 | * |
| 9206 | * This function initializes the adapter for the station mode. |
| 9207 | * |
| 9208 | * Return: 0 on success or errno on failure. |
| 9209 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9210 | int hdd_start_station_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9211 | { |
| 9212 | QDF_STATUS status; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9213 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9214 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 9215 | hdd_enter_dev(adapter->dev); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9216 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 9217 | hdd_err("session is already opened, %d", |
| 9218 | adapter->session_id); |
| 9219 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 9220 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9221 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9222 | ret = hdd_vdev_create(adapter, hdd_sme_roam_callback, adapter); |
| 9223 | if (ret) { |
| 9224 | hdd_err("failed to create vdev: %d", ret); |
| 9225 | return ret; |
| 9226 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9227 | status = hdd_init_station_mode(adapter); |
| 9228 | |
| 9229 | if (QDF_STATUS_SUCCESS != status) { |
| 9230 | hdd_err("Error Initializing station mode: %d", status); |
| 9231 | return qdf_status_to_os_return(status); |
| 9232 | } |
| 9233 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9234 | hdd_register_tx_flow_control(adapter, |
| 9235 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 9236 | hdd_tx_resume_cb, |
| 9237 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9238 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9239 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9240 | return 0; |
| 9241 | } |
| 9242 | |
| 9243 | /** |
| 9244 | * hdd_start_ap_adapter()- Start AP Adapter |
| 9245 | * @adapter: HDD adapter |
| 9246 | * |
| 9247 | * This function initializes the adapter for the AP mode. |
| 9248 | * |
| 9249 | * Return: 0 on success errno on failure. |
| 9250 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9251 | int hdd_start_ap_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9252 | { |
| 9253 | QDF_STATUS status; |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9254 | bool is_ssr = false; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9255 | int ret; |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9256 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9257 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9258 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9259 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9260 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 9261 | hdd_err("session is already opened, %d", |
| 9262 | adapter->session_id); |
| 9263 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 9264 | } |
| 9265 | /* |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9266 | * In SSR case no need to create new sap context. |
| 9267 | * Otherwise create sap context first and then create |
| 9268 | * vdev as while creating the vdev, driver needs to |
| 9269 | * register SAP callback and that callback uses sap context |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9270 | */ |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9271 | if (adapter->session.ap.sap_context) { |
| 9272 | is_ssr = true; |
| 9273 | } else if (!hdd_sap_create_ctx(adapter)) { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9274 | hdd_err("sap creation failed"); |
| 9275 | return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); |
| 9276 | } |
| 9277 | |
| 9278 | ret = hdd_vdev_create(adapter, wlansap_roam_callback, |
| 9279 | adapter->session.ap.sap_context); |
| 9280 | if (ret) { |
| 9281 | hdd_err("failed to create vdev, status:%d", ret); |
| 9282 | hdd_sap_destroy_ctx(adapter); |
| 9283 | return ret; |
| 9284 | } |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9285 | |
| 9286 | if (adapter->device_mode == QDF_SAP_MODE) |
| 9287 | sme_cli_set_command(adapter->session_id, |
| 9288 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_RESPONDER_ROLE, |
| 9289 | (bool)(hdd_ctx->config->fine_time_meas_cap & |
| 9290 | WMI_FW_AP_RTT_RESPR), |
| 9291 | VDEV_CMD); |
| 9292 | |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9293 | status = hdd_init_ap_mode(adapter, is_ssr); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9294 | |
| 9295 | if (QDF_STATUS_SUCCESS != status) { |
| 9296 | hdd_err("Error Initializing the AP mode: %d", status); |
| 9297 | return qdf_status_to_os_return(status); |
| 9298 | } |
| 9299 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9300 | hdd_register_tx_flow_control(adapter, |
| 9301 | hdd_softap_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 9302 | hdd_softap_tx_resume_cb, |
| 9303 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9304 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9305 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9306 | return 0; |
| 9307 | } |
| 9308 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 9309 | static int hdd_open_concurrent_interface(struct hdd_context *hdd_ctx, |
| 9310 | bool rtnl_held) |
| 9311 | { |
| 9312 | struct hdd_adapter *adapter; |
| 9313 | |
| 9314 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, |
| 9315 | hdd_ctx->config->enableConcurrentSTA, |
| 9316 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 9317 | NET_NAME_UNKNOWN, rtnl_held); |
| 9318 | |
| 9319 | if (!adapter) |
| 9320 | return -ENOSPC; |
| 9321 | |
| 9322 | return 0; |
| 9323 | } |
| 9324 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9325 | /** |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9326 | * hdd_open_interfaces - Open all required interfaces |
| 9327 | * hdd_ctx: HDD context |
| 9328 | * rtnl_held: True if RTNL lock is held |
| 9329 | * |
| 9330 | * Open all the interfaces like STA, P2P and OCB based on the configuration. |
| 9331 | * |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9332 | * Return: 0 if all interfaces were created, otherwise negative errno |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9333 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9334 | static int hdd_open_interfaces(struct hdd_context *hdd_ctx, bool rtnl_held) |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9335 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9336 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9337 | int ret; |
| 9338 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 9339 | /* open monitor mode adapter if con_mode is monitor mode */ |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 9340 | if (con_mode == QDF_GLOBAL_MONITOR_MODE || |
| 9341 | con_mode == QDF_GLOBAL_FTM_MODE) { |
| 9342 | uint8_t session_type = (con_mode == QDF_GLOBAL_MONITOR_MODE) ? |
| 9343 | QDF_MONITOR_MODE : QDF_FTM_MODE; |
| 9344 | |
| 9345 | adapter = hdd_open_adapter(hdd_ctx, session_type, "wlan%d", |
| 9346 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 9347 | NET_NAME_UNKNOWN, rtnl_held); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 9348 | if (!adapter) { |
| 9349 | hdd_err("open adapter failed"); |
| 9350 | return -ENOSPC; |
| 9351 | } |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 9352 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 9353 | return 0; |
| 9354 | } |
| 9355 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9356 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_STANDALONE) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9357 | /* Create only 802.11p interface */ |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9358 | return hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9359 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9360 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, "wlan%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9361 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 9362 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9363 | |
| 9364 | if (adapter == NULL) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9365 | return -ENOSPC; |
| 9366 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 9367 | if (strlen(hdd_ctx->config->enableConcurrentSTA) != 0) { |
| 9368 | ret = hdd_open_concurrent_interface(hdd_ctx, rtnl_held); |
| 9369 | if (ret) |
| 9370 | hdd_err("Cannot create concurrent STA interface"); |
| 9371 | } |
| 9372 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9373 | ret = hdd_open_p2p_interface(hdd_ctx, rtnl_held); |
| 9374 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9375 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9376 | |
| 9377 | /* Open 802.11p Interface */ |
| 9378 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_CONCURRENT) { |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9379 | ret = hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
| 9380 | if (ret) |
| 9381 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9382 | } |
| 9383 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9384 | return 0; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9385 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9386 | err_close_adapters: |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9387 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9388 | return ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9389 | } |
| 9390 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9391 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9392 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 9393 | /** |
| 9394 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 9395 | * @cds_cfg: CDS Configuration |
| 9396 | * @hdd_ctx: Pointer to hdd context |
| 9397 | * |
| 9398 | * Return: none |
| 9399 | */ |
| 9400 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 9401 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9402 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9403 | { |
| 9404 | cds_cfg->tx_flow_stop_queue_th = |
| 9405 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 9406 | cds_cfg->tx_flow_start_queue_offset = |
| 9407 | hdd_ctx->config->TxFlowStartQueueOffset; |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 9408 | /* configuration for DP RX Threads */ |
| 9409 | cds_cfg->enable_dp_rx_threads = hdd_ctx->enable_dp_rx_threads; |
| 9410 | cds_cfg->num_dp_rx_threads = hdd_ctx->config->num_dp_rx_threads; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9411 | } |
| 9412 | #else |
| 9413 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 9414 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9415 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9416 | { |
| 9417 | } |
| 9418 | #endif |
| 9419 | |
| 9420 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 9421 | /** |
| 9422 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 9423 | * @cds_cfg: CDS Configuration |
| 9424 | * @hdd_ctx: Pointer to hdd context |
| 9425 | * |
| 9426 | * Return: none |
| 9427 | */ |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 9428 | 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] | 9429 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9430 | { |
| 9431 | cds_cfg->ra_ratelimit_interval = |
| 9432 | hdd_ctx->config->RArateLimitInterval; |
| 9433 | cds_cfg->is_ra_ratelimit_enabled = |
| 9434 | hdd_ctx->config->IsRArateLimitEnabled; |
| 9435 | } |
| 9436 | #else |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 9437 | 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] | 9438 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9439 | { |
| 9440 | } |
| 9441 | #endif |
| 9442 | |
| 9443 | /** |
| 9444 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 9445 | * @hdd_ctx: HDD Context |
| 9446 | * |
| 9447 | * Return: 0 for Success, errno on failure |
| 9448 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9449 | static int hdd_update_cds_config(struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9450 | { |
| 9451 | struct cds_config_info *cds_cfg; |
| 9452 | |
| 9453 | cds_cfg = (struct cds_config_info *)qdf_mem_malloc(sizeof(*cds_cfg)); |
| 9454 | if (!cds_cfg) { |
| 9455 | hdd_err("failed to allocate cds config"); |
| 9456 | return -ENOMEM; |
| 9457 | } |
| 9458 | |
Srinivas Girigowda | 35b0031 | 2017-06-27 21:52:03 -0700 | [diff] [blame] | 9459 | cds_cfg->driver_type = QDF_DRIVER_TYPE_PRODUCTION; |
Kiran Kumar Lokere | 7006e0a | 2017-03-07 19:28:36 -0800 | [diff] [blame] | 9460 | if (!hdd_ctx->config->nMaxPsPoll || |
| 9461 | !hdd_ctx->config->enablePowersaveOffload) { |
| 9462 | cds_cfg->powersave_offload_enabled = |
| 9463 | hdd_ctx->config->enablePowersaveOffload; |
| 9464 | } else { |
| 9465 | if ((hdd_ctx->config->enablePowersaveOffload == |
| 9466 | PS_QPOWER_NODEEPSLEEP) || |
| 9467 | (hdd_ctx->config->enablePowersaveOffload == |
| 9468 | PS_LEGACY_NODEEPSLEEP)) |
| 9469 | cds_cfg->powersave_offload_enabled = |
| 9470 | PS_LEGACY_NODEEPSLEEP; |
| 9471 | else |
| 9472 | cds_cfg->powersave_offload_enabled = |
| 9473 | PS_LEGACY_DEEPSLEEP; |
| 9474 | hdd_info("Qpower disabled in cds config, %d", |
| 9475 | cds_cfg->powersave_offload_enabled); |
| 9476 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9477 | cds_cfg->sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 9478 | cds_cfg->sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 9479 | cds_cfg->sta_maxlimod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 9480 | cds_cfg->wow_enable = hdd_ctx->config->wowEnable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9481 | |
| 9482 | /* |
| 9483 | * Copy the DFS Phyerr Filtering Offload status. |
| 9484 | * This parameter reflects the value of the |
| 9485 | * dfs_phyerr_filter_offload flag as set in the ini. |
| 9486 | */ |
| 9487 | cds_cfg->dfs_phyerr_filter_offload = |
| 9488 | hdd_ctx->config->fDfsPhyerrFilterOffload; |
| 9489 | if (hdd_ctx->config->ssdp) |
| 9490 | cds_cfg->ssdp = hdd_ctx->config->ssdp; |
| 9491 | |
SaidiReddy Yenuga | cc733af | 2016-11-09 17:45:42 +0530 | [diff] [blame] | 9492 | cds_cfg->force_target_assert_enabled = |
| 9493 | hdd_ctx->config->crash_inject_enabled; |
| 9494 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9495 | cds_cfg->enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 9496 | cds_cfg->ap_maxoffload_peers = hdd_ctx->config->apMaxOffloadPeers; |
| 9497 | |
| 9498 | cds_cfg->ap_maxoffload_reorderbuffs = |
| 9499 | hdd_ctx->config->apMaxOffloadReorderBuffs; |
| 9500 | |
| 9501 | cds_cfg->ap_disable_intrabss_fwd = |
| 9502 | hdd_ctx->config->apDisableIntraBssFwd; |
| 9503 | |
| 9504 | cds_cfg->dfs_pri_multiplier = |
| 9505 | hdd_ctx->config->dfsRadarPriMultiplier; |
| 9506 | cds_cfg->reorder_offload = |
| 9507 | hdd_ctx->config->reorderOffloadSupport; |
| 9508 | |
| 9509 | /* IPA micro controller data path offload resource config item */ |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 9510 | cds_cfg->uc_offload_enabled = ucfg_ipa_uc_is_enabled(); |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9511 | if (!is_power_of_2(hdd_ctx->config->IpaUcTxBufCount)) { |
| 9512 | /* IpaUcTxBufCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9513 | hdd_debug("Round down IpaUcTxBufCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9514 | hdd_ctx->config->IpaUcTxBufCount); |
| 9515 | hdd_ctx->config->IpaUcTxBufCount = |
| 9516 | rounddown_pow_of_two( |
| 9517 | hdd_ctx->config->IpaUcTxBufCount); |
| 9518 | if (!hdd_ctx->config->IpaUcTxBufCount) { |
| 9519 | hdd_err("Failed to round down IpaUcTxBufCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9520 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9521 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9522 | hdd_debug("IpaUcTxBufCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9523 | hdd_ctx->config->IpaUcTxBufCount); |
| 9524 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9525 | cds_cfg->uc_txbuf_count = hdd_ctx->config->IpaUcTxBufCount; |
| 9526 | cds_cfg->uc_txbuf_size = hdd_ctx->config->IpaUcTxBufSize; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9527 | if (!is_power_of_2(hdd_ctx->config->IpaUcRxIndRingCount)) { |
| 9528 | /* IpaUcRxIndRingCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9529 | hdd_debug("Round down IpaUcRxIndRingCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9530 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9531 | hdd_ctx->config->IpaUcRxIndRingCount = |
| 9532 | rounddown_pow_of_two( |
| 9533 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9534 | if (!hdd_ctx->config->IpaUcRxIndRingCount) { |
| 9535 | hdd_err("Failed to round down IpaUcRxIndRingCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9536 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9537 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9538 | hdd_debug("IpaUcRxIndRingCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9539 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9540 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9541 | cds_cfg->uc_rxind_ringcount = |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9542 | hdd_ctx->config->IpaUcRxIndRingCount; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9543 | cds_cfg->uc_tx_partition_base = |
| 9544 | hdd_ctx->config->IpaUcTxPartitionBase; |
| 9545 | cds_cfg->max_scan = hdd_ctx->config->max_scan_count; |
| 9546 | |
| 9547 | cds_cfg->ip_tcp_udp_checksum_offload = |
| 9548 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
Jeff Johnson | e2ba3cd | 2017-10-30 20:02:09 -0700 | [diff] [blame] | 9549 | cds_cfg->enable_rxthread = hdd_ctx->enable_rxthread; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9550 | cds_cfg->ce_classify_enabled = |
| 9551 | hdd_ctx->config->ce_classify_enabled; |
Nachiket Kukade | e547a48 | 2018-05-22 16:43:30 +0530 | [diff] [blame] | 9552 | cds_cfg->apf_packet_filter_enable = |
| 9553 | hdd_ctx->config->apf_packet_filter_enable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9554 | cds_cfg->tx_chain_mask_cck = hdd_ctx->config->tx_chain_mask_cck; |
| 9555 | cds_cfg->self_gen_frm_pwr = hdd_ctx->config->self_gen_frm_pwr; |
| 9556 | cds_cfg->max_station = hdd_ctx->config->maxNumberOfPeers; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 9557 | cds_cfg->sub_20_channel_width = WLAN_SUB_20_CH_WIDTH_NONE; |
Manjunathappa Prakash | fff753c | 2016-09-01 19:34:56 -0700 | [diff] [blame] | 9558 | cds_cfg->flow_steering_enabled = hdd_ctx->config->flow_steering_enable; |
Orhan K AKYILDIZ | 30e8cbc | 2017-08-11 18:00:28 -0700 | [diff] [blame] | 9559 | cds_cfg->max_msdus_per_rxinorderind = |
| 9560 | hdd_ctx->config->max_msdus_per_rxinorderind; |
Naveen Rawat | 91df30a | 2016-10-12 21:26:18 -0700 | [diff] [blame] | 9561 | cds_cfg->self_recovery_enabled = hdd_ctx->config->enableSelfRecovery; |
Sandeep Puligilla | afa5289 | 2016-10-26 19:03:16 -0700 | [diff] [blame] | 9562 | cds_cfg->fw_timeout_crash = hdd_ctx->config->fw_timeout_crash; |
Nachiket Kukade | e547a48 | 2018-05-22 16:43:30 +0530 | [diff] [blame] | 9563 | cds_cfg->active_uc_apf_mode = hdd_ctx->config->active_uc_apf_mode; |
| 9564 | cds_cfg->active_mc_bc_apf_mode = hdd_ctx->config->active_mc_bc_apf_mode; |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 9565 | cds_cfg->auto_power_save_fail_mode = |
| 9566 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9567 | |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 9568 | cds_cfg->ito_repeat_count = hdd_ctx->config->ito_repeat_count; |
Sandeep Puligilla | 819d94f | 2017-10-10 18:33:56 -0700 | [diff] [blame] | 9569 | cds_cfg->bandcapability = hdd_ctx->config->nBandCapability; |
Zhu Jianmin | a2f8e8d | 2018-02-11 16:37:10 +0800 | [diff] [blame] | 9570 | cds_cfg->delay_before_vdev_stop = |
| 9571 | hdd_ctx->config->delay_before_vdev_stop; |
Rachit Kankane | 0106e38 | 2018-05-16 18:59:28 +0530 | [diff] [blame] | 9572 | cds_cfg->num_vdevs = hdd_ctx->config->num_vdevs; |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 9573 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9574 | hdd_ra_populate_cds_config(cds_cfg, hdd_ctx); |
| 9575 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 9576 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9577 | cds_init_ini_config(cds_cfg); |
| 9578 | return 0; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9579 | |
| 9580 | exit: |
| 9581 | qdf_mem_free(cds_cfg); |
| 9582 | return -EINVAL; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9583 | } |
| 9584 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9585 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9586 | * hdd_update_user_config() - API to update user configuration |
| 9587 | * parameters to obj mgr which are used by multiple components |
| 9588 | * @hdd_ctx: HDD Context |
| 9589 | * |
| 9590 | * Return: 0 for Success, errno on failure |
| 9591 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9592 | static int hdd_update_user_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9593 | { |
| 9594 | struct wlan_objmgr_psoc_user_config *user_config; |
Wu Gao | e568979 | 2018-07-05 19:20:13 +0800 | [diff] [blame] | 9595 | bool skip_dfs_in_p2p_search = false; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9596 | |
| 9597 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
| 9598 | if (user_config == NULL) { |
| 9599 | hdd_alert("Failed to alloc memory for user_config!"); |
| 9600 | return -ENOMEM; |
| 9601 | } |
| 9602 | |
| 9603 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
| 9604 | user_config->dual_mac_feature_disable = |
| 9605 | hdd_ctx->config->dual_mac_feature_disable; |
| 9606 | user_config->indoor_channel_support = |
| 9607 | hdd_ctx->config->indoor_channel_support; |
| 9608 | user_config->is_11d_support_enabled = |
| 9609 | hdd_ctx->config->Is11dSupportEnabled; |
| 9610 | user_config->is_11h_support_enabled = |
| 9611 | hdd_ctx->config->Is11hSupportEnabled; |
| 9612 | user_config->optimize_chan_avoid_event = |
| 9613 | hdd_ctx->config->goptimize_chan_avoid_event; |
Wu Gao | e568979 | 2018-07-05 19:20:13 +0800 | [diff] [blame] | 9614 | cfg_p2p_get_skip_dfs_channel_p2p_search(hdd_ctx->hdd_psoc, |
| 9615 | &skip_dfs_in_p2p_search); |
| 9616 | user_config->skip_dfs_chnl_in_p2p_search = skip_dfs_in_p2p_search; |
Naveen Rawat | 222b2e9 | 2017-03-16 09:52:21 -0700 | [diff] [blame] | 9617 | user_config->band_capability = hdd_ctx->config->nBandCapability; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9618 | wlan_objmgr_psoc_set_user_config(hdd_ctx->hdd_psoc, user_config); |
| 9619 | |
| 9620 | qdf_mem_free(user_config); |
| 9621 | return 0; |
| 9622 | } |
| 9623 | |
| 9624 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9625 | * hdd_init_thermal_info - Initialize thermal level |
| 9626 | * @hdd_ctx: HDD context |
| 9627 | * |
| 9628 | * Initialize thermal level at SME layer and set the thermal level callback |
| 9629 | * which would be called when a configured thermal threshold is hit. |
| 9630 | * |
| 9631 | * Return: 0 on success and errno on failure |
| 9632 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9633 | static int hdd_init_thermal_info(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9634 | { |
| 9635 | tSmeThermalParams thermal_param; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9636 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9637 | mac_handle_t mac_handle; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9638 | |
| 9639 | thermal_param.smeThermalMgmtEnabled = |
| 9640 | hdd_ctx->config->thermalMitigationEnable; |
| 9641 | thermal_param.smeThrottlePeriod = hdd_ctx->config->throttlePeriod; |
| 9642 | |
Poddar, Siddarth | 8390502 | 2016-04-16 17:56:08 -0700 | [diff] [blame] | 9643 | thermal_param.sme_throttle_duty_cycle_tbl[0] = |
| 9644 | hdd_ctx->config->throttle_dutycycle_level0; |
| 9645 | thermal_param.sme_throttle_duty_cycle_tbl[1] = |
| 9646 | hdd_ctx->config->throttle_dutycycle_level1; |
| 9647 | thermal_param.sme_throttle_duty_cycle_tbl[2] = |
| 9648 | hdd_ctx->config->throttle_dutycycle_level2; |
| 9649 | thermal_param.sme_throttle_duty_cycle_tbl[3] = |
| 9650 | hdd_ctx->config->throttle_dutycycle_level3; |
| 9651 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9652 | thermal_param.smeThermalLevels[0].smeMinTempThreshold = |
| 9653 | hdd_ctx->config->thermalTempMinLevel0; |
| 9654 | thermal_param.smeThermalLevels[0].smeMaxTempThreshold = |
| 9655 | hdd_ctx->config->thermalTempMaxLevel0; |
| 9656 | thermal_param.smeThermalLevels[1].smeMinTempThreshold = |
| 9657 | hdd_ctx->config->thermalTempMinLevel1; |
| 9658 | thermal_param.smeThermalLevels[1].smeMaxTempThreshold = |
| 9659 | hdd_ctx->config->thermalTempMaxLevel1; |
| 9660 | thermal_param.smeThermalLevels[2].smeMinTempThreshold = |
| 9661 | hdd_ctx->config->thermalTempMinLevel2; |
| 9662 | thermal_param.smeThermalLevels[2].smeMaxTempThreshold = |
| 9663 | hdd_ctx->config->thermalTempMaxLevel2; |
| 9664 | thermal_param.smeThermalLevels[3].smeMinTempThreshold = |
| 9665 | hdd_ctx->config->thermalTempMinLevel3; |
| 9666 | thermal_param.smeThermalLevels[3].smeMaxTempThreshold = |
| 9667 | hdd_ctx->config->thermalTempMaxLevel3; |
| 9668 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9669 | mac_handle = hdd_ctx->mac_handle; |
| 9670 | status = sme_init_thermal_info(mac_handle, thermal_param); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9671 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9672 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 9673 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9674 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9675 | sme_add_set_thermal_level_callback(mac_handle, |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9676 | hdd_set_thermal_level_cb); |
| 9677 | |
| 9678 | return 0; |
| 9679 | |
| 9680 | } |
| 9681 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9682 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 9683 | /** |
| 9684 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 9685 | * |
| 9686 | * Hold RTNL lock |
| 9687 | * |
| 9688 | * Return: True if held and false otherwise |
| 9689 | */ |
| 9690 | static inline bool hdd_hold_rtnl_lock(void) |
| 9691 | { |
| 9692 | rtnl_lock(); |
| 9693 | return true; |
| 9694 | } |
| 9695 | |
| 9696 | /** |
| 9697 | * hdd_release_rtnl_lock - Release RTNL lock |
| 9698 | * |
| 9699 | * Release RTNL lock |
| 9700 | * |
| 9701 | * Return: None |
| 9702 | */ |
| 9703 | static inline void hdd_release_rtnl_lock(void) |
| 9704 | { |
| 9705 | rtnl_unlock(); |
| 9706 | } |
| 9707 | #else |
| 9708 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 9709 | static inline void hdd_release_rtnl_lock(void) { } |
| 9710 | #endif |
| 9711 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9712 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9713 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9714 | /* MAX iwpriv command support */ |
| 9715 | #define PKTLOG_SET_BUFF_SIZE 3 |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9716 | #define PKTLOG_CLEAR_BUFF 4 |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9717 | #define MAX_PKTLOG_SIZE 16 |
| 9718 | |
| 9719 | /** |
| 9720 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 9721 | * @hdd_ctx: hdd context |
| 9722 | * @set_value2: pktlog buffer size value |
| 9723 | * |
| 9724 | * |
| 9725 | * Return: 0 for success or error. |
| 9726 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9727 | 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] | 9728 | { |
| 9729 | struct sir_wifi_start_log start_log = { 0 }; |
| 9730 | QDF_STATUS status; |
| 9731 | |
| 9732 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9733 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 9734 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9735 | start_log.user_triggered = 1; |
| 9736 | start_log.size = set_value2; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9737 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9738 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9739 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9740 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9741 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9742 | hdd_exit(); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9743 | return -EINVAL; |
| 9744 | } |
| 9745 | |
| 9746 | return 0; |
| 9747 | } |
| 9748 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9749 | /** |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9750 | * hdd_pktlog_clear_buff() - clear pktlog buffer |
| 9751 | * @hdd_ctx: hdd context |
| 9752 | * |
| 9753 | * Return: 0 for success or error. |
| 9754 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9755 | static int hdd_pktlog_clear_buff(struct hdd_context *hdd_ctx) |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9756 | { |
| 9757 | struct sir_wifi_start_log start_log; |
| 9758 | QDF_STATUS status; |
| 9759 | |
| 9760 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9761 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 9762 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9763 | start_log.user_triggered = 1; |
| 9764 | start_log.size = 0; |
| 9765 | start_log.is_pktlog_buff_clear = true; |
| 9766 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9767 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9768 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9769 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9770 | hdd_exit(); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9771 | return -EINVAL; |
| 9772 | } |
| 9773 | |
| 9774 | return 0; |
| 9775 | } |
| 9776 | |
| 9777 | |
| 9778 | /** |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9779 | * hdd_process_pktlog_command() - process pktlog command |
| 9780 | * @hdd_ctx: hdd context |
| 9781 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9782 | * @set_value2: pktlog buffer size value |
| 9783 | * |
| 9784 | * This function process pktlog command. |
| 9785 | * set_value2 only matters when set_value is 3 (set buff size) |
| 9786 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9787 | * |
| 9788 | * Return: 0 for success or error. |
| 9789 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9790 | 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] | 9791 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9792 | { |
| 9793 | int ret; |
| 9794 | bool enable; |
| 9795 | uint8_t user_triggered = 0; |
| 9796 | |
| 9797 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9798 | if (0 != ret) |
| 9799 | return ret; |
| 9800 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9801 | hdd_debug("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9802 | |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9803 | if (set_value > PKTLOG_CLEAR_BUFF) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9804 | hdd_err("invalid pktlog value %d", set_value); |
| 9805 | return -EINVAL; |
| 9806 | } |
| 9807 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9808 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 9809 | if (set_value2 <= 0) { |
| 9810 | hdd_err("invalid pktlog size %d", set_value2); |
| 9811 | return -EINVAL; |
| 9812 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
| 9813 | hdd_err("Pktlog buff size is too large. max value is 16MB.\n"); |
| 9814 | return -EINVAL; |
| 9815 | } |
| 9816 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9817 | } else if (set_value == PKTLOG_CLEAR_BUFF) { |
| 9818 | return hdd_pktlog_clear_buff(hdd_ctx); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9819 | } |
| 9820 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9821 | /* |
| 9822 | * set_value = 0 then disable packetlog |
| 9823 | * set_value = 1 enable packetlog forcefully |
| 9824 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 9825 | * enable packetlog with AUTO type. |
| 9826 | */ |
| 9827 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 9828 | true : false; |
| 9829 | |
| 9830 | if (1 == set_value) { |
| 9831 | enable = true; |
| 9832 | user_triggered = 1; |
| 9833 | } |
| 9834 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9835 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9836 | } |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 9837 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9838 | /** |
| 9839 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 9840 | * @hdd_ctx: HDD context |
| 9841 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9842 | * @user_triggered: triggered through iwpriv |
| 9843 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9844 | * |
| 9845 | * Return: 0 on success; error number otherwise |
| 9846 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9847 | int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9848 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9849 | { |
| 9850 | struct sir_wifi_start_log start_log; |
| 9851 | QDF_STATUS status; |
| 9852 | |
| 9853 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9854 | start_log.verbose_level = |
| 9855 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9856 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9857 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9858 | start_log.size = size; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9859 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 9860 | /* |
| 9861 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 9862 | * commands. Host uses this flag to decide whether to send pktlog |
| 9863 | * disable command to fw without sending pktlog enable command |
| 9864 | * previously. For eg, If vendor sends pktlog disable command without |
| 9865 | * sending pktlog enable command, then host discards the packet |
| 9866 | * but for iwpriv command, host will send it to fw. |
| 9867 | */ |
| 9868 | start_log.is_iwpriv_command = 1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9869 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9870 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9871 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9872 | hdd_exit(); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9873 | return -EINVAL; |
| 9874 | } |
| 9875 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 9876 | if (enable == true) |
| 9877 | hdd_ctx->is_pktlog_enabled = 1; |
| 9878 | else |
| 9879 | hdd_ctx->is_pktlog_enabled = 0; |
| 9880 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9881 | return 0; |
| 9882 | } |
| 9883 | #endif /* REMOVE_PKT_LOG */ |
| 9884 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9885 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9886 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 9887 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9888 | * @dev: Device Pointer |
| 9889 | * @num: Number of Valid Mac address |
| 9890 | * |
| 9891 | * Return: Pointer to MAC address buffer |
| 9892 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9893 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 9894 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9895 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9896 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9897 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9898 | |
| 9899 | /** |
| 9900 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 9901 | * @hdd_ctx: HDD Context |
| 9902 | * @num: Number of random mac addresses needed |
| 9903 | * |
| 9904 | * Generate random addresses using bit manipulation on the base mac address |
| 9905 | * |
| 9906 | * Return: None |
| 9907 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9908 | 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] | 9909 | { |
| 9910 | uint32_t start_idx = QDF_MAX_CONCURRENCY_PERSONA - num; |
| 9911 | uint32_t iter; |
| 9912 | struct hdd_config *ini = hdd_ctx->config; |
| 9913 | uint8_t *buf = NULL; |
| 9914 | uint8_t macaddr_b3, tmp_br3; |
| 9915 | uint8_t *src = ini->intfMacAddr[0].bytes; |
| 9916 | |
| 9917 | for (iter = start_idx; iter < QDF_MAX_CONCURRENCY_PERSONA; ++iter) { |
| 9918 | buf = ini->intfMacAddr[iter].bytes; |
| 9919 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 9920 | macaddr_b3 = buf[3]; |
| 9921 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + iter) & |
| 9922 | INTF_MACADDR_MASK; |
| 9923 | macaddr_b3 += tmp_br3; |
| 9924 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 9925 | buf[0] |= 0x02; |
| 9926 | buf[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9927 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9928 | } |
| 9929 | } |
| 9930 | |
| 9931 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9932 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9933 | * @hdd_ctx: HDD Context |
| 9934 | * |
| 9935 | * API to get mac addresses from platform driver and update the driver |
| 9936 | * structures and configure FW with the base mac address. |
| 9937 | * Return: int |
| 9938 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9939 | static int hdd_platform_wlan_mac(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9940 | { |
| 9941 | uint32_t no_of_mac_addr, iter; |
| 9942 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 9943 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 9944 | uint8_t *addr, *buf; |
| 9945 | struct device *dev = hdd_ctx->parent_dev; |
| 9946 | struct hdd_config *ini = hdd_ctx->config; |
| 9947 | tSirMacAddr mac_addr; |
| 9948 | QDF_STATUS status; |
| 9949 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9950 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9951 | |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 9952 | if (no_of_mac_addr == 0 || !addr) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9953 | return -EINVAL; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9954 | |
| 9955 | if (no_of_mac_addr > max_mac_addr) |
| 9956 | no_of_mac_addr = max_mac_addr; |
| 9957 | |
| 9958 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 9959 | |
| 9960 | for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { |
| 9961 | buf = ini->intfMacAddr[iter].bytes; |
| 9962 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9963 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9964 | } |
| 9965 | |
| 9966 | status = sme_set_custom_mac_addr(mac_addr); |
| 9967 | |
| 9968 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9969 | return -EAGAIN; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9970 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9971 | if (no_of_mac_addr < max_mac_addr) |
| 9972 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 9973 | no_of_mac_addr); |
| 9974 | return 0; |
| 9975 | } |
| 9976 | |
| 9977 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9978 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 9979 | * @hdd_ctx: HDD Context |
| 9980 | * |
| 9981 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 9982 | * will generate its own MAC and update it to FW. |
| 9983 | * |
| 9984 | * Return: 0 for success |
| 9985 | * Non-zero error code for failure |
| 9986 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9987 | 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] | 9988 | { |
| 9989 | tSirMacAddr customMacAddr; |
| 9990 | QDF_STATUS status; |
| 9991 | |
| 9992 | qdf_mem_copy(&customMacAddr, |
| 9993 | &hdd_ctx->config->intfMacAddr[0].bytes[0], |
| 9994 | sizeof(tSirMacAddr)); |
| 9995 | status = sme_set_custom_mac_addr(customMacAddr); |
| 9996 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9997 | return -EAGAIN; |
| 9998 | return 0; |
| 9999 | } |
| 10000 | |
| 10001 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10002 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 10003 | * @hdd_ctx: HDD Context |
| 10004 | * |
| 10005 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 10006 | * is provisioned with mac addresses, driver uses it, else it will use |
| 10007 | * wlan_mac.bin to update HW MAC addresses. |
| 10008 | * |
| 10009 | * Return: None |
| 10010 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10011 | static void hdd_initialize_mac_address(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10012 | { |
| 10013 | QDF_STATUS status; |
| 10014 | int ret; |
| 10015 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10016 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10017 | if (!ret) { |
| 10018 | hdd_info("using MAC address from platform driver"); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10019 | return; |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10020 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10021 | |
| 10022 | status = hdd_update_mac_config(hdd_ctx); |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10023 | if (QDF_IS_STATUS_SUCCESS(status)) { |
| 10024 | hdd_info("using MAC address from wlan_mac.bin"); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10025 | return; |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10026 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10027 | |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10028 | hdd_info("using default MAC address"); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10029 | |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 10030 | if (hdd_ctx->update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10031 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10032 | if (ret) |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 10033 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10034 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10035 | } |
| 10036 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10037 | static int hdd_set_smart_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10038 | { |
| 10039 | int vdev_id = 0; |
| 10040 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
| 10041 | int value = hdd_ctx->config->smart_chainmask_enabled; |
| 10042 | int vpdev = PDEV_CMD; |
| 10043 | int ret; |
| 10044 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 10045 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10046 | if (ret) |
| 10047 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 10048 | |
| 10049 | return ret; |
| 10050 | } |
| 10051 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10052 | static int hdd_set_alternative_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10053 | { |
| 10054 | int vdev_id = 0; |
| 10055 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
| 10056 | int value = hdd_ctx->config->alternative_chainmask_enabled; |
| 10057 | int vpdev = PDEV_CMD; |
| 10058 | int ret; |
| 10059 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 10060 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10061 | if (ret) |
| 10062 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 10063 | ret); |
| 10064 | |
| 10065 | return ret; |
| 10066 | } |
| 10067 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10068 | static int hdd_set_ani_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10069 | { |
| 10070 | int vdev_id = 0; |
| 10071 | int param_id = WMI_PDEV_PARAM_ANI_ENABLE; |
| 10072 | int value = hdd_ctx->config->ani_enabled; |
| 10073 | int vpdev = PDEV_CMD; |
| 10074 | int ret; |
| 10075 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 10076 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10077 | if (ret) |
| 10078 | hdd_err("WMI_PDEV_PARAM_ANI_ENABLE failed %d", ret); |
| 10079 | |
| 10080 | return ret; |
| 10081 | } |
| 10082 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 10083 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10084 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 10085 | * @hdd_ctx: HDD context |
| 10086 | * |
| 10087 | * Pre configurations to be done at lower layer before calling cds enable. |
| 10088 | * |
| 10089 | * Return: 0 on success and errno on failure. |
| 10090 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10091 | static int hdd_pre_enable_configure(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10092 | { |
| 10093 | int ret; |
| 10094 | QDF_STATUS status; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 10095 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10096 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 10097 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Ajit Pal Singh | 5d26961 | 2018-04-19 16:29:12 +0530 | [diff] [blame] | 10098 | /* Register HL netdev flow control callback */ |
| 10099 | cdp_hl_fc_register(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10100 | /* |
| 10101 | * Set 802.11p config |
| 10102 | * TODO-OCB: This has been temporarily added here to ensure this |
| 10103 | * parameter is set in CSR when we init the channel list. This should |
| 10104 | * be removed once the 5.9 GHz channels are added to the regulatory |
| 10105 | * domain. |
| 10106 | */ |
| 10107 | hdd_set_dot11p_config(hdd_ctx); |
| 10108 | |
| 10109 | /* |
| 10110 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 10111 | * The cfg download must occur before we update the SME config |
| 10112 | * since the SME config operation must access the cfg database |
| 10113 | */ |
| 10114 | status = hdd_set_sme_config(hdd_ctx); |
| 10115 | |
| 10116 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10117 | hdd_err("Failed hdd_set_sme_config: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10118 | ret = qdf_status_to_os_return(status); |
| 10119 | goto out; |
| 10120 | } |
| 10121 | |
Tushnim Bhattacharyya | ba8ee93 | 2017-03-23 09:27:40 -0700 | [diff] [blame] | 10122 | status = hdd_set_policy_mgr_user_cfg(hdd_ctx); |
| 10123 | if (QDF_STATUS_SUCCESS != status) { |
| 10124 | hdd_alert("Failed hdd_set_policy_mgr_user_cfg: %d", status); |
| 10125 | ret = qdf_status_to_os_return(status); |
| 10126 | goto out; |
| 10127 | } |
| 10128 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 10129 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS, |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10130 | hdd_ctx->config->tx_chain_mask_1ss, |
| 10131 | PDEV_CMD); |
| 10132 | if (0 != ret) { |
| 10133 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 10134 | goto out; |
| 10135 | } |
| 10136 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10137 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 10138 | if (ret) |
| 10139 | goto out; |
| 10140 | |
| 10141 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 10142 | if (ret) |
| 10143 | goto out; |
| 10144 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10145 | ret = hdd_set_ani_enabled(hdd_ctx); |
| 10146 | if (ret) |
| 10147 | goto out; |
| 10148 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 10149 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 10150 | hdd_ctx->config->arp_ac_category, |
| 10151 | PDEV_CMD); |
| 10152 | if (0 != ret) { |
| 10153 | hdd_err("WMI_PDEV_PARAM_ARP_AC_OVERRIDE ac: %d ret: %d", |
| 10154 | hdd_ctx->config->arp_ac_category, ret); |
| 10155 | goto out; |
| 10156 | } |
| 10157 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10158 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 10159 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10160 | hdd_err("Failed to init channel list: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10161 | ret = qdf_status_to_os_return(status); |
| 10162 | goto out; |
| 10163 | } |
| 10164 | |
| 10165 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 10166 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10167 | hdd_err("config update failed"); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10168 | ret = -EINVAL; |
| 10169 | goto out; |
| 10170 | } |
| 10171 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10172 | /* |
| 10173 | * Set the MAC Address Currently this is used by HAL to add self sta. |
| 10174 | * Remove this once self sta is added as part of session open. |
| 10175 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10176 | status = sme_cfg_set_str(hdd_ctx->mac_handle, WNI_CFG_STA_ID, |
Jeff Johnson | bae59f9 | 2018-06-01 17:05:43 -0700 | [diff] [blame] | 10177 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 10178 | sizeof(hdd_ctx->config->intfMacAddr[0])); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10179 | |
Jeff Johnson | bae59f9 | 2018-06-01 17:05:43 -0700 | [diff] [blame] | 10180 | if (QDF_IS_STATUS_ERROR(status)) { |
| 10181 | hdd_err("Failed to set MAC Address, status %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10182 | ret = -EINVAL; |
| 10183 | goto out; |
| 10184 | } |
| 10185 | |
| 10186 | hdd_init_channel_avoidance(hdd_ctx); |
| 10187 | |
Ganesh Kondabattini | 408fb8d | 2017-08-08 22:00:20 +0530 | [diff] [blame] | 10188 | /* update enable sap mandatory chan list */ |
| 10189 | policy_mgr_enable_disable_sap_mandatory_chan_list(hdd_ctx->hdd_psoc, |
| 10190 | hdd_ctx->config->enable_sap_mandatory_chan_list); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10191 | out: |
| 10192 | return ret; |
| 10193 | } |
| 10194 | |
| 10195 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10196 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10197 | * @context: context registered with sme_register_p2p_lo_event(). HDD |
| 10198 | * always registers a hdd context pointer |
| 10199 | * @evt:event structure pointer |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10200 | * |
| 10201 | * This is the p2p listen offload stop event handler, it sends vendor |
| 10202 | * event back to supplicant to notify the stop reason. |
| 10203 | * |
| 10204 | * Return: None |
| 10205 | */ |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10206 | static void wlan_hdd_p2p_lo_event_callback(void *context, |
| 10207 | struct sir_p2p_lo_event *evt) |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10208 | { |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10209 | struct hdd_context *hdd_ctx = context; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10210 | struct sk_buff *vendor_event; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10211 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10212 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10213 | hdd_enter(); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10214 | |
| 10215 | if (hdd_ctx == NULL) { |
| 10216 | hdd_err("Invalid HDD context pointer"); |
| 10217 | return; |
| 10218 | } |
| 10219 | |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10220 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id); |
| 10221 | if (!adapter) { |
| 10222 | hdd_err("Cannot find adapter by vdev_id = %d", |
| 10223 | evt->vdev_id); |
| 10224 | return; |
| 10225 | } |
| 10226 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10227 | vendor_event = |
| 10228 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10229 | &(adapter->wdev), sizeof(uint32_t) + NLMSG_HDRLEN, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10230 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 10231 | GFP_KERNEL); |
| 10232 | |
| 10233 | if (!vendor_event) { |
| 10234 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 10235 | return; |
| 10236 | } |
| 10237 | |
| 10238 | if (nla_put_u32(vendor_event, |
| 10239 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 10240 | evt->reason_code)) { |
| 10241 | hdd_err("nla put failed"); |
| 10242 | kfree_skb(vendor_event); |
| 10243 | return; |
| 10244 | } |
| 10245 | |
| 10246 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10247 | hdd_debug("Sent P2P_LISTEN_OFFLOAD_STOP event for vdev_id = %d", |
| 10248 | evt->vdev_id); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10249 | } |
| 10250 | |
Rachit Kankane | f6834c4 | 2018-08-02 18:47:50 +0530 | [diff] [blame^] | 10251 | #ifdef FEATURE_WLAN_DYNAMIC_CVM |
| 10252 | static inline int hdd_set_vc_mode_config(struct hdd_context *hdd_ctx) |
| 10253 | { |
| 10254 | return sme_set_vc_mode_config(hdd_ctx->config->vc_mode_cfg_bitmap); |
| 10255 | } |
| 10256 | #else |
| 10257 | static inline int hdd_set_vc_mode_config(struct hdd_context *hdd_ctx) |
| 10258 | { |
| 10259 | return QDF_STATUS_SUCCESS; |
| 10260 | } |
| 10261 | #endif |
| 10262 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10263 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10264 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 10265 | * @hdd_ctx: HDD context |
| 10266 | * |
| 10267 | * This function sends the adaptive dwell time config configuration to the |
| 10268 | * firmware via WMA |
| 10269 | * |
| 10270 | * Return: 0 - success, < 0 - failure |
| 10271 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10272 | static int hdd_adaptive_dwelltime_init(struct hdd_context *hdd_ctx) |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10273 | { |
| 10274 | QDF_STATUS status; |
| 10275 | struct adaptive_dwelltime_params dwelltime_params; |
| 10276 | |
| 10277 | dwelltime_params.is_enabled = |
| 10278 | hdd_ctx->config->adaptive_dwell_mode_enabled; |
| 10279 | dwelltime_params.dwelltime_mode = |
| 10280 | hdd_ctx->config->global_adapt_dwelltime_mode; |
| 10281 | dwelltime_params.lpf_weight = |
| 10282 | hdd_ctx->config->adapt_dwell_lpf_weight; |
| 10283 | dwelltime_params.passive_mon_intval = |
| 10284 | hdd_ctx->config->adapt_dwell_passive_mon_intval; |
| 10285 | dwelltime_params.wifi_act_threshold = |
| 10286 | hdd_ctx->config->adapt_dwell_wifi_act_threshold; |
| 10287 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10288 | status = sme_set_adaptive_dwelltime_config(hdd_ctx->mac_handle, |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10289 | &dwelltime_params); |
| 10290 | |
| 10291 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 10292 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10293 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 10294 | return -EAGAIN; |
| 10295 | } |
| 10296 | return 0; |
| 10297 | } |
| 10298 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10299 | int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10300 | { |
| 10301 | QDF_STATUS status; |
| 10302 | struct wmi_dbs_scan_sel_params dbs_scan_params; |
| 10303 | uint32_t i = 0; |
| 10304 | uint8_t count = 0, numentries = 0; |
| 10305 | uint8_t dbs_scan_config[CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 10306 | * CDS_DBS_SCAN_CLIENTS_MAX]; |
| 10307 | |
| 10308 | /* check if DBS is enabled or supported */ |
Bala Venkatesh | c8236ca | 2018-03-09 12:38:29 +0530 | [diff] [blame] | 10309 | if ((hdd_ctx->config->dual_mac_feature_disable == |
| 10310 | DISABLE_DBS_CXN_AND_SCAN) || |
| 10311 | (hdd_ctx->config->dual_mac_feature_disable == |
| 10312 | ENABLE_DBS_CXN_AND_DISABLE_DBS_SCAN)) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10313 | return -EINVAL; |
| 10314 | |
| 10315 | hdd_string_to_u8_array(hdd_ctx->config->dbs_scan_selection, |
| 10316 | dbs_scan_config, &numentries, |
| 10317 | (CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 10318 | * CDS_DBS_SCAN_CLIENTS_MAX)); |
| 10319 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10320 | if (!numentries) { |
Dustin Brown | 6a8d39b | 2018-08-14 15:27:26 -0700 | [diff] [blame] | 10321 | hdd_debug("Do not send scan_selection_config"); |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10322 | return 0; |
| 10323 | } |
| 10324 | |
| 10325 | /* hdd_set_fw_log_params */ |
| 10326 | dbs_scan_params.num_clients = 0; |
| 10327 | while (count < (numentries - 2)) { |
| 10328 | dbs_scan_params.module_id[i] = dbs_scan_config[count]; |
| 10329 | dbs_scan_params.num_dbs_scans[i] = dbs_scan_config[count + 1]; |
| 10330 | dbs_scan_params.num_non_dbs_scans[i] = |
| 10331 | dbs_scan_config[count + 2]; |
| 10332 | dbs_scan_params.num_clients++; |
| 10333 | hdd_debug("module:%d NDS:%d NNDS:%d", |
| 10334 | dbs_scan_params.module_id[i], |
| 10335 | dbs_scan_params.num_dbs_scans[i], |
| 10336 | dbs_scan_params.num_non_dbs_scans[i]); |
| 10337 | count += CDS_DBS_SCAN_PARAM_PER_CLIENT; |
| 10338 | i++; |
| 10339 | } |
| 10340 | |
| 10341 | dbs_scan_params.pdev_id = 0; |
| 10342 | |
| 10343 | hdd_debug("clients:%d pdev:%d", |
| 10344 | dbs_scan_params.num_clients, dbs_scan_params.pdev_id); |
| 10345 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10346 | status = sme_set_dbs_scan_selection_config(hdd_ctx->mac_handle, |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10347 | &dbs_scan_params); |
| 10348 | hdd_debug("Sending DBS Scan Selection Configuration to fw"); |
| 10349 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10350 | hdd_err("Failed to send DBS Scan selection configuration!"); |
| 10351 | return -EAGAIN; |
| 10352 | } |
| 10353 | return 0; |
| 10354 | } |
| 10355 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10356 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 10357 | /** |
| 10358 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 10359 | * @hdd_ctx: HDD context |
| 10360 | * |
| 10361 | * Set auto shutdown callback to get indications from firmware to indicate |
| 10362 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 10363 | * |
| 10364 | * Return: 0 on success and errno on failure. |
| 10365 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10366 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10367 | { |
| 10368 | QDF_STATUS status; |
| 10369 | |
| 10370 | if (!hdd_ctx->config->WlanAutoShutdown) |
| 10371 | return 0; |
| 10372 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10373 | status = sme_set_auto_shutdown_cb(hdd_ctx->mac_handle, |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10374 | wlan_hdd_auto_shutdown_cb); |
| 10375 | if (status != QDF_STATUS_SUCCESS) |
| 10376 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 10377 | status); |
| 10378 | |
| 10379 | return qdf_status_to_os_return(status); |
| 10380 | } |
| 10381 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10382 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10383 | { |
| 10384 | return 0; |
| 10385 | } |
| 10386 | #endif |
| 10387 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10388 | #ifdef MWS_COEX |
| 10389 | /** |
| 10390 | * hdd_set_mws_coex() - Set MWS coex configurations |
| 10391 | * @hdd_ctx: HDD context |
| 10392 | * |
| 10393 | * This function sends MWS-COEX 4G quick FTDM and |
| 10394 | * MWS-COEX 5G-NR power limit to FW |
| 10395 | * |
| 10396 | * Return: 0 on success and errno on failure. |
| 10397 | */ |
| 10398 | static int hdd_init_mws_coex(struct hdd_context *hdd_ctx) |
| 10399 | { |
| 10400 | int ret = 0; |
| 10401 | |
| 10402 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_MWSCOEX_4G_ALLOW_QUICK_FTDM, |
| 10403 | hdd_ctx->config->mws_coex_4g_quick_tdm, |
| 10404 | PDEV_CMD); |
| 10405 | if (ret) { |
| 10406 | hdd_warn("Unable to send MWS-COEX 4G quick FTDM policy"); |
| 10407 | return ret; |
| 10408 | } |
| 10409 | |
| 10410 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_MWSCOEX_SET_5GNR_PWR_LIMIT, |
| 10411 | hdd_ctx->config->mws_coex_5g_nr_pwr_limit, |
| 10412 | PDEV_CMD); |
| 10413 | if (ret) { |
| 10414 | hdd_warn("Unable to send MWS-COEX 4G quick FTDM policy"); |
| 10415 | return ret; |
| 10416 | } |
| 10417 | return ret; |
| 10418 | } |
| 10419 | #else |
| 10420 | static int hdd_init_mws_coex(struct hdd_context *hdd_ctx) |
| 10421 | { |
| 10422 | return 0; |
| 10423 | } |
| 10424 | #endif |
| 10425 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10426 | /** |
| 10427 | * hdd_features_init() - Init features |
| 10428 | * @hdd_ctx: HDD context |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10429 | * |
| 10430 | * Initialize features and their feature context after WLAN firmware is up. |
| 10431 | * |
| 10432 | * Return: 0 on success and errno on failure. |
| 10433 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10434 | static int hdd_features_init(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10435 | { |
| 10436 | tSirTxPowerLimit hddtxlimit; |
| 10437 | QDF_STATUS status; |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 10438 | struct sme_5g_band_pref_params band_pref_params; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10439 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10440 | mac_handle_t mac_handle; |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 10441 | struct hdd_config *cfg; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10442 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10443 | hdd_enter(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10444 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10445 | ret = hdd_init_mws_coex(hdd_ctx); |
| 10446 | if (ret) |
| 10447 | hdd_warn("Error initializing mws-coex"); |
| 10448 | |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 10449 | cfg = hdd_ctx->config; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10450 | /* FW capabilities received, Set the Dot11 mode */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10451 | mac_handle = hdd_ctx->mac_handle; |
| 10452 | sme_setdef_dot11mode(mac_handle); |
| 10453 | sme_set_prefer_80MHz_over_160MHz(mac_handle, |
Kiran Kumar Lokere | 1aa9c9a | 2016-10-05 18:50:59 -0700 | [diff] [blame] | 10454 | hdd_ctx->config->sta_prefer_80MHz_over_160MHz); |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 10455 | sme_set_etsi13_srd_ch_in_master_mode(mac_handle, |
| 10456 | cfg-> |
| 10457 | etsi13_srd_chan_in_master_mode); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10458 | |
| 10459 | if (hdd_ctx->config->fIsImpsEnabled) |
| 10460 | hdd_set_idle_ps_config(hdd_ctx, true); |
| 10461 | else |
| 10462 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 10463 | |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 10464 | /* Send Enable/Disable data stall detection cmd to FW */ |
| 10465 | sme_cli_set_command(0, WMI_PDEV_PARAM_DATA_STALL_DETECT_ENABLE, |
| 10466 | hdd_ctx->config->enable_data_stall_det, PDEV_CMD); |
| 10467 | |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 10468 | if (hdd_ctx->config->enable_go_cts2self_for_sta) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10469 | sme_set_cts2self_for_p2p_go(mac_handle); |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 10470 | |
Rachit Kankane | f6834c4 | 2018-08-02 18:47:50 +0530 | [diff] [blame^] | 10471 | if (hdd_set_vc_mode_config(hdd_ctx)) |
Nachiket Kukade | 8983cf6 | 2017-10-12 18:14:48 +0530 | [diff] [blame] | 10472 | hdd_warn("Error in setting Voltage Corner mode config to FW"); |
| 10473 | |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10474 | if (hdd_rx_ol_init(hdd_ctx)) |
| 10475 | hdd_err("Unable to initialize Rx LRO/GRO in fw"); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10476 | |
| 10477 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 10478 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 10479 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10480 | if (hdd_dbs_scan_selection_init(hdd_ctx)) |
| 10481 | hdd_err("Unable to send DBS scan selection setting to FW"); |
| 10482 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10483 | ret = hdd_init_thermal_info(hdd_ctx); |
| 10484 | if (ret) { |
| 10485 | hdd_err("Error while initializing thermal information"); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10486 | return ret; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10487 | } |
| 10488 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10489 | /** |
| 10490 | * In case of SSR/PDR, if pktlog was enabled manually before |
| 10491 | * SSR/PDR, Then enabled it again automatically after Wlan |
| 10492 | * device up. |
| 10493 | */ |
| 10494 | if (cds_is_driver_recovering()) { |
| 10495 | if (hdd_ctx->is_pktlog_enabled) |
| 10496 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
Alok Kumar | 5a75b9d | 2018-08-31 10:55:43 +0530 | [diff] [blame] | 10497 | } else if (cds_is_packet_log_enabled()) |
| 10498 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 10499 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10500 | hddtxlimit.txPower2g = hdd_ctx->config->TxPower2g; |
| 10501 | hddtxlimit.txPower5g = hdd_ctx->config->TxPower5g; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10502 | status = sme_txpower_limit(mac_handle, &hddtxlimit); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10503 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10504 | hdd_err("Error setting txlimit in sme: %d", status); |
| 10505 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10506 | wlan_hdd_tsf_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10507 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10508 | ret = hdd_register_cb(hdd_ctx); |
| 10509 | if (ret) { |
| 10510 | hdd_err("Failed to register HDD callbacks!"); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10511 | return ret; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10512 | } |
| 10513 | |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 10514 | if (hdd_ctx->config->goptimize_chan_avoid_event) { |
| 10515 | status = sme_enable_disable_chanavoidind_event( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10516 | mac_handle, 0); |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 10517 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10518 | hdd_err("Failed to disable Chan Avoidance Indication"); |
| 10519 | goto deregister_cb; |
| 10520 | } |
| 10521 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10522 | |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 10523 | if (hdd_ctx->config->enable_5g_band_pref) { |
| 10524 | band_pref_params.rssi_boost_threshold_5g = |
| 10525 | hdd_ctx->config->rssi_boost_threshold_5g; |
| 10526 | band_pref_params.rssi_boost_factor_5g = |
| 10527 | hdd_ctx->config->rssi_boost_factor_5g; |
| 10528 | band_pref_params.max_rssi_boost_5g = |
| 10529 | hdd_ctx->config->max_rssi_boost_5g; |
| 10530 | band_pref_params.rssi_penalize_threshold_5g = |
| 10531 | hdd_ctx->config->rssi_penalize_threshold_5g; |
| 10532 | band_pref_params.rssi_penalize_factor_5g = |
| 10533 | hdd_ctx->config->rssi_penalize_factor_5g; |
| 10534 | band_pref_params.max_rssi_penalize_5g = |
| 10535 | hdd_ctx->config->max_rssi_penalize_5g; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10536 | sme_set_5g_band_pref(mac_handle, &band_pref_params); |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 10537 | } |
| 10538 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10539 | /* register P2P Listen Offload event callback */ |
| 10540 | if (wma_is_p2p_lo_capable()) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10541 | sme_register_p2p_lo_event(mac_handle, hdd_ctx, |
| 10542 | wlan_hdd_p2p_lo_event_callback); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10543 | |
| 10544 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 10545 | |
| 10546 | if (ret) |
| 10547 | goto deregister_cb; |
| 10548 | |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10549 | wlan_hdd_init_chan_info(hdd_ctx); |
Varun Reddy Yeturu | 3c9f89c | 2018-04-18 19:10:34 -0700 | [diff] [blame] | 10550 | wlan_hdd_twt_init(hdd_ctx); |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10551 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10552 | hdd_exit(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10553 | return 0; |
| 10554 | |
| 10555 | deregister_cb: |
| 10556 | hdd_deregister_cb(hdd_ctx); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10557 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10558 | return -EINVAL; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10559 | } |
| 10560 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10561 | /** |
| 10562 | * hdd_features_deinit() - Deinit features |
| 10563 | * @hdd_ctx: HDD context |
| 10564 | * |
| 10565 | * De-Initialize features and their feature context. |
| 10566 | * |
| 10567 | * Return: none. |
| 10568 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10569 | static void hdd_features_deinit(struct hdd_context *hdd_ctx) |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10570 | { |
Varun Reddy Yeturu | 3c9f89c | 2018-04-18 19:10:34 -0700 | [diff] [blame] | 10571 | wlan_hdd_twt_deinit(hdd_ctx); |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10572 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10573 | wlan_hdd_tsf_deinit(hdd_ctx); |
| 10574 | } |
| 10575 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10576 | /** |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10577 | * hdd_register_bcn_cb() - register scan beacon callback |
| 10578 | * @hdd_ctx - Pointer to the HDD context |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10579 | * |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10580 | * Return: QDF_STATUS |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10581 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10582 | 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] | 10583 | { |
| 10584 | QDF_STATUS status; |
| 10585 | |
| 10586 | status = ucfg_scan_register_bcn_cb(hdd_ctx->hdd_psoc, |
| 10587 | wlan_cfg80211_inform_bss_frame, |
| 10588 | SCAN_CB_TYPE_INFORM_BCN); |
| 10589 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10590 | hdd_err("failed with status code %08d [x%08x]", |
| 10591 | status, status); |
| 10592 | return status; |
| 10593 | } |
| 10594 | |
| 10595 | return QDF_STATUS_SUCCESS; |
| 10596 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10597 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10598 | /** |
Manjunathappa Prakash | a0cbc92 | 2018-05-08 19:48:34 -0700 | [diff] [blame] | 10599 | * hdd_v2_flow_pool_map() - Flow pool create callback when vdev is active |
| 10600 | * @vdev_id: vdev_id, corresponds to flow_pool |
| 10601 | * |
| 10602 | * Return: none. |
| 10603 | */ |
| 10604 | static void hdd_v2_flow_pool_map(int vdev_id) |
| 10605 | { |
| 10606 | QDF_STATUS status; |
| 10607 | |
| 10608 | status = cdp_flow_pool_map(cds_get_context(QDF_MODULE_ID_SOC), |
| 10609 | cds_get_context(QDF_MODULE_ID_TXRX), |
| 10610 | vdev_id); |
| 10611 | /* |
| 10612 | * For Adrastea flow control v2 is based on FW MAP events, |
| 10613 | * so this above callback is not implemented. |
| 10614 | * Hence this is not actual failure. Dont return failure |
| 10615 | */ |
| 10616 | if ((status != QDF_STATUS_SUCCESS) && |
| 10617 | (status != QDF_STATUS_E_INVAL)) { |
| 10618 | hdd_err("vdev_id: %d, failed to create flow pool status %d", |
| 10619 | vdev_id, status); |
| 10620 | } |
| 10621 | } |
| 10622 | |
| 10623 | /** |
| 10624 | * hdd_v2_flow_pool_unmap() - Flow pool create callback when vdev is not active |
| 10625 | * @vdev_id: vdev_id, corresponds to flow_pool |
| 10626 | * |
| 10627 | * Return: none. |
| 10628 | */ |
| 10629 | static void hdd_v2_flow_pool_unmap(int vdev_id) |
| 10630 | { |
| 10631 | cdp_flow_pool_unmap(cds_get_context(QDF_MODULE_ID_SOC), |
| 10632 | cds_get_context(QDF_MODULE_ID_TXRX), vdev_id); |
| 10633 | } |
| 10634 | |
| 10635 | /** |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 10636 | * hdd_action_oui_config() - Configure action_oui strings |
| 10637 | * @hdd_ctx: pointer to hdd context |
| 10638 | * |
| 10639 | * This is a HDD wrapper function which invokes ucfg api |
| 10640 | * of action_oui component to parse action oui strings. |
| 10641 | * |
| 10642 | * Return: None |
| 10643 | */ |
| 10644 | static void hdd_action_oui_config(struct hdd_context *hdd_ctx) |
| 10645 | { |
| 10646 | QDF_STATUS status; |
| 10647 | uint32_t id; |
| 10648 | uint8_t *str; |
| 10649 | |
| 10650 | if (!hdd_ctx->config->action_oui_enable) |
| 10651 | return; |
| 10652 | |
| 10653 | for (id = 0; id < ACTION_OUI_MAXIMUM_ID; id++) { |
| 10654 | str = hdd_ctx->config->action_oui_str[id]; |
| 10655 | if (!qdf_str_len(str)) |
| 10656 | continue; |
| 10657 | |
| 10658 | status = ucfg_action_oui_parse(hdd_ctx->hdd_psoc, str, id); |
| 10659 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10660 | hdd_err("Failed to parse action_oui str: %u", id); |
| 10661 | } |
| 10662 | } |
| 10663 | |
| 10664 | /** |
| 10665 | * hdd_action_oui_send() - Send action_oui extensions to firmware |
| 10666 | * @hdd_ctx: pointer to hdd context |
| 10667 | * |
| 10668 | * This is a HDD wrapper function which invokes ucfg api |
| 10669 | * of action_oui component to send action oui extensions to firmware. |
| 10670 | * |
| 10671 | * Return: None |
| 10672 | */ |
| 10673 | static void hdd_action_oui_send(struct hdd_context *hdd_ctx) |
| 10674 | { |
| 10675 | QDF_STATUS status; |
| 10676 | |
| 10677 | if (!hdd_ctx->config->action_oui_enable) |
| 10678 | return; |
| 10679 | |
| 10680 | status = ucfg_action_oui_send(hdd_ctx->hdd_psoc); |
| 10681 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10682 | hdd_err("Failed to send one or all action_ouis"); |
| 10683 | } |
| 10684 | |
| 10685 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10686 | * hdd_configure_cds() - Configure cds modules |
| 10687 | * @hdd_ctx: HDD context |
| 10688 | * @adapter: Primary adapter context |
| 10689 | * |
| 10690 | * Enable Cds modules after WLAN firmware is up. |
| 10691 | * |
| 10692 | * Return: 0 on success and errno on failure. |
| 10693 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10694 | int hdd_configure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10695 | { |
| 10696 | int ret; |
| 10697 | QDF_STATUS status; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10698 | int set_value; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10699 | mac_handle_t mac_handle; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10700 | uint32_t num_abg_tx_chains = 0; |
| 10701 | uint32_t num_11b_tx_chains = 0; |
| 10702 | uint32_t num_11ag_tx_chains = 0; |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10703 | struct policy_mgr_dp_cbacks dp_cbs = {0}; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10704 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10705 | mac_handle = hdd_ctx->mac_handle; |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 10706 | |
| 10707 | hdd_action_oui_send(hdd_ctx); |
| 10708 | |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10709 | if (hdd_ctx->config->is_force_1x1) |
| 10710 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_SET_IOT_PATTERN, |
| 10711 | 1, PDEV_CMD); |
| 10712 | /* set chip power save failure detected callback */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10713 | sme_set_chip_pwr_save_fail_cb(mac_handle, |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10714 | hdd_chip_pwr_save_fail_detected_cb); |
| 10715 | |
| 10716 | if (hdd_ctx->config->max_mpdus_inampdu) { |
| 10717 | set_value = hdd_ctx->config->max_mpdus_inampdu; |
| 10718 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_MAX_MPDUS_IN_AMPDU, |
| 10719 | set_value, PDEV_CMD); |
| 10720 | } |
| 10721 | |
| 10722 | if (hdd_ctx->config->enable_rts_sifsbursting) { |
| 10723 | set_value = hdd_ctx->config->enable_rts_sifsbursting; |
| 10724 | sme_cli_set_command(0, |
| 10725 | (int)WMI_PDEV_PARAM_ENABLE_RTS_SIFS_BURSTING, |
| 10726 | set_value, PDEV_CMD); |
| 10727 | } |
| 10728 | |
| 10729 | if (hdd_ctx->config->sap_get_peer_info) { |
| 10730 | set_value = hdd_ctx->config->sap_get_peer_info; |
| 10731 | sme_cli_set_command(0, |
| 10732 | (int)WMI_PDEV_PARAM_PEER_STATS_INFO_ENABLE, |
| 10733 | set_value, PDEV_CMD); |
| 10734 | } |
| 10735 | |
| 10736 | num_11b_tx_chains = hdd_ctx->config->num_11b_tx_chains; |
| 10737 | num_11ag_tx_chains = hdd_ctx->config->num_11ag_tx_chains; |
| 10738 | if (!hdd_ctx->config->enable2x2) { |
| 10739 | if (num_11b_tx_chains > 1) |
| 10740 | num_11b_tx_chains = 1; |
| 10741 | if (num_11ag_tx_chains > 1) |
| 10742 | num_11ag_tx_chains = 1; |
| 10743 | } |
| 10744 | WMI_PDEV_PARAM_SET_11B_TX_CHAIN_NUM(num_abg_tx_chains, |
| 10745 | num_11b_tx_chains); |
| 10746 | WMI_PDEV_PARAM_SET_11AG_TX_CHAIN_NUM(num_abg_tx_chains, |
| 10747 | num_11ag_tx_chains); |
| 10748 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_ABG_MODE_TX_CHAIN_NUM, |
| 10749 | num_abg_tx_chains, PDEV_CMD); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10750 | |
| 10751 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 10752 | if (ret) { |
| 10753 | hdd_err("Failed to pre-configure cds"); |
| 10754 | goto out; |
| 10755 | } |
| 10756 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 10757 | /* Always get latest IPA resources allocated from cds_open and configure |
| 10758 | * IPA module before configuring them to FW. Sequence required as crash |
| 10759 | * observed otherwise. |
| 10760 | */ |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 10761 | if (ucfg_ipa_uc_ol_init(hdd_ctx->hdd_pdev, |
| 10762 | cds_get_context(QDF_MODULE_ID_QDF_DEVICE))) { |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 10763 | hdd_err("Failed to setup pipes"); |
| 10764 | goto out; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 10765 | } |
| 10766 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10767 | /* |
| 10768 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 10769 | * else |
| 10770 | */ |
Jeff Johnson | 8f9dd5f | 2017-09-13 14:16:08 -0700 | [diff] [blame] | 10771 | status = cds_enable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10772 | |
| 10773 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10774 | hdd_err("cds_enable failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10775 | goto out; |
| 10776 | } |
| 10777 | |
| 10778 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 10779 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10780 | hdd_err("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10781 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10782 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10783 | status = hdd_register_bcn_cb(hdd_ctx); |
| 10784 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 10785 | hdd_err("hdd_register_bcn_cb failed"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10786 | goto cds_disable; |
| 10787 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10788 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10789 | ret = hdd_features_init(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10790 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10791 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10792 | |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10793 | if (hdd_ctx->ol_enable) |
| 10794 | dp_cbs.hdd_disable_rx_ol_in_concurrency = |
| 10795 | hdd_disable_rx_ol_in_concurrency; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 10796 | dp_cbs.hdd_set_rx_mode_rps_cb = hdd_set_rx_mode_rps; |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 10797 | 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] | 10798 | dp_cbs.hdd_v2_flow_pool_map = hdd_v2_flow_pool_map; |
| 10799 | dp_cbs.hdd_v2_flow_pool_unmap = hdd_v2_flow_pool_unmap; |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10800 | status = policy_mgr_register_dp_cb(hdd_ctx->hdd_psoc, &dp_cbs); |
| 10801 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 10802 | hdd_debug("Failed to register DP cb with Policy Manager"); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10803 | goto cds_disable; |
| 10804 | } |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 10805 | status = policy_mgr_register_mode_change_cb(hdd_ctx->hdd_psoc, |
| 10806 | wlan_hdd_send_mode_change_event); |
| 10807 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10808 | hdd_debug("Failed to register mode change cb with Policy Manager"); |
| 10809 | goto cds_disable; |
| 10810 | } |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10811 | |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 10812 | if (hdd_green_ap_enable_egap(hdd_ctx)) |
Nachiket Kukade | fbd1afc | 2017-07-12 17:41:54 +0530 | [diff] [blame] | 10813 | hdd_debug("enhance green ap is not enabled"); |
| 10814 | |
Nachiket Kukade | dd30266 | 2017-07-13 17:31:44 +0530 | [diff] [blame] | 10815 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 10816 | hdd_debug("Failed to set wow pulse"); |
| 10817 | |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 10818 | sme_cli_set_command(0, WMI_PDEV_PARAM_GCMP_SUPPORT_ENABLE, |
| 10819 | hdd_ctx->config->gcmp_enabled, PDEV_CMD); |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 10820 | sme_cli_set_command(0, WMI_PDEV_AUTO_DETECT_POWER_FAILURE, |
| 10821 | hdd_ctx->config->auto_pwr_save_fail_mode, PDEV_CMD); |
| 10822 | |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 10823 | |
| 10824 | if (hdd_ctx->config->enable_phy_reg_retention) |
| 10825 | wma_cli_set_command(0, WMI_PDEV_PARAM_FAST_PWR_TRANSITION, |
| 10826 | hdd_ctx->config->enable_phy_reg_retention, PDEV_CMD); |
| 10827 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10828 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10829 | |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10830 | cds_disable: |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 10831 | cds_disable(hdd_ctx->hdd_psoc); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10832 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10833 | out: |
| 10834 | return -EINVAL; |
| 10835 | } |
| 10836 | |
| 10837 | /** |
| 10838 | * hdd_deconfigure_cds() -De-Configure cds |
| 10839 | * @hdd_ctx: HDD context |
| 10840 | * |
| 10841 | * Deconfigure Cds modules before WLAN firmware is down. |
| 10842 | * |
| 10843 | * Return: 0 on success and errno on failure. |
| 10844 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10845 | static int hdd_deconfigure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10846 | { |
| 10847 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10848 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10849 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10850 | hdd_enter(); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10851 | |
| 10852 | /* De-init features */ |
| 10853 | hdd_features_deinit(hdd_ctx); |
| 10854 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10855 | /* De-register the SME callbacks */ |
| 10856 | hdd_deregister_cb(hdd_ctx); |
| 10857 | |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 10858 | qdf_status = policy_mgr_deregister_mode_change_cb(hdd_ctx->hdd_psoc); |
| 10859 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10860 | hdd_debug("Failed to deregister mode change cb with Policy Manager"); |
| 10861 | } |
| 10862 | |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 10863 | qdf_status = cds_disable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10864 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10865 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 10866 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10867 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10868 | } |
| 10869 | |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 10870 | if (ucfg_ipa_uc_ol_deinit(hdd_ctx->hdd_pdev) != QDF_STATUS_SUCCESS) { |
Sravan Kumar Kairam | 7112171 | 2017-04-15 00:34:42 +0530 | [diff] [blame] | 10871 | hdd_err("Failed to disconnect pipes"); |
| 10872 | ret = -EINVAL; |
| 10873 | } |
| 10874 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10875 | hdd_exit(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10876 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10877 | } |
| 10878 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 10879 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 10880 | static void hdd_deregister_policy_manager_callback( |
| 10881 | struct wlan_objmgr_psoc *psoc) |
| 10882 | { |
| 10883 | if (QDF_STATUS_SUCCESS != |
| 10884 | policy_mgr_deregister_hdd_cb(psoc)) { |
| 10885 | hdd_err("HDD callback deregister with policy manager failed"); |
| 10886 | } |
| 10887 | } |
| 10888 | #else |
| 10889 | static void hdd_deregister_policy_manager_callback( |
| 10890 | struct wlan_objmgr_psoc *psoc) |
| 10891 | { |
| 10892 | } |
| 10893 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10894 | |
| 10895 | /** |
| 10896 | * hdd_wlan_stop_modules - Single driver state machine for stoping modules |
| 10897 | * @hdd_ctx: HDD context |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10898 | * @ftm_mode: ftm mode |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10899 | * |
| 10900 | * This function maintains the driver state machine it will be invoked from |
| 10901 | * exit, shutdown and con_mode change handler. Depending on the driver state |
| 10902 | * shall perform the stopping/closing of the modules. |
| 10903 | * |
| 10904 | * Return: 0 for success; non-zero for failure |
| 10905 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10906 | 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] | 10907 | { |
| 10908 | void *hif_ctx; |
| 10909 | qdf_device_t qdf_ctx; |
| 10910 | QDF_STATUS qdf_status; |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10911 | bool is_recovery_stop = cds_is_driver_recovering(); |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 10912 | int ret = 0; |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10913 | int active_threads; |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 10914 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10915 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10916 | hdd_enter(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10917 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 10918 | hdd_deregister_policy_manager_callback(hdd_ctx->hdd_psoc); |
| 10919 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10920 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 10921 | if (!qdf_ctx) { |
| 10922 | hdd_err("QDF device context NULL"); |
| 10923 | return -EINVAL; |
| 10924 | } |
| 10925 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10926 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 10927 | hdd_ctx->stop_modules_in_progress = true; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10928 | cds_set_module_stop_in_progress(true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10929 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10930 | active_threads = cds_return_external_threads_count(); |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10931 | if (active_threads > 0 || hdd_ctx->is_wiphy_suspended) { |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 10932 | hdd_warn("External threads %d wiphy suspend %d", |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10933 | active_threads, hdd_ctx->is_wiphy_suspended); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10934 | |
| 10935 | cds_print_external_threads(); |
| 10936 | |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 10937 | if (IS_IDLE_STOP && !ftm_mode) { |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10938 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 10939 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 10940 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10941 | hdd_prevent_suspend_timeout( |
| 10942 | hdd_ctx->config->iface_change_wait_time, |
| 10943 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10944 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10945 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 10946 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10947 | return 0; |
| 10948 | } |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 10949 | } |
| 10950 | |
Kabilan Kannan | 6edafeb | 2017-11-16 16:34:34 -0800 | [diff] [blame] | 10951 | /* free user wowl patterns */ |
| 10952 | hdd_free_user_wowl_ptrns(); |
| 10953 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10954 | switch (hdd_ctx->driver_status) { |
| 10955 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 10956 | hdd_debug("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10957 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10958 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 10959 | hdd_debug("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10960 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10961 | case DRIVER_MODULES_ENABLED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10962 | hdd_info("Wlan transitioning (OPENED <- ENABLED)"); |
| 10963 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 10964 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10965 | if (hdd_deconfigure_cds(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10966 | hdd_err("Failed to de-configure CDS"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10967 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10968 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10969 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10970 | hdd_debug("successfully Disabled the CDS modules!"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10971 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10972 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10973 | hdd_info("Wlan transitioned (now OPENED)"); |
| 10974 | |
| 10975 | /* fall through */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10976 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10977 | hdd_info("Wlan transitioning (CLOSED <- OPENED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10978 | break; |
| 10979 | default: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 10980 | QDF_DEBUG_PANIC("Unknown driver state:%d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10981 | hdd_ctx->driver_status); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10982 | ret = -EINVAL; |
| 10983 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10984 | } |
| 10985 | |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 10986 | hdd_sysfs_destroy_version_interface(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10987 | hdd_debug("Closing CDS modules!"); |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 10988 | |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 10989 | qdf_status = cds_post_disable(); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 10990 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10991 | hdd_err("Failed to process post CDS disable Modules! :%d", |
| 10992 | qdf_status); |
| 10993 | ret = -EINVAL; |
| 10994 | QDF_ASSERT(0); |
| 10995 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 10996 | |
psimha | deea0a1 | 2017-12-18 14:50:02 -0800 | [diff] [blame] | 10997 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
| 10998 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 10999 | qdf_status = cds_dp_close(hdd_ctx->hdd_psoc); |
| 11000 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11001 | hdd_warn("Failed to stop CDS DP: %d", qdf_status); |
| 11002 | ret = -EINVAL; |
| 11003 | QDF_ASSERT(0); |
| 11004 | } |
| 11005 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 11006 | qdf_status = cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11007 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11008 | hdd_warn("Failed to stop CDS: %d", qdf_status); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 11009 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11010 | QDF_ASSERT(0); |
| 11011 | } |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 11012 | |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 11013 | hdd_component_psoc_close(hdd_ctx->hdd_psoc); |
Amar Singhal | 410675c | 2018-01-10 12:14:21 -0800 | [diff] [blame] | 11014 | dispatcher_pdev_close(hdd_ctx->hdd_pdev); |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 11015 | ret = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 11016 | if (ret) { |
| 11017 | hdd_err("Failed to destroy pdev; errno:%d", ret); |
| 11018 | QDF_ASSERT(0); |
| 11019 | } |
| 11020 | |
| 11021 | /* |
| 11022 | * Reset total mac phy during module stop such that during |
| 11023 | * next module start same psoc is used to populate new service |
| 11024 | * ready data |
| 11025 | */ |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 11026 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->hdd_psoc); |
| 11027 | if (tgt_hdl) |
| 11028 | target_psoc_set_total_mac_phy_cnt(tgt_hdl, 0); |
| 11029 | |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 11030 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11031 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 11032 | if (!hif_ctx) { |
| 11033 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11034 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11035 | } |
| 11036 | |
Arunk Khandavalli | 4b40433 | 2017-09-26 12:46:00 +0530 | [diff] [blame] | 11037 | if (hdd_ctx->target_hw_name) { |
| 11038 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 11039 | hdd_ctx->target_hw_name = NULL; |
| 11040 | } |
| 11041 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 11042 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11043 | |
| 11044 | ol_cds_free(); |
| 11045 | |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 11046 | if (IS_IDLE_STOP && cds_is_target_ready()) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11047 | ret = pld_power_off(qdf_ctx->dev); |
| 11048 | if (ret) |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11049 | hdd_err("Failed to power down device; errno:%d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11050 | } |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11051 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11052 | /* Free the cache channels of the command SET_DISABLE_CHANNEL_LIST */ |
| 11053 | wlan_hdd_free_cache_channels(hdd_ctx); |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 11054 | |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 11055 | hdd_check_for_leaks(hdd_ctx, is_recovery_stop); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 11056 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11057 | |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 11058 | /* Once the firmware sequence is completed reset this flag */ |
| 11059 | hdd_ctx->imps_enabled = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11060 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11061 | hdd_info("Wlan transitioned (now CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11062 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11063 | done: |
| 11064 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 11065 | cds_set_module_stop_in_progress(false); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11066 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11067 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11068 | hdd_exit(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11069 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11070 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11071 | } |
| 11072 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11073 | |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11074 | #ifdef WLAN_FEATURE_MEMDUMP_ENABLE |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11075 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11076 | * hdd_state_info_dump() - prints state information of hdd layer |
| 11077 | * @buf: buffer pointer |
| 11078 | * @size: size of buffer to be filled |
| 11079 | * |
| 11080 | * This function is used to dump state information of hdd layer |
| 11081 | * |
| 11082 | * Return: None |
| 11083 | */ |
| 11084 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 11085 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11086 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 11087 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11088 | struct hdd_adapter *adapter; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11089 | uint16_t len = 0; |
| 11090 | char *buf = *buf_ptr; |
| 11091 | |
| 11092 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11093 | if (!hdd_ctx) { |
| 11094 | hdd_err("Failed to get hdd context "); |
| 11095 | return; |
| 11096 | } |
| 11097 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11098 | hdd_debug("size of buffer: %d", *size); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11099 | |
| 11100 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 11101 | "\n is_wiphy_suspended %d", hdd_ctx->is_wiphy_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11102 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 11103 | "\n is_scheduler_suspended %d", |
| 11104 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11105 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11106 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11107 | if (adapter->dev) |
| 11108 | len += scnprintf(buf + len, *size - len, |
| 11109 | "\n device name: %s", adapter->dev->name); |
wadesong | 42968e9 | 2017-06-08 14:11:21 +0800 | [diff] [blame] | 11110 | len += scnprintf(buf + len, *size - len, |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11111 | "\n device_mode: %d", adapter->device_mode); |
| 11112 | switch (adapter->device_mode) { |
| 11113 | case QDF_STA_MODE: |
| 11114 | case QDF_P2P_CLIENT_MODE: |
| 11115 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 11116 | len += scnprintf(buf + len, *size - len, |
| 11117 | "\n connState: %d", |
| 11118 | hdd_sta_ctx->conn_info.connState); |
| 11119 | break; |
| 11120 | |
| 11121 | default: |
| 11122 | break; |
| 11123 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11124 | } |
| 11125 | |
| 11126 | *size -= len; |
| 11127 | *buf_ptr += len; |
| 11128 | } |
| 11129 | |
| 11130 | /** |
| 11131 | * hdd_register_debug_callback() - registration function for hdd layer |
| 11132 | * to print hdd state information |
| 11133 | * |
| 11134 | * Return: None |
| 11135 | */ |
| 11136 | static void hdd_register_debug_callback(void) |
| 11137 | { |
| 11138 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 11139 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11140 | #else /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Wen Gong | aa6d55d | 2018-04-26 16:33:21 +0800 | [diff] [blame] | 11141 | static void hdd_register_debug_callback(void) |
| 11142 | { |
| 11143 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11144 | #endif /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11145 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 11146 | /* |
| 11147 | * wlan_init_bug_report_lock() - Initialize bug report lock |
| 11148 | * |
| 11149 | * This function is used to create bug report lock |
| 11150 | * |
| 11151 | * Return: None |
| 11152 | */ |
| 11153 | static void wlan_init_bug_report_lock(void) |
| 11154 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 11155 | struct cds_context *p_cds_context; |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 11156 | |
| 11157 | p_cds_context = cds_get_global_context(); |
| 11158 | if (!p_cds_context) { |
| 11159 | hdd_err("cds context is NULL"); |
| 11160 | return; |
| 11161 | } |
| 11162 | |
| 11163 | qdf_spinlock_create(&p_cds_context->bug_report_lock); |
| 11164 | } |
| 11165 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11166 | #ifdef CONFIG_DP_TRACE |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11167 | void hdd_dp_trace_init(struct hdd_config *config) |
| 11168 | { |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11169 | bool live_mode = DP_TRACE_CONFIG_DEFAULT_LIVE_MODE; |
| 11170 | uint8_t thresh = DP_TRACE_CONFIG_DEFAULT_THRESH; |
| 11171 | uint16_t thresh_time_limit = DP_TRACE_CONFIG_DEFAULT_THRESH_TIME_LIMIT; |
| 11172 | uint8_t verbosity = DP_TRACE_CONFIG_DEFAULT_VERBOSTY; |
| 11173 | uint8_t proto_bitmap = DP_TRACE_CONFIG_DEFAULT_BITMAP; |
| 11174 | uint8_t config_params[DP_TRACE_CONFIG_NUM_PARAMS]; |
| 11175 | uint8_t num_entries = 0; |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11176 | uint32_t bw_compute_interval; |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11177 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11178 | if (!config->enable_dp_trace) { |
| 11179 | hdd_err("dp trace is disabled from ini"); |
| 11180 | return; |
| 11181 | } |
| 11182 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11183 | hdd_string_to_u8_array(config->dp_trace_config, config_params, |
| 11184 | &num_entries, sizeof(config_params)); |
| 11185 | |
| 11186 | /* calculating, num bw timer intervals in a second (1000ms) */ |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11187 | bw_compute_interval = GET_BW_COMPUTE_INTV(config); |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 11188 | if (bw_compute_interval <= 1000 && bw_compute_interval > 0) |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11189 | thresh_time_limit = 1000 / bw_compute_interval; |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 11190 | else if (bw_compute_interval > 1000) { |
| 11191 | hdd_err("busBandwidthComputeInterval > 1000, using 1000"); |
| 11192 | thresh_time_limit = 1; |
| 11193 | } else |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11194 | hdd_err("busBandwidthComputeInterval is 0, using defaults"); |
| 11195 | |
| 11196 | switch (num_entries) { |
| 11197 | case 4: |
| 11198 | proto_bitmap = config_params[3]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11199 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11200 | case 3: |
| 11201 | verbosity = config_params[2]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11202 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11203 | case 2: |
| 11204 | thresh = config_params[1]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11205 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11206 | case 1: |
| 11207 | live_mode = config_params[0]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11208 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11209 | default: |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 11210 | hdd_debug("live_mode %u thresh %u time_limit %u verbosity %u bitmap 0x%x", |
| 11211 | live_mode, thresh, thresh_time_limit, |
| 11212 | verbosity, proto_bitmap); |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11213 | }; |
| 11214 | |
| 11215 | qdf_dp_trace_init(live_mode, thresh, thresh_time_limit, |
| 11216 | verbosity, proto_bitmap); |
| 11217 | |
| 11218 | } |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11219 | #endif |
| 11220 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11221 | #ifdef DISABLE_CHANNEL_LIST |
| 11222 | static int wlan_hdd_cache_chann_mutex_create(struct hdd_context *hdd_ctx) |
| 11223 | { |
| 11224 | return qdf_mutex_create(&hdd_ctx->cache_channel_lock); |
| 11225 | } |
| 11226 | #else |
| 11227 | static int wlan_hdd_cache_chann_mutex_create(struct hdd_context *hdd_ctx) |
| 11228 | { |
| 11229 | return 0; |
| 11230 | } |
| 11231 | #endif |
| 11232 | |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11233 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11234 | * hdd_wlan_startup() - HDD init function |
| 11235 | * @dev: Pointer to the underlying device |
| 11236 | * |
| 11237 | * This is the driver startup code executed once a WLAN device has been detected |
| 11238 | * |
| 11239 | * Return: 0 for success, < 0 for failure |
| 11240 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11241 | int hdd_wlan_startup(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11242 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11243 | QDF_STATUS status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11244 | struct hdd_context *hdd_ctx; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 11245 | struct wlan_objmgr_psoc *psoc; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11246 | int ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 11247 | bool rtnl_held; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11248 | mac_handle_t mac_handle; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11249 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11250 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11251 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11252 | hdd_ctx = hdd_context_create(dev); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11253 | |
| 11254 | if (IS_ERR(hdd_ctx)) |
| 11255 | return PTR_ERR(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11256 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 11257 | ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, |
| 11258 | DEFAULT_PSOC_ID); |
| 11259 | if (ret) { |
| 11260 | hdd_err("Psoc creation fails!"); |
| 11261 | QDF_BUG(0); |
| 11262 | goto err_hdd_free_context; |
| 11263 | } |
| 11264 | |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11265 | hdd_action_oui_config(hdd_ctx); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 11266 | psoc = hdd_ctx->hdd_psoc; |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11267 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 11268 | qdf_nbuf_init_replenish_timer(); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11269 | |
| 11270 | ret = wlan_hdd_cache_chann_mutex_create(hdd_ctx); |
| 11271 | if (QDF_IS_STATUS_ERROR(ret)) |
| 11272 | goto err_hdd_free_context; |
| 11273 | |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 11274 | #ifdef FEATURE_WLAN_CH_AVOID |
| 11275 | mutex_init(&hdd_ctx->avoid_freq_lock); |
| 11276 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11277 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 11278 | osif_request_manager_init(); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 11279 | qdf_atomic_init(&hdd_ctx->con_mode_flag); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11280 | hdd_driver_memdump_init(); |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 11281 | hdd_bus_bandwidth_init(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11282 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 11283 | ret = hdd_wlan_start_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11284 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11285 | hdd_err("Failed to start modules: %d", ret); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11286 | goto err_memdump_deinit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11287 | } |
| 11288 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 11289 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11290 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11291 | mac_handle = cds_get_context(QDF_MODULE_ID_SME); |
| 11292 | hdd_ctx->mac_handle = mac_handle; |
| 11293 | if (!mac_handle) { |
| 11294 | hdd_err("Mac Handle is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11295 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11296 | } |
| 11297 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 11298 | ret = hdd_wiphy_init(hdd_ctx); |
| 11299 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11300 | hdd_err("Failed to initialize wiphy: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11301 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11302 | } |
| 11303 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11304 | hdd_dp_trace_init(hdd_ctx->config); |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 11305 | |
Yuanyuan Liu | c98370e | 2016-10-13 11:22:13 -0700 | [diff] [blame] | 11306 | hdd_initialize_mac_address(hdd_ctx); |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 11307 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11308 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 11309 | if (ret) { |
| 11310 | hdd_err("register_netdevice_notifier failed: %d", ret); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 11311 | goto err_wiphy_unregister; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11312 | } |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 11313 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 11314 | ret = register_reboot_notifier(&system_reboot_notifier); |
| 11315 | if (ret) { |
| 11316 | hdd_err("Failed to register reboot notifier: %d", ret); |
| 11317 | goto err_unregister_netdev; |
| 11318 | } |
| 11319 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 11320 | rtnl_held = hdd_hold_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11321 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 11322 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 11323 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11324 | hdd_err("Failed to open interfaces: %d", ret); |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 11325 | goto err_release_rtnl_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11326 | } |
| 11327 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 11328 | hdd_release_rtnl_lock(); |
| 11329 | rtnl_held = false; |
| 11330 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 11331 | wlan_hdd_update_11n_mode(hdd_ctx->config); |
| 11332 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11333 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 11334 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 11335 | QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11336 | hdd_skip_acs_scan_timer_handler, |
| 11337 | (void *)hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11338 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 11339 | hdd_err("Failed to init ACS Skip timer"); |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 11340 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11341 | #endif |
| 11342 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 11343 | hdd_lpass_notify_wlan_version(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11344 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 11345 | if (hdd_ctx->rps) |
| 11346 | hdd_set_rps_cpu_mask(hdd_ctx); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 11347 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11348 | ret = hdd_register_notifiers(hdd_ctx); |
| 11349 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 11350 | goto err_close_adapters; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 11351 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11352 | status = wlansap_global_init(); |
| 11353 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11354 | hdd_unregister_notifiers(hdd_ctx); |
| 11355 | goto err_close_adapters; |
| 11356 | } |
| 11357 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11358 | if (hdd_ctx->config->fIsImpsEnabled) |
| 11359 | hdd_set_idle_ps_config(hdd_ctx, true); |
Kiran Kumar Lokere | b0f19c3 | 2017-10-13 12:23:26 -0700 | [diff] [blame] | 11360 | else |
| 11361 | hdd_set_idle_ps_config(hdd_ctx, false); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11362 | |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 11363 | if (QDF_GLOBAL_FTM_MODE != hdd_get_conparam()) { |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 11364 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 11365 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 11366 | hdd_prevent_suspend_timeout( |
| 11367 | hdd_ctx->config->iface_change_wait_time, |
| 11368 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
| 11369 | } |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 11370 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11371 | goto success; |
| 11372 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 11373 | err_close_adapters: |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 11374 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11375 | |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 11376 | err_release_rtnl_lock: |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 11377 | unregister_reboot_notifier(&system_reboot_notifier); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 11378 | if (rtnl_held) |
| 11379 | hdd_release_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11380 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 11381 | err_unregister_netdev: |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11382 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 11383 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11384 | err_wiphy_unregister: |
Rachit Kankane | 3080733 | 2018-06-27 18:39:36 +0530 | [diff] [blame] | 11385 | qdf_dp_trace_deinit(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11386 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11387 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11388 | err_stop_modules: |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 11389 | hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11390 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11391 | err_memdump_deinit: |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 11392 | hdd_bus_bandwidth_deinit(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11393 | hdd_driver_memdump_deinit(); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11394 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 11395 | osif_request_manager_deinit(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 11396 | hdd_exit_netlink_services(hdd_ctx); |
| 11397 | |
Dustin Brown | 2091246 | 2017-06-07 13:48:25 -0700 | [diff] [blame] | 11398 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 11399 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11400 | err_hdd_free_context: |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 11401 | if (cds_is_fw_down()) |
| 11402 | hdd_err("Not setting the complete event as fw is down"); |
| 11403 | else |
| 11404 | hdd_start_complete(ret); |
| 11405 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 11406 | qdf_nbuf_deinit_replenish_timer(); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 11407 | hdd_context_destroy(hdd_ctx); |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 11408 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11409 | |
| 11410 | success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11411 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11412 | return 0; |
| 11413 | } |
| 11414 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11415 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11416 | * hdd_wlan_update_target_info() - update target type info |
| 11417 | * @hdd_ctx: HDD context |
| 11418 | * @context: hif context |
| 11419 | * |
| 11420 | * Update target info received from firmware in hdd context |
| 11421 | * Return:None |
| 11422 | */ |
| 11423 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11424 | 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] | 11425 | { |
| 11426 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 11427 | |
| 11428 | if (!tgt_info) { |
| 11429 | hdd_err("Target info is Null"); |
| 11430 | return; |
| 11431 | } |
| 11432 | |
| 11433 | hdd_ctx->target_type = tgt_info->target_type; |
| 11434 | } |
| 11435 | |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11436 | 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] | 11437 | { |
| 11438 | struct hdd_context *hdd_ctx = (struct hdd_context *)data; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11439 | int status; |
| 11440 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11441 | struct osif_request *request = NULL; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11442 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11443 | hdd_enter(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11444 | |
| 11445 | if (!rsp) { |
| 11446 | hdd_err("data is null"); |
| 11447 | return; |
| 11448 | } |
| 11449 | |
| 11450 | status = wlan_hdd_validate_context(hdd_ctx); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11451 | if (status != 0) |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11452 | return; |
| 11453 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11454 | request = osif_request_get(context); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11455 | if (!request) { |
| 11456 | hdd_err("obselete request"); |
| 11457 | return; |
| 11458 | } |
| 11459 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11460 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id); |
| 11461 | if ((NULL == adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
| 11462 | hdd_err("Invalid adapter or adapter has invalid magic"); |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11463 | osif_request_put(request); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11464 | return; |
| 11465 | } |
| 11466 | |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 11467 | hdd_info("rsp->arp_req_enqueue :%x", rsp->arp_req_enqueue); |
| 11468 | hdd_info("rsp->arp_req_tx_success :%x", rsp->arp_req_tx_success); |
| 11469 | hdd_info("rsp->arp_req_tx_failure :%x", rsp->arp_req_tx_failure); |
| 11470 | hdd_info("rsp->arp_rsp_recvd :%x", rsp->arp_rsp_recvd); |
| 11471 | hdd_info("rsp->out_of_order_arp_rsp_drop_cnt :%x", |
| 11472 | rsp->out_of_order_arp_rsp_drop_cnt); |
| 11473 | hdd_info("rsp->dad_detected :%x", rsp->dad_detected); |
| 11474 | hdd_info("rsp->connect_status :%x", rsp->connect_status); |
| 11475 | hdd_info("rsp->ba_session_establishment_status :%x", |
| 11476 | rsp->ba_session_establishment_status); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11477 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11478 | 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] | 11479 | adapter->dad |= rsp->dad_detected; |
| 11480 | adapter->con_status = rsp->connect_status; |
| 11481 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 11482 | /* Flag true indicates connectivity check stats present. */ |
| 11483 | if (rsp->connect_stats_present) { |
| 11484 | hdd_info("rsp->tcp_ack_recvd :%x", rsp->tcp_ack_recvd); |
| 11485 | hdd_info("rsp->icmpv4_rsp_recvd :%x", rsp->icmpv4_rsp_recvd); |
| 11486 | adapter->hdd_stats.hdd_tcp_stats.rx_fw_cnt = rsp->tcp_ack_recvd; |
| 11487 | adapter->hdd_stats.hdd_icmpv4_stats.rx_fw_cnt = |
| 11488 | rsp->icmpv4_rsp_recvd; |
| 11489 | } |
| 11490 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11491 | osif_request_complete(request); |
| 11492 | osif_request_put(request); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11493 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11494 | hdd_exit(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11495 | } |
| 11496 | |
| 11497 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11498 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11499 | * @hdd_ctx: HDD context |
| 11500 | * |
| 11501 | * Register the HDD callbacks to CDS/SME. |
| 11502 | * |
| 11503 | * Return: 0 for success or Error code for failure |
| 11504 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11505 | int hdd_register_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11506 | { |
| 11507 | QDF_STATUS status; |
| 11508 | int ret = 0; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11509 | mac_handle_t mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11510 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11511 | hdd_enter(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11512 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11513 | mac_handle = hdd_ctx->mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11514 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11515 | sme_register_oem_data_rsp_callback(mac_handle, |
| 11516 | hdd_send_oem_data_rsp_msg); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11517 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11518 | sme_register_mgmt_frame_ind_callback(mac_handle, |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 11519 | hdd_indicate_mgmt_frame); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11520 | sme_set_tsfcb(mac_handle, hdd_get_tsf_cb, hdd_ctx); |
| 11521 | sme_nan_register_callback(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11522 | wlan_hdd_cfg80211_nan_callback); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11523 | sme_stats_ext_register_callback(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11524 | wlan_hdd_cfg80211_stats_ext_callback); |
| 11525 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11526 | sme_ext_scan_register_callback(mac_handle, |
| 11527 | wlan_hdd_cfg80211_extscan_callback); |
| 11528 | sme_stats_ext2_register_callback(mac_handle, |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 11529 | wlan_hdd_cfg80211_stats_ext2_callback); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11530 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11531 | sme_set_rssi_threshold_breached_cb(mac_handle, |
| 11532 | hdd_rssi_threshold_breached); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11533 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11534 | sme_set_link_layer_stats_ind_cb(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11535 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 11536 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11537 | 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] | 11538 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11539 | sme_set_link_layer_ext_cb(mac_handle, |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 11540 | wlan_hdd_cfg80211_link_layer_stats_ext_callback); |
| 11541 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11542 | status = sme_set_lost_link_info_cb(mac_handle, |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 11543 | hdd_lost_link_info_cb); |
| 11544 | /* print error and not block the startup process */ |
| 11545 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11546 | hdd_err("set lost link info callback failed"); |
| 11547 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 11548 | ret = hdd_register_data_stall_detect_cb(); |
| 11549 | if (ret) { |
| 11550 | hdd_err("Register data stall detect detect callback failed."); |
| 11551 | return ret; |
| 11552 | } |
| 11553 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11554 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 11555 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11556 | sme_register_set_connection_info_cb(mac_handle, |
| 11557 | hdd_set_connection_in_progress, |
| 11558 | hdd_is_connection_in_progress); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 11559 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11560 | status = sme_congestion_register_callback(mac_handle, |
| 11561 | hdd_update_cca_info_cb); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 11562 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11563 | hdd_err("set congestion callback failed"); |
| 11564 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11565 | status = sme_set_bt_activity_info_cb(mac_handle, |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 11566 | hdd_bt_activity_cb); |
| 11567 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11568 | hdd_err("set bt activity info callback failed"); |
| 11569 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11570 | status = sme_register_tx_queue_cb(mac_handle, |
Varun Reddy Yeturu | 076eaa8 | 2018-01-16 12:16:14 -0800 | [diff] [blame] | 11571 | hdd_tx_queue_cb); |
| 11572 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11573 | hdd_err("Register tx queue callback failed"); |
| 11574 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11575 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11576 | |
| 11577 | return ret; |
| 11578 | } |
| 11579 | |
| 11580 | /** |
| 11581 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 11582 | * @hdd_ctx: HDD context |
| 11583 | * |
| 11584 | * De-Register the HDD callbacks to CDS/SME. |
| 11585 | * |
| 11586 | * Return: void |
| 11587 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11588 | void hdd_deregister_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11589 | { |
| 11590 | QDF_STATUS status; |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 11591 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11592 | mac_handle_t mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11593 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11594 | hdd_enter(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11595 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11596 | mac_handle = hdd_ctx->mac_handle; |
| 11597 | sme_deregister_tx_queue_cb(mac_handle); |
| 11598 | status = sme_deregister_for_dcc_stats_event(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11599 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11600 | hdd_err("De-register of dcc stats callback failed: %d", |
| 11601 | status); |
| 11602 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11603 | sme_reset_link_layer_stats_ind_cb(mac_handle); |
| 11604 | sme_reset_rssi_threshold_breached_cb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11605 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11606 | sme_stats_ext_register_callback(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11607 | wlan_hdd_cfg80211_stats_ext_callback); |
| 11608 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11609 | sme_nan_deregister_callback(mac_handle); |
| 11610 | status = sme_reset_tsfcb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11611 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11612 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 11613 | status); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11614 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 11615 | ret = hdd_deregister_data_stall_detect_cb(); |
| 11616 | if (ret) |
| 11617 | hdd_err("Failed to de-register data stall detect event callback"); |
| 11618 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11619 | sme_deregister_oem_data_rsp_callback(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11620 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11621 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11622 | } |
| 11623 | |
| 11624 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11625 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
| 11626 | * @adapter: Pointer to the HDD |
| 11627 | * @enable: bool value |
| 11628 | * |
| 11629 | * This to take counter measure to handle deauth req from HDD |
| 11630 | * |
| 11631 | * Return: None |
| 11632 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11633 | QDF_STATUS hdd_softap_sta_deauth(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 11634 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11635 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11636 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11637 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11638 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11639 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11640 | /* Ignore request to deauth bcmc station */ |
| 11641 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11642 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11643 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11644 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11645 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 11646 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11647 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11648 | hdd_exit(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11649 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11650 | } |
| 11651 | |
| 11652 | /** |
| 11653 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
| 11654 | * @adapter: Pointer to the HDD |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 11655 | * @p_del_sta_params: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11656 | * |
| 11657 | * This to take counter measure to handle deauth req from HDD |
| 11658 | * |
| 11659 | * Return: None |
| 11660 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11661 | void hdd_softap_sta_disassoc(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 11662 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11663 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11664 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11665 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11666 | /* Ignore request to disassoc bcmc station */ |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 11667 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11668 | return; |
| 11669 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11670 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 11671 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11672 | } |
| 11673 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11674 | /** |
| 11675 | * hdd_issta_p2p_clientconnected() - check if sta or p2p client is connected |
| 11676 | * @hdd_ctx: HDD Context |
| 11677 | * |
| 11678 | * API to find if there is any STA or P2P-Client is connected |
| 11679 | * |
| 11680 | * Return: true if connected; false otherwise |
| 11681 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11682 | QDF_STATUS hdd_issta_p2p_clientconnected(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11683 | { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11684 | return sme_is_sta_p2p_client_connected(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11685 | } |
| 11686 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11687 | void wlan_hdd_disable_roaming(struct hdd_adapter *cur_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11688 | { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11689 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(cur_adapter); |
| 11690 | struct hdd_adapter *adapter = NULL; |
| 11691 | struct csr_roam_profile *roam_profile; |
| 11692 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11693 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11694 | if (!policy_mgr_is_sta_active_connection_exists(hdd_ctx->hdd_psoc)) { |
| 11695 | hdd_debug("No active sta session"); |
| 11696 | return; |
| 11697 | } |
| 11698 | |
| 11699 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11700 | roam_profile = hdd_roam_profile(adapter); |
| 11701 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 11702 | |
| 11703 | if (cur_adapter->session_id != adapter->session_id && |
| 11704 | adapter->device_mode == QDF_STA_MODE && |
| 11705 | hdd_conn_is_connected(sta_ctx)) { |
| 11706 | hdd_debug("%d Disable roaming", adapter->session_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11707 | sme_stop_roaming(hdd_ctx->mac_handle, |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11708 | adapter->session_id, |
| 11709 | ecsr_driver_disabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11710 | } |
| 11711 | } |
| 11712 | } |
| 11713 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11714 | void wlan_hdd_enable_roaming(struct hdd_adapter *cur_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11715 | { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11716 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(cur_adapter); |
| 11717 | struct hdd_adapter *adapter = NULL; |
| 11718 | struct csr_roam_profile *roam_profile; |
| 11719 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11720 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11721 | if (!policy_mgr_is_sta_active_connection_exists(hdd_ctx->hdd_psoc)) { |
| 11722 | hdd_debug("No active sta session"); |
| 11723 | return; |
| 11724 | } |
| 11725 | |
| 11726 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11727 | roam_profile = hdd_roam_profile(adapter); |
| 11728 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 11729 | |
| 11730 | if (cur_adapter->session_id != adapter->session_id && |
| 11731 | adapter->device_mode == QDF_STA_MODE && |
| 11732 | hdd_conn_is_connected(sta_ctx)) { |
| 11733 | hdd_debug("%d Enable roaming", adapter->session_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11734 | sme_start_roaming(hdd_ctx->mac_handle, |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11735 | adapter->session_id, |
| 11736 | REASON_DRIVER_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11737 | } |
| 11738 | } |
| 11739 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11740 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 11741 | /** |
| 11742 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 11743 | * @skb: sk buffer pointer |
| 11744 | * |
| 11745 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 11746 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 11747 | * |
| 11748 | * Return: None |
| 11749 | */ |
| 11750 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 11751 | { |
| 11752 | #ifdef CNSS_GENL |
| 11753 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 11754 | #else |
| 11755 | nl_srv_bcast(skb); |
| 11756 | #endif |
| 11757 | } |
| 11758 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11759 | 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] | 11760 | { |
| 11761 | struct sk_buff *skb; |
| 11762 | struct nlmsghdr *nlh; |
| 11763 | tAniMsgHdr *ani_hdr; |
| 11764 | void *nl_data = NULL; |
| 11765 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11766 | struct radio_index_tlv *radio_info; |
| 11767 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11768 | |
| 11769 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 11770 | flags = GFP_ATOMIC; |
| 11771 | |
| 11772 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 11773 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11774 | if (skb == NULL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11775 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11776 | |
| 11777 | nlh = (struct nlmsghdr *)skb->data; |
| 11778 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 11779 | nlh->nlmsg_flags = 0; |
| 11780 | nlh->nlmsg_seq = 0; |
| 11781 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 11782 | |
| 11783 | ani_hdr = NLMSG_DATA(nlh); |
| 11784 | ani_hdr->type = type; |
| 11785 | |
| 11786 | switch (type) { |
| 11787 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 11788 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11789 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11790 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 11791 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11792 | ani_hdr->length = 0; |
| 11793 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11794 | break; |
| 11795 | case WLAN_SVC_WLAN_STATUS_IND: |
| 11796 | case WLAN_SVC_WLAN_VERSION_IND: |
| 11797 | case WLAN_SVC_DFS_CAC_START_IND: |
| 11798 | case WLAN_SVC_DFS_CAC_END_IND: |
| 11799 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 11800 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 11801 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 11802 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 11803 | case WLAN_SVC_RPS_ENABLE_IND: |
Orhan K AKYILDIZ | e7445a2 | 2017-01-19 21:21:47 -0800 | [diff] [blame] | 11804 | case WLAN_SVC_CORE_MINFREQ: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11805 | ani_hdr->length = len; |
| 11806 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 11807 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 11808 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11809 | break; |
| 11810 | |
| 11811 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 11812 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11813 | type); |
| 11814 | kfree_skb(skb); |
| 11815 | return; |
| 11816 | } |
| 11817 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11818 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 11819 | * Add radio index at the end of the svc event in TLV format |
| 11820 | * to maintain the backward compatibility with userspace |
| 11821 | * applications. |
| 11822 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11823 | |
| 11824 | tlv_len = 0; |
| 11825 | |
| 11826 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 11827 | < WLAN_NL_MAX_PAYLOAD) { |
| 11828 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 11829 | sizeof(*ani_hdr) + len); |
| 11830 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 11831 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 11832 | radio_info->radio = radio; |
| 11833 | tlv_len = sizeof(*radio_info); |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 11834 | hdd_debug("Added radio index tlv - radio index %d", |
| 11835 | radio_info->radio); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11836 | } |
| 11837 | |
| 11838 | nlh->nlmsg_len += tlv_len; |
| 11839 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 11840 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 11841 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11842 | } |
| 11843 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11844 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 11845 | void wlan_hdd_auto_shutdown_cb(void) |
| 11846 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11847 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11848 | |
| 11849 | if (!hdd_ctx) |
| 11850 | return; |
| 11851 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11852 | hdd_debug("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11853 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 11854 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11855 | } |
| 11856 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11857 | 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] | 11858 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11859 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11860 | bool ap_connected = false, sta_connected = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11861 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11862 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11863 | mac_handle = hdd_ctx->mac_handle; |
| 11864 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11865 | return; |
| 11866 | |
| 11867 | if (hdd_ctx->config->WlanAutoShutdown == 0) |
| 11868 | return; |
| 11869 | |
| 11870 | if (enable == false) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11871 | if (sme_set_auto_shutdown_timer(mac_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11872 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11873 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11874 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11875 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 11876 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11877 | return; |
| 11878 | } |
| 11879 | |
| 11880 | /* To enable shutdown timer check conncurrency */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11881 | if (policy_mgr_concurrent_open_sessions_running(hdd_ctx->hdd_psoc)) { |
| 11882 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11883 | if (adapter->device_mode == QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11884 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 11885 | conn_info.connState == |
| 11886 | eConnectionState_Associated) { |
| 11887 | sta_connected = true; |
| 11888 | break; |
| 11889 | } |
| 11890 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11891 | |
| 11892 | if (adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11893 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 11894 | ap_active == true) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11895 | ap_connected = true; |
| 11896 | break; |
| 11897 | } |
| 11898 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11899 | } |
| 11900 | } |
| 11901 | |
| 11902 | if (ap_connected == true || sta_connected == true) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11903 | hdd_debug("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11904 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11905 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 11906 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11907 | if (sme_set_auto_shutdown_timer(mac_handle, |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 11908 | hdd_ctx->config->WlanAutoShutdown) |
| 11909 | != QDF_STATUS_SUCCESS) |
| 11910 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 11911 | else |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 11912 | hdd_info("Auto Shutdown timer for %d seconds enabled", |
| 11913 | hdd_ctx->config->WlanAutoShutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11914 | } |
| 11915 | #endif |
| 11916 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11917 | struct hdd_adapter * |
| 11918 | hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, |
| 11919 | bool check_start_bss) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11920 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11921 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11922 | struct hdd_adapter *adapter, *con_sap_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11923 | |
| 11924 | con_sap_adapter = NULL; |
| 11925 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11926 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11927 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 11928 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11929 | adapter != this_sap_adapter) { |
| 11930 | if (check_start_bss) { |
| 11931 | if (test_bit(SOFTAP_BSS_STARTED, |
| 11932 | &adapter->event_flags)) { |
| 11933 | con_sap_adapter = adapter; |
| 11934 | break; |
| 11935 | } |
| 11936 | } else { |
| 11937 | con_sap_adapter = adapter; |
| 11938 | break; |
| 11939 | } |
| 11940 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11941 | } |
| 11942 | |
| 11943 | return con_sap_adapter; |
| 11944 | } |
| 11945 | |
| 11946 | #ifdef MSM_PLATFORM |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11947 | static inline bool hdd_adapter_is_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11948 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11949 | return adapter->device_mode == QDF_STA_MODE || |
| 11950 | adapter->device_mode == QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11951 | } |
| 11952 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11953 | static inline bool hdd_adapter_is_ap(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11954 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11955 | return adapter->device_mode == QDF_SAP_MODE || |
| 11956 | adapter->device_mode == QDF_P2P_GO_MODE; |
| 11957 | } |
| 11958 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11959 | static bool hdd_any_adapter_is_assoc(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11960 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11961 | struct hdd_adapter *adapter; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11962 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11963 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11964 | if (hdd_adapter_is_sta(adapter) && |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11965 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 11966 | conn_info.connState == eConnectionState_Associated) { |
| 11967 | return true; |
| 11968 | } |
| 11969 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11970 | if (hdd_adapter_is_ap(adapter) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 11971 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11972 | return true; |
| 11973 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11974 | } |
| 11975 | |
| 11976 | return false; |
| 11977 | } |
| 11978 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11979 | 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] | 11980 | { |
| 11981 | bool is_running; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11982 | |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 11983 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11984 | is_running = hdd_ctx->bus_bw_timer_running; |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 11985 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11986 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11987 | return is_running; |
| 11988 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11989 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11990 | 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] | 11991 | { |
| 11992 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 11993 | hdd_ctx->bus_bw_timer_running = true; |
| 11994 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
| 11995 | hdd_ctx->config->busBandwidthComputeInterval); |
| 11996 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 11997 | } |
| 11998 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11999 | void hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12000 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12001 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12002 | |
| 12003 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 12004 | hdd_debug("Bandwidth compute timer already started"); |
| 12005 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12006 | } |
| 12007 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12008 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 12009 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12010 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12011 | } |
| 12012 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12013 | 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] | 12014 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12015 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12016 | |
| 12017 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 12018 | hdd_debug("Bandwidth compute timer already started"); |
| 12019 | return; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 12020 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12021 | |
| 12022 | if (hdd_any_adapter_is_assoc(hdd_ctx)) |
| 12023 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 12024 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12025 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12026 | } |
| 12027 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12028 | 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] | 12029 | { |
Sravan Kumar Kairam | 9e99e9a | 2018-03-12 19:09:45 +0530 | [diff] [blame] | 12030 | ucfg_ipa_set_perf_level(hdd_ctx->hdd_pdev, 0, 0); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12031 | |
| 12032 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12033 | hdd_ctx->bus_bw_timer_running = false; |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 12034 | qdf_timer_sync_cancel(&hdd_ctx->bus_bw_timer); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12035 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 12036 | |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 12037 | /* work callback is long running; flush outside of lock */ |
| 12038 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12039 | hdd_reset_tcp_delack(hdd_ctx); |
| 12040 | } |
| 12041 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12042 | void hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12043 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12044 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12045 | |
| 12046 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 12047 | hdd_debug("Bandwidth compute timer already stopped"); |
| 12048 | return; |
| 12049 | } |
| 12050 | |
| 12051 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 12052 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12053 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12054 | } |
| 12055 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12056 | 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] | 12057 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12058 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12059 | |
| 12060 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 12061 | hdd_debug("Bandwidth compute timer already stopped"); |
| 12062 | return; |
| 12063 | } |
| 12064 | |
| 12065 | if (!hdd_any_adapter_is_assoc(hdd_ctx)) |
| 12066 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 12067 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12068 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12069 | } |
| 12070 | #endif |
| 12071 | |
| 12072 | /** |
| 12073 | * wlan_hdd_check_custom_con_channel_rules() - This function checks the sap's |
| 12074 | * and sta's operating channel. |
| 12075 | * @sta_adapter: Describe the first argument to foobar. |
| 12076 | * @ap_adapter: Describe the second argument to foobar. |
| 12077 | * @roam_profile: Roam profile of AP to which STA wants to connect. |
| 12078 | * @concurrent_chnl_same: If both SAP and STA channels are same then |
| 12079 | * set this flag to true else false. |
| 12080 | * |
| 12081 | * This function checks the sap's operating channel and sta's operating channel. |
| 12082 | * if both are same then it will return false else it will restart the sap in |
| 12083 | * sta's channel and return true. |
| 12084 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12085 | * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12086 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 12087 | QDF_STATUS |
| 12088 | wlan_hdd_check_custom_con_channel_rules(struct hdd_adapter *sta_adapter, |
| 12089 | struct hdd_adapter *ap_adapter, |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 12090 | struct csr_roam_profile *roam_profile, |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 12091 | tScanResultHandle *scan_cache, |
| 12092 | bool *concurrent_chnl_same) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12093 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12094 | struct hdd_ap_ctx *hdd_ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12095 | uint8_t channel_id; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12096 | QDF_STATUS status; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 12097 | enum QDF_OPMODE device_mode = ap_adapter->device_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12098 | *concurrent_chnl_same = true; |
| 12099 | |
| 12100 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 12101 | status = |
Archana Ramachandran | 2eb7a61 | 2017-03-23 22:58:42 -0700 | [diff] [blame] | 12102 | sme_get_ap_channel_from_scan_cache(roam_profile, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12103 | scan_cache, |
| 12104 | &channel_id); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12105 | if (QDF_STATUS_SUCCESS == status) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 12106 | if ((QDF_SAP_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12107 | (channel_id < SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 12108 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12109 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12110 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12111 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 12112 | } else if ((QDF_P2P_GO_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12113 | (channel_id >= SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 12114 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12115 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12116 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12117 | } |
| 12118 | } |
| 12119 | } else { |
| 12120 | /* |
| 12121 | * Lets handle worst case scenario here, Scan cache lookup is |
| 12122 | * failed so we have to stop the SAP to avoid any channel |
| 12123 | * discrepancy between SAP's channel and STA's channel. |
| 12124 | * Return the status as failure so caller function could know |
| 12125 | * that scan look up is failed. |
| 12126 | */ |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12127 | hdd_err("Finding AP from scan cache failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12128 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12129 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12130 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12131 | } |
| 12132 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12133 | /** |
| 12134 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 12135 | * @ap_adapter: SAP adapter |
| 12136 | * |
| 12137 | * This function will process the stopping of sap adapter. |
| 12138 | * |
| 12139 | * Return: None |
| 12140 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12141 | void wlan_hdd_stop_sap(struct hdd_adapter *ap_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12142 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12143 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 12144 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12145 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12146 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12147 | |
| 12148 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12149 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12150 | return; |
| 12151 | } |
| 12152 | |
| 12153 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 12154 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 12155 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12156 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 12157 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12158 | mutex_lock(&hdd_ctx->sap_lock); |
| 12159 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 12160 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12161 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12162 | hdd_debug("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 12163 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12164 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 12165 | sap_context)) { |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 12166 | qdf_status = qdf_wait_for_event_completion(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 12167 | qdf_stop_bss_event, |
| 12168 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12169 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12170 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12171 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12172 | return; |
| 12173 | } |
| 12174 | } |
| 12175 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12176 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 12177 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12178 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 12179 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12180 | false); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12181 | hdd_debug("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12182 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12183 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12184 | } |
| 12185 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12186 | } |
| 12187 | |
| 12188 | /** |
| 12189 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 12190 | * @ap_adapter: SAP adapter |
| 12191 | * |
| 12192 | * This function will process the starting of sap adapter. |
| 12193 | * |
| 12194 | * Return: None |
| 12195 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12196 | void wlan_hdd_start_sap(struct hdd_adapter *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12197 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12198 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 12199 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12200 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12201 | struct hdd_context *hdd_ctx; |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 12202 | tsap_config_t *sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12203 | |
| 12204 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12205 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12206 | return; |
| 12207 | } |
| 12208 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 12209 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 12210 | hdd_err("SoftAp role has not been enabled"); |
| 12211 | return; |
| 12212 | } |
| 12213 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12214 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 12215 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 12216 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 12217 | sap_config = &ap_adapter->session.ap.sap_config; |
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 | mutex_lock(&hdd_ctx->sap_lock); |
| 12220 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 12221 | goto end; |
| 12222 | |
| 12223 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12224 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12225 | goto end; |
| 12226 | } |
| 12227 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 12228 | qdf_event_reset(&hostapd_state->qdf_event); |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 12229 | 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] | 12230 | &hdd_ap_ctx->sap_config, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12231 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12232 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12233 | goto end; |
| 12234 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12235 | hdd_debug("Waiting for SAP to start"); |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 12236 | qdf_status = qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 12237 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12238 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12239 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12240 | goto end; |
| 12241 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12242 | hdd_info("SAP Start Success"); |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 12243 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12244 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12245 | if (hostapd_state->bss_state == BSS_START) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12246 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 12247 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12248 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 12249 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12250 | true); |
| 12251 | } |
Sourav Mohapatra | 9bc6711 | 2017-11-08 09:36:11 +0530 | [diff] [blame] | 12252 | mutex_unlock(&hdd_ctx->sap_lock); |
| 12253 | |
| 12254 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12255 | end: |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 12256 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12257 | mutex_unlock(&hdd_ctx->sap_lock); |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 12258 | /* SAP context and beacon cleanup will happen during driver unload |
| 12259 | * in hdd_stop_adapter |
| 12260 | */ |
| 12261 | hdd_err("SAP restart after SSR failed! Reload WLAN and try SAP again"); |
| 12262 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12263 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12264 | |
| 12265 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12266 | * hdd_get_fw_version() - Get FW version |
| 12267 | * @hdd_ctx: pointer to HDD context. |
| 12268 | * @major_spid: FW version - major spid. |
| 12269 | * @minor_spid: FW version - minor spid |
| 12270 | * @ssid: FW version - ssid |
| 12271 | * @crmid: FW version - crmid |
| 12272 | * |
| 12273 | * This function is called to get the firmware build version stored |
| 12274 | * as part of the HDD context |
| 12275 | * |
| 12276 | * Return: None |
| 12277 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12278 | void hdd_get_fw_version(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12279 | uint32_t *major_spid, uint32_t *minor_spid, |
| 12280 | uint32_t *siid, uint32_t *crmid) |
| 12281 | { |
| 12282 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 12283 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 12284 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 12285 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 12286 | } |
| 12287 | |
| 12288 | #ifdef QCA_CONFIG_SMP |
| 12289 | /** |
| 12290 | * wlan_hdd_get_cpu() - get cpu_index |
| 12291 | * |
| 12292 | * Return: cpu_index |
| 12293 | */ |
| 12294 | int wlan_hdd_get_cpu(void) |
| 12295 | { |
| 12296 | int cpu_index = get_cpu(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12297 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12298 | put_cpu(); |
| 12299 | return cpu_index; |
| 12300 | } |
| 12301 | #endif |
| 12302 | |
| 12303 | /** |
| 12304 | * hdd_get_fwpath() - get framework path |
| 12305 | * |
| 12306 | * This function is used to get the string written by |
| 12307 | * userspace to start the wlan driver |
| 12308 | * |
| 12309 | * Return: string |
| 12310 | */ |
| 12311 | const char *hdd_get_fwpath(void) |
| 12312 | { |
| 12313 | return fwpath.string; |
| 12314 | } |
| 12315 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 12316 | static int hdd_qdf_print_init(void) |
| 12317 | { |
| 12318 | int qdf_print_idx; |
| 12319 | QDF_STATUS status; |
| 12320 | |
| 12321 | status = qdf_print_setup(); |
| 12322 | if (status != QDF_STATUS_SUCCESS) { |
| 12323 | pr_err("qdf_print_setup failed\n"); |
| 12324 | return -EINVAL; |
| 12325 | } |
| 12326 | |
| 12327 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, "MCL_WLAN"); |
| 12328 | |
| 12329 | if (qdf_print_idx < 0) { |
| 12330 | pr_err("qdf_print_ctrl_register failed, ret = %d\n", |
| 12331 | qdf_print_idx); |
| 12332 | return -EINVAL; |
| 12333 | } |
| 12334 | |
| 12335 | qdf_set_pidx(qdf_print_idx); |
| 12336 | |
| 12337 | return 0; |
| 12338 | } |
| 12339 | |
| 12340 | static void hdd_qdf_print_deinit(void) |
| 12341 | { |
| 12342 | int qdf_print_idx; |
| 12343 | |
| 12344 | qdf_print_idx = qdf_get_pidx(); |
| 12345 | qdf_print_ctrl_cleanup(qdf_print_idx); |
| 12346 | } |
| 12347 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12348 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12349 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12350 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12351 | * This function initilizes CDS global context with the help of cds_init. This |
| 12352 | * has to be the first function called after probe to get a valid global |
| 12353 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12354 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12355 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12356 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12357 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12358 | { |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 12359 | QDF_STATUS status; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12360 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12361 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 12362 | status = cds_init(); |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 12363 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12364 | hdd_err("Failed to allocate CDS context"); |
| 12365 | ret = -ENOMEM; |
| 12366 | goto err_out; |
| 12367 | } |
Hanumanth Reddy Pothula | 788a37e | 2017-08-17 18:40:11 +0530 | [diff] [blame] | 12368 | |
| 12369 | wlan_init_bug_report_lock(); |
| 12370 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12371 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12372 | wlan_logging_sock_init_svc(); |
| 12373 | #endif |
| 12374 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 12375 | qdf_timer_init(NULL, &hdd_drv_ops_inactivity_timer, |
| 12376 | (void *)hdd_drv_ops_inactivity_handler, NULL, |
| 12377 | QDF_TIMER_TYPE_SW); |
| 12378 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12379 | hdd_trace_init(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 12380 | hdd_qdf_print_init(); |
| 12381 | |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 12382 | hdd_register_debug_callback(); |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12383 | wlan_roam_debug_init(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12384 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12385 | err_out: |
| 12386 | return ret; |
| 12387 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12388 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12389 | /** |
| 12390 | * hdd_deinit() - Deinitialize Driver |
| 12391 | * |
| 12392 | * This function frees CDS global context with the help of cds_deinit. This |
| 12393 | * has to be the last function call in remove callback to free the global |
| 12394 | * context. |
| 12395 | */ |
| 12396 | void hdd_deinit(void) |
| 12397 | { |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12398 | wlan_roam_debug_deinit(); |
| 12399 | hdd_qdf_print_deinit(); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 12400 | qdf_timer_free(&hdd_drv_ops_inactivity_timer); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12401 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12402 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12403 | wlan_logging_sock_deinit_svc(); |
| 12404 | #endif |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12405 | |
| 12406 | wlan_destroy_bug_report_lock(); |
| 12407 | cds_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12408 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12409 | |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 12410 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 12411 | #define HDD_WLAN_START_WAIT_TIME ((CDS_WMA_TIMEOUT + 5000) * 100) |
| 12412 | #else |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12413 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 12414 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12415 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12416 | static int wlan_hdd_state_ctrl_param_open(struct inode *inode, |
| 12417 | struct file *file) |
| 12418 | { |
| 12419 | return 0; |
| 12420 | } |
| 12421 | |
| 12422 | static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, |
| 12423 | const char __user *user_buf, |
| 12424 | size_t count, |
| 12425 | loff_t *f_pos) |
| 12426 | { |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12427 | char buf[3]; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12428 | static const char wlan_off_str[] = "OFF"; |
| 12429 | static const char wlan_on_str[] = "ON"; |
| 12430 | int ret; |
| 12431 | unsigned long rc; |
| 12432 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12433 | if (copy_from_user(buf, user_buf, 3)) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12434 | pr_err("Failed to read buffer\n"); |
| 12435 | return -EINVAL; |
| 12436 | } |
| 12437 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12438 | if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12439 | pr_debug("Wifi turning off from UI\n"); |
| 12440 | goto exit; |
| 12441 | } |
| 12442 | |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 12443 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) == 0) { |
| 12444 | pr_info("Wifi Turning On from UI\n"); |
| 12445 | } |
| 12446 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12447 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12448 | pr_err("Invalid value received from framework"); |
| 12449 | goto exit; |
| 12450 | } |
| 12451 | |
| 12452 | if (!cds_is_driver_loaded()) { |
Sachin Ahuja | ee62b54 | 2017-04-21 14:14:16 +0530 | [diff] [blame] | 12453 | init_completion(&wlan_start_comp); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12454 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 12455 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 12456 | if (!rc) { |
| 12457 | hdd_alert("Timed-out waiting in wlan_hdd_state_ctrl_param_write"); |
| 12458 | ret = -EINVAL; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12459 | return ret; |
| 12460 | } |
| 12461 | |
| 12462 | hdd_start_complete(0); |
| 12463 | } |
| 12464 | |
| 12465 | exit: |
| 12466 | return count; |
| 12467 | } |
| 12468 | |
| 12469 | |
| 12470 | const struct file_operations wlan_hdd_state_fops = { |
| 12471 | .owner = THIS_MODULE, |
| 12472 | .open = wlan_hdd_state_ctrl_param_open, |
| 12473 | .write = wlan_hdd_state_ctrl_param_write, |
| 12474 | }; |
| 12475 | |
| 12476 | static int wlan_hdd_state_ctrl_param_create(void) |
| 12477 | { |
| 12478 | unsigned int wlan_hdd_state_major = 0; |
| 12479 | int ret; |
| 12480 | struct device *dev; |
| 12481 | |
| 12482 | device = MKDEV(wlan_hdd_state_major, 0); |
| 12483 | |
| 12484 | ret = alloc_chrdev_region(&device, 0, dev_num, "qcwlanstate"); |
| 12485 | if (ret) { |
| 12486 | pr_err("Failed to register qcwlanstate"); |
| 12487 | goto dev_alloc_err; |
| 12488 | } |
| 12489 | wlan_hdd_state_major = MAJOR(device); |
| 12490 | |
| 12491 | class = class_create(THIS_MODULE, WLAN_MODULE_NAME); |
| 12492 | if (IS_ERR(class)) { |
| 12493 | pr_err("wlan_hdd_state class_create error"); |
| 12494 | goto class_err; |
| 12495 | } |
| 12496 | |
| 12497 | dev = device_create(class, NULL, device, NULL, WLAN_MODULE_NAME); |
| 12498 | if (IS_ERR(dev)) { |
| 12499 | pr_err("wlan_hdd_statedevice_create error"); |
| 12500 | goto err_class_destroy; |
| 12501 | } |
| 12502 | |
| 12503 | cdev_init(&wlan_hdd_state_cdev, &wlan_hdd_state_fops); |
| 12504 | ret = cdev_add(&wlan_hdd_state_cdev, device, dev_num); |
| 12505 | if (ret) { |
| 12506 | pr_err("Failed to add cdev error"); |
| 12507 | goto cdev_add_err; |
| 12508 | } |
| 12509 | |
| 12510 | pr_info("wlan_hdd_state %s major(%d) initialized", |
| 12511 | WLAN_MODULE_NAME, wlan_hdd_state_major); |
| 12512 | |
| 12513 | return 0; |
| 12514 | |
| 12515 | cdev_add_err: |
| 12516 | device_destroy(class, device); |
| 12517 | err_class_destroy: |
| 12518 | class_destroy(class); |
| 12519 | class_err: |
| 12520 | unregister_chrdev_region(device, dev_num); |
| 12521 | dev_alloc_err: |
| 12522 | return -ENODEV; |
| 12523 | } |
| 12524 | |
| 12525 | static void wlan_hdd_state_ctrl_param_destroy(void) |
| 12526 | { |
| 12527 | cdev_del(&wlan_hdd_state_cdev); |
| 12528 | device_destroy(class, device); |
| 12529 | class_destroy(class); |
| 12530 | unregister_chrdev_region(device, dev_num); |
| 12531 | |
| 12532 | pr_info("Device node unregistered"); |
| 12533 | } |
| 12534 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12535 | /** |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12536 | * component_init - API to init cld component's |
| 12537 | * |
| 12538 | * Return: None |
| 12539 | */ |
| 12540 | static void component_init(void) |
| 12541 | { |
Sandeep Puligilla | c5609d5 | 2018-05-17 19:23:41 -0700 | [diff] [blame] | 12542 | mlme_init(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12543 | pmo_init(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12544 | disa_init(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 12545 | ucfg_ocb_init(); |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 12546 | ipa_init(); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 12547 | ucfg_action_oui_init(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12548 | } |
| 12549 | |
| 12550 | /** |
| 12551 | * component_deinit - API to deinit cld component's |
| 12552 | * |
| 12553 | * Return: None |
| 12554 | */ |
| 12555 | static void component_deinit(void) |
| 12556 | { |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 12557 | ucfg_action_oui_deinit(); |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 12558 | ipa_deinit(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 12559 | ucfg_ocb_deinit(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12560 | pmo_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12561 | disa_deinit(); |
Sandeep Puligilla | c5609d5 | 2018-05-17 19:23:41 -0700 | [diff] [blame] | 12562 | mlme_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12563 | } |
| 12564 | |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 12565 | QDF_STATUS hdd_component_psoc_open(struct wlan_objmgr_psoc *psoc) |
| 12566 | { |
| 12567 | return mlme_psoc_open(psoc); |
| 12568 | } |
| 12569 | |
| 12570 | void hdd_component_psoc_close(struct wlan_objmgr_psoc *psoc) |
| 12571 | { |
| 12572 | mlme_psoc_close(psoc); |
| 12573 | } |
| 12574 | |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12575 | void hdd_component_psoc_enable(struct wlan_objmgr_psoc *psoc) |
| 12576 | { |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 12577 | ocb_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12578 | disa_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12579 | } |
| 12580 | |
| 12581 | void hdd_component_psoc_disable(struct wlan_objmgr_psoc *psoc) |
| 12582 | { |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12583 | disa_psoc_disable(psoc); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 12584 | ocb_psoc_disable(psoc); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12585 | } |
| 12586 | |
| 12587 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12588 | * __hdd_module_init - Module init helper |
| 12589 | * |
| 12590 | * Module init helper function used by both module and static driver. |
| 12591 | * |
| 12592 | * Return: 0 for success, errno on failure |
| 12593 | */ |
| 12594 | static int __hdd_module_init(void) |
| 12595 | { |
| 12596 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12597 | |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 12598 | pr_err("%s: Loading driver v%s (%s)\n", |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 12599 | WLAN_MODULE_NAME, |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 12600 | g_wlan_driver_version, |
Dustin Brown | c1034df | 2018-02-07 14:51:32 -0800 | [diff] [blame] | 12601 | TIMER_MANAGER_STR MEMORY_DEBUG_STR PANIC_ON_BUG_STR); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12602 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 12603 | pld_init(); |
| 12604 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12605 | ret = hdd_init(); |
| 12606 | if (ret) { |
| 12607 | pr_err("hdd_init failed %x\n", ret); |
| 12608 | goto err_hdd_init; |
| 12609 | } |
| 12610 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12611 | dispatcher_init(); |
| 12612 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12613 | /* Ensure to call post objmgr init */ |
| 12614 | component_init(); |
| 12615 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 12616 | qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12617 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12618 | hdd_set_conparam((uint32_t) con_mode); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12619 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12620 | ret = wlan_hdd_register_driver(); |
| 12621 | if (ret) { |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 12622 | pr_err("%s: driver load failure, err %d\n", WLAN_MODULE_NAME, |
| 12623 | ret); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12624 | goto out; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12625 | } |
| 12626 | |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 12627 | ret = wlan_hdd_state_ctrl_param_create(); |
| 12628 | if (ret) { |
| 12629 | pr_err("wlan_hdd_state_create:%x\n", ret); |
| 12630 | goto out; |
| 12631 | } |
| 12632 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 12633 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12634 | |
| 12635 | return 0; |
| 12636 | out: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 12637 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Liangwei Dong | 9fcc721 | 2017-10-24 13:43:52 +0800 | [diff] [blame] | 12638 | component_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12639 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12640 | hdd_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12641 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12642 | err_hdd_init: |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 12643 | pld_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12644 | return ret; |
| 12645 | } |
| 12646 | |
| 12647 | /** |
| 12648 | * __hdd_module_exit - Module exit helper |
| 12649 | * |
| 12650 | * Module exit helper function used by both module and static driver. |
| 12651 | */ |
| 12652 | static void __hdd_module_exit(void) |
| 12653 | { |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 12654 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 12655 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12656 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 12657 | QWLAN_VERSIONSTR); |
| 12658 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 12659 | if (!hdd_wait_for_recovery_completion()) |
| 12660 | return; |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 12661 | |
Will Huang | ba035ec | 2018-07-05 11:13:30 +0800 | [diff] [blame] | 12662 | cds_set_driver_loaded(false); |
| 12663 | cds_set_unload_in_progress(true); |
| 12664 | |
| 12665 | if (!cds_wait_for_external_threads_completion(__func__)) |
| 12666 | hdd_warn("External threads are still active attempting " |
| 12667 | "driver unload anyway"); |
| 12668 | |
Rajeev Kumar | 3505ae5 | 2018-05-10 18:44:45 -0700 | [diff] [blame] | 12669 | if (hdd_ctx) |
| 12670 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 12671 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12672 | wlan_hdd_unregister_driver(); |
| 12673 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 12674 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12675 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12676 | /* Ensure to call prior to objmgr deinit */ |
| 12677 | component_deinit(); |
| 12678 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12679 | dispatcher_deinit(); |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 12680 | |
| 12681 | hdd_sysfs_destroy_version_interface(); |
| 12682 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12683 | hdd_deinit(); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 12684 | pld_deinit(); |
| 12685 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12686 | wlan_hdd_state_ctrl_param_destroy(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12687 | } |
| 12688 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12689 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12690 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12691 | * wlan_boot_cb() - Wlan boot callback |
| 12692 | * @kobj: object whose directory we're creating the link in. |
| 12693 | * @attr: attribute the user is interacting with |
| 12694 | * @buff: the buffer containing the user data |
| 12695 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12696 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12697 | * This callback is invoked when the fs is ready to start the |
| 12698 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12699 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12700 | * 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] | 12701 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12702 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12703 | struct kobj_attribute *attr, |
| 12704 | const char *buf, |
| 12705 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12706 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12707 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12708 | if (wlan_loader->loaded_state) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12709 | pr_err("%s: wlan driver already initialized\n", __func__); |
| 12710 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12711 | } |
| 12712 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12713 | if (__hdd_module_init()) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12714 | pr_err("%s: wlan driver initialization failed\n", __func__); |
| 12715 | return -EIO; |
| 12716 | } |
| 12717 | |
| 12718 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12719 | |
| 12720 | return count; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12721 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12722 | |
| 12723 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12724 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 12725 | * |
| 12726 | * Return: None |
| 12727 | * |
| 12728 | */ |
| 12729 | static void hdd_sysfs_cleanup(void) |
| 12730 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12731 | /* remove from group */ |
| 12732 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 12733 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 12734 | wlan_loader->attr_group); |
| 12735 | |
| 12736 | /* unlink the object from parent */ |
| 12737 | kobject_del(wlan_loader->boot_wlan_obj); |
| 12738 | |
| 12739 | /* free the object */ |
| 12740 | kobject_put(wlan_loader->boot_wlan_obj); |
| 12741 | |
| 12742 | kfree(wlan_loader->attr_group); |
| 12743 | kfree(wlan_loader); |
| 12744 | |
| 12745 | wlan_loader = NULL; |
| 12746 | } |
| 12747 | |
| 12748 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12749 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 12750 | * ready |
| 12751 | * |
| 12752 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 12753 | * when the filesystem is ready. |
| 12754 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12755 | * QDF API cannot be used here since this function is called even before |
| 12756 | * initializing WLAN driver. |
| 12757 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 12758 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12759 | */ |
| 12760 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12761 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12762 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12763 | |
| 12764 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12765 | if (!wlan_loader) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12766 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12767 | |
| 12768 | wlan_loader->boot_wlan_obj = NULL; |
| 12769 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 12770 | GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12771 | if (!wlan_loader->attr_group) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12772 | goto error_return; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12773 | |
| 12774 | wlan_loader->loaded_state = 0; |
| 12775 | wlan_loader->attr_group->attrs = attrs; |
| 12776 | |
| 12777 | wlan_loader->boot_wlan_obj = kobject_create_and_add("boot_wlan", |
| 12778 | kernel_kobj); |
| 12779 | if (!wlan_loader->boot_wlan_obj) { |
| 12780 | pr_err("%s: sysfs create and add failed\n", __func__); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12781 | goto error_return; |
| 12782 | } |
| 12783 | |
| 12784 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 12785 | wlan_loader->attr_group); |
| 12786 | if (ret) { |
| 12787 | pr_err("%s: sysfs create group failed %d\n", __func__, ret); |
| 12788 | goto error_return; |
| 12789 | } |
| 12790 | |
| 12791 | return 0; |
| 12792 | |
| 12793 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12794 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12795 | |
| 12796 | return ret; |
| 12797 | } |
| 12798 | |
| 12799 | /** |
| 12800 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 12801 | * |
| 12802 | * Return: 0 on success or errno on failure |
| 12803 | */ |
| 12804 | static int wlan_deinit_sysfs(void) |
| 12805 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12806 | if (!wlan_loader) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12807 | hdd_err("wlan loader context is Null!"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12808 | return -EINVAL; |
| 12809 | } |
| 12810 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12811 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12812 | return 0; |
| 12813 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12814 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12815 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12816 | |
| 12817 | #ifdef MODULE |
| 12818 | /** |
| 12819 | * __hdd_module_init - Module init helper |
| 12820 | * |
| 12821 | * Module init helper function used by both module and static driver. |
| 12822 | * |
| 12823 | * Return: 0 for success, errno on failure |
| 12824 | */ |
| 12825 | static int hdd_module_init(void) |
| 12826 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12827 | if (__hdd_module_init()) { |
| 12828 | pr_err("%s: Failed to register handler\n", __func__); |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 12829 | return -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12830 | } |
| 12831 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 12832 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12833 | } |
| 12834 | #else |
| 12835 | static int __init hdd_module_init(void) |
| 12836 | { |
| 12837 | int ret = -EINVAL; |
| 12838 | |
| 12839 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 12840 | if (ret) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12841 | pr_err("Failed to create sysfs entry for loading wlan"); |
| 12842 | |
| 12843 | return ret; |
| 12844 | } |
| 12845 | #endif |
| 12846 | |
| 12847 | |
| 12848 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12849 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12850 | * hdd_module_exit() - Exit function |
| 12851 | * |
| 12852 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 12853 | * |
| 12854 | * Return: None |
| 12855 | */ |
| 12856 | static void __exit hdd_module_exit(void) |
| 12857 | { |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12858 | __hdd_module_exit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12859 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12860 | #else |
| 12861 | static void __exit hdd_module_exit(void) |
| 12862 | { |
| 12863 | __hdd_module_exit(); |
| 12864 | wlan_deinit_sysfs(); |
| 12865 | } |
| 12866 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12867 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12868 | static int fwpath_changed_handler(const char *kmessage, |
| 12869 | const struct kernel_param *kp) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12870 | { |
| 12871 | return param_set_copystring(kmessage, kp); |
| 12872 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12873 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 12874 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
| 12875 | static bool is_monitor_mode_supported(void) |
| 12876 | { |
| 12877 | return true; |
| 12878 | } |
| 12879 | #else |
| 12880 | static bool is_monitor_mode_supported(void) |
| 12881 | { |
| 12882 | pr_err("Monitor mode not supported!"); |
| 12883 | return false; |
| 12884 | } |
| 12885 | #endif |
| 12886 | |
| 12887 | #ifdef WLAN_FEATURE_EPPING |
| 12888 | static bool is_epping_mode_supported(void) |
| 12889 | { |
| 12890 | return true; |
| 12891 | } |
| 12892 | #else |
| 12893 | static bool is_epping_mode_supported(void) |
| 12894 | { |
| 12895 | pr_err("Epping mode not supported!"); |
| 12896 | return false; |
| 12897 | } |
| 12898 | #endif |
| 12899 | |
Ryan Hsu | 6e9db0b | 2018-06-01 10:45:51 -0700 | [diff] [blame] | 12900 | #ifdef QCA_WIFI_FTM |
| 12901 | static bool is_ftm_mode_supported(void) |
| 12902 | { |
| 12903 | return true; |
| 12904 | } |
| 12905 | #else |
| 12906 | static bool is_ftm_mode_supported(void) |
| 12907 | { |
| 12908 | pr_err("FTM mode not supported!"); |
| 12909 | return false; |
| 12910 | } |
| 12911 | #endif |
| 12912 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12913 | /** |
| 12914 | * is_con_mode_valid() check con mode is valid or not |
| 12915 | * @mode: global con mode |
| 12916 | * |
| 12917 | * Return: TRUE on success FALSE on failure |
| 12918 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12919 | static bool is_con_mode_valid(enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12920 | { |
| 12921 | switch (mode) { |
| 12922 | case QDF_GLOBAL_MONITOR_MODE: |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 12923 | return is_monitor_mode_supported(); |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12924 | case QDF_GLOBAL_EPPING_MODE: |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 12925 | return is_epping_mode_supported(); |
| 12926 | case QDF_GLOBAL_FTM_MODE: |
Ryan Hsu | 6e9db0b | 2018-06-01 10:45:51 -0700 | [diff] [blame] | 12927 | return is_ftm_mode_supported(); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12928 | case QDF_GLOBAL_MISSION_MODE: |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12929 | return true; |
| 12930 | default: |
| 12931 | return false; |
| 12932 | } |
| 12933 | } |
| 12934 | |
| 12935 | /** |
| 12936 | * hdd_get_adpter_mode() - returns adapter mode based on global con mode |
| 12937 | * @mode: global con mode |
| 12938 | * |
| 12939 | * Return: adapter mode |
| 12940 | */ |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 12941 | static enum QDF_OPMODE hdd_get_adpter_mode( |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12942 | enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12943 | { |
| 12944 | |
| 12945 | switch (mode) { |
| 12946 | case QDF_GLOBAL_MISSION_MODE: |
| 12947 | return QDF_STA_MODE; |
| 12948 | case QDF_GLOBAL_MONITOR_MODE: |
| 12949 | return QDF_MONITOR_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12950 | case QDF_GLOBAL_EPPING_MODE: |
| 12951 | return QDF_EPPING_MODE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12952 | case QDF_GLOBAL_FTM_MODE: |
| 12953 | return QDF_FTM_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12954 | case QDF_GLOBAL_QVIT_MODE: |
| 12955 | return QDF_QVIT_MODE; |
| 12956 | default: |
| 12957 | return QDF_MAX_NO_OF_MODE; |
| 12958 | } |
| 12959 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12960 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12961 | static void hdd_stop_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12962 | enum QDF_GLOBAL_MODE curr_mode) |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12963 | { |
| 12964 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) |
| 12965 | return; |
| 12966 | |
| 12967 | switch (curr_mode) { |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12968 | case QDF_GLOBAL_MONITOR_MODE: |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12969 | hdd_info("Release wakelock for monitor mode!"); |
| 12970 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 12971 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
Dundi Raviteja | 0a2a65b | 2018-04-30 12:34:11 +0530 | [diff] [blame] | 12972 | /* fallthrough */ |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12973 | case QDF_GLOBAL_MISSION_MODE: |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12974 | case QDF_GLOBAL_FTM_MODE: |
| 12975 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 12976 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, NULL); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 12977 | hdd_stop_all_adapters(hdd_ctx); |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12978 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12979 | break; |
| 12980 | default: |
| 12981 | break; |
| 12982 | } |
| 12983 | } |
| 12984 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12985 | static void hdd_cleanup_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12986 | enum QDF_GLOBAL_MODE curr_mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12987 | { |
Ashish Kumar Dhanotiya | 0024313 | 2017-01-24 16:37:34 +0530 | [diff] [blame] | 12988 | int driver_status; |
| 12989 | |
| 12990 | driver_status = hdd_ctx->driver_status; |
| 12991 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12992 | switch (curr_mode) { |
| 12993 | case QDF_GLOBAL_MISSION_MODE: |
| 12994 | case QDF_GLOBAL_MONITOR_MODE: |
| 12995 | case QDF_GLOBAL_FTM_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12996 | hdd_deinit_all_adapters(hdd_ctx, false); |
| 12997 | hdd_close_all_adapters(hdd_ctx, false); |
| 12998 | break; |
| 12999 | case QDF_GLOBAL_EPPING_MODE: |
| 13000 | epping_disable(); |
| 13001 | epping_close(); |
| 13002 | break; |
| 13003 | default: |
| 13004 | return; |
| 13005 | } |
| 13006 | } |
| 13007 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13008 | static int hdd_register_req_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13009 | enum QDF_GLOBAL_MODE mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13010 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13011 | struct hdd_adapter *adapter; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13012 | int ret = 0; |
| 13013 | bool rtnl_held; |
| 13014 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 13015 | QDF_STATUS status; |
| 13016 | |
| 13017 | if (!qdf_dev) { |
| 13018 | hdd_err("qdf device context is Null return!"); |
| 13019 | return -EINVAL; |
| 13020 | } |
| 13021 | |
| 13022 | rtnl_held = hdd_hold_rtnl_lock(); |
| 13023 | switch (mode) { |
| 13024 | case QDF_GLOBAL_MISSION_MODE: |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 13025 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 13026 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13027 | hdd_err("Failed to open interfaces: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13028 | break; |
| 13029 | case QDF_GLOBAL_FTM_MODE: |
| 13030 | adapter = hdd_open_adapter(hdd_ctx, QDF_FTM_MODE, "wlan%d", |
| 13031 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 13032 | NET_NAME_UNKNOWN, rtnl_held); |
| 13033 | if (adapter == NULL) |
| 13034 | ret = -EINVAL; |
| 13035 | break; |
| 13036 | case QDF_GLOBAL_MONITOR_MODE: |
| 13037 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
| 13038 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 13039 | NET_NAME_UNKNOWN, rtnl_held); |
| 13040 | if (adapter == NULL) |
| 13041 | ret = -EINVAL; |
| 13042 | break; |
| 13043 | case QDF_GLOBAL_EPPING_MODE: |
| 13044 | status = epping_open(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 13045 | if (status != QDF_STATUS_SUCCESS) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13046 | hdd_err("Failed to open in eeping mode: %d", status); |
| 13047 | ret = -EINVAL; |
| 13048 | break; |
| 13049 | } |
| 13050 | ret = epping_enable(qdf_dev->dev); |
| 13051 | if (ret) { |
| 13052 | hdd_err("Failed to enable in epping mode : %d", ret); |
| 13053 | epping_close(); |
| 13054 | } |
| 13055 | break; |
| 13056 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13057 | hdd_err("Mode not supported"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13058 | ret = -ENOTSUPP; |
| 13059 | break; |
| 13060 | } |
| 13061 | hdd_release_rtnl_lock(); |
| 13062 | rtnl_held = false; |
| 13063 | return ret; |
| 13064 | } |
| 13065 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13066 | /** |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13067 | * __con_mode_handler() - Handles module param con_mode change |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13068 | * @kmessage: con mode name on which driver to be bring up |
| 13069 | * @kp: The associated kernel parameter |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13070 | * @hdd_ctx: Pointer to the global HDD context |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13071 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13072 | * This function is invoked when user updates con mode using sys entry, |
| 13073 | * to initialize and bring-up driver in that specific mode. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13074 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13075 | * Return - 0 on success and failure code on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13076 | */ |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13077 | static int __con_mode_handler(const char *kmessage, |
| 13078 | const struct kernel_param *kp, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13079 | struct hdd_context *hdd_ctx) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13080 | { |
| 13081 | int ret; |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13082 | enum QDF_GLOBAL_MODE curr_mode; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 13083 | enum QDF_OPMODE adapter_mode; |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 13084 | int new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13085 | |
Dustin Brown | ab6029b | 2017-05-24 13:04:19 -0700 | [diff] [blame] | 13086 | hdd_info("con_mode handler: %s", kmessage); |
| 13087 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13088 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13089 | if (ret) |
| 13090 | return ret; |
| 13091 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 13092 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 1); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13093 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 13094 | ret = kstrtoint(kmessage, 0, &new_con_mode); |
| 13095 | if (ret) { |
| 13096 | hdd_err("Failed to parse con_mode '%s'", kmessage); |
| 13097 | goto reset_flags; |
| 13098 | } |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 13099 | mutex_lock(&hdd_init_deinit_lock); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13100 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 13101 | if (!is_con_mode_valid(new_con_mode)) { |
| 13102 | hdd_err("invalid con_mode %d", new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13103 | ret = -EINVAL; |
| 13104 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13105 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13106 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13107 | curr_mode = hdd_get_conparam(); |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 13108 | if (curr_mode == new_con_mode) { |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13109 | hdd_err("curr mode: %d is same as user triggered mode %d", |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 13110 | curr_mode, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13111 | ret = 0; |
| 13112 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13113 | } |
| 13114 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13115 | /* ensure adapters are stopped */ |
| 13116 | hdd_stop_present_mode(hdd_ctx, curr_mode); |
| 13117 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 13118 | ret = hdd_wlan_stop_modules(hdd_ctx, true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13119 | if (ret) { |
| 13120 | hdd_err("Stop wlan modules failed"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13121 | goto reset_flags; |
| 13122 | } |
| 13123 | |
Dustin Brown | dd4e50f | 2018-05-24 15:43:42 -0700 | [diff] [blame] | 13124 | /* Cleanup present mode before switching to new mode */ |
| 13125 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
Ashish Kumar Dhanotiya | cda5766 | 2017-08-14 14:45:25 +0530 | [diff] [blame] | 13126 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 13127 | hdd_set_conparam(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13128 | |
| 13129 | /* Register for new con_mode & then kick_start modules again */ |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 13130 | ret = hdd_register_req_mode(hdd_ctx, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13131 | if (ret) { |
| 13132 | hdd_err("Failed to register for new mode"); |
| 13133 | goto reset_flags; |
| 13134 | } |
| 13135 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 13136 | adapter_mode = hdd_get_adpter_mode(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13137 | if (adapter_mode == QDF_MAX_NO_OF_MODE) { |
| 13138 | hdd_err("invalid adapter"); |
| 13139 | ret = -EINVAL; |
| 13140 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13141 | } |
| 13142 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 13143 | ret = hdd_wlan_start_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13144 | if (ret) { |
| 13145 | hdd_err("Start wlan modules failed: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13146 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13147 | } |
| 13148 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 13149 | if (new_con_mode == QDF_GLOBAL_MONITOR_MODE) { |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 13150 | struct hdd_adapter *adapter = |
| 13151 | hdd_get_adapter(hdd_ctx, adapter_mode); |
| 13152 | |
| 13153 | if (!adapter) { |
| 13154 | hdd_err("Failed to get adapter:%d", adapter_mode); |
| 13155 | goto reset_flags; |
| 13156 | } |
| 13157 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13158 | if (hdd_start_adapter(adapter)) { |
| 13159 | hdd_err("Failed to start %s adapter", kmessage); |
| 13160 | ret = -EINVAL; |
| 13161 | goto reset_flags; |
| 13162 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13163 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 13164 | hdd_info("Acquire wakelock for monitor mode!"); |
| 13165 | qdf_wake_lock_acquire(&hdd_ctx->monitor_mode_wakelock, |
| 13166 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 13167 | } |
| 13168 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 13169 | /* con_mode is a global module parameter */ |
| 13170 | con_mode = new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13171 | hdd_info("Mode successfully changed to %s", kmessage); |
| 13172 | ret = 0; |
| 13173 | |
| 13174 | reset_flags: |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 13175 | mutex_unlock(&hdd_init_deinit_lock); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 13176 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 0); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13177 | return ret; |
| 13178 | } |
| 13179 | |
| 13180 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13181 | 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] | 13182 | { |
| 13183 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13184 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13185 | |
| 13186 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13187 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13188 | if (ret) |
| 13189 | return ret; |
| 13190 | |
Ashish Kumar Dhanotiya | 759b327 | 2018-05-18 17:49:46 +0530 | [diff] [blame] | 13191 | if (!cds_wait_for_external_threads_completion(__func__)) { |
| 13192 | hdd_warn("External threads are still active, can not change mode"); |
| 13193 | return -EAGAIN; |
| 13194 | } |
| 13195 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13196 | cds_ssr_protect(__func__); |
| 13197 | ret = __con_mode_handler(kmessage, kp, hdd_ctx); |
| 13198 | cds_ssr_unprotect(__func__); |
| 13199 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13200 | return ret; |
| 13201 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13202 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 13203 | static int con_mode_handler_ftm(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13204 | const struct kernel_param *kp) |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 13205 | { |
| 13206 | int ret; |
| 13207 | |
| 13208 | ret = param_set_int(kmessage, kp); |
| 13209 | |
| 13210 | if (con_mode_ftm != QDF_GLOBAL_FTM_MODE) { |
| 13211 | pr_err("Only FTM mode supported!"); |
| 13212 | return -ENOTSUPP; |
| 13213 | } |
| 13214 | |
| 13215 | hdd_set_conparam(con_mode_ftm); |
| 13216 | con_mode = con_mode_ftm; |
| 13217 | |
| 13218 | return ret; |
| 13219 | } |
| 13220 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 13221 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 13222 | static int con_mode_handler_monitor(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13223 | const struct kernel_param *kp) |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 13224 | { |
| 13225 | int ret; |
| 13226 | |
| 13227 | ret = param_set_int(kmessage, kp); |
| 13228 | |
| 13229 | if (con_mode_monitor != QDF_GLOBAL_MONITOR_MODE) { |
| 13230 | pr_err("Only Monitor mode supported!"); |
| 13231 | return -ENOTSUPP; |
| 13232 | } |
| 13233 | |
| 13234 | hdd_set_conparam(con_mode_monitor); |
| 13235 | con_mode = con_mode_monitor; |
| 13236 | |
| 13237 | return ret; |
| 13238 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 13239 | #endif |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 13240 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13241 | /** |
| 13242 | * hdd_get_conparam() - driver exit point |
| 13243 | * |
| 13244 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 13245 | * |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13246 | * Return: enum QDF_GLOBAL_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13247 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13248 | enum QDF_GLOBAL_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13249 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13250 | return (enum QDF_GLOBAL_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13251 | } |
| 13252 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 13253 | void hdd_set_conparam(uint32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13254 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 13255 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13256 | } |
| 13257 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 13258 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 13259 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 13260 | * @hdd_ctx: HDD context |
| 13261 | * |
| 13262 | * Cleans up the pre cac interface, if it exists |
| 13263 | * |
| 13264 | * Return: None |
| 13265 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13266 | void hdd_clean_up_pre_cac_interface(struct hdd_context *hdd_ctx) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 13267 | { |
| 13268 | uint8_t session_id; |
| 13269 | QDF_STATUS status; |
Jeff Johnson | 85b5c11 | 2017-08-11 15:15:23 -0700 | [diff] [blame] | 13270 | struct hdd_adapter *precac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 13271 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13272 | 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] | 13273 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13274 | hdd_err("failed to get pre cac vdev id"); |
| 13275 | return; |
| 13276 | } |
| 13277 | |
| 13278 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, session_id); |
| 13279 | if (!precac_adapter) { |
Jeff Johnson | dd2f1fc | 2018-05-06 11:22:52 -0700 | [diff] [blame] | 13280 | hdd_err("invalid pre cac adapter"); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 13281 | return; |
| 13282 | } |
| 13283 | |
| 13284 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 13285 | wlan_hdd_sap_pre_cac_failure, |
| 13286 | (void *)precac_adapter); |
| 13287 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 13288 | |
| 13289 | } |
| 13290 | |
| 13291 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13292 | * hdd_update_ol_config - API to update ol configuration parameters |
| 13293 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 13294 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 13295 | * Return: void |
| 13296 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13297 | static void hdd_update_ol_config(struct hdd_context *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 13298 | { |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13299 | struct ol_config_info cfg; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 13300 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 13301 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13302 | if (!ol_ctx) |
| 13303 | return; |
| 13304 | |
| 13305 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
| 13306 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 13307 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 13308 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 13309 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13310 | |
| 13311 | ol_init_ini_config(ol_ctx, &cfg); |
| 13312 | } |
| 13313 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 13314 | #ifdef FEATURE_RUNTIME_PM |
| 13315 | /** |
| 13316 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 13317 | * @hdd_ctx: hdd context |
| 13318 | * @cfg: pointer to the configuration memory being populated |
| 13319 | * |
| 13320 | * Return: void |
| 13321 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13322 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 13323 | struct hif_config_info *cfg) |
| 13324 | { |
| 13325 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
| 13326 | cfg->runtime_pm_delay = hdd_ctx->config->runtime_pm_delay; |
| 13327 | } |
| 13328 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13329 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 13330 | struct hif_config_info *cfg) |
| 13331 | { |
| 13332 | } |
| 13333 | #endif |
| 13334 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13335 | /** |
| 13336 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 13337 | * @hdd_ctx: HDD Context |
| 13338 | * |
| 13339 | * Return: void |
| 13340 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13341 | static void hdd_update_hif_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13342 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 13343 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13344 | struct hif_config_info cfg; |
| 13345 | |
| 13346 | if (!scn) |
| 13347 | return; |
| 13348 | |
| 13349 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 13350 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13351 | hif_init_ini_config(scn, &cfg); |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 13352 | |
| 13353 | if (hdd_ctx->config->prevent_link_down) |
| 13354 | hif_vote_link_up(scn); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13355 | } |
| 13356 | |
| 13357 | /** |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13358 | * hdd_update_dp_config() - Propagate config parameters to Lithium |
| 13359 | * datapath |
| 13360 | * @hdd_ctx: HDD Context |
| 13361 | * |
| 13362 | * Return: 0 for success/errno for failure |
| 13363 | */ |
| 13364 | static int hdd_update_dp_config(struct hdd_context *hdd_ctx) |
| 13365 | { |
| 13366 | struct cdp_config_params params; |
| 13367 | QDF_STATUS status; |
| 13368 | |
| 13369 | params.tso_enable = hdd_ctx->config->tso_enable; |
| 13370 | params.lro_enable = hdd_ctx->config->lro_enable; |
| 13371 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 13372 | params.tx_flow_stop_queue_threshold = |
| 13373 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 13374 | params.tx_flow_start_queue_offset = |
| 13375 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 13376 | #endif |
| 13377 | params.flow_steering_enable = hdd_ctx->config->flow_steering_enable; |
| 13378 | params.napi_enable = hdd_ctx->napi_enable; |
| 13379 | params.tcp_udp_checksumoffload = |
| 13380 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
| 13381 | |
| 13382 | status = cdp_update_config_parameters( |
| 13383 | cds_get_context(QDF_MODULE_ID_SOC), |
| 13384 | ¶ms); |
| 13385 | if (status) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 13386 | hdd_err("Failed to attach config parameters"); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13387 | return status; |
| 13388 | } |
| 13389 | |
| 13390 | return 0; |
| 13391 | } |
| 13392 | |
| 13393 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13394 | * hdd_update_config() - Initialize driver per module ini parameters |
| 13395 | * @hdd_ctx: HDD Context |
| 13396 | * |
| 13397 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 13398 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13399 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13400 | int hdd_update_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13401 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 13402 | int ret; |
| 13403 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13404 | hdd_update_ol_config(hdd_ctx); |
| 13405 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 13406 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 13407 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 13408 | else |
| 13409 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 13410 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 13411 | |
| 13412 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 13413 | } |
| 13414 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13415 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 13416 | /** |
| 13417 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 13418 | * @psoc_cfg: pmo psoc Configuration |
| 13419 | * @hdd_ctx: Pointer to hdd context |
| 13420 | * |
| 13421 | * Return: none |
| 13422 | */ |
| 13423 | static inline void hdd_ra_populate_pmo_config( |
| 13424 | struct pmo_psoc_cfg *psoc_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13425 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13426 | { |
| 13427 | psoc_cfg->ra_ratelimit_interval = |
| 13428 | hdd_ctx->config->RArateLimitInterval; |
| 13429 | psoc_cfg->ra_ratelimit_enable = |
| 13430 | hdd_ctx->config->IsRArateLimitEnabled; |
| 13431 | } |
| 13432 | #else |
| 13433 | static inline void hdd_ra_populate_pmo_config( |
| 13434 | struct cds_config_info *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13435 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13436 | { |
| 13437 | } |
| 13438 | #endif |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 13439 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13440 | /** |
| 13441 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 13442 | * @hdd_ctx: HDD context |
| 13443 | * |
| 13444 | * Return: void |
| 13445 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13446 | static int hdd_update_pmo_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13447 | { |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13448 | struct pmo_psoc_cfg psoc_cfg; |
| 13449 | QDF_STATUS status; |
| 13450 | |
| 13451 | /* |
| 13452 | * Value of hdd_ctx->wowEnable can be, |
| 13453 | * 0 - Disable both magic pattern match and pattern byte match. |
| 13454 | * 1 - Enable magic pattern match on all interfaces. |
| 13455 | * 2 - Enable pattern byte match on all interfaces. |
| 13456 | * 3 - Enable both magic patter and pattern byte match on |
| 13457 | * all interfaces. |
| 13458 | */ |
| 13459 | psoc_cfg.magic_ptrn_enable = |
| 13460 | (hdd_ctx->config->wowEnable & 0x01) ? true : false; |
| 13461 | psoc_cfg.ptrn_match_enable_all_vdev = |
| 13462 | (hdd_ctx->config->wowEnable & 0x02) ? true : false; |
Nachiket Kukade | e547a48 | 2018-05-22 16:43:30 +0530 | [diff] [blame] | 13463 | psoc_cfg.apf_enable = hdd_ctx->config->apf_packet_filter_enable; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13464 | psoc_cfg.arp_offload_enable = hdd_ctx->config->fhostArpOffload; |
Nachiket Kukade | f080407 | 2018-02-27 18:20:07 +0530 | [diff] [blame] | 13465 | psoc_cfg.hw_filter_mode_bitmap = hdd_ctx->config->hw_filter_mode_bitmap; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 13466 | psoc_cfg.ns_offload_enable_dynamic = hdd_ctx->config->fhostNSOffload; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13467 | psoc_cfg.ns_offload_enable_static = hdd_ctx->config->fhostNSOffload; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 13468 | psoc_cfg.packet_filter_enabled = !hdd_ctx->config->disablePacketFilter; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13469 | psoc_cfg.ssdp = hdd_ctx->config->ssdp; |
| 13470 | psoc_cfg.enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 13471 | psoc_cfg.active_mode_offload = hdd_ctx->config->active_mode_offload; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13472 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 13473 | psoc_cfg.d0_wow_supported = wma_d0_wow_is_supported(); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 13474 | psoc_cfg.sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 13475 | psoc_cfg.sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 13476 | psoc_cfg.sta_max_li_mod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 13477 | psoc_cfg.power_save_mode = hdd_ctx->config->enablePowersaveOffload; |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 13478 | psoc_cfg.auto_power_save_fail_mode = |
| 13479 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13480 | |
| 13481 | hdd_ra_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 13482 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13483 | |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 13484 | status = ucfg_pmo_update_psoc_config(hdd_ctx->hdd_psoc, &psoc_cfg); |
| 13485 | if (QDF_IS_STATUS_ERROR(status)) |
| 13486 | hdd_err("failed pmo psoc configuration; status:%d", status); |
| 13487 | |
| 13488 | return qdf_status_to_os_return(status); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13489 | } |
| 13490 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13491 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 13492 | static inline void hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
| 13493 | struct hdd_config *cfg) |
| 13494 | { |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 13495 | struct nlo_mawc_params *mawc_cfg = &pno_cfg->mawc_params; |
| 13496 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13497 | pno_cfg->channel_prediction = cfg->pno_channel_prediction; |
| 13498 | pno_cfg->top_k_num_of_channels = cfg->top_k_num_of_channels; |
| 13499 | pno_cfg->stationary_thresh = cfg->stationary_thresh; |
| 13500 | pno_cfg->adaptive_dwell_mode = cfg->adaptive_dwell_mode_enabled; |
| 13501 | pno_cfg->channel_prediction_full_scan = |
| 13502 | cfg->channel_prediction_full_scan; |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 13503 | mawc_cfg->enable = cfg->MAWCEnabled && cfg->mawc_nlo_enabled; |
| 13504 | mawc_cfg->exp_backoff_ratio = cfg->mawc_nlo_exp_backoff_ratio; |
| 13505 | mawc_cfg->init_scan_interval = cfg->mawc_nlo_init_scan_interval; |
| 13506 | mawc_cfg->max_scan_interval = cfg->mawc_nlo_max_scan_interval; |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13507 | } |
| 13508 | #else |
| 13509 | static inline void |
| 13510 | hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
Jeff Johnson | 33a0792 | 2017-10-05 09:08:46 -0700 | [diff] [blame] | 13511 | struct hdd_config *cfg) |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13512 | { |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13513 | } |
| 13514 | #endif |
| 13515 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 13516 | void hdd_update_ie_whitelist_attr(struct probe_req_whitelist_attr *ie_whitelist, |
| 13517 | struct hdd_config *cfg) |
| 13518 | { |
| 13519 | uint8_t i = 0; |
| 13520 | |
| 13521 | ie_whitelist->white_list = cfg->probe_req_ie_whitelist; |
| 13522 | if (!ie_whitelist->white_list) |
| 13523 | return; |
| 13524 | |
| 13525 | ie_whitelist->ie_bitmap[0] = cfg->probe_req_ie_bitmap_0; |
| 13526 | ie_whitelist->ie_bitmap[1] = cfg->probe_req_ie_bitmap_1; |
| 13527 | ie_whitelist->ie_bitmap[2] = cfg->probe_req_ie_bitmap_2; |
| 13528 | ie_whitelist->ie_bitmap[3] = cfg->probe_req_ie_bitmap_3; |
| 13529 | ie_whitelist->ie_bitmap[4] = cfg->probe_req_ie_bitmap_4; |
| 13530 | ie_whitelist->ie_bitmap[5] = cfg->probe_req_ie_bitmap_5; |
| 13531 | ie_whitelist->ie_bitmap[6] = cfg->probe_req_ie_bitmap_6; |
| 13532 | ie_whitelist->ie_bitmap[7] = cfg->probe_req_ie_bitmap_7; |
| 13533 | |
| 13534 | ie_whitelist->num_vendor_oui = cfg->no_of_probe_req_ouis; |
| 13535 | for (i = 0; i < ie_whitelist->num_vendor_oui; i++) |
| 13536 | ie_whitelist->voui[i] = cfg->probe_req_voui[i]; |
| 13537 | } |
| 13538 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 13539 | uint32_t hdd_limit_max_per_index_score(uint32_t per_index_score) |
| 13540 | { |
| 13541 | uint8_t i, score; |
| 13542 | |
| 13543 | for (i = 0; i < MAX_INDEX_PER_INI; i++) { |
| 13544 | score = WLAN_GET_SCORE_PERCENTAGE(per_index_score, i); |
| 13545 | if (score > MAX_INDEX_SCORE) |
| 13546 | WLAN_SET_SCORE_PERCENTAGE(per_index_score, |
| 13547 | MAX_INDEX_SCORE, i); |
| 13548 | } |
| 13549 | |
| 13550 | return per_index_score; |
| 13551 | } |
| 13552 | |
| 13553 | /** |
| 13554 | * hdd_update_score_config - API to update candidate scoring related params |
| 13555 | * configuration parameters |
| 13556 | * @score_config: score config to update |
| 13557 | * @cfg: config params |
| 13558 | * |
| 13559 | * Return: 0 if success else err |
| 13560 | */ |
| 13561 | static void hdd_update_score_config( |
| 13562 | struct scoring_config *score_config, struct hdd_config *cfg) |
| 13563 | { |
| 13564 | int total_weight; |
| 13565 | |
| 13566 | score_config->weight_cfg.rssi_weightage = cfg->rssi_weightage; |
| 13567 | score_config->weight_cfg.ht_caps_weightage = cfg->ht_caps_weightage; |
| 13568 | score_config->weight_cfg.vht_caps_weightage = |
| 13569 | cfg->vht_caps_weightage; |
| 13570 | score_config->weight_cfg.he_caps_weightage = |
| 13571 | cfg->he_caps_weightage; |
| 13572 | score_config->weight_cfg.chan_width_weightage = |
| 13573 | cfg->chan_width_weightage; |
| 13574 | score_config->weight_cfg.chan_band_weightage = |
| 13575 | cfg->chan_band_weightage; |
| 13576 | score_config->weight_cfg.nss_weightage = cfg->nss_weightage; |
| 13577 | score_config->weight_cfg.beamforming_cap_weightage = |
| 13578 | cfg->beamforming_cap_weightage; |
| 13579 | score_config->weight_cfg.pcl_weightage = cfg->pcl_weightage; |
| 13580 | score_config->weight_cfg.channel_congestion_weightage = |
| 13581 | cfg->channel_congestion_weightage; |
| 13582 | score_config->weight_cfg.oce_wan_weightage = cfg->oce_wan_weightage; |
| 13583 | |
| 13584 | total_weight = score_config->weight_cfg.rssi_weightage + |
| 13585 | score_config->weight_cfg.ht_caps_weightage + |
| 13586 | score_config->weight_cfg.vht_caps_weightage + |
| 13587 | score_config->weight_cfg.he_caps_weightage + |
| 13588 | score_config->weight_cfg.chan_width_weightage + |
| 13589 | score_config->weight_cfg.chan_band_weightage + |
| 13590 | score_config->weight_cfg.nss_weightage + |
| 13591 | score_config->weight_cfg.beamforming_cap_weightage + |
| 13592 | score_config->weight_cfg.pcl_weightage + |
| 13593 | score_config->weight_cfg.channel_congestion_weightage + |
| 13594 | score_config->weight_cfg.oce_wan_weightage; |
| 13595 | |
| 13596 | if (total_weight > BEST_CANDIDATE_MAX_WEIGHT) { |
| 13597 | hdd_err("total weight is greater than %d fallback to default values", |
| 13598 | BEST_CANDIDATE_MAX_WEIGHT); |
| 13599 | |
| 13600 | score_config->weight_cfg.rssi_weightage = RSSI_WEIGHTAGE; |
| 13601 | score_config->weight_cfg.ht_caps_weightage = |
| 13602 | HT_CAPABILITY_WEIGHTAGE; |
| 13603 | score_config->weight_cfg.vht_caps_weightage = VHT_CAP_WEIGHTAGE; |
| 13604 | score_config->weight_cfg.he_caps_weightage = HE_CAP_WEIGHTAGE; |
| 13605 | score_config->weight_cfg.chan_width_weightage = |
| 13606 | CHAN_WIDTH_WEIGHTAGE; |
| 13607 | score_config->weight_cfg.chan_band_weightage = |
| 13608 | CHAN_BAND_WEIGHTAGE; |
| 13609 | score_config->weight_cfg.nss_weightage = NSS_WEIGHTAGE; |
| 13610 | score_config->weight_cfg.beamforming_cap_weightage = |
| 13611 | BEAMFORMING_CAP_WEIGHTAGE; |
| 13612 | score_config->weight_cfg.pcl_weightage = PCL_WEIGHT; |
| 13613 | score_config->weight_cfg.channel_congestion_weightage = |
| 13614 | CHANNEL_CONGESTION_WEIGHTAGE; |
| 13615 | score_config->weight_cfg.oce_wan_weightage = OCE_WAN_WEIGHTAGE; |
| 13616 | } |
| 13617 | |
| 13618 | score_config->bandwidth_weight_per_index = |
| 13619 | hdd_limit_max_per_index_score( |
| 13620 | cfg->bandwidth_weight_per_index); |
| 13621 | score_config->nss_weight_per_index = |
| 13622 | hdd_limit_max_per_index_score(cfg->nss_weight_per_index); |
| 13623 | score_config->band_weight_per_index = |
| 13624 | hdd_limit_max_per_index_score(cfg->band_weight_per_index); |
| 13625 | |
| 13626 | score_config->rssi_score.best_rssi_threshold = |
| 13627 | cfg->best_rssi_threshold; |
| 13628 | score_config->rssi_score.good_rssi_threshold = |
| 13629 | cfg->good_rssi_threshold; |
| 13630 | score_config->rssi_score.bad_rssi_threshold = |
| 13631 | cfg->bad_rssi_threshold; |
| 13632 | score_config->rssi_score.good_rssi_pcnt = cfg->good_rssi_pcnt; |
| 13633 | score_config->rssi_score.bad_rssi_pcnt = cfg->bad_rssi_pcnt; |
| 13634 | score_config->rssi_score.good_rssi_bucket_size = |
| 13635 | cfg->good_rssi_bucket_size; |
| 13636 | score_config->rssi_score.bad_rssi_bucket_size = |
| 13637 | cfg->bad_rssi_bucket_size; |
| 13638 | score_config->rssi_score.rssi_pref_5g_rssi_thresh = |
| 13639 | cfg->rssi_pref_5g_rssi_thresh; |
| 13640 | |
| 13641 | score_config->esp_qbss_scoring.num_slot = cfg->num_esp_qbss_slots; |
| 13642 | score_config->esp_qbss_scoring.score_pcnt3_to_0 = |
| 13643 | hdd_limit_max_per_index_score( |
| 13644 | cfg->esp_qbss_score_slots3_to_0); |
| 13645 | score_config->esp_qbss_scoring.score_pcnt7_to_4 = |
| 13646 | hdd_limit_max_per_index_score( |
| 13647 | cfg->esp_qbss_score_slots7_to_4); |
| 13648 | score_config->esp_qbss_scoring.score_pcnt11_to_8 = |
| 13649 | hdd_limit_max_per_index_score( |
| 13650 | cfg->esp_qbss_score_slots11_to_8); |
| 13651 | score_config->esp_qbss_scoring.score_pcnt15_to_12 = |
| 13652 | hdd_limit_max_per_index_score( |
| 13653 | cfg->esp_qbss_score_slots15_to_12); |
| 13654 | |
| 13655 | score_config->oce_wan_scoring.num_slot = cfg->num_oce_wan_slots; |
| 13656 | score_config->oce_wan_scoring.score_pcnt3_to_0 = |
| 13657 | hdd_limit_max_per_index_score( |
| 13658 | cfg->oce_wan_score_slots3_to_0); |
| 13659 | score_config->oce_wan_scoring.score_pcnt7_to_4 = |
| 13660 | hdd_limit_max_per_index_score( |
| 13661 | cfg->oce_wan_score_slots7_to_4); |
| 13662 | score_config->oce_wan_scoring.score_pcnt11_to_8 = |
| 13663 | hdd_limit_max_per_index_score( |
| 13664 | cfg->oce_wan_score_slots11_to_8); |
| 13665 | score_config->oce_wan_scoring.score_pcnt15_to_12 = |
| 13666 | hdd_limit_max_per_index_score( |
| 13667 | cfg->oce_wan_score_slots15_to_12); |
| 13668 | |
| 13669 | |
| 13670 | score_config->cb_mode_24G = cfg->nChannelBondingMode24GHz; |
| 13671 | score_config->cb_mode_5G = cfg->nChannelBondingMode5GHz; |
| 13672 | score_config->nss = cfg->enable2x2 ? 2 : 1; |
| 13673 | |
| 13674 | if (cfg->dot11Mode == eHDD_DOT11_MODE_AUTO || |
| 13675 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 13676 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) |
| 13677 | score_config->he_cap = 1; |
| 13678 | |
| 13679 | if (score_config->he_cap || |
| 13680 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 13681 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) |
| 13682 | score_config->vht_cap = 1; |
| 13683 | |
| 13684 | if (score_config->vht_cap || cfg->dot11Mode == eHDD_DOT11_MODE_11n || |
| 13685 | cfg->dot11Mode == eHDD_DOT11_MODE_11n_ONLY) |
| 13686 | score_config->ht_cap = 1; |
| 13687 | |
| 13688 | if (score_config->vht_cap && cfg->enableVhtFor24GHzBand) |
| 13689 | score_config->vht_24G_cap = 1; |
| 13690 | |
| 13691 | if (cfg->enableTxBF) |
| 13692 | score_config->beamformee_cap = 1; |
| 13693 | |
| 13694 | } |
| 13695 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13696 | /** |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 13697 | * hdd_update_dfs_config() - API to update dfs configuration parameters. |
| 13698 | * @hdd_ctx: HDD context |
| 13699 | * |
| 13700 | * Return: 0 if success else err |
| 13701 | */ |
| 13702 | static int hdd_update_dfs_config(struct hdd_context *hdd_ctx) |
| 13703 | { |
| 13704 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 13705 | struct hdd_config *cfg = hdd_ctx->config; |
| 13706 | struct dfs_user_config dfs_cfg; |
| 13707 | QDF_STATUS status; |
| 13708 | |
| 13709 | dfs_cfg.dfs_is_phyerr_filter_offload = !!cfg->fDfsPhyerrFilterOffload; |
| 13710 | status = ucfg_dfs_update_config(psoc, &dfs_cfg); |
| 13711 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13712 | hdd_err("failed dfs psoc configuration"); |
| 13713 | return -EINVAL; |
| 13714 | } |
| 13715 | |
| 13716 | return 0; |
| 13717 | } |
| 13718 | |
| 13719 | /** |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13720 | * hdd_update_scan_config - API to update scan configuration parameters |
| 13721 | * @hdd_ctx: HDD context |
| 13722 | * |
| 13723 | * Return: 0 if success else err |
| 13724 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13725 | static int hdd_update_scan_config(struct hdd_context *hdd_ctx) |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13726 | { |
| 13727 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 13728 | struct scan_user_cfg scan_cfg; |
| 13729 | struct hdd_config *cfg = hdd_ctx->config; |
| 13730 | QDF_STATUS status; |
| 13731 | |
| 13732 | scan_cfg.active_dwell = cfg->nActiveMaxChnTime; |
| 13733 | scan_cfg.passive_dwell = cfg->nPassiveMaxChnTime; |
| 13734 | scan_cfg.conc_active_dwell = cfg->nActiveMaxChnTimeConc; |
| 13735 | scan_cfg.conc_passive_dwell = cfg->nPassiveMaxChnTimeConc; |
| 13736 | scan_cfg.conc_max_rest_time = cfg->nRestTimeConc; |
| 13737 | scan_cfg.conc_min_rest_time = cfg->min_rest_time_conc; |
| 13738 | scan_cfg.conc_idle_time = cfg->idle_time_conc; |
Abhishek Singh | 158fe25 | 2017-03-23 11:09:34 +0530 | [diff] [blame] | 13739 | /* convert to ms */ |
| 13740 | scan_cfg.scan_cache_aging_time = |
| 13741 | cfg->scanAgingTimeout * 1000; |
| 13742 | scan_cfg.prefer_5ghz = cfg->nRoamPrefer5GHz; |
| 13743 | scan_cfg.select_5ghz_margin = cfg->nSelect5GHzMargin; |
| 13744 | scan_cfg.scan_bucket_threshold = cfg->first_scan_bucket_threshold; |
| 13745 | scan_cfg.rssi_cat_gap = cfg->nRssiCatGap; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13746 | scan_cfg.scan_dwell_time_mode = cfg->scan_adaptive_dwell_mode; |
Kapil Gupta | fa9a8c6 | 2017-04-10 15:25:40 +0530 | [diff] [blame] | 13747 | scan_cfg.is_snr_monitoring_enabled = cfg->fEnableSNRMonitoring; |
Jeff Johnson | 81c00d0 | 2017-11-07 12:34:36 -0800 | [diff] [blame] | 13748 | scan_cfg.usr_cfg_probe_rpt_time = cfg->scan_probe_repeat_time; |
| 13749 | scan_cfg.usr_cfg_num_probes = cfg->scan_num_probes; |
Abhishek Singh | b58164a | 2017-07-19 18:47:23 +0530 | [diff] [blame] | 13750 | scan_cfg.is_bssid_hint_priority = cfg->is_bssid_hint_priority; |
Kiran Kumar Lokere | d547fdd | 2017-09-13 17:20:55 -0700 | [diff] [blame] | 13751 | scan_cfg.enable_mac_spoofing = cfg->enable_mac_spoofing; |
Abhishek Singh | c87bb04 | 2018-01-30 17:10:42 +0530 | [diff] [blame] | 13752 | scan_cfg.sta_miracast_mcc_rest_time = |
| 13753 | cfg->sta_miracast_mcc_rest_time_val; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13754 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13755 | hdd_update_pno_config(&scan_cfg.pno_cfg, cfg); |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 13756 | hdd_update_ie_whitelist_attr(&scan_cfg.ie_whitelist, cfg); |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 13757 | hdd_update_score_config(&scan_cfg.score_config, cfg); |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13758 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13759 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 13760 | if (status != QDF_STATUS_SUCCESS) { |
| 13761 | hdd_err("failed pmo psoc configuration"); |
| 13762 | return -EINVAL; |
| 13763 | } |
| 13764 | |
| 13765 | return 0; |
| 13766 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13767 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13768 | int hdd_update_components_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13769 | { |
| 13770 | int ret; |
| 13771 | |
| 13772 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13773 | if (ret) |
| 13774 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13775 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13776 | ret = hdd_update_scan_config(hdd_ctx); |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 13777 | if (ret) |
| 13778 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13779 | |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 13780 | ret = hdd_update_tdls_config(hdd_ctx); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13781 | if (ret) |
| 13782 | return ret; |
| 13783 | |
| 13784 | ret = hdd_update_dp_config(hdd_ctx); |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 13785 | if (ret) |
| 13786 | return ret; |
| 13787 | |
| 13788 | ret = hdd_update_dfs_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13789 | |
| 13790 | return ret; |
| 13791 | } |
| 13792 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13793 | /** |
| 13794 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 13795 | * @mode : cfg80211 DFS mode |
| 13796 | * |
| 13797 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 13798 | */ |
| 13799 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 13800 | { |
| 13801 | switch (mode) { |
| 13802 | case DFS_MODE_ENABLE: |
| 13803 | return ACS_DFS_MODE_ENABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13804 | case DFS_MODE_DISABLE: |
| 13805 | return ACS_DFS_MODE_DISABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13806 | case DFS_MODE_DEPRIORITIZE: |
| 13807 | return ACS_DFS_MODE_DEPRIORITIZE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13808 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13809 | hdd_debug("ACS dfs mode is NONE"); |
| 13810 | return ACS_DFS_MODE_NONE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13811 | } |
| 13812 | } |
| 13813 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13814 | /** |
| 13815 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 13816 | * @hddctx: pointer to hdd context |
| 13817 | * @set_value: enable/disable |
| 13818 | * |
| 13819 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 13820 | * Host(even though it is duplicate). When Host send vendor command |
| 13821 | * disable,FW doesn't perform any action. Whenever any change in |
| 13822 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 13823 | * |
| 13824 | * return - 0 on success, appropriate error values on failure. |
| 13825 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13826 | 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] | 13827 | { |
| 13828 | QDF_STATUS status; |
| 13829 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13830 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13831 | return -EAGAIN; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13832 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13833 | if (!hdd_ctx->config->goptimize_chan_avoid_event) { |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13834 | hdd_warn("goptimize_chan_avoid_event ini param disabled"); |
| 13835 | return -EINVAL; |
| 13836 | } |
| 13837 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13838 | status = sme_enable_disable_chanavoidind_event(hdd_ctx->mac_handle, |
| 13839 | set_value); |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13840 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13841 | hdd_err("Failed to send chan avoid command to SME"); |
| 13842 | return -EINVAL; |
| 13843 | } |
| 13844 | return 0; |
| 13845 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13846 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13847 | /** |
| 13848 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 13849 | * @value: value to set |
| 13850 | * |
| 13851 | * This function will set the passed value to roaming in progress flag. |
| 13852 | * |
| 13853 | * Return: None |
| 13854 | */ |
| 13855 | void hdd_set_roaming_in_progress(bool value) |
| 13856 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13857 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13858 | |
| 13859 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13860 | if (!hdd_ctx) { |
| 13861 | hdd_err("HDD context is NULL"); |
| 13862 | return; |
| 13863 | } |
| 13864 | |
| 13865 | hdd_ctx->roaming_in_progress = value; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13866 | hdd_debug("Roaming in Progress set to %d", value); |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13867 | } |
| 13868 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 13869 | bool hdd_is_roaming_in_progress(struct hdd_context *hdd_ctx) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13870 | { |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13871 | if (!hdd_ctx) { |
| 13872 | hdd_err("HDD context is NULL"); |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 13873 | return false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13874 | } |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13875 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 13876 | hdd_debug("roaming_in_progress = %d", hdd_ctx->roaming_in_progress); |
| 13877 | |
| 13878 | return hdd_ctx->roaming_in_progress; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13879 | } |
| 13880 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13881 | /** |
| 13882 | * hdd_is_connection_in_progress() - check if connection is in |
| 13883 | * progress |
| 13884 | * @session_id: session id |
| 13885 | * @reason: scan reject reason |
| 13886 | * |
| 13887 | * Go through each adapter and check if Connection is in progress |
| 13888 | * |
| 13889 | * Return: true if connection is in progress else false |
| 13890 | */ |
| 13891 | bool hdd_is_connection_in_progress(uint8_t *session_id, |
| 13892 | enum scan_reject_states *reason) |
| 13893 | { |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 13894 | struct hdd_station_ctx *hdd_sta_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13895 | struct hdd_adapter *adapter = NULL; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13896 | uint8_t sta_id = 0; |
| 13897 | uint8_t *sta_mac = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13898 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13899 | mac_handle_t mac_handle; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13900 | |
| 13901 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13902 | if (!hdd_ctx) { |
| 13903 | hdd_err("HDD context is NULL"); |
| 13904 | return false; |
| 13905 | } |
| 13906 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13907 | mac_handle = hdd_ctx->mac_handle; |
| 13908 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 13909 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Tushnim Bhattacharyya | 929afa4 | 2018-06-01 15:04:44 -0700 | [diff] [blame] | 13910 | hdd_debug("Adapter with device mode %s(%d) exists", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13911 | hdd_device_mode_to_string(adapter->device_mode), |
| 13912 | adapter->device_mode); |
| 13913 | if (((QDF_STA_MODE == adapter->device_mode) |
| 13914 | || (QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 13915 | || (QDF_P2P_DEVICE_MODE == adapter->device_mode)) |
| 13916 | && (eConnectionState_Connecting == |
| 13917 | (WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> |
| 13918 | conn_info.connState)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13919 | hdd_debug("%pK(%d) Connection is in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13920 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13921 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13922 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13923 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13924 | *reason = CONNECTION_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13925 | } |
| 13926 | return true; |
| 13927 | } |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 13928 | /* |
| 13929 | * sme_neighbor_middle_of_roaming is for LFR2 |
| 13930 | * hdd_is_roaming_in_progress is for LFR3 |
| 13931 | */ |
| 13932 | if (((QDF_STA_MODE == adapter->device_mode) && |
| 13933 | sme_neighbor_middle_of_roaming( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13934 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13935 | adapter->session_id)) || |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 13936 | hdd_is_roaming_in_progress(hdd_ctx)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13937 | hdd_debug("%pK(%d) Reassociation in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13938 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13939 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13940 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13941 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13942 | *reason = REASSOC_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13943 | } |
| 13944 | return true; |
| 13945 | } |
| 13946 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 13947 | (QDF_P2P_CLIENT_MODE == adapter->device_mode) || |
| 13948 | (QDF_P2P_DEVICE_MODE == adapter->device_mode)) { |
| 13949 | hdd_sta_ctx = |
| 13950 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 13951 | if ((eConnectionState_Associated == |
Vignesh Viswanathan | 0a56929 | 2018-02-14 15:34:47 +0530 | [diff] [blame] | 13952 | hdd_sta_ctx->conn_info.connState) |
| 13953 | && sme_is_sta_key_exchange_in_progress( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13954 | mac_handle, adapter->session_id)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13955 | sta_mac = (uint8_t *) |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 13956 | &(adapter->mac_addr.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13957 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13958 | " is in middle of WPS/EAPOL exchange.", |
| 13959 | MAC_ADDR_ARRAY(sta_mac)); |
| 13960 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13961 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13962 | *reason = EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13963 | } |
| 13964 | return true; |
| 13965 | } |
| 13966 | } else if ((QDF_SAP_MODE == adapter->device_mode) || |
| 13967 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
| 13968 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; |
| 13969 | sta_id++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13970 | if (!((adapter->sta_info[sta_id].in_use) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13971 | && (OL_TXRX_PEER_STATE_CONN == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13972 | adapter->sta_info[sta_id].peer_state))) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13973 | continue; |
| 13974 | |
| 13975 | sta_mac = (uint8_t *) |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13976 | &(adapter->sta_info[sta_id]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 13977 | sta_mac.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13978 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13979 | " of SAP/GO is in middle of WPS/EAPOL exchange", |
| 13980 | MAC_ADDR_ARRAY(sta_mac)); |
| 13981 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13982 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13983 | *reason = SAP_EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13984 | } |
| 13985 | return true; |
| 13986 | } |
| 13987 | if (hdd_ctx->connection_in_progress) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13988 | hdd_debug("AP/GO: connection is in progress"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13989 | return true; |
| 13990 | } |
| 13991 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13992 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 13993 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13994 | return false; |
| 13995 | } |
| 13996 | |
| 13997 | /** |
| 13998 | * hdd_restart_sap() - to restart SAP in driver internally |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13999 | * @ap_adapter: Pointer to SAP struct hdd_adapter structure |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14000 | * |
| 14001 | * Return: None |
| 14002 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14003 | void hdd_restart_sap(struct hdd_adapter *ap_adapter) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14004 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 14005 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 14006 | struct hdd_hostapd_state *hostapd_state; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14007 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14008 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 14009 | tsap_config_t *sap_config; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14010 | void *sap_ctx; |
| 14011 | |
| 14012 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 14013 | sap_config = &hdd_ap_ctx->sap_config; |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 14014 | sap_ctx = hdd_ap_ctx->sap_context; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14015 | |
| 14016 | mutex_lock(&hdd_ctx->sap_lock); |
| 14017 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
| 14018 | wlan_hdd_del_station(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14019 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 14020 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
| 14021 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(sap_ctx)) { |
| 14022 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 14023 | qdf_wait_for_event_completion(&hostapd_state-> |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14024 | qdf_stop_bss_event, |
| 14025 | SME_CMD_TIMEOUT_VALUE); |
| 14026 | |
| 14027 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14028 | hdd_err("SAP Stop Failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14029 | goto end; |
| 14030 | } |
| 14031 | } |
| 14032 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14033 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14034 | ap_adapter->device_mode, ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 14035 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14036 | false); |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14037 | hdd_err("SAP Stop Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14038 | |
| 14039 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14040 | hdd_err("SAP Not able to set AP IEs"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14041 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14042 | eUPDATE_IE_ALL); |
| 14043 | goto end; |
| 14044 | } |
| 14045 | |
| 14046 | qdf_event_reset(&hostapd_state->qdf_event); |
| 14047 | if (wlansap_start_bss(sap_ctx, hdd_hostapd_sap_event_cb, |
| 14048 | sap_config, |
| 14049 | ap_adapter->dev) != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14050 | hdd_err("SAP Start Bss fail"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14051 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14052 | eUPDATE_IE_ALL); |
| 14053 | goto end; |
| 14054 | } |
| 14055 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14056 | hdd_info("Waiting for SAP to start"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14057 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 14058 | qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14059 | SME_CMD_TIMEOUT_VALUE); |
| 14060 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14061 | eUPDATE_IE_ALL); |
| 14062 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14063 | hdd_err("SAP Start failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14064 | goto end; |
| 14065 | } |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14066 | hdd_err("SAP Start Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14067 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14068 | if (hostapd_state->bss_state == BSS_START) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14069 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 14070 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14071 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 14072 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14073 | ap_adapter->device_mode, |
| 14074 | true); |
| 14075 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14076 | } |
| 14077 | end: |
| 14078 | mutex_unlock(&hdd_ctx->sap_lock); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14079 | } |
| 14080 | |
| 14081 | /** |
| 14082 | * hdd_check_and_restart_sap_with_non_dfs_acs() - Restart SAP |
| 14083 | * with non dfs acs |
| 14084 | * |
| 14085 | * Restarts SAP in non-DFS ACS mode when STA-AP mode DFS is not supported |
| 14086 | * |
| 14087 | * Return: None |
| 14088 | */ |
| 14089 | void hdd_check_and_restart_sap_with_non_dfs_acs(void) |
| 14090 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14091 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14092 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 14093 | struct cds_context *cds_ctx; |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14094 | uint8_t restart_chan; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14095 | |
| 14096 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14097 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14098 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14099 | return; |
| 14100 | } |
| 14101 | |
| 14102 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 14103 | if (!cds_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14104 | hdd_err("Invalid CDS Context"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14105 | return; |
| 14106 | } |
| 14107 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14108 | if (policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc) |
| 14109 | != (QDF_STA_MASK | QDF_SAP_MASK)) { |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 14110 | hdd_debug("Concurrency mode is not SAP"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14111 | return; |
| 14112 | } |
| 14113 | |
| 14114 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 14115 | if (ap_adapter != NULL && test_bit(SOFTAP_BSS_STARTED, |
| 14116 | &ap_adapter->event_flags) && |
| 14117 | wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 14118 | ap_adapter->session.ap.operating_channel)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14119 | |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14120 | 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] | 14121 | |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14122 | restart_chan = |
| 14123 | hdd_get_safe_channel_from_pcl_and_acs_range(ap_adapter); |
| 14124 | if (!restart_chan || |
| 14125 | wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, restart_chan)) |
| 14126 | restart_chan = SAP_DEFAULT_5GHZ_CHANNEL; |
| 14127 | |
| 14128 | hdd_switch_sap_channel(ap_adapter, restart_chan, true); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14129 | } |
| 14130 | } |
| 14131 | |
| 14132 | /** |
| 14133 | * hdd_set_connection_in_progress() - to set the connection in |
| 14134 | * progress flag |
| 14135 | * @value: value to set |
| 14136 | * |
| 14137 | * This function will set the passed value to connection in progress flag. |
| 14138 | * If value is previously being set to true then no need to set it again. |
| 14139 | * |
| 14140 | * Return: true if value is being set correctly and false otherwise. |
| 14141 | */ |
| 14142 | bool hdd_set_connection_in_progress(bool value) |
| 14143 | { |
| 14144 | bool status = true; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14145 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14146 | |
| 14147 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14148 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14149 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14150 | return false; |
| 14151 | } |
| 14152 | |
| 14153 | qdf_spin_lock(&hdd_ctx->connection_status_lock); |
| 14154 | /* |
| 14155 | * if the value is set to true previously and if someone is |
| 14156 | * trying to make it true again then it could be some race |
| 14157 | * condition being triggered. Avoid this situation by returning |
| 14158 | * false |
| 14159 | */ |
| 14160 | if (hdd_ctx->connection_in_progress && value) |
| 14161 | status = false; |
| 14162 | else |
| 14163 | hdd_ctx->connection_in_progress = value; |
| 14164 | qdf_spin_unlock(&hdd_ctx->connection_status_lock); |
| 14165 | return status; |
| 14166 | } |
| 14167 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14168 | 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] | 14169 | { |
| 14170 | if (!adapter) { |
| 14171 | hdd_err("Invalid adapter"); |
| 14172 | return -EINVAL; |
| 14173 | } |
| 14174 | hdd_info("Send MCC P2P QUOTA to WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14175 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 14176 | WMA_VDEV_MCC_SET_TIME_QUOTA, |
| 14177 | set_value, VDEV_CMD); |
| 14178 | return 0; |
| 14179 | |
| 14180 | } |
| 14181 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14182 | 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] | 14183 | { |
| 14184 | if (!adapter) { |
| 14185 | hdd_err("Invalid adapter"); |
| 14186 | return -EINVAL; |
| 14187 | } |
| 14188 | |
| 14189 | hdd_info("Send MCC latency WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14190 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 14191 | WMA_VDEV_MCC_SET_TIME_LATENCY, |
| 14192 | set_value, VDEV_CMD); |
| 14193 | return 0; |
| 14194 | } |
| 14195 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14196 | 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] | 14197 | *psoc, uint8_t vdev_id) |
| 14198 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14199 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14200 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 14201 | |
| 14202 | /* |
| 14203 | * Currently PSOC is not being used. But this logic will |
| 14204 | * change once we have the converged implementation of |
| 14205 | * HDD context per PSOC in place. This would break if |
| 14206 | * multiple vdev objects reuse the vdev id. |
| 14207 | */ |
| 14208 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 14209 | if (!adapter) |
| 14210 | hdd_err("Get adapter by vdev id failed"); |
| 14211 | |
| 14212 | return adapter; |
| 14213 | } |
| 14214 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14215 | 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] | 14216 | int8_t *rssi, int8_t *snr) |
| 14217 | { |
| 14218 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14219 | mac_handle_t mac_handle; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 14220 | struct csr_roam_profile *roam_profile; |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 14221 | |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 14222 | roam_profile = hdd_roam_profile(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14223 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 14224 | status = sme_get_rssi_snr_by_bssid(mac_handle, |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 14225 | roam_profile, bssid, rssi, snr); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 14226 | if (QDF_STATUS_SUCCESS != status) { |
| 14227 | hdd_warn("sme_get_rssi_snr_by_bssid failed"); |
| 14228 | return -EINVAL; |
| 14229 | } |
| 14230 | |
| 14231 | return 0; |
| 14232 | } |
| 14233 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 14234 | /** |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14235 | * hdd_reset_limit_off_chan() - reset limit off-channel command parameters |
| 14236 | * @adapter - HDD adapter |
| 14237 | * |
| 14238 | * Return: 0 on success and non zero value on failure |
| 14239 | */ |
| 14240 | int hdd_reset_limit_off_chan(struct hdd_adapter *adapter) |
| 14241 | { |
| 14242 | struct hdd_context *hdd_ctx; |
| 14243 | int ret; |
| 14244 | QDF_STATUS status; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14245 | |
| 14246 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 14247 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 14248 | if (ret < 0) |
| 14249 | return ret; |
| 14250 | |
| 14251 | /* set the system preferece to default */ |
| 14252 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 14253 | hdd_ctx->config->conc_system_pref); |
| 14254 | |
| 14255 | /* clear the bitmap */ |
| 14256 | adapter->active_ac = 0; |
| 14257 | |
| 14258 | hdd_debug("reset ac_bitmap for session %hu active_ac %0x", |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14259 | adapter->session_id, adapter->active_ac); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14260 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14261 | status = sme_send_limit_off_channel_params(hdd_ctx->mac_handle, |
| 14262 | adapter->session_id, |
| 14263 | false, 0, 0, false); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14264 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 14265 | hdd_err("failed to reset limit off chan params"); |
| 14266 | ret = -EINVAL; |
| 14267 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 14268 | |
| 14269 | return ret; |
| 14270 | } |
| 14271 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14272 | /** |
| 14273 | * hdd_start_driver_ops_timer() - Starts driver ops inactivity timer |
| 14274 | * @drv_op: Enum indicating driver op |
| 14275 | * |
| 14276 | * Return: none |
| 14277 | */ |
| 14278 | void hdd_start_driver_ops_timer(int drv_op) |
| 14279 | { |
| 14280 | memset(drv_ops_string, 0, MAX_OPS_NAME_STRING_SIZE); |
| 14281 | switch (drv_op) { |
| 14282 | case eHDD_DRV_OP_PROBE: |
| 14283 | memcpy(drv_ops_string, "probe", sizeof("probe")); |
| 14284 | break; |
| 14285 | case eHDD_DRV_OP_REMOVE: |
| 14286 | memcpy(drv_ops_string, "remove", sizeof("remove")); |
| 14287 | break; |
| 14288 | case eHDD_DRV_OP_SHUTDOWN: |
| 14289 | memcpy(drv_ops_string, "shutdown", sizeof("shutdown")); |
| 14290 | break; |
| 14291 | case eHDD_DRV_OP_REINIT: |
| 14292 | memcpy(drv_ops_string, "reinit", sizeof("reinit")); |
| 14293 | break; |
Arunk Khandavalli | e9ef42a | 2017-10-04 14:49:51 +0530 | [diff] [blame] | 14294 | case eHDD_DRV_OP_IFF_UP: |
| 14295 | memcpy(drv_ops_string, "iff_up", sizeof("iff_up")); |
| 14296 | break; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14297 | } |
| 14298 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 14299 | hdd_drv_ops_task = current; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14300 | qdf_timer_start(&hdd_drv_ops_inactivity_timer, |
Dustin Brown | cfc54fe | 2018-06-18 16:17:41 -0700 | [diff] [blame] | 14301 | HDD_OPS_INACTIVITY_TIMEOUT * qdf_timer_get_multiplier()); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14302 | } |
| 14303 | |
| 14304 | /** |
| 14305 | * hdd_stop_driver_ops_timer() - Stops driver ops inactivity timer |
| 14306 | * |
| 14307 | * Return: none |
| 14308 | */ |
| 14309 | void hdd_stop_driver_ops_timer(void) |
| 14310 | { |
| 14311 | qdf_timer_sync_cancel(&hdd_drv_ops_inactivity_timer); |
| 14312 | } |
| 14313 | |
| 14314 | /** |
| 14315 | * hdd_drv_ops_inactivity_handler() - Timeout handler for driver ops |
| 14316 | * inactivity timer |
| 14317 | * |
| 14318 | * Return: None |
| 14319 | */ |
| 14320 | void hdd_drv_ops_inactivity_handler(void) |
| 14321 | { |
Rajeev Kumar | 4471f1b | 2018-06-08 14:18:28 -0700 | [diff] [blame] | 14322 | 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] | 14323 | __func__, HDD_OPS_INACTIVITY_TIMEOUT/1000, drv_ops_string); |
| 14324 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 14325 | if (hdd_drv_ops_task) { |
| 14326 | printk("Call stack for \"%s\"\n", hdd_drv_ops_task->comm); |
| 14327 | qdf_print_thread_trace(hdd_drv_ops_task); |
| 14328 | } else { |
| 14329 | hdd_err("hdd_drv_ops_task is null"); |
| 14330 | } |
| 14331 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14332 | /* Driver shutdown is stuck, no recovery possible at this point */ |
| 14333 | if (0 == qdf_mem_cmp(&drv_ops_string[0], "shutdown", |
| 14334 | sizeof("shutdown"))) |
| 14335 | QDF_BUG(0); |
| 14336 | |
Rajeev Kumar | 1e57b9c | 2018-01-04 16:17:10 -0800 | [diff] [blame] | 14337 | if (cds_is_fw_down()) { |
| 14338 | hdd_err("FW is down"); |
| 14339 | return; |
| 14340 | } |
| 14341 | |
Dustin Brown | 83044c2 | 2018-08-13 15:00:44 -0700 | [diff] [blame] | 14342 | cds_trigger_recovery(QDF_REASON_UNSPECIFIED); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14343 | } |
| 14344 | |
Sravan Kumar Kairam | d80c766 | 2017-10-03 16:11:05 +0530 | [diff] [blame] | 14345 | void hdd_pld_ipa_uc_shutdown_pipes(void) |
| 14346 | { |
| 14347 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14348 | |
| 14349 | if (!hdd_ctx) |
| 14350 | return; |
| 14351 | |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 14352 | ucfg_ipa_uc_force_pipe_shutdown(hdd_ctx->hdd_pdev); |
Sravan Kumar Kairam | d80c766 | 2017-10-03 16:11:05 +0530 | [diff] [blame] | 14353 | } |
| 14354 | |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 14355 | /** |
| 14356 | * hdd_set_rx_mode_rps() - Enable/disable RPS in SAP mode |
| 14357 | * @struct hdd_context *hdd_ctx |
| 14358 | * @struct hdd_adapter *padapter |
| 14359 | * @bool enble |
| 14360 | * |
| 14361 | * Return: none |
| 14362 | */ |
| 14363 | void hdd_set_rx_mode_rps(bool enable) |
| 14364 | { |
| 14365 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 14366 | struct hdd_context *hdd_ctx; |
| 14367 | struct hdd_adapter *adapter; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 14368 | |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 14369 | if (!cds_cfg) |
| 14370 | return; |
| 14371 | |
| 14372 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14373 | if (!hdd_ctx) |
| 14374 | return; |
| 14375 | |
| 14376 | adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 14377 | if (!adapter) |
| 14378 | return; |
| 14379 | |
| 14380 | if (!hdd_ctx->rps && cds_cfg->uc_offload_enabled) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 14381 | if (enable && !cds_cfg->rps_enabled) |
| 14382 | hdd_send_rps_ind(adapter); |
| 14383 | else if (!enable && cds_cfg->rps_enabled) |
| 14384 | hdd_send_rps_disable_ind(adapter); |
| 14385 | } |
| 14386 | } |
| 14387 | |
Hanumanth Reddy Pothula | 3862ca9 | 2018-01-12 16:44:10 +0530 | [diff] [blame] | 14388 | bool hdd_is_cli_iface_up(struct hdd_context *hdd_ctx) |
| 14389 | { |
| 14390 | struct hdd_adapter *adapter = NULL; |
| 14391 | |
| 14392 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 14393 | if ((adapter->device_mode == QDF_STA_MODE || |
| 14394 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
| 14395 | qdf_atomic_test_bit(DEVICE_IFACE_OPENED, |
| 14396 | &adapter->event_flags)){ |
| 14397 | return true; |
| 14398 | } |
| 14399 | } |
| 14400 | |
| 14401 | return false; |
| 14402 | } |
| 14403 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14404 | /* Register the module init/exit functions */ |
| 14405 | module_init(hdd_module_init); |
| 14406 | module_exit(hdd_module_exit); |
| 14407 | |
| 14408 | MODULE_LICENSE("Dual BSD/GPL"); |
| 14409 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 14410 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 14411 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14412 | static const struct kernel_param_ops con_mode_ops = { |
| 14413 | .set = con_mode_handler, |
| 14414 | .get = param_get_int, |
| 14415 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14416 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14417 | static const struct kernel_param_ops con_mode_ftm_ops = { |
| 14418 | .set = con_mode_handler_ftm, |
| 14419 | .get = param_get_int, |
| 14420 | }; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 14421 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14422 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14423 | static const struct kernel_param_ops con_mode_monitor_ops = { |
| 14424 | .set = con_mode_handler_monitor, |
| 14425 | .get = param_get_int, |
| 14426 | }; |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14427 | #endif |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 14428 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14429 | static const struct kernel_param_ops fwpath_ops = { |
| 14430 | .set = fwpath_changed_handler, |
| 14431 | .get = param_get_string, |
| 14432 | }; |
| 14433 | |
| 14434 | module_param_cb(con_mode, &con_mode_ops, &con_mode, |
| 14435 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 14436 | |
| 14437 | module_param_cb(con_mode_ftm, &con_mode_ftm_ops, &con_mode_ftm, |
| 14438 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 14439 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14440 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14441 | module_param_cb(con_mode_monitor, &con_mode_monitor_ops, &con_mode_monitor, |
| 14442 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14443 | #endif |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14444 | |
| 14445 | module_param_cb(fwpath, &fwpath_ops, &fwpath, |
| 14446 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14447 | |
| 14448 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 14449 | |
| 14450 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 14451 | |
| 14452 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |