Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Jeff Johnson | d9f0860 | 2016-12-02 11:31:30 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
| 28 | /** |
| 29 | * DOC: wlan_hdd_main.c |
| 30 | * |
| 31 | * WLAN Host Device Driver implementation |
| 32 | * |
| 33 | */ |
| 34 | |
| 35 | /* Include Files */ |
| 36 | #include <wlan_hdd_includes.h> |
| 37 | #include <cds_api.h> |
| 38 | #include <cds_sched.h> |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 39 | #include <linux/cpu.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 40 | #include <linux/etherdevice.h> |
| 41 | #include <linux/firmware.h> |
| 42 | #include <wlan_hdd_tx_rx.h> |
| 43 | #include <wni_api.h> |
| 44 | #include <wlan_hdd_cfg.h> |
| 45 | #include <wlan_ptt_sock_svc.h> |
| 46 | #include <dbglog_host.h> |
| 47 | #include <wlan_logging_sock_svc.h> |
| 48 | #include <wlan_hdd_wowl.h> |
| 49 | #include <wlan_hdd_misc.h> |
| 50 | #include <wlan_hdd_wext.h> |
| 51 | #include "wlan_hdd_trace.h" |
| 52 | #include "wlan_hdd_ioctl.h" |
| 53 | #include "wlan_hdd_ftm.h" |
| 54 | #include "wlan_hdd_power.h" |
| 55 | #include "wlan_hdd_stats.h" |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 56 | #include "wlan_hdd_scan.h" |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 57 | #include "wlan_hdd_request_manager.h" |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 58 | #include "qdf_types.h" |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 59 | #include "qdf_trace.h" |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 60 | #include <cdp_txrx_peer_ops.h> |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 61 | #include <cdp_txrx_misc.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 62 | |
| 63 | #include <net/addrconf.h> |
| 64 | #include <linux/wireless.h> |
| 65 | #include <net/cfg80211.h> |
| 66 | #include <linux/inetdevice.h> |
| 67 | #include <net/addrconf.h> |
| 68 | #include "wlan_hdd_cfg80211.h" |
| 69 | #include "wlan_hdd_ext_scan.h" |
| 70 | #include "wlan_hdd_p2p.h" |
| 71 | #include <linux/rtnetlink.h> |
| 72 | #include "sap_api.h" |
| 73 | #include <linux/semaphore.h> |
| 74 | #include <linux/ctype.h> |
| 75 | #include <linux/compat.h> |
| 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> |
| 81 | #include "cfg_api.h" |
| 82 | #include "qwlan_version.h" |
| 83 | #include "wma_types.h" |
| 84 | #include "wlan_hdd_tdls.h" |
| 85 | #ifdef FEATURE_WLAN_CH_AVOID |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 86 | #include "cds_regdomain.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 87 | #endif /* FEATURE_WLAN_CH_AVOID */ |
Dustin Brown | ce46d1d | 2017-08-15 13:34:24 -0700 | [diff] [blame] | 88 | #include "cdp_txrx_flow_ctrl_v2.h" |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 89 | #include "pld_common.h" |
Tushnim Bhattacharyya | 15596cf | 2016-02-12 11:57:02 -0800 | [diff] [blame] | 90 | #include "wlan_hdd_ocb.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 91 | #include "wlan_hdd_nan.h" |
| 92 | #include "wlan_hdd_debugfs.h" |
| 93 | #include "wlan_hdd_driver_ops.h" |
| 94 | #include "epping_main.h" |
| 95 | #include "wlan_hdd_memdump.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" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 103 | #include "wlan_hdd_green_ap.h" |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 104 | #include "bmi.h" |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 105 | #include <wlan_hdd_regulatory.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 106 | #include "wlan_hdd_lpass.h" |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 107 | #include "nan_api.h" |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 108 | #include <wlan_hdd_napi.h> |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 109 | #include "wlan_hdd_disa.h" |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 110 | #include <dispatcher_init_deinit.h> |
Rajeev Kumar | 699debf | 2017-01-06 14:17:00 -0800 | [diff] [blame] | 111 | #include "wlan_hdd_object_manager.h" |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 112 | #include "cds_utils.h" |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 113 | #include <cdp_txrx_handle.h> |
Sandeep Puligilla | fdd201e | 2017-02-02 18:43:46 -0800 | [diff] [blame] | 114 | #include <qca_vendor.h> |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 115 | #include "wlan_pmo_ucfg_api.h" |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 116 | #include "sir_api.h" |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 117 | #include "os_if_wifi_pos.h" |
| 118 | #include "wifi_pos_api.h" |
| 119 | #include "wlan_hdd_oemdata.h" |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 120 | #include "wlan_hdd_he.h" |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 121 | #include "os_if_nan.h" |
| 122 | #include "nan_public_structs.h" |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 123 | #include "wlan_reg_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> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 128 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 129 | #ifdef CNSS_GENL |
| 130 | #include <net/cnss_nl.h> |
| 131 | #endif |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 132 | #include "wlan_reg_ucfg_api.h" |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 133 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 134 | #ifdef MODULE |
| 135 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 136 | #else |
| 137 | #define WLAN_MODULE_NAME "wlan" |
| 138 | #endif |
| 139 | |
| 140 | #ifdef TIMER_MANAGER |
| 141 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 142 | #else |
| 143 | #define TIMER_MANAGER_STR "" |
| 144 | #endif |
| 145 | |
| 146 | #ifdef MEMORY_DEBUG |
| 147 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 148 | #else |
| 149 | #define MEMORY_DEBUG_STR "" |
| 150 | #endif |
| 151 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 152 | int wlan_start_ret_val; |
| 153 | static DECLARE_COMPLETION(wlan_start_comp); |
| 154 | static unsigned int dev_num = 1; |
| 155 | static struct cdev wlan_hdd_state_cdev; |
| 156 | static struct class *class; |
| 157 | static dev_t device; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 158 | #ifndef MODULE |
| 159 | static struct gwlan_loader *wlan_loader; |
| 160 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 161 | struct kobj_attribute *attr, |
| 162 | const char *buf, size_t count); |
| 163 | struct gwlan_loader { |
| 164 | bool loaded_state; |
| 165 | struct kobject *boot_wlan_obj; |
| 166 | struct attribute_group *attr_group; |
| 167 | }; |
| 168 | |
| 169 | static struct kobj_attribute wlan_boot_attribute = |
| 170 | __ATTR(boot_wlan, 0220, NULL, wlan_boot_cb); |
| 171 | |
| 172 | static struct attribute *attrs[] = { |
| 173 | &wlan_boot_attribute.attr, |
| 174 | NULL, |
| 175 | }; |
| 176 | |
| 177 | #define MODULE_INITIALIZED 1 |
| 178 | #endif |
| 179 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 180 | #define HDD_OPS_INACTIVITY_TIMEOUT (120000) |
| 181 | #define MAX_OPS_NAME_STRING_SIZE 20 |
| 182 | |
| 183 | static qdf_timer_t hdd_drv_ops_inactivity_timer; |
| 184 | static char drv_ops_string[MAX_OPS_NAME_STRING_SIZE]; |
| 185 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 186 | /* the Android framework expects this param even though we don't use it */ |
| 187 | #define BUF_LEN 20 |
| 188 | static char fwpath_buffer[BUF_LEN]; |
| 189 | static struct kparam_string fwpath = { |
| 190 | .string = fwpath_buffer, |
| 191 | .maxlen = BUF_LEN, |
| 192 | }; |
| 193 | |
| 194 | static char *country_code; |
| 195 | static int enable_11d = -1; |
| 196 | static int enable_dfs_chan_scan = -1; |
| 197 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 198 | /* |
| 199 | * spinlock for synchronizing asynchronous request/response |
| 200 | * (full description of use in wlan_hdd_main.h) |
| 201 | */ |
| 202 | DEFINE_SPINLOCK(hdd_context_lock); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 203 | DEFINE_MUTEX(hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 204 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 205 | #define WLAN_NLINK_CESIUM 30 |
| 206 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 207 | static qdf_wake_lock_t wlan_wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 208 | |
| 209 | #define WOW_MAX_FILTER_LISTS 1 |
| 210 | #define WOW_MAX_FILTERS_PER_LIST 4 |
| 211 | #define WOW_MIN_PATTERN_SIZE 6 |
| 212 | #define WOW_MAX_PATTERN_SIZE 64 |
| 213 | |
| 214 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 215 | static const struct wiphy_wowlan_support wowlan_support_reg_init = { |
| 216 | .flags = WIPHY_WOWLAN_ANY | |
| 217 | WIPHY_WOWLAN_MAGIC_PKT | |
| 218 | WIPHY_WOWLAN_DISCONNECT | |
| 219 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 220 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 221 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 222 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 223 | WIPHY_WOWLAN_RFKILL_RELEASE, |
| 224 | .n_patterns = WOW_MAX_FILTER_LISTS * WOW_MAX_FILTERS_PER_LIST, |
| 225 | .pattern_min_len = WOW_MIN_PATTERN_SIZE, |
| 226 | .pattern_max_len = WOW_MAX_PATTERN_SIZE, |
| 227 | }; |
| 228 | #endif |
| 229 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 230 | static const struct category_info cinfo[MAX_SUPPORTED_CATEGORY] = { |
| 231 | [QDF_MODULE_ID_TLSHIM] = {QDF_TRACE_LEVEL_ALL}, |
| 232 | [QDF_MODULE_ID_WMI] = {QDF_TRACE_LEVEL_ALL}, |
| 233 | [QDF_MODULE_ID_HTT] = {QDF_TRACE_LEVEL_ALL}, |
| 234 | [QDF_MODULE_ID_HDD] = {QDF_TRACE_LEVEL_ALL}, |
| 235 | [QDF_MODULE_ID_SME] = {QDF_TRACE_LEVEL_ALL}, |
| 236 | [QDF_MODULE_ID_PE] = {QDF_TRACE_LEVEL_ALL}, |
| 237 | [QDF_MODULE_ID_WMA] = {QDF_TRACE_LEVEL_ALL}, |
| 238 | [QDF_MODULE_ID_SYS] = {QDF_TRACE_LEVEL_ALL}, |
| 239 | [QDF_MODULE_ID_QDF] = {QDF_TRACE_LEVEL_ALL}, |
| 240 | [QDF_MODULE_ID_SAP] = {QDF_TRACE_LEVEL_ALL}, |
| 241 | [QDF_MODULE_ID_HDD_SOFTAP] = {QDF_TRACE_LEVEL_ALL}, |
| 242 | [QDF_MODULE_ID_HDD_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 243 | [QDF_MODULE_ID_HDD_SAP_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 244 | [QDF_MODULE_ID_HIF] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 245 | [QDF_MODULE_ID_HTC] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 246 | [QDF_MODULE_ID_TXRX] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 247 | [QDF_MODULE_ID_QDF_DEVICE] = {QDF_TRACE_LEVEL_ALL}, |
| 248 | [QDF_MODULE_ID_CFG] = {QDF_TRACE_LEVEL_ALL}, |
| 249 | [QDF_MODULE_ID_BMI] = {QDF_TRACE_LEVEL_ALL}, |
| 250 | [QDF_MODULE_ID_EPPING] = {QDF_TRACE_LEVEL_ALL}, |
| 251 | [QDF_MODULE_ID_QVIT] = {QDF_TRACE_LEVEL_ALL}, |
| 252 | [QDF_MODULE_ID_DP] = {QDF_TRACE_LEVEL_ALL}, |
| 253 | [QDF_MODULE_ID_SOC] = {QDF_TRACE_LEVEL_ALL}, |
| 254 | [QDF_MODULE_ID_OS_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 255 | [QDF_MODULE_ID_TARGET_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 256 | [QDF_MODULE_ID_SCHEDULER] = {QDF_TRACE_LEVEL_ALL}, |
| 257 | [QDF_MODULE_ID_MGMT_TXRX] = {QDF_TRACE_LEVEL_ALL}, |
| 258 | [QDF_MODULE_ID_PMO] = {QDF_TRACE_LEVEL_ALL}, |
| 259 | [QDF_MODULE_ID_SCAN] = {QDF_TRACE_LEVEL_ALL}, |
| 260 | [QDF_MODULE_ID_POLICY_MGR] = {QDF_TRACE_LEVEL_ALL}, |
| 261 | [QDF_MODULE_ID_P2P] = {QDF_TRACE_LEVEL_ALL}, |
| 262 | [QDF_MODULE_ID_TDLS] = {QDF_TRACE_LEVEL_ALL}, |
| 263 | [QDF_MODULE_ID_REGULATORY] = {QDF_TRACE_LEVEL_ALL}, |
| 264 | [QDF_MODULE_ID_SERIALIZATION] = {QDF_TRACE_LEVEL_ALL}, |
Arif Hussain | fde76e7 | 2017-09-05 16:58:23 -0700 | [diff] [blame] | 265 | [QDF_MODULE_ID_DFS] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar | ca8ef9d | 2017-10-06 10:43:21 -0700 | [diff] [blame] | 266 | [QDF_MODULE_ID_OBJ_MGR] = {QDF_TRACE_LEVEL_ALL}, |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 267 | }; |
| 268 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 269 | int limit_off_chan_tbl[HDD_MAX_AC][HDD_MAX_OFF_CHAN_ENTRIES] = { |
| 270 | { HDD_AC_BK_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_BK }, |
| 271 | { HDD_AC_BE_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_BE }, |
| 272 | { HDD_AC_VI_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_VI }, |
| 273 | { HDD_AC_VO_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_VO }, |
| 274 | }; |
| 275 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 276 | /* internal function declaration */ |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 277 | struct notifier_block hdd_netdev_notifier; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 278 | |
| 279 | struct sock *cesium_nl_srv_sock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 280 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 281 | static void wlan_hdd_auto_shutdown_cb(void); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 282 | #endif |
| 283 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 284 | void hdd_start_complete(int ret) |
| 285 | { |
| 286 | wlan_start_ret_val = ret; |
| 287 | |
| 288 | complete(&wlan_start_comp); |
| 289 | } |
| 290 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 291 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 292 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 293 | * @hdd_ctx: pointer to struct hdd_context |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 294 | * |
| 295 | * Return: none |
| 296 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 297 | static void hdd_set_rps_cpu_mask(struct hdd_context *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 298 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 299 | struct hdd_adapter *adapter; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 300 | hdd_adapter_list_node_t *adapter_node, *next; |
| 301 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 302 | |
| 303 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 304 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 305 | adapter = adapter_node->adapter; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 306 | if (NULL != adapter) |
| 307 | hdd_send_rps_ind(adapter); |
| 308 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 309 | adapter_node = next; |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 314 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 315 | * @vdev_id: vdev_id |
| 316 | * @action: action type |
| 317 | * @reason: reason type |
| 318 | * |
| 319 | * Return: none |
| 320 | */ |
| 321 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 322 | enum netif_action_type action, enum netif_reason_type reason) |
| 323 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 324 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 325 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 326 | |
| 327 | if (!hdd_ctx) { |
| 328 | hdd_err("hdd ctx is NULL"); |
| 329 | return; |
| 330 | } |
| 331 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 332 | |
| 333 | wlan_hdd_netif_queue_control(adapter, action, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | /* |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 337 | * Store WLAN driver version and timestamp info in global variables such that |
| 338 | * crash debugger can extract them from driver debug symbol and crashdump for |
| 339 | * post processing |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 340 | */ |
| 341 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR; |
Naveen Rawat | 9383625 | 2017-06-20 16:30:59 -0700 | [diff] [blame] | 342 | |
| 343 | #ifndef BUILD_TIMESTAMP |
| 344 | #define BUILD_TIMESTAMP "" |
| 345 | #endif |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 346 | uint8_t g_wlan_driver_timestamp[] = BUILD_TIMESTAMP; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 347 | |
| 348 | /** |
| 349 | * hdd_device_mode_to_string() - return string conversion of device mode |
| 350 | * @device_mode: device mode |
| 351 | * |
| 352 | * This utility function helps log string conversion of device mode. |
| 353 | * |
| 354 | * Return: string conversion of device mode, if match found; |
| 355 | * "Unknown" otherwise. |
| 356 | */ |
| 357 | const char *hdd_device_mode_to_string(uint8_t device_mode) |
| 358 | { |
| 359 | switch (device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 360 | CASE_RETURN_STRING(QDF_STA_MODE); |
| 361 | CASE_RETURN_STRING(QDF_SAP_MODE); |
| 362 | CASE_RETURN_STRING(QDF_P2P_CLIENT_MODE); |
| 363 | CASE_RETURN_STRING(QDF_P2P_GO_MODE); |
| 364 | CASE_RETURN_STRING(QDF_FTM_MODE); |
| 365 | CASE_RETURN_STRING(QDF_IBSS_MODE); |
| 366 | CASE_RETURN_STRING(QDF_P2P_DEVICE_MODE); |
| 367 | CASE_RETURN_STRING(QDF_OCB_MODE); |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 368 | CASE_RETURN_STRING(QDF_NDI_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 369 | default: |
| 370 | return "Unknown"; |
| 371 | } |
| 372 | } |
| 373 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 374 | /** |
| 375 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 376 | * @adapter: HDD adapter |
| 377 | * @chan_number: Channel number |
| 378 | * @chan_bw: Bandwidth |
| 379 | * |
| 380 | * Checks if the given bandwidth is valid for the given channel number. |
| 381 | * |
| 382 | * Return: 0 for success, non-zero for failure |
| 383 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 384 | int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 385 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 386 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 387 | { |
| 388 | uint8_t chan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 389 | uint32_t len = WNI_CFG_VALID_CHANNEL_LIST_LEN, i; |
| 390 | bool found = false; |
| 391 | tHalHandle hal; |
| 392 | |
| 393 | hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 394 | if (!hal) { |
| 395 | hdd_err("Invalid HAL context"); |
| 396 | return -EINVAL; |
| 397 | } |
| 398 | |
| 399 | if (0 != sme_cfg_get_str(hal, WNI_CFG_VALID_CHANNEL_LIST, chan, &len)) { |
| 400 | hdd_err("No valid channel list"); |
| 401 | return -EOPNOTSUPP; |
| 402 | } |
| 403 | |
| 404 | for (i = 0; i < len; i++) { |
| 405 | if (chan[i] == chan_number) { |
| 406 | found = true; |
| 407 | break; |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | if (found == false) { |
| 412 | hdd_err("Channel not in driver's valid channel list"); |
| 413 | return -EOPNOTSUPP; |
| 414 | } |
| 415 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 416 | if ((!WLAN_REG_IS_24GHZ_CH(chan_number)) && |
| 417 | (!WLAN_REG_IS_5GHZ_CH(chan_number))) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 418 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 419 | return -EINVAL; |
| 420 | } |
| 421 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 422 | if (WLAN_REG_IS_24GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 423 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 424 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 425 | return -EINVAL; |
| 426 | } |
| 427 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 428 | (chan_bw != CH_WIDTH_MAX)) { |
| 429 | hdd_err("Only BW20 possible on channel 14"); |
| 430 | return -EINVAL; |
| 431 | } |
| 432 | } |
| 433 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 434 | if (WLAN_REG_IS_5GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 435 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 436 | (chan_bw != CH_WIDTH_MAX)) { |
| 437 | hdd_err("Only BW20 possible on channel 165"); |
| 438 | return -EINVAL; |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | return 0; |
| 443 | } |
| 444 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 445 | /** |
| 446 | * hdd_wait_for_recovery_completion() - Wait for cds recovery completion |
| 447 | * |
| 448 | * Block the unloading of the driver (or) interface up until the |
| 449 | * cds recovery is completed |
| 450 | * |
| 451 | * Return: true for recovery completion else false |
| 452 | */ |
| 453 | static bool hdd_wait_for_recovery_completion(void) |
| 454 | { |
| 455 | int retry = 0; |
| 456 | |
| 457 | /* Wait for recovery to complete */ |
| 458 | while (cds_is_driver_recovering()) { |
| 459 | if (retry == HDD_MOD_EXIT_SSR_MAX_RETRIES/2) |
| 460 | hdd_err("Recovery in progress; wait here!!!"); |
| 461 | msleep(1000); |
| 462 | if (retry++ == HDD_MOD_EXIT_SSR_MAX_RETRIES) { |
| 463 | hdd_err("SSR never completed, error"); |
| 464 | /* |
| 465 | * Trigger the bug_on in the internal builds, in the |
| 466 | * customer builds self-recovery will be enabled |
| 467 | * in those cases just return error. |
| 468 | */ |
| 469 | if (cds_is_self_recovery_enabled()) |
| 470 | return false; |
| 471 | QDF_BUG(0); |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | hdd_info("Recovery completed successfully!"); |
| 476 | return true; |
| 477 | } |
| 478 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 479 | static int __hdd_netdev_notifier_call(struct notifier_block *nb, |
| 480 | unsigned long state, void *data) |
| 481 | { |
| 482 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 483 | struct netdev_notifier_info *dev_notif_info = data; |
| 484 | struct net_device *dev = dev_notif_info->dev; |
| 485 | #else |
| 486 | struct net_device *dev = data; |
| 487 | #endif |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 488 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 489 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 490 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 491 | ENTER_DEV(dev); |
| 492 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 493 | /* Make sure that this callback corresponds to our device. */ |
| 494 | if ((strncmp(dev->name, "wlan", 4)) && (strncmp(dev->name, "p2p", 3))) |
| 495 | return NOTIFY_DONE; |
| 496 | |
Samuel Ahn | c9c48ca | 2016-09-19 15:46:36 +0530 | [diff] [blame] | 497 | if ((adapter->magic != WLAN_HDD_ADAPTER_MAGIC) || |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 498 | (adapter->dev != dev)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 499 | hdd_err("device adapter is not matching!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 500 | return NOTIFY_DONE; |
| 501 | } |
| 502 | |
| 503 | if (!dev->ieee80211_ptr) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 504 | hdd_err("ieee80211_ptr is NULL!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 505 | return NOTIFY_DONE; |
| 506 | } |
| 507 | |
| 508 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 509 | if (NULL == hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 510 | hdd_err("HDD Context Null Pointer"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 511 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 512 | return NOTIFY_DONE; |
| 513 | } |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 514 | |
| 515 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 516 | hdd_err("%s: Driver module is closed", __func__); |
| 517 | return NOTIFY_DONE; |
| 518 | } |
| 519 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 520 | if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 521 | return NOTIFY_DONE; |
| 522 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 523 | hdd_debug("%s New Net Device State = %lu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 524 | dev->name, state); |
| 525 | |
| 526 | switch (state) { |
| 527 | case NETDEV_REGISTER: |
| 528 | break; |
| 529 | |
| 530 | case NETDEV_UNREGISTER: |
| 531 | break; |
| 532 | |
| 533 | case NETDEV_UP: |
| 534 | sme_ch_avoid_update_req(hdd_ctx->hHal); |
| 535 | break; |
| 536 | |
| 537 | case NETDEV_DOWN: |
| 538 | break; |
| 539 | |
| 540 | case NETDEV_CHANGE: |
| 541 | if (true == adapter->isLinkUpSvcNeeded) |
| 542 | complete(&adapter->linkup_event_var); |
| 543 | break; |
| 544 | |
| 545 | case NETDEV_GOING_DOWN: |
| 546 | if (adapter->scan_info.mScanPending != false) { |
Abhishek Singh | 69ccb51 | 2017-04-25 11:58:16 +0530 | [diff] [blame] | 547 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
| 548 | adapter->sessionId, INVALID_SCAN_ID, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 549 | } else { |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 550 | cds_flush_work(&adapter->scan_block_work); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 551 | hdd_debug("Scan is not Pending from user"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 552 | } |
| 553 | break; |
| 554 | |
| 555 | default: |
| 556 | break; |
| 557 | } |
| 558 | |
| 559 | return NOTIFY_DONE; |
| 560 | } |
| 561 | |
| 562 | /** |
| 563 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 564 | * @nb: pointer to notifier block |
| 565 | * @state: state |
| 566 | * @ndev: ndev pointer |
| 567 | * |
| 568 | * Return: 0 on success, error number otherwise. |
| 569 | */ |
| 570 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 571 | unsigned long state, |
| 572 | void *ndev) |
| 573 | { |
| 574 | int ret; |
| 575 | |
| 576 | cds_ssr_protect(__func__); |
| 577 | ret = __hdd_netdev_notifier_call(nb, state, ndev); |
| 578 | cds_ssr_unprotect(__func__); |
| 579 | |
| 580 | return ret; |
| 581 | } |
| 582 | |
| 583 | struct notifier_block hdd_netdev_notifier = { |
| 584 | .notifier_call = hdd_netdev_notifier_call, |
| 585 | }; |
| 586 | |
| 587 | /* variable to hold the insmod parameters */ |
| 588 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 589 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 590 | static int con_mode_ftm; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 591 | int con_mode_monitor; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 592 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 593 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 594 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 595 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 596 | /** |
| 597 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 598 | * @ch_width: NL channel width |
| 599 | * |
| 600 | * Converts the NL channel width to the driver's internal representation |
| 601 | * |
| 602 | * Return: Converted channel width. In case of non matching NL channel width, |
| 603 | * CH_WIDTH_MAX will be returned. |
| 604 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 605 | 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] | 606 | { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 607 | uint8_t fw_ch_bw; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 608 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 609 | fw_ch_bw = wma_get_vht_ch_width(); |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 610 | switch (ch_width) { |
| 611 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 612 | case NL80211_CHAN_WIDTH_20: |
| 613 | return CH_WIDTH_20MHZ; |
| 614 | case NL80211_CHAN_WIDTH_40: |
| 615 | return CH_WIDTH_40MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 616 | case NL80211_CHAN_WIDTH_80: |
| 617 | return CH_WIDTH_80MHZ; |
| 618 | case NL80211_CHAN_WIDTH_80P80: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 619 | if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ) |
| 620 | return CH_WIDTH_80P80MHZ; |
| 621 | else if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 622 | return CH_WIDTH_160MHZ; |
| 623 | else |
| 624 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 625 | case NL80211_CHAN_WIDTH_160: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 626 | if (fw_ch_bw >= WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 627 | return CH_WIDTH_160MHZ; |
| 628 | else |
| 629 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 630 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 631 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 632 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 633 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 634 | default: |
| 635 | hdd_err("Invalid channel width %d, setting to default", |
| 636 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 637 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 638 | } |
| 639 | } |
| 640 | |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 641 | /* wlan_hdd_find_opclass() - Find operating class for a channel |
| 642 | * @hal: handler to HAL |
| 643 | * @channel: channel id |
| 644 | * @bw_offset: bandwidth offset |
| 645 | * |
| 646 | * Function invokes sme api to find the operating class |
| 647 | * |
| 648 | * Return: operating class |
| 649 | */ |
| 650 | uint8_t wlan_hdd_find_opclass(tHalHandle hal, uint8_t channel, |
| 651 | uint8_t bw_offset) |
| 652 | { |
| 653 | uint8_t opclass = 0; |
| 654 | |
| 655 | sme_get_opclass(hal, channel, bw_offset, &opclass); |
| 656 | return opclass; |
| 657 | } |
| 658 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 659 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 660 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 661 | * @module_id: Module whose trace level is being configured |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 662 | * @bitmask: Bitmask of log levels to be enabled |
| 663 | * |
| 664 | * Called immediately after the cfg.ini is read in order to configure |
| 665 | * the desired trace levels. |
| 666 | * |
| 667 | * Return: None |
| 668 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 669 | 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] | 670 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 671 | QDF_TRACE_LEVEL level; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 672 | int qdf_print_idx = -1; |
| 673 | int status = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 674 | /* |
| 675 | * if the bitmask is the default value, then a bitmask was not |
| 676 | * specified in cfg.ini, so leave the logging level alone (it |
| 677 | * will remain at the "compiled in" default value) |
| 678 | */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 679 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 680 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 681 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 682 | qdf_print_idx = qdf_get_pidx(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 683 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 684 | /* a mask was specified. start by disabling all logging */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 685 | status = qdf_print_set_category_verbose(qdf_print_idx, module_id, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 686 | QDF_TRACE_LEVEL_NONE, 0); |
| 687 | |
| 688 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 689 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 690 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Ashish Kumar Dhanotiya | 83f286b | 2017-09-15 19:52:58 +0530 | [diff] [blame] | 691 | level = QDF_TRACE_LEVEL_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 692 | while (0 != bitmask) { |
| 693 | if (bitmask & 1) { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 694 | status = qdf_print_set_category_verbose(qdf_print_idx, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 695 | module_id, level, 1); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 696 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 697 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 698 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 699 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 700 | level++; |
| 701 | bitmask >>= 1; |
| 702 | } |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 703 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 704 | } |
| 705 | |
| 706 | /** |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 707 | * wlan_hdd_validate_context_in_loading() - check the HDD context in loading |
| 708 | * @hdd_ctx: HDD context pointer |
| 709 | * |
| 710 | * Return: 0 if the context is valid. Error code otherwise |
| 711 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 712 | int wlan_hdd_validate_context_in_loading(struct hdd_context *hdd_ctx) |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 713 | { |
| 714 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
| 715 | hdd_info("%pS HDD context is Null", (void *)_RET_IP_); |
| 716 | return -ENODEV; |
| 717 | } |
| 718 | |
| 719 | if (cds_is_driver_recovering()) { |
| 720 | hdd_info("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
| 721 | (void *)_RET_IP_, cds_get_driver_state()); |
| 722 | return -EAGAIN; |
| 723 | } |
| 724 | |
| 725 | if (hdd_ctx->start_modules_in_progress || |
| 726 | hdd_ctx->stop_modules_in_progress) { |
| 727 | hdd_info("%pS Start/Stop Modules in progress. Ignore!!!", |
| 728 | (void *)_RET_IP_); |
| 729 | return -EAGAIN; |
| 730 | } |
| 731 | |
| 732 | return 0; |
| 733 | } |
| 734 | |
| 735 | |
| 736 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 737 | * wlan_hdd_validate_context() - check the HDD context |
| 738 | * @hdd_ctx: HDD context pointer |
| 739 | * |
| 740 | * Return: 0 if the context is valid. Error code otherwise |
| 741 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 742 | int wlan_hdd_validate_context(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 743 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 744 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 745 | hdd_err("%pS HDD context is Null", (void *)_RET_IP_); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 746 | return -ENODEV; |
| 747 | } |
| 748 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 749 | if (cds_is_driver_recovering()) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 750 | hdd_debug("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 751 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 752 | return -EAGAIN; |
| 753 | } |
| 754 | |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 755 | if (cds_is_load_or_unload_in_progress()) { |
| 756 | hdd_debug("%pS Load or unload in progress, state: 0x%x, ignore!", |
| 757 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 758 | return -EAGAIN; |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 759 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 760 | |
| 761 | if (hdd_ctx->start_modules_in_progress || |
| 762 | hdd_ctx->stop_modules_in_progress) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 763 | hdd_debug("%pS Start/Stop Modules in progress. Ignore!!!", |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 764 | (void *)_RET_IP_); |
| 765 | return -EAGAIN; |
| 766 | } |
| 767 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 768 | if (cds_is_driver_in_bad_state()) { |
| 769 | hdd_debug("%pS driver in bad State: 0x%x Ignore!!!", |
| 770 | (void *)_RET_IP_, cds_get_driver_state()); |
| 771 | return -ENODEV; |
| 772 | } |
| 773 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 774 | return 0; |
| 775 | } |
| 776 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 777 | int hdd_validate_adapter(struct hdd_adapter *adapter) |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 778 | { |
| 779 | if (!adapter) { |
| 780 | hdd_err("adapter is null"); |
| 781 | return -EINVAL; |
| 782 | } |
| 783 | |
| 784 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
| 785 | hdd_err("bad adapter magic: 0x%x (should be 0x%x)", |
| 786 | adapter->magic, WLAN_HDD_ADAPTER_MAGIC); |
| 787 | return -EINVAL; |
| 788 | } |
| 789 | |
| 790 | if (!adapter->dev) { |
| 791 | hdd_err("adapter net_device is null"); |
| 792 | return -EINVAL; |
| 793 | } |
| 794 | |
| 795 | if (!(adapter->dev->flags & IFF_UP)) { |
| 796 | hdd_info("adapter net_device is not up"); |
| 797 | return -EAGAIN; |
| 798 | } |
| 799 | |
| 800 | if (adapter->sessionId == HDD_SESSION_ID_INVALID) { |
| 801 | hdd_info("adapter session is not open"); |
| 802 | return -EAGAIN; |
| 803 | } |
| 804 | |
| 805 | if (adapter->sessionId >= MAX_NUMBER_OF_ADAPTERS) { |
| 806 | hdd_err("bad adapter session Id: %u", adapter->sessionId); |
| 807 | return -EINVAL; |
| 808 | } |
| 809 | |
| 810 | return 0; |
| 811 | } |
| 812 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 813 | /** |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 814 | * wlan_hdd_validate_modules_state() - Check modules status |
| 815 | * @hdd_ctx: HDD context pointer |
| 816 | * |
| 817 | * Check's the driver module's state and returns true if the |
| 818 | * modules are enabled returns false if modules are closed. |
| 819 | * |
| 820 | * Return: True if modules are enabled or false. |
| 821 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 822 | bool wlan_hdd_validate_modules_state(struct hdd_context *hdd_ctx) |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 823 | { |
| 824 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 825 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 826 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 827 | hdd_notice("Modules not enabled, Present status: %d", |
| 828 | hdd_ctx->driver_status); |
| 829 | return false; |
| 830 | } |
| 831 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 832 | return true; |
| 833 | } |
| 834 | |
| 835 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 836 | * 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] | 837 | * @struct hdd_adapter Hdd adapter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 838 | * |
| 839 | * This function sets the IBSS power save config parameters to WMA |
| 840 | * which will send it to firmware if FW supports IBSS power save |
| 841 | * before vdev start. |
| 842 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 843 | * 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] | 844 | * on failure. |
| 845 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 846 | QDF_STATUS hdd_set_ibss_power_save_params(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 847 | { |
| 848 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 849 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 850 | |
| 851 | if (hdd_ctx == NULL) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 852 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 853 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 854 | } |
| 855 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 856 | ret = sme_cli_set_command(adapter->sessionId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 857 | WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE, |
| 858 | hdd_ctx->config->ibssATIMWinSize, |
| 859 | VDEV_CMD); |
| 860 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 861 | hdd_err("WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 862 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 863 | } |
| 864 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 865 | ret = sme_cli_set_command(adapter->sessionId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 866 | WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED, |
| 867 | hdd_ctx->config->isIbssPowerSaveAllowed, |
| 868 | VDEV_CMD); |
| 869 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 870 | hdd_err("WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED failed %d", |
| 871 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 872 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 873 | } |
| 874 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 875 | ret = sme_cli_set_command(adapter->sessionId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 876 | WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED, |
| 877 | hdd_ctx->config-> |
| 878 | isIbssPowerCollapseAllowed, VDEV_CMD); |
| 879 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 880 | hdd_err("WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED failed %d", |
| 881 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 882 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 883 | } |
| 884 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 885 | ret = sme_cli_set_command(adapter->sessionId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 886 | WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX, |
| 887 | hdd_ctx->config->isIbssAwakeOnTxRx, |
| 888 | VDEV_CMD); |
| 889 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 890 | hdd_err("WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 891 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 892 | } |
| 893 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 894 | ret = sme_cli_set_command(adapter->sessionId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 895 | WMA_VDEV_IBSS_SET_INACTIVITY_TIME, |
| 896 | hdd_ctx->config->ibssInactivityCount, |
| 897 | VDEV_CMD); |
| 898 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 899 | hdd_err("WMA_VDEV_IBSS_SET_INACTIVITY_TIME failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 900 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 901 | } |
| 902 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 903 | ret = sme_cli_set_command(adapter->sessionId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 904 | WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME, |
| 905 | hdd_ctx->config->ibssTxSpEndInactivityTime, |
| 906 | VDEV_CMD); |
| 907 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 908 | hdd_err("WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME failed %d", |
| 909 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 910 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 911 | } |
| 912 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 913 | ret = sme_cli_set_command(adapter->sessionId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 914 | WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS, |
| 915 | hdd_ctx->config->ibssPsWarmupTime, |
| 916 | VDEV_CMD); |
| 917 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 918 | hdd_err("WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS failed %d", |
| 919 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 920 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 921 | } |
| 922 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 923 | ret = sme_cli_set_command(adapter->sessionId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 924 | WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW, |
| 925 | hdd_ctx->config->ibssPs1RxChainInAtimEnable, |
| 926 | VDEV_CMD); |
| 927 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 928 | hdd_err("WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW failed %d", |
| 929 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 930 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 931 | } |
| 932 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 933 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 934 | } |
| 935 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 936 | #ifdef FEATURE_RUNTIME_PM |
| 937 | /** |
| 938 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 939 | * @hdd_ctx: HDD context |
| 940 | * |
| 941 | * Return: None |
| 942 | */ |
| 943 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) |
| 944 | { |
| 945 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 946 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 947 | qdf_runtime_lock_init(&ctx->dfs); |
| 948 | |
| 949 | wlan_scan_runtime_pm_init(hdd_ctx->hdd_pdev); |
| 950 | } |
| 951 | |
| 952 | /** |
| 953 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 954 | * @hdd_ctx: HDD Context |
| 955 | * |
| 956 | * Return: None |
| 957 | */ |
| 958 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) |
| 959 | { |
| 960 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 961 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 962 | qdf_runtime_lock_deinit(&ctx->dfs); |
| 963 | |
| 964 | wlan_scan_runtime_pm_deinit(hdd_ctx->hdd_pdev); |
| 965 | } |
| 966 | |
| 967 | static void hdd_adapter_runtime_suspend_init(struct hdd_adapter *adapter) |
| 968 | { |
| 969 | struct hdd_connect_pm_context *ctx = &adapter->connect_rpm_ctx; |
| 970 | |
| 971 | qdf_runtime_lock_init(&ctx->connect); |
| 972 | } |
| 973 | |
| 974 | static void hdd_adapter_runtime_suspend_denit(struct hdd_adapter *adapter) |
| 975 | { |
| 976 | struct hdd_connect_pm_context *ctx = &adapter->connect_rpm_ctx; |
| 977 | |
| 978 | qdf_runtime_lock_deinit(&ctx->connect); |
| 979 | } |
| 980 | #else /* FEATURE_RUNTIME_PM */ |
| 981 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) {} |
| 982 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) {} |
| 983 | static void hdd_adapter_runtime_suspend_init(struct hdd_adapter *adapter) {} |
| 984 | static void hdd_adapter_runtime_suspend_denit(struct hdd_adapter *adapter) {} |
| 985 | #endif /* FEATURE_RUNTIME_PM */ |
| 986 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 987 | #define INTF_MACADDR_MASK 0x7 |
| 988 | |
| 989 | /** |
| 990 | * hdd_update_macaddr() - update mac address |
| 991 | * @config: hdd configuration |
| 992 | * @hw_macaddr: mac address |
| 993 | * |
| 994 | * Mac address for multiple virtual interface is found as following |
| 995 | * i) The mac address of the first interface is just the actual hw mac address. |
| 996 | * ii) MSM 3 or 4 bits of byte5 of the actual mac address are used to |
| 997 | * define the mac address for the remaining interfaces and locally |
| 998 | * admistered bit is set. INTF_MACADDR_MASK is based on the number of |
| 999 | * supported virtual interfaces, right now this is 0x07 (meaning 8 |
| 1000 | * interface). |
| 1001 | * Byte[3] of second interface will be hw_macaddr[3](bit5..7) + 1, |
| 1002 | * for third interface it will be hw_macaddr[3](bit5..7) + 2, etc. |
| 1003 | * |
| 1004 | * Return: None |
| 1005 | */ |
| 1006 | void hdd_update_macaddr(struct hdd_config *config, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1007 | struct qdf_mac_addr hw_macaddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1008 | { |
| 1009 | int8_t i; |
| 1010 | uint8_t macaddr_b3, tmp_br3; |
| 1011 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1012 | qdf_mem_copy(config->intfMacAddr[0].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1013 | QDF_MAC_ADDR_SIZE); |
| 1014 | for (i = 1; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1015 | qdf_mem_copy(config->intfMacAddr[i].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1016 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1017 | macaddr_b3 = config->intfMacAddr[i].bytes[3]; |
| 1018 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 1019 | INTF_MACADDR_MASK; |
| 1020 | macaddr_b3 += tmp_br3; |
| 1021 | |
| 1022 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 1023 | * mac address range before collision |
| 1024 | */ |
| 1025 | macaddr_b3 ^= (1 << 7); |
| 1026 | |
| 1027 | /* Set locally administered bit */ |
| 1028 | config->intfMacAddr[i].bytes[0] |= 0x02; |
| 1029 | config->intfMacAddr[i].bytes[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1030 | hdd_debug("config->intfMacAddr[%d]: " |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1031 | MAC_ADDRESS_STR, i, |
| 1032 | MAC_ADDR_ARRAY(config->intfMacAddr[i].bytes)); |
| 1033 | } |
| 1034 | } |
| 1035 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1036 | static void hdd_update_tgt_services(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1037 | struct wma_tgt_services *cfg) |
| 1038 | { |
| 1039 | struct hdd_config *config = hdd_ctx->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1040 | |
| 1041 | /* Set up UAPSD */ |
| 1042 | config->apUapsdEnabled &= cfg->uapsd; |
| 1043 | |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 1044 | /* 11AX mode support */ |
| 1045 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 1046 | config->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) && !cfg->en_11ax) |
| 1047 | config->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 1048 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1049 | /* 11AC mode support */ |
| 1050 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 1051 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 1052 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1053 | |
| 1054 | /* ARP offload: override user setting if invalid */ |
| 1055 | config->fhostArpOffload &= cfg->arp_offload; |
| 1056 | |
| 1057 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 1058 | /* PNO offload */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1059 | hdd_debug("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1060 | if (cfg->pno_offload) |
| 1061 | config->PnoOffload = true; |
| 1062 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1063 | #ifdef FEATURE_WLAN_TDLS |
| 1064 | config->fEnableTDLSSupport &= cfg->en_tdls; |
Manjeet Singh | fdd2ac7 | 2016-09-02 18:11:43 +0530 | [diff] [blame] | 1065 | config->fEnableTDLSOffChannel = config->fEnableTDLSOffChannel && |
| 1066 | cfg->en_tdls_offchan; |
| 1067 | config->fEnableTDLSBufferSta = config->fEnableTDLSBufferSta && |
| 1068 | cfg->en_tdls_uapsd_buf_sta; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1069 | if (config->fTDLSUapsdMask && cfg->en_tdls_uapsd_sleep_sta) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1070 | config->fEnableTDLSSleepSta = true; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1071 | else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1072 | config->fEnableTDLSSleepSta = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1073 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1074 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1075 | config->isRoamOffloadEnabled &= cfg->en_roam_offload; |
| 1076 | #endif |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 1077 | config->sap_get_peer_info &= cfg->get_peer_info_enabled; |
Varun Reddy Yeturu | 62c3265 | 2017-10-26 15:32:35 -0700 | [diff] [blame^] | 1078 | config->MAWCEnabled &= cfg->is_fw_mawc_capable; |
Krishna Kumaar Natarajan | 052c6e6 | 2015-09-28 15:32:55 -0700 | [diff] [blame] | 1079 | sme_update_tgt_services(hdd_ctx->hHal, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1080 | |
| 1081 | } |
| 1082 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1083 | /** |
| 1084 | * hdd_update_vdev_nss() - sets the vdev nss |
| 1085 | * @hdd_ctx: HDD context |
| 1086 | * |
| 1087 | * Sets the Nss per vdev type based on INI |
| 1088 | * |
| 1089 | * Return: None |
| 1090 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1091 | static void hdd_update_vdev_nss(struct hdd_context *hdd_ctx) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1092 | { |
| 1093 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1094 | uint8_t max_supp_nss = 1; |
| 1095 | |
Naveen Rawat | 10b1c15 | 2017-01-18 11:16:06 -0800 | [diff] [blame] | 1096 | if (cfg_ini->enable2x2 && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1097 | max_supp_nss = 2; |
| 1098 | |
| 1099 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
| 1100 | cfg_ini->vdev_type_nss_2g, eCSR_BAND_24); |
| 1101 | |
| 1102 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
| 1103 | cfg_ini->vdev_type_nss_5g, eCSR_BAND_5G); |
| 1104 | } |
| 1105 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1106 | /** |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1107 | * hdd_update_wiphy_vhtcap() - Updates wiphy vhtcap fields |
| 1108 | * @hdd_ctx: HDD context |
| 1109 | * |
| 1110 | * Updates wiphy vhtcap fields |
| 1111 | * |
| 1112 | * Return: None |
| 1113 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1114 | static void hdd_update_wiphy_vhtcap(struct hdd_context *hdd_ctx) |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1115 | { |
| 1116 | struct ieee80211_supported_band *band_5g = |
| 1117 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]; |
| 1118 | uint32_t val; |
| 1119 | |
| 1120 | if (!band_5g) { |
| 1121 | hdd_debug("5GHz band disabled, skipping capability population"); |
| 1122 | return; |
| 1123 | } |
| 1124 | |
| 1125 | val = hdd_ctx->config->txBFCsnValue; |
| 1126 | band_5g->vht_cap.cap |= (val << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT); |
| 1127 | |
| 1128 | val = NUM_OF_SOUNDING_DIMENSIONS; |
| 1129 | band_5g->vht_cap.cap |= |
| 1130 | (val << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT); |
| 1131 | |
| 1132 | hdd_info("Updated wiphy vhtcap:0x%x, CSNAntSupp:%d, NumSoundDim:%d", |
| 1133 | band_5g->vht_cap.cap, hdd_ctx->config->txBFCsnValue, val); |
| 1134 | } |
| 1135 | |
| 1136 | /** |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1137 | * hdd_update_hw_dbs_capable() - sets the dbs capability of the device |
| 1138 | * @hdd_ctx: HDD context |
| 1139 | * |
| 1140 | * Sets the DBS capability as per INI and firmware capability |
| 1141 | * |
| 1142 | * Return: None |
| 1143 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1144 | static void hdd_update_hw_dbs_capable(struct hdd_context *hdd_ctx) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1145 | { |
| 1146 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1147 | uint8_t hw_dbs_capable = 0; |
| 1148 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 1149 | if (policy_mgr_is_hw_dbs_capable(hdd_ctx->hdd_psoc) && |
| 1150 | ((cfg_ini->dual_mac_feature_disable == |
| 1151 | ENABLE_DBS_CXN_AND_SCAN) || |
| 1152 | (cfg_ini->dual_mac_feature_disable == |
| 1153 | ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF))) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1154 | hw_dbs_capable = 1; |
| 1155 | |
| 1156 | sme_update_hw_dbs_capable(hdd_ctx->hHal, hw_dbs_capable); |
| 1157 | } |
| 1158 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1159 | static void hdd_update_tgt_ht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1160 | struct wma_tgt_ht_cap *cfg) |
| 1161 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1162 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1163 | uint32_t value, val32; |
| 1164 | uint16_t val16; |
| 1165 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1166 | tSirMacHTCapabilityInfo *phtCapInfo; |
| 1167 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
| 1168 | uint8_t enable_tx_stbc; |
| 1169 | |
| 1170 | /* check and update RX STBC */ |
| 1171 | if (pconfig->enableRxSTBC && !cfg->ht_rx_stbc) |
| 1172 | pconfig->enableRxSTBC = cfg->ht_rx_stbc; |
| 1173 | |
| 1174 | /* get the MPDU density */ |
| 1175 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, &value); |
| 1176 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1177 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1178 | hdd_err("could not get MPDU DENSITY"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1179 | value = 0; |
| 1180 | } |
| 1181 | |
| 1182 | /* |
| 1183 | * MPDU density: |
| 1184 | * override user's setting if value is larger |
| 1185 | * than the one supported by target |
| 1186 | */ |
| 1187 | if (value > cfg->mpdu_density) { |
| 1188 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, |
| 1189 | cfg->mpdu_density); |
| 1190 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1191 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1192 | hdd_err("could not set MPDU DENSITY to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1193 | } |
| 1194 | |
| 1195 | /* get the HT capability info */ |
| 1196 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_HT_CAP_INFO, &val32); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1197 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1198 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1199 | return; |
| 1200 | } |
| 1201 | val16 = (uint16_t) val32; |
| 1202 | phtCapInfo = (tSirMacHTCapabilityInfo *) &val16; |
| 1203 | |
| 1204 | /* Set the LDPC capability */ |
| 1205 | phtCapInfo->advCodingCap = cfg->ht_rx_ldpc; |
| 1206 | |
| 1207 | if (pconfig->ShortGI20MhzEnable && !cfg->ht_sgi_20) |
| 1208 | pconfig->ShortGI20MhzEnable = cfg->ht_sgi_20; |
| 1209 | |
| 1210 | if (pconfig->ShortGI40MhzEnable && !cfg->ht_sgi_40) |
| 1211 | pconfig->ShortGI40MhzEnable = cfg->ht_sgi_40; |
| 1212 | |
| 1213 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 1214 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 1215 | |
| 1216 | enable_tx_stbc = pconfig->enableTxSTBC; |
| 1217 | |
| 1218 | if (pconfig->enable2x2 && (cfg->num_rf_chains == 2)) { |
| 1219 | pconfig->enable2x2 = 1; |
| 1220 | } else { |
| 1221 | pconfig->enable2x2 = 0; |
| 1222 | enable_tx_stbc = 0; |
| 1223 | |
| 1224 | /* 1x1 */ |
| 1225 | /* Update Rx Highest Long GI data Rate */ |
| 1226 | if (sme_cfg_set_int(hdd_ctx->hHal, |
| 1227 | WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1228 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1229 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1230 | 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] | 1231 | } |
| 1232 | |
| 1233 | /* Update Tx Highest Long GI data Rate */ |
| 1234 | if (sme_cfg_set_int |
| 1235 | (hdd_ctx->hHal, |
| 1236 | WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1237 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1238 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1239 | hdd_err("VHT_TX_HIGHEST_SUPP_RATE_1_1 to CCM fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1240 | } |
| 1241 | } |
| 1242 | if (!(cfg->ht_tx_stbc && pconfig->enable2x2)) |
| 1243 | enable_tx_stbc = 0; |
| 1244 | phtCapInfo->txSTBC = enable_tx_stbc; |
| 1245 | |
| 1246 | val32 = val16; |
| 1247 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_HT_CAP_INFO, val32); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1248 | if (status != QDF_STATUS_SUCCESS) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1249 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1250 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
| 1251 | value = SIZE_OF_SUPPORTED_MCS_SET; |
| 1252 | if (sme_cfg_get_str(hdd_ctx->hHal, WNI_CFG_SUPPORTED_MCS_SET, mcs_set, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1253 | &value) == QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1254 | hdd_debug("Read MCS rate set"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1255 | |
| 1256 | if (pconfig->enable2x2) { |
| 1257 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 1258 | mcs_set[value] = |
| 1259 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 1260 | |
| 1261 | status = |
| 1262 | sme_cfg_set_str(hdd_ctx->hHal, |
| 1263 | WNI_CFG_SUPPORTED_MCS_SET, |
| 1264 | mcs_set, |
| 1265 | SIZE_OF_SUPPORTED_MCS_SET); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1266 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1267 | hdd_err("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1268 | } |
| 1269 | } |
| 1270 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 1271 | } |
| 1272 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1273 | static void hdd_update_tgt_vht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1274 | struct wma_tgt_vht_cap *cfg) |
| 1275 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1276 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1277 | uint32_t value = 0; |
| 1278 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1279 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 1280 | struct ieee80211_supported_band *band_5g = |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 1281 | wiphy->bands[HDD_NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1282 | uint32_t temp = 0; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1283 | uint32_t ch_width = eHT_CHANNEL_WIDTH_80MHZ; |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1284 | uint32_t hw_rx_ldpc_enabled; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1285 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1286 | if (!band_5g) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1287 | hdd_debug("5GHz band disabled, skipping capability population"); |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1288 | return; |
| 1289 | } |
| 1290 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1291 | /* Get the current MPDU length */ |
| 1292 | status = |
| 1293 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1294 | &value); |
| 1295 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1296 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1297 | hdd_err("could not get MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1298 | value = 0; |
| 1299 | } |
| 1300 | |
| 1301 | /* |
| 1302 | * VHT max MPDU length: |
| 1303 | * override if user configured value is too high |
| 1304 | * that the target cannot support |
| 1305 | */ |
| 1306 | if (value > cfg->vht_max_mpdu) { |
| 1307 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1308 | WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1309 | cfg->vht_max_mpdu); |
| 1310 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1311 | if (status == QDF_STATUS_E_FAILURE) |
| 1312 | hdd_err("could not set VHT MAX MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1313 | } |
| 1314 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1315 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, &temp); |
| 1316 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1317 | |
| 1318 | if (pconfig->enable2x2) |
| 1319 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1320 | |
| 1321 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, temp) == |
| 1322 | QDF_STATUS_E_FAILURE) { |
| 1323 | hdd_err("Could not pass VHT_BASIC_MCS_SET to CCM"); |
| 1324 | } |
| 1325 | |
| 1326 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, &temp); |
| 1327 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1328 | if (pconfig->enable2x2) |
| 1329 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1330 | |
| 1331 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, temp) == |
| 1332 | QDF_STATUS_E_FAILURE) { |
| 1333 | hdd_err("Could not pass WNI_CFG_VHT_RX_MCS_MAP to CCM"); |
| 1334 | } |
| 1335 | |
| 1336 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, &temp); |
| 1337 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtTxMCS; |
| 1338 | if (pconfig->enable2x2) |
| 1339 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtTxMCS2x2 << 2); |
| 1340 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1341 | hdd_debug("vhtRxMCS2x2 - %x temp - %u enable2x2 %d", |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1342 | pconfig->vhtRxMCS2x2, temp, pconfig->enable2x2); |
| 1343 | |
| 1344 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, temp) == |
| 1345 | QDF_STATUS_E_FAILURE) { |
| 1346 | hdd_err("Could not pass WNI_CFG_VHT_TX_MCS_MAP to CCM"); |
| 1347 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1348 | /* Get the current RX LDPC setting */ |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1349 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_LDPC_CODING_CAP, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1350 | &value); |
| 1351 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1352 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1353 | hdd_err("could not get VHT LDPC CODING CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1354 | value = 0; |
| 1355 | } |
| 1356 | |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1357 | /* Set HW RX LDPC capability */ |
| 1358 | hw_rx_ldpc_enabled = !!cfg->vht_rx_ldpc; |
| 1359 | if (hw_rx_ldpc_enabled != value) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1360 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1361 | WNI_CFG_VHT_LDPC_CODING_CAP, |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1362 | hw_rx_ldpc_enabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1363 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1364 | if (status == QDF_STATUS_E_FAILURE) |
| 1365 | hdd_err("could not set VHT LDPC CODING CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1366 | } |
| 1367 | |
| 1368 | /* Get current GI 80 value */ |
| 1369 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1370 | &value); |
| 1371 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1372 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1373 | hdd_err("could not get SHORT GI 80MHZ"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1374 | value = 0; |
| 1375 | } |
| 1376 | |
| 1377 | /* set the Guard interval 80MHz */ |
| 1378 | if (value && !cfg->vht_short_gi_80) { |
| 1379 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1380 | WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1381 | cfg->vht_short_gi_80); |
| 1382 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1383 | if (status == QDF_STATUS_E_FAILURE) |
| 1384 | hdd_err("could not set SHORT GI 80MHZ to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1385 | } |
| 1386 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1387 | /* Get VHT TX STBC cap */ |
| 1388 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, &value); |
| 1389 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1390 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1391 | hdd_err("could not get VHT TX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1392 | value = 0; |
| 1393 | } |
| 1394 | |
| 1395 | /* VHT TX STBC cap */ |
| 1396 | if (value && !cfg->vht_tx_stbc) { |
| 1397 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, |
| 1398 | cfg->vht_tx_stbc); |
| 1399 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1400 | if (status == QDF_STATUS_E_FAILURE) |
| 1401 | hdd_err("could not set the VHT TX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1402 | } |
| 1403 | |
| 1404 | /* Get VHT RX STBC cap */ |
| 1405 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, &value); |
| 1406 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1407 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1408 | hdd_err("could not get VHT RX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1409 | value = 0; |
| 1410 | } |
| 1411 | |
| 1412 | /* VHT RX STBC cap */ |
| 1413 | if (value && !cfg->vht_rx_stbc) { |
| 1414 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, |
| 1415 | cfg->vht_rx_stbc); |
| 1416 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1417 | if (status == QDF_STATUS_E_FAILURE) |
| 1418 | hdd_err("could not set the VHT RX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1419 | } |
| 1420 | |
| 1421 | /* Get VHT SU Beamformer cap */ |
| 1422 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1423 | &value); |
| 1424 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1425 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1426 | hdd_err("could not get VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1427 | value = 0; |
| 1428 | } |
| 1429 | |
| 1430 | /* set VHT SU Beamformer cap */ |
| 1431 | if (value && !cfg->vht_su_bformer) { |
| 1432 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1433 | WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1434 | cfg->vht_su_bformer); |
| 1435 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1436 | if (status == QDF_STATUS_E_FAILURE) |
| 1437 | hdd_err("could not set VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1438 | } |
| 1439 | |
| 1440 | /* check and update SU BEAMFORMEE capabality */ |
| 1441 | if (pconfig->enableTxBF && !cfg->vht_su_bformee) |
| 1442 | pconfig->enableTxBF = cfg->vht_su_bformee; |
| 1443 | |
| 1444 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1445 | WNI_CFG_VHT_SU_BEAMFORMEE_CAP, |
| 1446 | pconfig->enableTxBF); |
| 1447 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1448 | if (status == QDF_STATUS_E_FAILURE) |
| 1449 | hdd_err("could not set VHT SU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1450 | |
| 1451 | /* Get VHT MU Beamformer cap */ |
| 1452 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1453 | &value); |
| 1454 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1455 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1456 | hdd_err("could not get VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1457 | value = 0; |
| 1458 | } |
| 1459 | |
| 1460 | /* set VHT MU Beamformer cap */ |
| 1461 | if (value && !cfg->vht_mu_bformer) { |
| 1462 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1463 | WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1464 | cfg->vht_mu_bformer); |
| 1465 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1466 | if (status == QDF_STATUS_E_FAILURE) |
| 1467 | hdd_err("could not set the VHT MU BEAMFORMER CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1468 | } |
| 1469 | |
| 1470 | /* Get VHT MU Beamformee cap */ |
| 1471 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1472 | &value); |
| 1473 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1474 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1475 | hdd_err("could not get VHT MU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1476 | value = 0; |
| 1477 | } |
| 1478 | |
| 1479 | /* set VHT MU Beamformee cap */ |
| 1480 | if (value && !cfg->vht_mu_bformee) { |
| 1481 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1482 | WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1483 | cfg->vht_mu_bformee); |
| 1484 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1485 | if (status == QDF_STATUS_E_FAILURE) |
| 1486 | hdd_err("could not set VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1487 | } |
| 1488 | |
| 1489 | /* Get VHT MAX AMPDU Len exp */ |
| 1490 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1491 | &value); |
| 1492 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1493 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1494 | hdd_err("could not get VHT AMPDU LEN"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1495 | value = 0; |
| 1496 | } |
| 1497 | |
| 1498 | /* |
| 1499 | * VHT max AMPDU len exp: |
| 1500 | * override if user configured value is too high |
| 1501 | * that the target cannot support. |
| 1502 | * Even though Rome publish ampdu_len=7, it can |
| 1503 | * only support 4 because of some h/w bug. |
| 1504 | */ |
| 1505 | |
| 1506 | if (value > cfg->vht_max_ampdu_len_exp) { |
| 1507 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1508 | WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1509 | cfg->vht_max_ampdu_len_exp); |
| 1510 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1511 | if (status == QDF_STATUS_E_FAILURE) |
| 1512 | hdd_err("could not set the VHT AMPDU LEN EXP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1513 | } |
| 1514 | |
| 1515 | /* Get VHT TXOP PS CAP */ |
| 1516 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, &value); |
| 1517 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1518 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1519 | hdd_err("could not get VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1520 | value = 0; |
| 1521 | } |
| 1522 | |
| 1523 | /* set VHT TXOP PS cap */ |
| 1524 | if (value && !cfg->vht_txop_ps) { |
| 1525 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, |
| 1526 | cfg->vht_txop_ps); |
| 1527 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1528 | if (status == QDF_STATUS_E_FAILURE) |
| 1529 | hdd_err("could not set the VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1530 | } |
| 1531 | |
| 1532 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1533 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1534 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1535 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1536 | else |
| 1537 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1538 | |
| 1539 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1540 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) { |
| 1541 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1542 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1543 | VHT_CAP_160_AND_80P80_SUPP); |
| 1544 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1545 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1546 | band_5g->vht_cap.cap |= |
| 1547 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1548 | ch_width = eHT_CHANNEL_WIDTH_80P80MHZ; |
| 1549 | } else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) { |
| 1550 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1551 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1552 | VHT_CAP_160_SUPP); |
| 1553 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1554 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1555 | band_5g->vht_cap.cap |= |
| 1556 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1557 | ch_width = eHT_CHANNEL_WIDTH_160MHZ; |
| 1558 | } |
| 1559 | pconfig->vhtChannelWidth = QDF_MIN(pconfig->vhtChannelWidth, |
| 1560 | ch_width); |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1561 | /* Get the current GI 160 value */ |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1562 | status = sme_cfg_get_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1563 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1564 | &value); |
| 1565 | if (status != QDF_STATUS_SUCCESS) { |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1566 | hdd_err("could not get GI 80 & 160"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1567 | value = 0; |
| 1568 | } |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1569 | /* set the Guard interval 160MHz */ |
| 1570 | if (value && !cfg->vht_short_gi_160) { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1571 | status = sme_cfg_set_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1572 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
| 1573 | cfg->vht_short_gi_160); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1574 | |
| 1575 | if (status == QDF_STATUS_E_FAILURE) |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1576 | hdd_err("failed to set SHORT GI 160MHZ"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1577 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1578 | |
| 1579 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) |
| 1580 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1581 | |
| 1582 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1583 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1584 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1585 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1586 | |
| 1587 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1588 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1589 | |
| 1590 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1591 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1592 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1593 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1594 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1595 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1596 | |
| 1597 | band_5g->vht_cap.cap |= |
| 1598 | (cfg->vht_max_ampdu_len_exp << |
| 1599 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1600 | |
| 1601 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1602 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1603 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1604 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1605 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1606 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1607 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1608 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1609 | |
| 1610 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1611 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1612 | |
| 1613 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1614 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1615 | /** |
| 1616 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1617 | * @hdd_ctx: Pointer to the HDD context |
| 1618 | * |
| 1619 | * Auto-generate mac address using device serial number. |
| 1620 | * Keep the first 3 bytes of OUI as before and replace |
| 1621 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1622 | * |
| 1623 | * Return: 0 for success |
| 1624 | * Non zero failure code for errors |
| 1625 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1626 | static int hdd_generate_macaddr_auto(struct hdd_context *hdd_ctx) |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1627 | { |
| 1628 | unsigned int serialno = 0; |
| 1629 | struct qdf_mac_addr mac_addr = { |
| 1630 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1631 | }; |
| 1632 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1633 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1634 | if (serialno == 0) |
| 1635 | return -EINVAL; |
| 1636 | |
| 1637 | serialno &= 0x00ffffff; |
| 1638 | |
| 1639 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1640 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1641 | mac_addr.bytes[5] = serialno & 0xff; |
| 1642 | |
| 1643 | hdd_update_macaddr(hdd_ctx->config, mac_addr); |
| 1644 | return 0; |
| 1645 | } |
| 1646 | |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1647 | /** |
| 1648 | * hdd_update_ra_rate_limit() - Update RA rate limit from target |
| 1649 | * configuration to cfg_ini in HDD |
| 1650 | * @hdd_ctx: Pointer to hdd_ctx |
| 1651 | * @cfg: target configuration |
| 1652 | * |
| 1653 | * Return: None |
| 1654 | */ |
| 1655 | #ifdef FEATURE_WLAN_RA_FILTERING |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1656 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1657 | struct wma_tgt_cfg *cfg) |
| 1658 | { |
| 1659 | hdd_ctx->config->IsRArateLimitEnabled = cfg->is_ra_rate_limit_enabled; |
| 1660 | } |
| 1661 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1662 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1663 | struct wma_tgt_cfg *cfg) |
| 1664 | { |
| 1665 | } |
| 1666 | #endif |
| 1667 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1668 | void hdd_update_tgt_cfg(void *context, void *param) |
| 1669 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1670 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1671 | struct hdd_context *hdd_ctx = (struct hdd_context *) context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1672 | struct wma_tgt_cfg *cfg = param; |
| 1673 | uint8_t temp_band_cap; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1674 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1675 | uint8_t antenna_mode; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1676 | |
Yue Ma | e3e86ab | 2017-05-08 10:48:24 -0700 | [diff] [blame] | 1677 | /* Reuse same pdev for module start/stop or SSR */ |
Ashish Kumar Dhanotiya | fd758ec | 2017-08-04 12:03:18 +0530 | [diff] [blame] | 1678 | if (((hdd_get_conparam() == QDF_GLOBAL_FTM_MODE) || |
| 1679 | (hdd_get_conparam() == QDF_GLOBAL_MONITOR_MODE) || |
| 1680 | !cds_is_driver_loading()) && (hdd_ctx->hdd_pdev != NULL)) { |
| 1681 | hdd_debug("Reuse pdev for module start/stop or SSR pdev_id = %u", |
| 1682 | hdd_ctx->hdd_pdev->pdev_objmgr.wlan_pdev_id); |
Yue Ma | e3e86ab | 2017-05-08 10:48:24 -0700 | [diff] [blame] | 1683 | /* Restore pdev to MAC/WMA contexts */ |
| 1684 | sme_store_pdev(hdd_ctx->hHal, hdd_ctx->hdd_pdev); |
Sandeep Puligilla | 1cf6ebe | 2017-04-04 14:40:27 -0700 | [diff] [blame] | 1685 | } else { |
| 1686 | ret = hdd_objmgr_create_and_store_pdev(hdd_ctx); |
| 1687 | if (ret) { |
| 1688 | hdd_err("pdev creation fails!"); |
| 1689 | QDF_BUG(0); |
Ashish Kumar Dhanotiya | fd758ec | 2017-08-04 12:03:18 +0530 | [diff] [blame] | 1690 | } else |
| 1691 | hdd_debug("New pdev has been created with pdev_id = %u", |
| 1692 | hdd_ctx->hdd_pdev->pdev_objmgr.wlan_pdev_id); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1693 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1694 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1695 | if (cds_cfg) { |
| 1696 | if (hdd_ctx->config->enable_sub_20_channel_width != |
| 1697 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
| 1698 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1699 | cds_cfg->sub_20_channel_width = |
| 1700 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1701 | } else { |
| 1702 | cds_cfg->sub_20_channel_width = |
| 1703 | hdd_ctx->config->enable_sub_20_channel_width; |
| 1704 | } |
| 1705 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1706 | |
| 1707 | /* first store the INI band capability */ |
| 1708 | temp_band_cap = hdd_ctx->config->nBandCapability; |
| 1709 | |
| 1710 | hdd_ctx->config->nBandCapability = cfg->band_cap; |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 1711 | hdd_ctx->is_fils_roaming_supported = |
| 1712 | cfg->services.is_fils_roaming_supported; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1713 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 1714 | /* |
| 1715 | * now overwrite the target band capability with INI |
| 1716 | * setting if INI setting is a subset |
| 1717 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1718 | |
| 1719 | if ((hdd_ctx->config->nBandCapability == eCSR_BAND_ALL) && |
| 1720 | (temp_band_cap != eCSR_BAND_ALL)) |
| 1721 | hdd_ctx->config->nBandCapability = temp_band_cap; |
| 1722 | else if ((hdd_ctx->config->nBandCapability != eCSR_BAND_ALL) && |
| 1723 | (temp_band_cap != eCSR_BAND_ALL) && |
| 1724 | (hdd_ctx->config->nBandCapability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1725 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1726 | } |
| 1727 | |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 1728 | hdd_ctx->curr_band = hdd_ctx->config->nBandCapability; |
| 1729 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1730 | if (!cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1731 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 1732 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 1733 | } |
| 1734 | |
| 1735 | /* This can be extended to other configurations like ht, vht cap... */ |
| 1736 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 1737 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1738 | hdd_update_macaddr(hdd_ctx->config, cfg->hw_macaddr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1739 | hdd_ctx->update_mac_addr_to_fw = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1740 | } else { |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1741 | static struct qdf_mac_addr default_mac_addr = { |
| 1742 | {0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF} |
| 1743 | }; |
| 1744 | if (qdf_is_macaddr_equal(&hdd_ctx->config->intfMacAddr[0], |
| 1745 | &default_mac_addr)) { |
| 1746 | if (hdd_generate_macaddr_auto(hdd_ctx) != 0) |
| 1747 | hdd_err("Fail to auto-generate MAC, using MAC from ini file " |
| 1748 | MAC_ADDRESS_STR, |
| 1749 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1750 | intfMacAddr[0].bytes)); |
| 1751 | } else { |
| 1752 | hdd_err("Invalid MAC passed from target, using MAC from ini file " |
| 1753 | MAC_ADDRESS_STR, |
| 1754 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1755 | intfMacAddr[0].bytes)); |
| 1756 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1757 | hdd_ctx->update_mac_addr_to_fw = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1758 | } |
| 1759 | |
| 1760 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 1761 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1762 | |
| 1763 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 1764 | |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 1765 | hdd_lpass_target_config(hdd_ctx, cfg); |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 1766 | hdd_green_ap_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1767 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1768 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 1769 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 1770 | |
| 1771 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 1772 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1773 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame] | 1774 | if (cfg->services.en_11ax) { |
| 1775 | hdd_info("11AX: 11ax is enabled - update HDD config"); |
| 1776 | hdd_update_tgt_he_cap(hdd_ctx, cfg); |
| 1777 | } |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1778 | |
| 1779 | hdd_update_vdev_nss(hdd_ctx); |
| 1780 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1781 | hdd_update_hw_dbs_capable(hdd_ctx); |
| 1782 | |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1783 | hdd_ctx->config->fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 1784 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1785 | hdd_debug("fine_time_meas_cap: 0x%x", |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1786 | hdd_ctx->config->fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1787 | |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1788 | antenna_mode = (hdd_ctx->config->enable2x2 == 0x01) ? |
| 1789 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 1790 | hdd_update_smps_antenna_mode(hdd_ctx, antenna_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1791 | hdd_debug("Init current antenna mode: %d", |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1792 | hdd_ctx->current_antenna_mode); |
| 1793 | |
Rajeev Kumar | dd3bc60 | 2016-08-16 14:21:05 -0700 | [diff] [blame] | 1794 | hdd_ctx->bpf_enabled = (cfg->bpf_enabled && |
| 1795 | hdd_ctx->config->bpf_packet_filter_enable); |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1796 | hdd_update_ra_rate_limit(hdd_ctx, cfg); |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1797 | |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 1798 | if ((hdd_ctx->config->txBFCsnValue > |
| 1799 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF) && |
| 1800 | !cfg->tx_bfee_8ss_enabled) |
| 1801 | hdd_ctx->config->txBFCsnValue = |
| 1802 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF; |
| 1803 | |
| 1804 | if (sme_cfg_set_int(hdd_ctx->hHal, |
| 1805 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED, |
| 1806 | hdd_ctx->config->txBFCsnValue) == QDF_STATUS_E_FAILURE) |
| 1807 | hdd_err("fw update WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED to CFG fails"); |
| 1808 | |
| 1809 | |
| 1810 | hdd_debug("Target BPF %d Host BPF %d 8ss fw support %d txBFCsnValue %d", |
| 1811 | cfg->bpf_enabled, hdd_ctx->config->bpf_packet_filter_enable, |
| 1812 | cfg->tx_bfee_8ss_enabled, hdd_ctx->config->txBFCsnValue); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1813 | |
| 1814 | /* |
| 1815 | * Update txBFCsnValue and NumSoundingDim values to vhtcap in wiphy |
| 1816 | */ |
| 1817 | hdd_update_wiphy_vhtcap(hdd_ctx); |
Manjeet Singh | 70d3d93 | 2016-12-20 20:41:10 +0530 | [diff] [blame] | 1818 | |
| 1819 | hdd_ctx->fw_mem_dump_enabled = cfg->fw_mem_dump_enabled; |
| 1820 | |
Arun Khandavalli | d454d42 | 2016-08-17 12:47:05 +0530 | [diff] [blame] | 1821 | /* |
| 1822 | * If BPF is enabled, maxWowFilters set to WMA_STA_WOW_DEFAULT_PTRN_MAX |
| 1823 | * because we need atleast WMA_STA_WOW_DEFAULT_PTRN_MAX free slots to |
| 1824 | * configure the STA mode wow pattern. |
| 1825 | */ |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1826 | if (hdd_ctx->bpf_enabled) |
Arun Khandavalli | d454d42 | 2016-08-17 12:47:05 +0530 | [diff] [blame] | 1827 | hdd_ctx->config->maxWoWFilters = WMA_STA_WOW_DEFAULT_PTRN_MAX; |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1828 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 1829 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 1830 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1831 | /* |
| 1832 | * This needs to be done after HDD pdev is created and stored since |
| 1833 | * it will access the HDD pdev object lock. |
| 1834 | */ |
| 1835 | hdd_runtime_suspend_context_init(hdd_ctx); |
| 1836 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 1837 | /* Configure NAN datapath features */ |
| 1838 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Arif Hussain | 759a023 | 2017-03-20 13:17:18 -0700 | [diff] [blame] | 1839 | hdd_ctx->dfs_cac_offload = cfg->dfs_cac_offload; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1840 | } |
| 1841 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1842 | bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1843 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1844 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 1845 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1846 | QDF_STATUS status; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 1847 | struct hdd_ap_ctx *ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1848 | |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1849 | if (!hdd_ctx || hdd_ctx->config->disableDFSChSwitch) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 1850 | hdd_info("skip tx block hdd_ctx=%pK, disableDFSChSwitch=%d", |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1851 | hdd_ctx, hdd_ctx->config->disableDFSChSwitch); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1852 | return true; |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1853 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1854 | |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1855 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 1856 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 1857 | adapter = adapterNode->adapter; |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1858 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 1859 | |
| 1860 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 1861 | QDF_P2P_GO_MODE == adapter->device_mode) && |
| 1862 | (wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
| 1863 | ap_ctx->operatingChannel))) { |
| 1864 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->dfs_cac_block_tx = |
| 1865 | true; |
| 1866 | hdd_info("tx blocked for session: %d", |
| 1867 | adapter->sessionId); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1868 | } |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1869 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 1870 | adapterNode = pNext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1871 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1872 | |
| 1873 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1874 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1875 | |
| 1876 | /** |
| 1877 | * hdd_is_valid_mac_address() - validate MAC address |
| 1878 | * @pMacAddr: Pointer to the input MAC address |
| 1879 | * |
| 1880 | * This function validates whether the given MAC address is valid or not |
| 1881 | * Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 1882 | * where X is the hexa decimal digit character and separated by ':' |
| 1883 | * This algorithm works even if MAC address is not separated by ':' |
| 1884 | * |
| 1885 | * This code checks given input string mac contains exactly 12 hexadecimal |
| 1886 | * digits and a separator colon : appears in the input string only after |
| 1887 | * an even number of hex digits. |
| 1888 | * |
| 1889 | * Return: 1 for valid and 0 for invalid |
| 1890 | */ |
| 1891 | bool hdd_is_valid_mac_address(const uint8_t *pMacAddr) |
| 1892 | { |
| 1893 | int xdigit = 0; |
| 1894 | int separator = 0; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1895 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1896 | while (*pMacAddr) { |
| 1897 | if (isxdigit(*pMacAddr)) { |
| 1898 | xdigit++; |
| 1899 | } else if (':' == *pMacAddr) { |
| 1900 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 1901 | break; |
| 1902 | |
| 1903 | ++separator; |
| 1904 | } else { |
| 1905 | /* Invalid MAC found */ |
| 1906 | return 0; |
| 1907 | } |
| 1908 | ++pMacAddr; |
| 1909 | } |
| 1910 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 1911 | } |
| 1912 | |
| 1913 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 1914 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 1915 | * @dev: Handle to struct net_device to be updated. |
| 1916 | * |
| 1917 | * Return: None |
| 1918 | */ |
| 1919 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 1920 | { |
| 1921 | dev->header_ops = NULL; |
| 1922 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 1923 | dev->hard_header_len = ETH_HLEN; |
| 1924 | dev->mtu = ETH_DATA_LEN; |
| 1925 | dev->addr_len = ETH_ALEN; |
| 1926 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 1927 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 1928 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 1929 | |
| 1930 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 1931 | } |
| 1932 | |
| 1933 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1934 | * __hdd__mon_open() - HDD Open function |
| 1935 | * @dev: Pointer to net_device structure |
| 1936 | * |
| 1937 | * This is called in response to ifconfig up |
| 1938 | * |
| 1939 | * Return: 0 for success; non-zero for failure |
| 1940 | */ |
| 1941 | static int __hdd_mon_open(struct net_device *dev) |
| 1942 | { |
| 1943 | int ret; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 1944 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1945 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1946 | |
| 1947 | ENTER_DEV(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 1948 | |
| 1949 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 1950 | if (ret) |
| 1951 | return ret; |
| 1952 | |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 1953 | hdd_mon_mode_ether_setup(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 1954 | |
| 1955 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
| 1956 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 1957 | if (ret) { |
| 1958 | hdd_err("Failed to start WLAN modules return"); |
| 1959 | return ret; |
| 1960 | } |
| 1961 | hdd_err("hdd_wlan_start_modules() successful !"); |
| 1962 | |
| 1963 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 1964 | ret = hdd_start_adapter(adapter); |
| 1965 | if (ret) { |
| 1966 | hdd_err("Failed to start adapter :%d", |
| 1967 | adapter->device_mode); |
| 1968 | return ret; |
| 1969 | } |
| 1970 | hdd_err("hdd_start_adapters() successful !"); |
| 1971 | } |
| 1972 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 1973 | } |
| 1974 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1975 | ret = hdd_set_mon_rx_cb(dev); |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 1976 | |
| 1977 | if (!ret) |
| 1978 | ret = hdd_enable_monitor_mode(dev); |
| 1979 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1980 | return ret; |
| 1981 | } |
| 1982 | |
| 1983 | /** |
| 1984 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 1985 | * @dev: Pointer to net_device structure |
| 1986 | * |
| 1987 | * This is called in response to ifconfig up |
| 1988 | * |
| 1989 | * Return: 0 for success; non-zero for failure |
| 1990 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 1991 | static int hdd_mon_open(struct net_device *dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1992 | { |
| 1993 | int ret; |
| 1994 | |
| 1995 | cds_ssr_protect(__func__); |
| 1996 | ret = __hdd_mon_open(dev); |
| 1997 | cds_ssr_unprotect(__func__); |
| 1998 | |
| 1999 | return ret; |
| 2000 | } |
| 2001 | |
| 2002 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2003 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 2004 | * @adapter: pointer to HDD adapter |
| 2005 | * |
| 2006 | * This function is called to start the device specific adapter for |
| 2007 | * the mode passed in the adapter's device_mode. |
| 2008 | * |
| 2009 | * Return: 0 for success; non-zero for failure |
| 2010 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2011 | int hdd_start_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2012 | { |
| 2013 | |
| 2014 | int ret; |
| 2015 | enum tQDF_ADAPTER_MODE device_mode = adapter->device_mode; |
| 2016 | |
| 2017 | ENTER_DEV(adapter->dev); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2018 | hdd_debug("Start_adapter for mode : %d", adapter->device_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2019 | |
| 2020 | switch (device_mode) { |
| 2021 | case QDF_P2P_CLIENT_MODE: |
| 2022 | case QDF_P2P_DEVICE_MODE: |
| 2023 | case QDF_OCB_MODE: |
| 2024 | case QDF_STA_MODE: |
| 2025 | case QDF_MONITOR_MODE: |
| 2026 | ret = hdd_start_station_adapter(adapter); |
| 2027 | if (ret) |
| 2028 | goto err_start_adapter; |
| 2029 | break; |
| 2030 | case QDF_P2P_GO_MODE: |
| 2031 | case QDF_SAP_MODE: |
| 2032 | ret = hdd_start_ap_adapter(adapter); |
| 2033 | if (ret) |
| 2034 | goto err_start_adapter; |
| 2035 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 2036 | case QDF_IBSS_MODE: |
| 2037 | /* |
| 2038 | * For IBSS interface is initialized as part of |
| 2039 | * hdd_init_station_mode() |
| 2040 | */ |
| 2041 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2042 | case QDF_FTM_MODE: |
| 2043 | ret = hdd_start_ftm_adapter(adapter); |
| 2044 | if (ret) |
| 2045 | goto err_start_adapter; |
| 2046 | break; |
| 2047 | default: |
| 2048 | hdd_err("Invalid session type %d", device_mode); |
| 2049 | QDF_ASSERT(0); |
| 2050 | goto err_start_adapter; |
| 2051 | } |
| 2052 | if (hdd_set_fw_params(adapter)) |
| 2053 | hdd_err("Failed to set the FW params for the adapter!"); |
| 2054 | |
| 2055 | /* |
| 2056 | * Action frame registered in one adapter which will |
| 2057 | * applicable to all interfaces |
| 2058 | */ |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2059 | ret = wlan_hdd_cfg80211_register_frames(adapter); |
| 2060 | if (ret < 0) { |
| 2061 | hdd_err("Failed to register frames - ret %d", ret); |
| 2062 | goto err_start_adapter; |
| 2063 | } |
| 2064 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2065 | EXIT(); |
| 2066 | return 0; |
| 2067 | err_start_adapter: |
| 2068 | return -EINVAL; |
| 2069 | } |
| 2070 | |
| 2071 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2072 | * hdd_enable_power_management() - API to Enable Power Management |
| 2073 | * |
| 2074 | * API invokes Bus Interface Layer power management functionality |
| 2075 | * |
| 2076 | * Return: None |
| 2077 | */ |
| 2078 | static void hdd_enable_power_management(void) |
| 2079 | { |
| 2080 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2081 | |
| 2082 | if (!hif_ctx) { |
| 2083 | hdd_err("Bus Interface Context is Invalid"); |
| 2084 | return; |
| 2085 | } |
| 2086 | |
| 2087 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 2088 | } |
| 2089 | |
| 2090 | /** |
| 2091 | * hdd_disable_power_management() - API to disable Power Management |
| 2092 | * |
| 2093 | * API disable Bus Interface Layer Power management functionality |
| 2094 | * |
| 2095 | * Return: None |
| 2096 | */ |
| 2097 | static void hdd_disable_power_management(void) |
| 2098 | { |
| 2099 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2100 | |
| 2101 | if (!hif_ctx) { |
| 2102 | hdd_err("Bus Interface Context is Invalid"); |
| 2103 | return; |
| 2104 | } |
| 2105 | |
| 2106 | hif_disable_power_management(hif_ctx); |
| 2107 | } |
| 2108 | |
| 2109 | /** |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2110 | * hdd_update_hw_sw_info() - API to update the HW/SW information |
| 2111 | * |
| 2112 | * API to update the HW and SW information in the driver |
| 2113 | * |
| 2114 | * Return: None |
| 2115 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2116 | static void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2117 | { |
| 2118 | void *hif_sc; |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2119 | size_t target_hw_name_len; |
| 2120 | const char *target_hw_name; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2121 | |
| 2122 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
| 2123 | if (!hif_sc) { |
| 2124 | hdd_err("HIF context is NULL"); |
| 2125 | return; |
| 2126 | } |
| 2127 | |
| 2128 | /* |
| 2129 | * target hw version/revision would only be retrieved after firmware |
| 2130 | * download |
| 2131 | */ |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2132 | hif_get_hw_info(hif_sc, |
| 2133 | &hdd_ctx->target_hw_version, |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2134 | &hdd_ctx->target_hw_revision, |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2135 | &target_hw_name); |
| 2136 | |
| 2137 | if (hdd_ctx->target_hw_name) |
| 2138 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2139 | |
| 2140 | target_hw_name_len = strlen(target_hw_name) + 1; |
| 2141 | hdd_ctx->target_hw_name = qdf_mem_malloc(target_hw_name_len); |
| 2142 | if (hdd_ctx->target_hw_name) |
| 2143 | qdf_mem_copy(hdd_ctx->target_hw_name, target_hw_name, |
| 2144 | target_hw_name_len); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2145 | |
| 2146 | /* Get the wlan hw/fw version */ |
| 2147 | hdd_wlan_get_version(hdd_ctx, NULL, NULL); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2148 | } |
| 2149 | |
| 2150 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2151 | * hdd_update_cds_ac_specs_params() - update cds ac_specs params |
| 2152 | * @hdd_ctx: Pointer to hdd context |
| 2153 | * |
| 2154 | * Return: none |
| 2155 | */ |
| 2156 | static void |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2157 | hdd_update_cds_ac_specs_params(struct hdd_context *hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2158 | { |
| 2159 | uint8_t num_entries = 0; |
| 2160 | uint8_t tx_sched_wrr_param[TX_SCHED_WRR_PARAMS_NUM]; |
| 2161 | uint8_t *tx_sched_wrr_ac; |
| 2162 | int i; |
| 2163 | cds_context_type *cds_ctx; |
| 2164 | |
| 2165 | if (NULL == hdd_ctx) |
| 2166 | return; |
| 2167 | |
| 2168 | if (NULL == hdd_ctx->config) { |
| 2169 | /* Do nothing if hdd_ctx is invalid */ |
| 2170 | hdd_err("%s: Warning: hdd_ctx->cfg_ini is NULL", __func__); |
| 2171 | return; |
| 2172 | } |
| 2173 | |
| 2174 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2175 | |
| 2176 | if (!cds_ctx) { |
| 2177 | hdd_err("Invalid CDS Context"); |
| 2178 | return; |
| 2179 | } |
| 2180 | |
| 2181 | for (i = 0; i < OL_TX_NUM_WMM_AC; i++) { |
| 2182 | switch (i) { |
| 2183 | case OL_TX_WMM_AC_BE: |
| 2184 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_be; |
| 2185 | break; |
| 2186 | case OL_TX_WMM_AC_BK: |
| 2187 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_bk; |
| 2188 | break; |
| 2189 | case OL_TX_WMM_AC_VI: |
| 2190 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vi; |
| 2191 | break; |
| 2192 | case OL_TX_WMM_AC_VO: |
| 2193 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vo; |
| 2194 | break; |
| 2195 | default: |
| 2196 | tx_sched_wrr_ac = NULL; |
| 2197 | break; |
| 2198 | } |
| 2199 | |
| 2200 | hdd_string_to_u8_array(tx_sched_wrr_ac, |
| 2201 | tx_sched_wrr_param, |
| 2202 | &num_entries, |
| 2203 | sizeof(tx_sched_wrr_param)); |
| 2204 | |
| 2205 | if (num_entries == TX_SCHED_WRR_PARAMS_NUM) { |
| 2206 | cds_ctx->ac_specs[i].wrr_skip_weight = |
| 2207 | tx_sched_wrr_param[0]; |
| 2208 | cds_ctx->ac_specs[i].credit_threshold = |
| 2209 | tx_sched_wrr_param[1]; |
| 2210 | cds_ctx->ac_specs[i].send_limit = |
| 2211 | tx_sched_wrr_param[2]; |
| 2212 | cds_ctx->ac_specs[i].credit_reserve = |
| 2213 | tx_sched_wrr_param[3]; |
| 2214 | cds_ctx->ac_specs[i].discard_weight = |
| 2215 | tx_sched_wrr_param[4]; |
| 2216 | } |
| 2217 | |
| 2218 | num_entries = 0; |
| 2219 | } |
| 2220 | } |
| 2221 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2222 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2223 | static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev( |
| 2224 | struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) |
| 2225 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2226 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2227 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2228 | |
| 2229 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 2230 | if (!adapter) { |
| 2231 | hdd_err("Adapter is NULL"); |
| 2232 | return PM_MAX_NUM_OF_MODE; |
| 2233 | } |
| 2234 | |
| 2235 | return policy_mgr_convert_device_mode_to_qdf_type( |
| 2236 | adapter->device_mode); |
| 2237 | } |
| 2238 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2239 | static void hdd_register_policy_manager_callback( |
| 2240 | struct wlan_objmgr_psoc *psoc) |
| 2241 | { |
| 2242 | struct policy_mgr_hdd_cbacks hdd_cbacks; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 2243 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2244 | hdd_cbacks.sap_restart_chan_switch_cb = |
Jeff Johnson | 2381294 | 2017-10-06 11:33:55 -0700 | [diff] [blame] | 2245 | hdd_sap_restart_chan_switch_cb; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2246 | hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = |
| 2247 | wlan_hdd_get_channel_for_sap_restart; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2248 | hdd_cbacks.get_mode_for_non_connected_vdev = |
| 2249 | wlan_hdd_get_mode_for_non_connected_vdev; |
| 2250 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2251 | if (QDF_STATUS_SUCCESS != |
| 2252 | policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { |
| 2253 | hdd_err("HDD callback registration with policy manager failed"); |
| 2254 | } |
| 2255 | } |
| 2256 | #else |
| 2257 | static void hdd_register_policy_manager_callback( |
| 2258 | struct wlan_objmgr_psoc *psoc) |
| 2259 | { |
| 2260 | } |
| 2261 | #endif |
| 2262 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2263 | #ifdef WLAN_FEATURE_NAN_CONVERGENCE |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2264 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2265 | { |
| 2266 | struct nan_callbacks cb_obj = {0}; |
| 2267 | |
| 2268 | cb_obj.ndi_open = hdd_ndi_open; |
| 2269 | cb_obj.ndi_close = hdd_ndi_close; |
| 2270 | cb_obj.ndi_start = hdd_ndi_start; |
| 2271 | cb_obj.ndi_delete = hdd_ndi_delete; |
| 2272 | cb_obj.drv_ndi_create_rsp_handler = hdd_ndi_drv_ndi_create_rsp_handler; |
| 2273 | cb_obj.drv_ndi_delete_rsp_handler = hdd_ndi_drv_ndi_delete_rsp_handler; |
| 2274 | |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2275 | cb_obj.new_peer_ind = hdd_ndp_new_peer_handler; |
| 2276 | cb_obj.get_peer_idx = hdd_ndp_get_peer_idx; |
Naveen Rawat | b3143ea | 2017-03-26 22:25:46 -0700 | [diff] [blame] | 2277 | cb_obj.peer_departed_ind = hdd_ndp_peer_departed_handler; |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2278 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2279 | os_if_nan_register_hdd_callbacks(hdd_ctx->hdd_psoc, &cb_obj); |
| 2280 | } |
| 2281 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2282 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2283 | { |
| 2284 | } |
| 2285 | #endif |
| 2286 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2287 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2288 | * hdd_wlan_start_modules() - Single driver state machine for starting modules |
| 2289 | * @hdd_ctx: HDD context |
| 2290 | * @adapter: HDD adapter |
| 2291 | * @reinit: flag to indicate from SSR or normal path |
| 2292 | * |
| 2293 | * This function maintains the driver state machine it will be invoked from |
| 2294 | * startup, reinit and change interface. Depending on the driver state shall |
| 2295 | * perform the opening of the modules. |
| 2296 | * |
| 2297 | * Return: 0 for success; non-zero for failure |
| 2298 | */ |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2299 | int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, |
| 2300 | struct hdd_adapter *adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2301 | bool reinit) |
| 2302 | { |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2303 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2304 | qdf_device_t qdf_dev; |
| 2305 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2306 | bool unint = false; |
| 2307 | void *hif_ctx; |
| 2308 | |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2309 | hdd_debug("state:%d reinit:%d", hdd_ctx->driver_status, reinit); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2310 | |
| 2311 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2312 | if (!qdf_dev) { |
| 2313 | hdd_err("QDF Device Context is Invalid return"); |
| 2314 | return -EINVAL; |
| 2315 | } |
| 2316 | |
| 2317 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2318 | hdd_ctx->start_modules_in_progress = true; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2319 | |
| 2320 | if (QDF_TIMER_STATE_RUNNING == |
| 2321 | qdf_mc_timer_get_current_state(&hdd_ctx->iface_change_timer)) { |
| 2322 | |
| 2323 | hdd_set_idle_ps_config(hdd_ctx, false); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2324 | hdd_debug("Interface change Timer running Stop timer"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2325 | qdf_mc_timer_stop(&hdd_ctx->iface_change_timer); |
| 2326 | } |
| 2327 | |
| 2328 | switch (hdd_ctx->driver_status) { |
| 2329 | case DRIVER_MODULES_UNINITIALIZED: |
| 2330 | unint = true; |
| 2331 | /* Fall through dont add break here */ |
| 2332 | case DRIVER_MODULES_CLOSED: |
| 2333 | if (!reinit && !unint) { |
| 2334 | ret = pld_power_on(qdf_dev->dev); |
| 2335 | if (ret) { |
| 2336 | hdd_err("Failed to Powerup the device: %d", ret); |
| 2337 | goto release_lock; |
| 2338 | } |
| 2339 | } |
Yuanyuan Liu | f8fe4bc | 2017-06-07 16:55:58 -0700 | [diff] [blame] | 2340 | |
| 2341 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 2342 | hdd_ctx->config->enable_fw_log); |
| 2343 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2344 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 2345 | qdf_dev->bus_type, |
| 2346 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 2347 | HIF_ENABLE_TYPE_PROBE); |
| 2348 | if (ret) { |
| 2349 | hdd_err("Failed to open hif: %d", ret); |
| 2350 | goto power_down; |
| 2351 | } |
| 2352 | |
| 2353 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2354 | if (!hif_ctx) { |
| 2355 | hdd_err("hif context is null!!"); |
| 2356 | goto power_down; |
| 2357 | } |
| 2358 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2359 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 2360 | if (status != QDF_STATUS_SUCCESS) { |
| 2361 | hdd_err("No Memory to Create BMI Context :%d", status); |
| 2362 | goto hif_close; |
| 2363 | } |
| 2364 | |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2365 | ret = hdd_update_config(hdd_ctx); |
| 2366 | if (ret) { |
| 2367 | hdd_err("Failed to update configuration :%d", ret); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2368 | goto cds_free; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2369 | } |
| 2370 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2371 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 2372 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2373 | status = cds_open(hdd_ctx->hdd_psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2374 | if (QDF_IS_STATUS_ERROR(status)) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2375 | hdd_err("Failed to Open CDS: %d", status); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2376 | ret = qdf_status_to_os_return(status); |
| 2377 | goto deinit_config; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2378 | } |
| 2379 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2380 | /* initalize components configurations after psoc open */ |
| 2381 | ret = hdd_update_components_config(hdd_ctx); |
| 2382 | if (ret) { |
| 2383 | hdd_err("Failed to update components configs :%d", |
| 2384 | ret); |
| 2385 | goto close; |
| 2386 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2387 | status = cds_dp_open(hdd_ctx->hdd_psoc); |
| 2388 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 2389 | hdd_err("Failed to Open cds post open: %d", status); |
| 2390 | goto close; |
| 2391 | } |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2392 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2393 | /* |
| 2394 | * NAN compoenet requires certian operations like, open adapter, |
| 2395 | * close adapter, etc. to be initiated by HDD, for those |
| 2396 | * register HDD callbacks with UMAC's NAN componenet. |
| 2397 | */ |
| 2398 | hdd_nan_register_callbacks(hdd_ctx); |
| 2399 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2400 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
| 2401 | |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 2402 | status = cds_pre_enable(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2403 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 2404 | hdd_err("Failed to pre-enable CDS: %d", status); |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2405 | ret = (status == QDF_STATUS_E_NOMEM) ? -ENOMEM : -EINVAL; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2406 | goto cds_txrx_free; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2407 | } |
| 2408 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2409 | hdd_register_policy_manager_callback( |
| 2410 | hdd_ctx->hdd_psoc); |
| 2411 | |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2412 | hdd_update_hw_sw_info(hdd_ctx); |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 2413 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2414 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2415 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2416 | sme_register_ftm_msg_processor(hdd_ctx->hHal, |
| 2417 | hdd_ftm_mc_process_msg); |
| 2418 | break; |
| 2419 | } |
| 2420 | if (unint) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2421 | hdd_debug("In phase-1 initialization don't enable modules"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2422 | break; |
| 2423 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2424 | |
| 2425 | if (reinit) { |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 2426 | if (hdd_ipa_uc_ssr_reinit(hdd_ctx)) { |
| 2427 | hdd_err("HDD IPA UC reinit failed"); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2428 | goto post_disable; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 2429 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2430 | } |
| 2431 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2432 | /* Fall through dont add break here */ |
| 2433 | case DRIVER_MODULES_OPENED: |
| 2434 | if (!adapter) { |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2435 | hdd_alert("adapter is Null"); |
| 2436 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2437 | } |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2438 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2439 | hdd_err("in ftm mode, no need to configure cds modules"); |
| 2440 | break; |
| 2441 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2442 | if (hdd_configure_cds(hdd_ctx, adapter)) { |
| 2443 | hdd_err("Failed to Enable cds modules"); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2444 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2445 | } |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2446 | hdd_enable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2447 | hdd_info("Driver Modules Successfully Enabled"); |
| 2448 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
| 2449 | break; |
| 2450 | case DRIVER_MODULES_ENABLED: |
| 2451 | hdd_info("Driver modules already Enabled"); |
| 2452 | break; |
| 2453 | default: |
| 2454 | hdd_err("WLAN start invoked in wrong state! :%d\n", |
| 2455 | hdd_ctx->driver_status); |
| 2456 | goto release_lock; |
| 2457 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2458 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2459 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 2460 | EXIT(); |
| 2461 | return 0; |
| 2462 | |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2463 | post_disable: |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 2464 | cds_post_disable(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2465 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2466 | cds_txrx_free: |
| 2467 | cds_dp_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2468 | close: |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2469 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 2470 | cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2471 | |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2472 | deinit_config: |
| 2473 | cds_deinit_ini_config(); |
| 2474 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2475 | cds_free: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2476 | ol_cds_free(); |
| 2477 | |
| 2478 | hif_close: |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2479 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2480 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2481 | power_down: |
| 2482 | if (!reinit && !unint) |
| 2483 | pld_power_off(qdf_dev->dev); |
| 2484 | release_lock: |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2485 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2486 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2487 | EXIT(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2488 | |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2489 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2490 | } |
| 2491 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2492 | #ifdef WIFI_POS_CONVERGED |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2493 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2494 | { |
| 2495 | int ret = os_if_wifi_pos_register_nl(); |
| 2496 | |
| 2497 | if (ret) |
| 2498 | hdd_err("os_if_wifi_pos_register_nl failed"); |
| 2499 | |
| 2500 | return ret; |
| 2501 | } |
| 2502 | |
| 2503 | static int hdd_deactivate_wifi_pos(void) |
| 2504 | { |
| 2505 | int ret = os_if_wifi_pos_deregister_nl(); |
| 2506 | |
| 2507 | if (ret) |
| 2508 | hdd_err("os_if_wifi_pos_deregister_nl failed"); |
| 2509 | |
| 2510 | return ret; |
| 2511 | } |
| 2512 | |
| 2513 | /** |
| 2514 | * hdd_populate_wifi_pos_cfg - populates wifi_pos parameters |
| 2515 | * @hdd_ctx: hdd context |
| 2516 | * |
| 2517 | * Return: status of operation |
| 2518 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2519 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2520 | { |
| 2521 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 2522 | struct hdd_config *cfg = hdd_ctx->config; |
| 2523 | |
| 2524 | wifi_pos_set_oem_target_type(psoc, hdd_ctx->target_type); |
| 2525 | wifi_pos_set_oem_fw_version(psoc, hdd_ctx->target_fw_version); |
| 2526 | wifi_pos_set_drv_ver_major(psoc, QWLAN_VERSION_MAJOR); |
| 2527 | wifi_pos_set_drv_ver_minor(psoc, QWLAN_VERSION_MINOR); |
| 2528 | wifi_pos_set_drv_ver_patch(psoc, QWLAN_VERSION_PATCH); |
| 2529 | wifi_pos_set_drv_ver_build(psoc, QWLAN_VERSION_BUILD); |
| 2530 | wifi_pos_set_dwell_time_min(psoc, cfg->nNeighborScanMinChanTime); |
| 2531 | wifi_pos_set_dwell_time_max(psoc, cfg->nNeighborScanMaxChanTime); |
| 2532 | } |
| 2533 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2534 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2535 | { |
| 2536 | return oem_activate_service(hdd_ctx); |
| 2537 | } |
| 2538 | |
| 2539 | static int hdd_deactivate_wifi_pos(void) |
| 2540 | { |
| 2541 | return 0; |
| 2542 | } |
| 2543 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2544 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2545 | { |
| 2546 | } |
| 2547 | #endif |
| 2548 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2549 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2550 | * __hdd_open() - HDD Open function |
| 2551 | * @dev: Pointer to net_device structure |
| 2552 | * |
| 2553 | * This is called in response to ifconfig up |
| 2554 | * |
| 2555 | * Return: 0 for success; non-zero for failure |
| 2556 | */ |
| 2557 | static int __hdd_open(struct net_device *dev) |
| 2558 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2559 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2560 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2561 | int ret; |
| 2562 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2563 | ENTER_DEV(dev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2564 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2565 | adapter->sessionId, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2566 | |
Ashish Kumar Dhanotiya | 15a7db5 | 2017-08-03 10:27:34 +0530 | [diff] [blame] | 2567 | /* Nothing to be done if device is unloading */ |
| 2568 | if (cds_is_driver_unloading()) { |
| 2569 | hdd_err("Driver is unloading can not open the hdd"); |
| 2570 | return -EBUSY; |
| 2571 | } |
| 2572 | |
Dustin Brown | 0184775 | 2017-10-25 13:56:27 -0700 | [diff] [blame] | 2573 | if (cds_is_driver_recovering()) { |
| 2574 | hdd_err("WLAN is currently recovering; Please try again."); |
| 2575 | return -EBUSY; |
| 2576 | } |
| 2577 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2578 | mutex_lock(&hdd_init_deinit_lock); |
| 2579 | |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 2580 | hdd_start_driver_ops_timer(eHDD_DRV_OP_IFF_UP); |
| 2581 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2582 | /* |
| 2583 | * This scenario can be hit in cases where in the wlan driver after |
| 2584 | * registering the netdevices and there is a failure in driver |
| 2585 | * initialization. So return error gracefully because the netdevices |
| 2586 | * will be de-registered as part of the load failure. |
| 2587 | */ |
| 2588 | |
| 2589 | if (!cds_is_driver_loaded()) { |
| 2590 | hdd_err("Failed to start the wlan driver!!"); |
| 2591 | ret = -EIO; |
| 2592 | goto err_hdd_hdd_init_deinit_lock; |
| 2593 | } |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2594 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2595 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2596 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 2597 | if (ret) { |
| 2598 | hdd_err("Failed to start WLAN modules return"); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2599 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2600 | } |
| 2601 | |
| 2602 | |
| 2603 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2604 | ret = hdd_start_adapter(adapter); |
| 2605 | if (ret) { |
| 2606 | hdd_err("Failed to start adapter :%d", |
| 2607 | adapter->device_mode); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2608 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2609 | } |
| 2610 | } |
| 2611 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2612 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2613 | 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] | 2614 | hdd_debug("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2615 | /* Enable TX queues only when we are connected */ |
| 2616 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2617 | WLAN_START_ALL_NETIF_QUEUE, |
| 2618 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2619 | } |
| 2620 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2621 | /* Enable carrier and transmit queues for NDI */ |
| 2622 | if (WLAN_HDD_IS_NDI(adapter)) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 2623 | hdd_debug("Enabling Tx Queues"); |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2624 | wlan_hdd_netif_queue_control(adapter, |
| 2625 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 2626 | WLAN_CONTROL_PATH); |
| 2627 | } |
| 2628 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2629 | hdd_populate_wifi_pos_cfg(hdd_ctx); |
| 2630 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2631 | err_hdd_hdd_init_deinit_lock: |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 2632 | hdd_stop_driver_ops_timer(); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2633 | mutex_unlock(&hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2634 | return ret; |
| 2635 | } |
| 2636 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2637 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2638 | /** |
| 2639 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 2640 | * @dev: Pointer to net_device structure |
| 2641 | * |
| 2642 | * This is called in response to ifconfig up |
| 2643 | * |
| 2644 | * Return: 0 for success; non-zero for failure |
| 2645 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2646 | static int hdd_open(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2647 | { |
| 2648 | int ret; |
| 2649 | |
| 2650 | cds_ssr_protect(__func__); |
| 2651 | ret = __hdd_open(dev); |
| 2652 | cds_ssr_unprotect(__func__); |
| 2653 | |
| 2654 | return ret; |
| 2655 | } |
| 2656 | |
| 2657 | /** |
| 2658 | * __hdd_stop() - HDD stop function |
| 2659 | * @dev: Pointer to net_device structure |
| 2660 | * |
| 2661 | * This is called in response to ifconfig down |
| 2662 | * |
| 2663 | * Return: 0 for success; non-zero for failure |
| 2664 | */ |
| 2665 | static int __hdd_stop(struct net_device *dev) |
| 2666 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2667 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2668 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2669 | int ret; |
| 2670 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2671 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2672 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2673 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2674 | adapter->sessionId, adapter->device_mode)); |
| 2675 | |
| 2676 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 2677 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2678 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2679 | |
| 2680 | /* Nothing to be done if the interface is not opened */ |
| 2681 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2682 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2683 | return -ENODEV; |
| 2684 | } |
| 2685 | |
| 2686 | /* Make sure the interface is marked as closed */ |
| 2687 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 2688 | |
| 2689 | hdd_debug("Disabling Auto Power save timer"); |
| 2690 | sme_ps_disable_auto_ps_timer( |
| 2691 | WLAN_HDD_GET_HAL_CTX(adapter), |
| 2692 | adapter->sessionId); |
| 2693 | |
| 2694 | /* |
| 2695 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 2696 | * be called on that interface |
| 2697 | */ |
| 2698 | hdd_notice("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 2699 | wlan_hdd_netif_queue_control(adapter, |
| 2700 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 2701 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2702 | |
| 2703 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2704 | * NAN data interface is different in some sense. The traffic on NDI is |
| 2705 | * bursty in nature and depends on the need to transfer. The service |
| 2706 | * layer may down the interface after the usage and up again when |
| 2707 | * required. In some sense, the NDI is expected to be available |
| 2708 | * (like SAP) iface until NDI delete request is issued by the service |
| 2709 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 2710 | * interface (NDI). |
| 2711 | */ |
| 2712 | if (WLAN_HDD_IS_NDI(adapter)) |
| 2713 | return 0; |
| 2714 | |
| 2715 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2716 | * The interface is marked as down for outside world (aka kernel) |
| 2717 | * But the driver is pretty much alive inside. The driver needs to |
| 2718 | * tear down the existing connection on the netdev (session) |
| 2719 | * cleanup the data pipes and wait until the control plane is stabilized |
| 2720 | * for this interface. The call also needs to wait until the above |
| 2721 | * mentioned actions are completed before returning to the caller. |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2722 | * Notice that hdd_stop_adapter is requested not to close the session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2723 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 2724 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2725 | hdd_stop_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2726 | |
| 2727 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 2728 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 2729 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2730 | |
| 2731 | /* |
| 2732 | * Find if any iface is up. If any iface is up then can't put device to |
| 2733 | * sleep/power save mode |
| 2734 | */ |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 2735 | if (hdd_check_for_opened_interfaces(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2736 | hdd_debug("Closing all modules from the hdd_stop"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2737 | qdf_mc_timer_start(&hdd_ctx->iface_change_timer, |
Hanumanth Reddy Pothula | 42e714a | 2016-12-21 19:33:57 +0530 | [diff] [blame] | 2738 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 2739 | hdd_prevent_suspend_timeout( |
| 2740 | hdd_ctx->config->iface_change_wait_time, |
| 2741 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2742 | } |
| 2743 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2744 | EXIT(); |
| 2745 | return 0; |
| 2746 | } |
| 2747 | |
| 2748 | /** |
| 2749 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 2750 | * @dev: pointer to net_device structure |
| 2751 | * |
| 2752 | * This is called in response to ifconfig down |
| 2753 | * |
| 2754 | * Return: 0 for success and error number for failure |
| 2755 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2756 | static int hdd_stop(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2757 | { |
| 2758 | int ret; |
| 2759 | |
| 2760 | cds_ssr_protect(__func__); |
| 2761 | ret = __hdd_stop(dev); |
| 2762 | cds_ssr_unprotect(__func__); |
| 2763 | |
| 2764 | return ret; |
| 2765 | } |
| 2766 | |
| 2767 | /** |
| 2768 | * __hdd_uninit() - HDD uninit function |
| 2769 | * @dev: Pointer to net_device structure |
| 2770 | * |
| 2771 | * This is called during the netdev unregister to uninitialize all data |
| 2772 | * associated with the device |
| 2773 | * |
| 2774 | * Return: None |
| 2775 | */ |
| 2776 | static void __hdd_uninit(struct net_device *dev) |
| 2777 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2778 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 2779 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2780 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2781 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2782 | |
| 2783 | do { |
| 2784 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2785 | hdd_err("Invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2786 | break; |
| 2787 | } |
| 2788 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 2789 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2790 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2791 | hdd_err("NULL hdd_ctx"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2792 | break; |
| 2793 | } |
| 2794 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2795 | if (dev != adapter->dev) |
| 2796 | hdd_err("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2797 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 2798 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2799 | |
| 2800 | /* after uninit our adapter structure will no longer be valid */ |
| 2801 | adapter->dev = NULL; |
| 2802 | adapter->magic = 0; |
| 2803 | } while (0); |
| 2804 | |
| 2805 | EXIT(); |
| 2806 | } |
| 2807 | |
| 2808 | /** |
| 2809 | * hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 2810 | * @dev: pointer to net_device structure |
| 2811 | * |
| 2812 | * This is called during the netdev unregister to uninitialize all data |
| 2813 | * associated with the device |
| 2814 | * |
| 2815 | * Return: none |
| 2816 | */ |
| 2817 | static void hdd_uninit(struct net_device *dev) |
| 2818 | { |
| 2819 | cds_ssr_protect(__func__); |
| 2820 | __hdd_uninit(dev); |
| 2821 | cds_ssr_unprotect(__func__); |
| 2822 | } |
| 2823 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2824 | static int hdd_open_cesium_nl_sock(void) |
| 2825 | { |
| 2826 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 2827 | struct netlink_kernel_cfg cfg = { |
| 2828 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 2829 | .input = NULL |
| 2830 | }; |
| 2831 | #endif |
| 2832 | int ret = 0; |
| 2833 | |
| 2834 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 2835 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 2836 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 2837 | THIS_MODULE, |
| 2838 | #endif |
| 2839 | &cfg); |
| 2840 | #else |
| 2841 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 2842 | WLAN_NLINK_MCAST_GRP_ID, |
| 2843 | NULL, NULL, THIS_MODULE); |
| 2844 | #endif |
| 2845 | |
| 2846 | if (cesium_nl_srv_sock == NULL) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2847 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2848 | ret = -ECONNREFUSED; |
| 2849 | } |
| 2850 | |
| 2851 | return ret; |
| 2852 | } |
| 2853 | |
| 2854 | static void hdd_close_cesium_nl_sock(void) |
| 2855 | { |
| 2856 | if (NULL != cesium_nl_srv_sock) { |
| 2857 | netlink_kernel_release(cesium_nl_srv_sock); |
| 2858 | cesium_nl_srv_sock = NULL; |
| 2859 | } |
| 2860 | } |
| 2861 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2862 | /** |
| 2863 | * __hdd_set_mac_address() - set the user specified mac address |
| 2864 | * @dev: Pointer to the net device. |
| 2865 | * @addr: Pointer to the sockaddr. |
| 2866 | * |
| 2867 | * This function sets the user specified mac address using |
| 2868 | * the command ifconfig wlanX hw ether <mac adress>. |
| 2869 | * |
| 2870 | * Return: 0 for success, non zero for failure |
| 2871 | */ |
| 2872 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 2873 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2874 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2875 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2876 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2877 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2878 | int ret; |
| 2879 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2880 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2881 | |
| 2882 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2883 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2884 | if (0 != ret) |
| 2885 | return ret; |
| 2886 | |
| 2887 | memcpy(&adapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN); |
| 2888 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 2889 | |
| 2890 | EXIT(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2891 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2892 | } |
| 2893 | |
| 2894 | /** |
| 2895 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
| 2896 | * function from SSR |
| 2897 | * @dev: pointer to net_device structure |
| 2898 | * @addr: Pointer to the sockaddr |
| 2899 | * |
| 2900 | * This function sets the user specified mac address using |
| 2901 | * the command ifconfig wlanX hw ether <mac adress>. |
| 2902 | * |
| 2903 | * Return: 0 for success. |
| 2904 | */ |
| 2905 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 2906 | { |
| 2907 | int ret; |
| 2908 | |
| 2909 | cds_ssr_protect(__func__); |
| 2910 | ret = __hdd_set_mac_address(dev, addr); |
| 2911 | cds_ssr_unprotect(__func__); |
| 2912 | |
| 2913 | return ret; |
| 2914 | } |
| 2915 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2916 | uint8_t *wlan_hdd_get_intf_addr(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2917 | { |
| 2918 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2919 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2920 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2921 | if (0 == ((hdd_ctx->config->intfAddrMask) & (1 << i))) |
| 2922 | break; |
| 2923 | } |
| 2924 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2925 | if (QDF_MAX_CONCURRENCY_PERSONA == i) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2926 | return NULL; |
| 2927 | |
| 2928 | hdd_ctx->config->intfAddrMask |= (1 << i); |
| 2929 | return &hdd_ctx->config->intfMacAddr[i].bytes[0]; |
| 2930 | } |
| 2931 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 2932 | void wlan_hdd_release_intf_addr(struct hdd_context *hdd_ctx, |
| 2933 | uint8_t *releaseAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2934 | { |
| 2935 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2936 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2937 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2938 | if (!memcmp(releaseAddr, |
| 2939 | &hdd_ctx->config->intfMacAddr[i].bytes[0], |
| 2940 | 6)) { |
| 2941 | hdd_ctx->config->intfAddrMask &= ~(1 << i); |
| 2942 | break; |
| 2943 | } |
| 2944 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2945 | } |
| 2946 | |
| 2947 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 2948 | /** |
| 2949 | * __hdd_set_multicast_list() - set the multicast address list |
| 2950 | * @dev: Pointer to the WLAN device. |
| 2951 | * @skb: Pointer to OS packet (sk_buff). |
| 2952 | * |
| 2953 | * This funciton sets the multicast address list. |
| 2954 | * |
| 2955 | * Return: None |
| 2956 | */ |
| 2957 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 2958 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2959 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2960 | int i = 0, status; |
| 2961 | struct netdev_hw_addr *ha; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2962 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2963 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
| 2964 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 2965 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2966 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2967 | ENTER_DEV(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2968 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2969 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 2970 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2971 | status = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 2972 | if (0 != status) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2973 | goto out; |
| 2974 | |
Dustin Brown | c788acb | 2017-08-01 17:43:51 -0700 | [diff] [blame] | 2975 | status = hdd_validate_adapter(adapter); |
| 2976 | if (status) |
| 2977 | goto out; |
| 2978 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2979 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
| 2980 | if (!mc_list_request) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2981 | hdd_err("Cannot allocate mc_list_request"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2982 | goto out; |
| 2983 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2984 | |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 2985 | /* Delete already configured multicast address list */ |
| 2986 | if (adapter->mc_addr_list.mc_cnt > 0) { |
| 2987 | hdd_info("clear previously configured MC address list"); |
| 2988 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 2989 | pmo_mc_list_change_notify); |
| 2990 | } |
| 2991 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2992 | if (dev->flags & IFF_ALLMULTI) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2993 | hdd_debug("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2994 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 2995 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2996 | } else { |
| 2997 | mc_count = netdev_mc_count(dev); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2998 | if (mc_count > pmo_ucfg_max_mc_addr_supported(psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2999 | hdd_debug("Exceeded max MC filter addresses (%d). Allowing all MC frames by disabling MC address filtering", |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3000 | pmo_ucfg_max_mc_addr_supported(psoc)); |
| 3001 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3002 | pmo_mc_list_change_notify); |
| 3003 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3004 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3005 | netdev_for_each_mc_addr(ha, dev) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3006 | hdd_debug("ha_addr[%d] "MAC_ADDRESS_STR, |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 3007 | i, MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3008 | if (i == mc_count) |
| 3009 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3010 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 3011 | 0, ETH_ALEN); |
| 3012 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 3013 | ha->addr, ETH_ALEN); |
| 3014 | hdd_info("mlist[%d] = %pM", i, |
| 3015 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3016 | i++; |
| 3017 | } |
| 3018 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3019 | |
| 3020 | mc_list_request->psoc = psoc; |
| 3021 | mc_list_request->vdev_id = adapter->sessionId; |
| 3022 | mc_list_request->count = mc_count; |
| 3023 | status = hdd_cache_mc_addr_list(mc_list_request); |
| 3024 | if (status == 0) { |
| 3025 | hdd_enable_mc_addr_filtering(adapter, |
| 3026 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3027 | } else { |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3028 | hdd_err("error while caching mc list"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3029 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3030 | out: |
| 3031 | if (mc_list_request) |
| 3032 | qdf_mem_free(mc_list_request); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3033 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3034 | } |
| 3035 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3036 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3037 | /** |
| 3038 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
| 3039 | * @dev: pointer to net_device |
| 3040 | * |
| 3041 | * Return: none |
| 3042 | */ |
| 3043 | static void hdd_set_multicast_list(struct net_device *dev) |
| 3044 | { |
| 3045 | cds_ssr_protect(__func__); |
| 3046 | __hdd_set_multicast_list(dev); |
| 3047 | cds_ssr_unprotect(__func__); |
| 3048 | } |
| 3049 | #endif |
| 3050 | |
| 3051 | /** |
| 3052 | * hdd_select_queue() - used by Linux OS to decide which queue to use first |
| 3053 | * @dev: Pointer to the WLAN device. |
| 3054 | * @skb: Pointer to OS packet (sk_buff). |
| 3055 | * |
| 3056 | * This function is registered with the Linux OS for network |
| 3057 | * core to decide which queue to use first. |
| 3058 | * |
| 3059 | * Return: ac, Queue Index/access category corresponding to UP in IP header |
| 3060 | */ |
| 3061 | static uint16_t hdd_select_queue(struct net_device *dev, struct sk_buff *skb |
| 3062 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) |
| 3063 | , void *accel_priv |
| 3064 | #endif |
| 3065 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 3066 | , select_queue_fallback_t fallback |
| 3067 | #endif |
| 3068 | ) |
| 3069 | { |
| 3070 | return hdd_wmm_select_queue(dev, skb); |
| 3071 | } |
| 3072 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3073 | static const struct net_device_ops wlan_drv_ops = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3074 | .ndo_open = hdd_open, |
| 3075 | .ndo_stop = hdd_stop, |
| 3076 | .ndo_uninit = hdd_uninit, |
| 3077 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 3078 | .ndo_tx_timeout = hdd_tx_timeout, |
| 3079 | .ndo_get_stats = hdd_get_stats, |
| 3080 | .ndo_do_ioctl = hdd_ioctl, |
| 3081 | .ndo_set_mac_address = hdd_set_mac_address, |
| 3082 | .ndo_select_queue = hdd_select_queue, |
| 3083 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3084 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3085 | #endif |
| 3086 | }; |
| 3087 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3088 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3089 | static const struct net_device_ops wlan_mon_drv_ops = { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3090 | .ndo_open = hdd_mon_open, |
| 3091 | .ndo_stop = hdd_stop, |
| 3092 | .ndo_get_stats = hdd_get_stats, |
| 3093 | }; |
| 3094 | |
| 3095 | /** |
| 3096 | * hdd_set_station_ops() - update net_device ops for monitor mode |
| 3097 | * @pWlanDev: Handle to struct net_device to be updated. |
| 3098 | * Return: None |
| 3099 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3100 | void hdd_set_station_ops(struct net_device *pWlanDev) |
| 3101 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3102 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
| 3103 | pWlanDev->netdev_ops = &wlan_mon_drv_ops; |
| 3104 | else |
| 3105 | pWlanDev->netdev_ops = &wlan_drv_ops; |
| 3106 | } |
| 3107 | |
| 3108 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3109 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 3110 | * @hdd_ctx: global hdd context |
| 3111 | * @macAddr: mac address to assign to the interface |
| 3112 | * @name: User-visible name of the interface |
| 3113 | * |
| 3114 | * hdd adapter pointer would point to the netdev->priv space, this function |
| 3115 | * would retrive the pointer, and setup the hdd adapter configuration. |
| 3116 | * |
| 3117 | * Return: the pointer to hdd adapter, otherwise NULL |
| 3118 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3119 | 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] | 3120 | tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3121 | unsigned char name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3122 | const char *name) |
| 3123 | { |
| 3124 | struct net_device *pWlanDev = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3125 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 3126 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3127 | /* |
| 3128 | * cfg80211 initialization and registration.... |
| 3129 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3130 | pWlanDev = alloc_netdev_mq(sizeof(struct hdd_adapter), name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3131 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
| 3132 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3133 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3134 | (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam() ? |
| 3135 | hdd_mon_mode_ether_setup : ether_setup), |
| 3136 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3137 | |
| 3138 | if (pWlanDev != NULL) { |
| 3139 | |
| 3140 | /* Save the pointer to the net_device in the HDD adapter */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3141 | adapter = (struct hdd_adapter *) netdev_priv(pWlanDev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3142 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3143 | qdf_mem_zero(adapter, sizeof(struct hdd_adapter)); |
Hanumanth Reddy Pothula | 18553ae | 2017-04-28 15:03:10 +0530 | [diff] [blame] | 3144 | sta_ctx = &adapter->sessionCtx.station; |
| 3145 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 3146 | sizeof(sta_ctx->conn_info.staId), |
| 3147 | HDD_WLAN_INVALID_STA_ID); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3148 | adapter->dev = pWlanDev; |
Jeff Johnson | dba0db6 | 2017-08-30 11:12:39 -0700 | [diff] [blame] | 3149 | adapter->hdd_ctx = hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3150 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Arun Khandavalli | 9ad88f0 | 2016-09-01 19:03:37 +0530 | [diff] [blame] | 3151 | adapter->sessionId = HDD_SESSION_ID_INVALID; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3152 | |
| 3153 | init_completion(&adapter->session_open_comp_var); |
| 3154 | init_completion(&adapter->session_close_comp_var); |
| 3155 | init_completion(&adapter->disconnect_comp_var); |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 3156 | init_completion(&adapter->roaming_comp_var); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3157 | init_completion(&adapter->linkup_event_var); |
| 3158 | init_completion(&adapter->cancel_rem_on_chan_var); |
| 3159 | init_completion(&adapter->rem_on_chan_ready_event); |
| 3160 | init_completion(&adapter->sta_authorized_event); |
| 3161 | init_completion(&adapter->offchannel_tx_event); |
| 3162 | init_completion(&adapter->tx_action_cnf_event); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3163 | init_completion(&adapter->ibss_peer_info_comp); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3164 | init_completion(&adapter->change_country_code); |
| 3165 | |
| 3166 | |
| 3167 | init_completion(&adapter->scan_info.abortscan_event_var); |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 3168 | init_completion(&adapter->lfr_fw_status.disable_lfr_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3169 | |
| 3170 | adapter->offloads_configured = false; |
| 3171 | adapter->isLinkUpSvcNeeded = false; |
| 3172 | adapter->higherDtimTransition = true; |
| 3173 | /* Init the net_device structure */ |
| 3174 | strlcpy(pWlanDev->name, name, IFNAMSIZ); |
| 3175 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3176 | qdf_mem_copy(pWlanDev->dev_addr, (void *)macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3177 | sizeof(tSirMacAddr)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3178 | qdf_mem_copy(adapter->macAddressCurrent.bytes, macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3179 | sizeof(tSirMacAddr)); |
| 3180 | pWlanDev->watchdog_timeo = HDD_TX_TIMEOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3181 | |
| 3182 | if (hdd_ctx->config->enable_ip_tcp_udp_checksum_offload) |
| 3183 | pWlanDev->features |= |
| 3184 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
| 3185 | pWlanDev->features |= NETIF_F_RXCSUM; |
| 3186 | |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 3187 | hdd_set_tso_flags(hdd_ctx, pWlanDev); |
| 3188 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3189 | hdd_set_station_ops(adapter->dev); |
| 3190 | |
Dustin Brown | c81dd41 | 2017-08-15 16:26:28 -0700 | [diff] [blame] | 3191 | hdd_dev_setup_destructor(pWlanDev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3192 | pWlanDev->ieee80211_ptr = &adapter->wdev; |
Mohit Khanna | ee9e80f | 2015-11-10 11:32:49 -0800 | [diff] [blame] | 3193 | pWlanDev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3194 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
| 3195 | adapter->wdev.netdev = pWlanDev; |
| 3196 | /* set pWlanDev's parent to underlying device */ |
| 3197 | SET_NETDEV_DEV(pWlanDev, hdd_ctx->parent_dev); |
| 3198 | hdd_wmm_init(adapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3199 | hdd_adapter_runtime_suspend_init(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3200 | spin_lock_init(&adapter->pause_map_lock); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 3201 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3202 | } |
| 3203 | |
| 3204 | return adapter; |
| 3205 | } |
| 3206 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3207 | 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] | 3208 | { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3209 | struct net_device *dev = adapter->dev; |
| 3210 | int ret; |
| 3211 | |
| 3212 | ENTER(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3213 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3214 | if (rtnl_held) { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3215 | if (strnchr(dev->name, IFNAMSIZ - 1, '%')) { |
| 3216 | |
| 3217 | ret = dev_alloc_name(dev, dev->name); |
| 3218 | if (ret < 0) { |
| 3219 | hdd_err( |
| 3220 | "unable to get dev name: %s, err = 0x%x", |
| 3221 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3222 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3223 | } |
| 3224 | } |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3225 | |
| 3226 | ret = register_netdevice(dev); |
| 3227 | if (ret) { |
| 3228 | hdd_err("register_netdevice(%s) failed, err = 0x%x", |
| 3229 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3230 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3231 | } |
| 3232 | } else { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3233 | ret = register_netdev(dev); |
| 3234 | if (ret) { |
| 3235 | hdd_err("register_netdev(%s) failed, err = 0x%x", |
| 3236 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3237 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3238 | } |
| 3239 | } |
| 3240 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 3241 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3242 | EXIT(); |
| 3243 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3244 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3245 | } |
| 3246 | |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 3247 | QDF_STATUS hdd_sme_close_session_callback(void *pContext) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3248 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3249 | struct hdd_adapter *adapter = pContext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3250 | |
| 3251 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3252 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3253 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3254 | } |
| 3255 | |
| 3256 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3257 | hdd_err("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3258 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3259 | } |
| 3260 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3261 | /* |
| 3262 | * For NAN Data interface, the close session results in the final |
| 3263 | * indication to the userspace |
| 3264 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 3265 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3266 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3267 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3268 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3269 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3270 | /* |
| 3271 | * We can be blocked while waiting for scheduled work to be |
| 3272 | * flushed, and the adapter structure can potentially be freed, in |
| 3273 | * which case the magic will have been reset. So make sure the |
| 3274 | * magic is still good, and hence the adapter structure is still |
| 3275 | * valid, before signaling completion |
| 3276 | */ |
| 3277 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
| 3278 | complete(&adapter->session_close_comp_var); |
| 3279 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3280 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3281 | } |
| 3282 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3283 | int hdd_vdev_ready(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3284 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3285 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3286 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3287 | status = pmo_vdev_ready(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3288 | if (QDF_IS_STATUS_ERROR(status)) |
| 3289 | return qdf_status_to_os_return(status); |
| 3290 | |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3291 | status = ucfg_reg_11d_vdev_created_update(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3292 | if (QDF_IS_STATUS_ERROR(status)) |
| 3293 | return qdf_status_to_os_return(status); |
| 3294 | |
| 3295 | if (wma_capability_enhanced_mcast_filter()) |
| 3296 | status = pmo_ucfg_enhanced_mc_filter_enable(adapter->hdd_vdev); |
| 3297 | else |
| 3298 | status = pmo_ucfg_enhanced_mc_filter_disable(adapter->hdd_vdev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3299 | |
| 3300 | return qdf_status_to_os_return(status); |
| 3301 | } |
| 3302 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3303 | int hdd_vdev_destroy(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3304 | { |
| 3305 | QDF_STATUS status; |
| 3306 | int errno; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3307 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3308 | unsigned long rc; |
| 3309 | |
| 3310 | hdd_info("destroying vdev %d", adapter->sessionId); |
| 3311 | |
| 3312 | /* vdev created sanity check */ |
| 3313 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 3314 | hdd_err("vdev for Id %d does not exist", adapter->sessionId); |
| 3315 | return -EINVAL; |
| 3316 | } |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3317 | status = ucfg_reg_11d_vdev_delete_update(adapter->hdd_vdev); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3318 | /* |
| 3319 | * In SSR case, there is no need to destroy vdev in firmware since |
| 3320 | * it has already asserted. vdev can be released directly. |
| 3321 | */ |
| 3322 | if (cds_is_driver_recovering()) |
| 3323 | goto release_vdev; |
| 3324 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3325 | /* close sme session (destroy vdev in firmware via legacy API) */ |
| 3326 | INIT_COMPLETION(adapter->session_close_comp_var); |
| 3327 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3328 | status = sme_close_session(hdd_ctx->hHal, adapter->sessionId, |
| 3329 | hdd_sme_close_session_callback, adapter); |
| 3330 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3331 | hdd_err("failed to close sme session: %d", status); |
| 3332 | return qdf_status_to_os_return(status); |
| 3333 | } |
| 3334 | |
| 3335 | /* block on a completion variable until sme session is closed */ |
| 3336 | rc = wait_for_completion_timeout( |
| 3337 | &adapter->session_close_comp_var, |
| 3338 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
| 3339 | if (!rc) { |
| 3340 | hdd_err("timed out waiting for close sme session: %ld", rc); |
| 3341 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3342 | hdd_ndp_session_end_handler(adapter); |
| 3343 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3344 | return -ETIMEDOUT; |
| 3345 | } |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3346 | release_vdev: |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3347 | /* do vdev logical destroy via objmgr */ |
| 3348 | errno = hdd_objmgr_destroy_vdev(adapter); |
| 3349 | if (errno) { |
| 3350 | hdd_err("failed to destroy objmgr vdev: %d", errno); |
| 3351 | return errno; |
| 3352 | } |
| 3353 | |
Dustin Brown | 0d2eeae | 2017-03-24 15:21:32 -0700 | [diff] [blame] | 3354 | /* now that sme session is closed, allow physical vdev destroy */ |
| 3355 | errno = hdd_objmgr_release_vdev(adapter); |
| 3356 | if (errno) { |
| 3357 | hdd_err("failed to release objmgr vdev: %d", errno); |
| 3358 | return errno; |
| 3359 | } |
| 3360 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3361 | hdd_info("vdev destroyed successfully"); |
| 3362 | |
| 3363 | return 0; |
| 3364 | } |
| 3365 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3366 | int hdd_vdev_create(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3367 | { |
| 3368 | QDF_STATUS status; |
| 3369 | int errno; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3370 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3371 | uint32_t type; |
| 3372 | uint32_t sub_type; |
| 3373 | unsigned long rc; |
| 3374 | |
| 3375 | hdd_info("creating new vdev"); |
| 3376 | |
| 3377 | /* determine vdev (sub)type */ |
| 3378 | status = cds_get_vdev_types(adapter->device_mode, &type, &sub_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3379 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3380 | hdd_err("failed to get vdev type: %d", status); |
| 3381 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3382 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3383 | |
| 3384 | /* do vdev create via objmgr */ |
| 3385 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3386 | errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->hdd_pdev, adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3387 | if (errno) { |
| 3388 | hdd_err("failed to create objmgr vdev: %d", errno); |
| 3389 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3390 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3391 | |
| 3392 | /* Open a SME session (prepare vdev in firmware via legacy API) */ |
| 3393 | INIT_COMPLETION(adapter->session_open_comp_var); |
| 3394 | status = sme_open_session(hdd_ctx->hHal, hdd_sme_roam_callback, adapter, |
| 3395 | (uint8_t *)&adapter->macAddressCurrent, |
| 3396 | adapter->sessionId, type, sub_type); |
| 3397 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3398 | hdd_err("failed to open sme session: %d", status); |
| 3399 | errno = qdf_status_to_os_return(status); |
| 3400 | goto objmgr_vdev_destroy; |
| 3401 | } |
| 3402 | |
| 3403 | /* block on a completion variable until sme session is opened */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3404 | rc = wait_for_completion_timeout( |
| 3405 | &adapter->session_open_comp_var, |
| 3406 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
| 3407 | if (!rc) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3408 | hdd_err("timed out waiting for open sme session: %ld", rc); |
| 3409 | errno = -ETIMEDOUT; |
Abhishek Singh | 7e95dbc | 2017-07-06 17:57:50 +0530 | [diff] [blame] | 3410 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3411 | goto hdd_vdev_destroy; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3412 | } |
| 3413 | |
| 3414 | /* firmware ready for component communication, raise vdev_ready event */ |
| 3415 | errno = hdd_vdev_ready(adapter); |
| 3416 | if (errno) { |
| 3417 | hdd_err("failed to dispatch vdev ready event: %d", errno); |
| 3418 | goto hdd_vdev_destroy; |
| 3419 | } |
| 3420 | |
| 3421 | hdd_info("vdev %d created successfully", adapter->sessionId); |
| 3422 | |
| 3423 | return 0; |
| 3424 | |
| 3425 | /* |
| 3426 | * Due to legacy constraints, we need to destroy in the same order as |
| 3427 | * create. So, split error handling into 2 cases to accommodate. |
| 3428 | */ |
| 3429 | |
| 3430 | objmgr_vdev_destroy: |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3431 | QDF_BUG(!hdd_objmgr_release_and_destroy_vdev(adapter)); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3432 | |
| 3433 | return errno; |
| 3434 | |
| 3435 | hdd_vdev_destroy: |
| 3436 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
| 3437 | |
| 3438 | return errno; |
| 3439 | } |
| 3440 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3441 | QDF_STATUS hdd_init_station_mode(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3442 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3443 | struct hdd_station_ctx *sta_ctx = &adapter->sessionCtx.station; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3444 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3445 | QDF_STATUS status; |
| 3446 | int ret_val; |
| 3447 | |
| 3448 | ret_val = hdd_vdev_create(adapter); |
| 3449 | if (ret_val) { |
| 3450 | hdd_err("failed to create vdev: %d", ret_val); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 3451 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3452 | } |
| 3453 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3454 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3455 | sme_set_curr_device_mode(hdd_ctx->hHal, adapter->device_mode); |
| 3456 | sme_set_pdev_ht_vht_ies(hdd_ctx->hHal, hdd_ctx->config->enable2x2); |
Naveen Rawat | a410c5a | 2016-09-19 14:22:33 -0700 | [diff] [blame] | 3457 | sme_set_vdev_ies_per_band(hdd_ctx->hHal, adapter->sessionId); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3458 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3459 | /* Register wireless extensions */ |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3460 | status = hdd_register_wext(adapter->dev); |
| 3461 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3462 | hdd_err("failed to register wireless extensions: %d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3463 | goto error_register_wext; |
| 3464 | } |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 3465 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3466 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3467 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 3468 | sizeof(sta_ctx->conn_info.staId), HDD_WLAN_INVALID_STA_ID); |
Hanumanth Reddy Pothula | b2d729c | 2017-05-30 11:49:53 +0530 | [diff] [blame] | 3469 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 3470 | /* set fast roaming capability in sme session */ |
| 3471 | status = sme_config_fast_roaming(hdd_ctx->hHal, adapter->sessionId, |
| 3472 | adapter->fast_roaming_allowed); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3473 | /* Set the default operation channel */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3474 | sta_ctx->conn_info.operationChannel = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3475 | hdd_ctx->config->OperatingChannel; |
| 3476 | |
| 3477 | /* Make the default Auth Type as OPEN */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3478 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3479 | |
| 3480 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3481 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3482 | hdd_err("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3483 | status, status); |
| 3484 | goto error_init_txrx; |
| 3485 | } |
| 3486 | |
| 3487 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3488 | |
| 3489 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3490 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3491 | hdd_err("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3492 | status, status); |
| 3493 | goto error_wmm_init; |
| 3494 | } |
| 3495 | |
| 3496 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3497 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 3498 | ret_val = sme_cli_set_command(adapter->sessionId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3499 | WMI_PDEV_PARAM_BURST_ENABLE, |
| 3500 | hdd_ctx->config->enableSifsBurst, |
| 3501 | PDEV_CMD); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3502 | if (ret_val) |
| 3503 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", ret_val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3504 | |
Dhanashri Atre | 1a6a4ce | 2017-05-03 19:40:33 -0700 | [diff] [blame] | 3505 | adapter->dev->features |= NETIF_F_LRO; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3506 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3507 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3508 | error_wmm_init: |
| 3509 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3510 | hdd_deinit_tx_rx(adapter); |
| 3511 | error_init_txrx: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3512 | hdd_unregister_wext(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3513 | error_register_wext: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3514 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3515 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3516 | return status; |
| 3517 | } |
| 3518 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3519 | void hdd_cleanup_actionframe(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3520 | { |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 3521 | hdd_debug("Cleanup action frame"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3522 | } |
| 3523 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3524 | /** |
| 3525 | * hdd_station_adapter_deinit() - De-initialize the station adapter |
| 3526 | * @hdd_ctx: global hdd context |
| 3527 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3528 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 3529 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3530 | * |
| 3531 | * This function De-initializes the STA/P2P/OCB adapter. |
| 3532 | * |
| 3533 | * Return: None. |
| 3534 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3535 | static void hdd_station_adapter_deinit(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3536 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3537 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3538 | { |
| 3539 | ENTER_DEV(adapter->dev); |
| 3540 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 3541 | if (adapter->dev) { |
| 3542 | if (rtnl_held) |
| 3543 | adapter->dev->wireless_handlers = NULL; |
| 3544 | else { |
| 3545 | rtnl_lock(); |
| 3546 | adapter->dev->wireless_handlers = NULL; |
| 3547 | rtnl_unlock(); |
| 3548 | } |
| 3549 | } |
| 3550 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3551 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 3552 | hdd_deinit_tx_rx(adapter); |
| 3553 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3554 | } |
| 3555 | |
| 3556 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 3557 | hdd_wmm_adapter_close(adapter); |
| 3558 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3559 | } |
| 3560 | |
| 3561 | hdd_cleanup_actionframe(hdd_ctx, adapter); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3562 | |
| 3563 | EXIT(); |
| 3564 | } |
| 3565 | |
| 3566 | /** |
| 3567 | * hdd_ap_adapter_deinit() - De-initialize the ap adapter |
| 3568 | * @hdd_ctx: global hdd context |
| 3569 | * @adapter: HDD adapter |
| 3570 | * @rtnl_held: the rtnl lock hold flag |
| 3571 | * This function De-initializes the AP/P2PGo adapter. |
| 3572 | * |
| 3573 | * Return: None. |
| 3574 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3575 | static void hdd_ap_adapter_deinit(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3576 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3577 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3578 | { |
| 3579 | ENTER_DEV(adapter->dev); |
| 3580 | |
| 3581 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 3582 | hdd_wmm_adapter_close(adapter); |
| 3583 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3584 | } |
Liangwei Dong | 8baf7c8 | 2016-10-11 01:26:59 -0400 | [diff] [blame] | 3585 | wlan_hdd_undo_acs(adapter); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3586 | |
| 3587 | hdd_cleanup_actionframe(hdd_ctx, adapter); |
| 3588 | |
| 3589 | hdd_unregister_hostapd(adapter, rtnl_held); |
| 3590 | |
| 3591 | EXIT(); |
| 3592 | } |
| 3593 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3594 | void hdd_deinit_adapter(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3595 | bool rtnl_held) |
| 3596 | { |
| 3597 | ENTER(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3598 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3599 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3600 | case QDF_STA_MODE: |
| 3601 | case QDF_P2P_CLIENT_MODE: |
| 3602 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3603 | { |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 3604 | hdd_station_adapter_deinit(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3605 | break; |
| 3606 | } |
| 3607 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3608 | case QDF_SAP_MODE: |
| 3609 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3610 | { |
| 3611 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3612 | hdd_ap_adapter_deinit(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3613 | break; |
| 3614 | } |
| 3615 | |
| 3616 | default: |
| 3617 | break; |
| 3618 | } |
| 3619 | |
| 3620 | EXIT(); |
| 3621 | } |
| 3622 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3623 | 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] | 3624 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3625 | { |
| 3626 | struct net_device *pWlanDev = NULL; |
| 3627 | |
| 3628 | if (adapter) |
| 3629 | pWlanDev = adapter->dev; |
| 3630 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3631 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3632 | return; |
| 3633 | } |
| 3634 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 3635 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 3636 | |
| 3637 | if (adapter->scan_info.default_scan_ies) { |
| 3638 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 3639 | adapter->scan_info.default_scan_ies = NULL; |
| 3640 | } |
| 3641 | |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3642 | hdd_adapter_runtime_suspend_denit(adapter); |
| 3643 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3644 | /* |
| 3645 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 3646 | * the driver is almost closed and cannot handle either control |
| 3647 | * messages or data. However, unregister_netdevice() call above will |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3648 | * eventually invoke hdd_stop(ndo_close) driver callback, which attempts |
| 3649 | * to close the active connections(basically excites control path) which |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3650 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 3651 | * the interface is closed and restricts any operations on that |
| 3652 | */ |
| 3653 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 3654 | |
| 3655 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3656 | if (rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3657 | unregister_netdevice(pWlanDev); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3658 | else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3659 | unregister_netdev(pWlanDev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3660 | /* |
| 3661 | * Note that the adapter is no longer valid at this point |
| 3662 | * since the memory has been reclaimed |
| 3663 | */ |
| 3664 | } |
| 3665 | } |
| 3666 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3667 | 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] | 3668 | tSirMacAddr macAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3669 | { |
| 3670 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3671 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3672 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3673 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3674 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3675 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 3676 | adapter = adapterNode->adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3677 | if (adapter |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3678 | && !qdf_mem_cmp(adapter->macAddressCurrent.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3679 | macAddr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3680 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3681 | } |
| 3682 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 3683 | adapterNode = pNext; |
| 3684 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3685 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3686 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3687 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3688 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 3689 | /** |
| 3690 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 3691 | * @hdd_ctx: HDD Context |
| 3692 | * @adapter: HDD Adapter |
| 3693 | * |
| 3694 | * This function set the FW Debug log level based on the INI. |
| 3695 | * |
| 3696 | * Return: None |
| 3697 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3698 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3699 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3700 | { |
| 3701 | uint8_t count = 0, numentries = 0, |
| 3702 | moduleloglevel[FW_MODULE_LOG_LEVEL_STRING_LENGTH]; |
| 3703 | uint32_t value = 0; |
| 3704 | int ret; |
| 3705 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3706 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 3707 | (!hdd_ctx->config->enable_fw_log)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3708 | 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] | 3709 | return; |
| 3710 | } |
| 3711 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3712 | /* Enable FW logs based on INI configuration */ |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3713 | hdd_ctx->fw_log_settings.dl_type = |
| 3714 | hdd_ctx->config->enableFwLogType; |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 3715 | ret = sme_cli_set_command(adapter->sessionId, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3716 | WMI_DBGLOG_TYPE, |
| 3717 | hdd_ctx->config->enableFwLogType, |
| 3718 | DBG_CMD); |
| 3719 | if (ret != 0) |
| 3720 | hdd_err("Failed to enable FW log type ret %d", |
| 3721 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3722 | |
| 3723 | hdd_ctx->fw_log_settings.dl_loglevel = |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3724 | hdd_ctx->config->enableFwLogLevel; |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 3725 | ret = sme_cli_set_command(adapter->sessionId, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3726 | WMI_DBGLOG_LOG_LEVEL, |
| 3727 | hdd_ctx->config->enableFwLogLevel, |
| 3728 | DBG_CMD); |
| 3729 | if (ret != 0) |
| 3730 | hdd_err("Failed to enable FW log level ret %d", |
| 3731 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3732 | |
| 3733 | hdd_string_to_u8_array( |
| 3734 | hdd_ctx->config->enableFwModuleLogLevel, |
| 3735 | moduleloglevel, |
| 3736 | &numentries, |
| 3737 | FW_MODULE_LOG_LEVEL_STRING_LENGTH); |
| 3738 | |
| 3739 | while (count < numentries) { |
| 3740 | /* |
| 3741 | * FW module log level input string looks like |
| 3742 | * below: |
| 3743 | * gFwDebugModuleLoglevel=<FW Module ID>, |
| 3744 | * <Log Level>,... |
| 3745 | * For example: |
| 3746 | * gFwDebugModuleLoglevel= |
| 3747 | * 1,0,2,1,3,2,4,3,5,4,6,5,7,6 |
| 3748 | * Above input string means : |
| 3749 | * For FW module ID 1 enable log level 0 |
| 3750 | * For FW module ID 2 enable log level 1 |
| 3751 | * For FW module ID 3 enable log level 2 |
| 3752 | * For FW module ID 4 enable log level 3 |
| 3753 | * For FW module ID 5 enable log level 4 |
| 3754 | * For FW module ID 6 enable log level 5 |
| 3755 | * For FW module ID 7 enable log level 6 |
| 3756 | */ |
| 3757 | |
Nishank Aggarwal | e239d96 | 2017-03-03 12:26:02 +0530 | [diff] [blame] | 3758 | if ((moduleloglevel[count] > WLAN_MODULE_ID_MAX) |
| 3759 | || (moduleloglevel[count + 1] > DBGLOG_LVL_MAX)) { |
| 3760 | hdd_err("Module id %d and dbglog level %d input length is more than max", |
| 3761 | moduleloglevel[count], |
| 3762 | moduleloglevel[count + 1]); |
| 3763 | return; |
| 3764 | } |
| 3765 | |
| 3766 | value = moduleloglevel[count] << 16; |
| 3767 | value |= moduleloglevel[count + 1]; |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 3768 | ret = sme_cli_set_command(adapter->sessionId, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3769 | WMI_DBGLOG_MOD_LOG_LEVEL, |
| 3770 | value, DBG_CMD); |
| 3771 | if (ret != 0) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3772 | hdd_err("Failed to enable FW module log level %d ret %d", |
| 3773 | value, ret); |
| 3774 | |
| 3775 | count += 2; |
| 3776 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3777 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3778 | } |
| 3779 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3780 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3781 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3782 | { |
| 3783 | } |
| 3784 | |
| 3785 | #endif |
| 3786 | |
| 3787 | /** |
| 3788 | * hdd_set_fw_params() - Set parameters to firmware |
| 3789 | * @adapter: HDD adapter |
| 3790 | * |
| 3791 | * This function Sets various parameters to fw once the |
| 3792 | * adapter is started. |
| 3793 | * |
| 3794 | * Return: 0 on success or errno on failure |
| 3795 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3796 | int hdd_set_fw_params(struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3797 | { |
| 3798 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3799 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3800 | |
| 3801 | ENTER_DEV(adapter->dev); |
| 3802 | |
| 3803 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3804 | if (!hdd_ctx) |
| 3805 | return -EINVAL; |
| 3806 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 3807 | if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 3808 | hdd_debug("FTM Mode is active; nothing to do"); |
| 3809 | return 0; |
| 3810 | } |
| 3811 | |
Ashish Kumar Dhanotiya | b8630ab | 2017-07-21 14:18:14 +0530 | [diff] [blame] | 3812 | ret = sme_cli_set_command(adapter->sessionId, |
| 3813 | WMI_PDEV_PARAM_DTIM_SYNTH, |
| 3814 | hdd_ctx->config->enable_lprx, PDEV_CMD); |
| 3815 | if (ret) { |
| 3816 | hdd_err("Failed to set LPRx"); |
| 3817 | goto error; |
| 3818 | } |
| 3819 | |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 3820 | if (adapter->device_mode == QDF_STA_MODE) { |
| 3821 | sme_set_smps_cfg(adapter->sessionId, |
| 3822 | HDD_STA_SMPS_PARAM_UPPER_BRSSI_THRESH, |
| 3823 | hdd_ctx->config->upper_brssi_thresh); |
| 3824 | |
| 3825 | sme_set_smps_cfg(adapter->sessionId, |
| 3826 | HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH, |
| 3827 | hdd_ctx->config->lower_brssi_thresh); |
| 3828 | |
| 3829 | sme_set_smps_cfg(adapter->sessionId, |
| 3830 | HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE, |
| 3831 | hdd_ctx->config->enable_dtim_1chrx); |
| 3832 | } |
| 3833 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 3834 | if (hdd_ctx->config->enable2x2) { |
| 3835 | hdd_debug("configuring 2x2 mode fw params"); |
| 3836 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 3837 | ret = sme_cli_set_command(adapter->sessionId, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 3838 | WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE, |
| 3839 | hdd_ctx->config->enable_cck_tx_fir_override, |
| 3840 | PDEV_CMD); |
| 3841 | if (ret) { |
| 3842 | hdd_err("WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE set failed %d", |
| 3843 | ret); |
| 3844 | goto error; |
| 3845 | } |
| 3846 | } else { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3847 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 3848 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 3849 | hdd_debug("configuring 1x1 mode fw params"); |
| 3850 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3851 | /* |
| 3852 | * Disable DTIM 1 chain Rx when in 1x1, |
| 3853 | * we are passing two value |
| 3854 | * as param_id << 29 | param_value. |
| 3855 | * Below param_value = 0(disable) |
| 3856 | */ |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 3857 | ret = sme_cli_set_command(adapter->sessionId, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3858 | WMI_STA_SMPS_PARAM_CMDID, |
| 3859 | HDD_DTIM_1CHAIN_RX_ID << |
| 3860 | HDD_SMPS_PARAM_VALUE_S, |
| 3861 | VDEV_CMD); |
| 3862 | if (ret) { |
| 3863 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 3864 | goto error; |
| 3865 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3866 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 3867 | ret = sme_cli_set_command(adapter->sessionId, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3868 | WMI_PDEV_PARAM_TX_CHAIN_MASK, |
| 3869 | hdd_ctx->config->txchainmask1x1, |
| 3870 | PDEV_CMD); |
| 3871 | if (ret) { |
| 3872 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK set failed %d", |
| 3873 | ret); |
| 3874 | goto error; |
| 3875 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3876 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 3877 | ret = sme_cli_set_command(adapter->sessionId, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3878 | WMI_PDEV_PARAM_RX_CHAIN_MASK, |
| 3879 | hdd_ctx->config->rxchainmask1x1, |
| 3880 | PDEV_CMD); |
| 3881 | if (ret) { |
| 3882 | hdd_err("WMI_PDEV_PARAM_RX_CHAIN_MASK set failed %d", |
| 3883 | ret); |
| 3884 | goto error; |
| 3885 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3886 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 3887 | #undef HDD_SMPS_PARAM_VALUE_S |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3888 | } |
| 3889 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 3890 | ret = sme_cli_set_command(adapter->sessionId, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 3891 | WMI_PDEV_PARAM_HYST_EN, |
| 3892 | hdd_ctx->config->enableMemDeepSleep, |
| 3893 | PDEV_CMD); |
| 3894 | if (ret) { |
| 3895 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", ret); |
| 3896 | goto error; |
| 3897 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3898 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 3899 | ret = sme_cli_set_command(adapter->sessionId, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 3900 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
| 3901 | hdd_ctx->config->rts_profile, |
| 3902 | VDEV_CMD); |
| 3903 | if (ret) { |
| 3904 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 3905 | goto error; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3906 | } |
| 3907 | |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 3908 | hdd_debug("SET AMSDU num %d", hdd_ctx->config->max_amsdu_num); |
| 3909 | |
| 3910 | ret = wma_cli_set_command(adapter->sessionId, |
| 3911 | GEN_VDEV_PARAM_AMSDU, |
| 3912 | hdd_ctx->config->max_amsdu_num, |
| 3913 | GEN_CMD); |
| 3914 | if (ret != 0) { |
| 3915 | hdd_err("GEN_VDEV_PARAM_AMSDU set failed %d", ret); |
| 3916 | goto error; |
| 3917 | } |
| 3918 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3919 | hdd_set_fw_log_params(hdd_ctx, adapter); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3920 | EXIT(); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 3921 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3922 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3923 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3924 | error: |
| 3925 | return -EINVAL; |
| 3926 | } |
| 3927 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3928 | /** |
| 3929 | * hdd_open_adapter() - open and setup the hdd adatper |
| 3930 | * @hdd_ctx: global hdd context |
| 3931 | * @session_type: type of the interface to be created |
| 3932 | * @iface_name: User-visible name of the interface |
| 3933 | * @macAddr: MAC address to assign to the interface |
| 3934 | * @name_assign_type: the name of assign type of the netdev |
| 3935 | * @rtnl_held: the rtnl lock hold flag |
| 3936 | * |
| 3937 | * This function open and setup the hdd adpater according to the device |
| 3938 | * type request, assign the name, the mac address assigned, and then prepared |
| 3939 | * the hdd related parameters, queue, lock and ready to start. |
| 3940 | * |
| 3941 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 3942 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3943 | 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] | 3944 | const char *iface_name, tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3945 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3946 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3947 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3948 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3949 | hdd_adapter_list_node_t *pHddAdapterNode = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3950 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3951 | |
| 3952 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 3953 | /* |
| 3954 | * Max limit reached on the number of vdevs configured by the |
| 3955 | * host. Return error |
| 3956 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3957 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 3958 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3959 | return NULL; |
| 3960 | } |
| 3961 | |
| 3962 | if (macAddr == NULL) { |
| 3963 | /* Not received valid macAddr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3964 | 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] | 3965 | return NULL; |
| 3966 | } |
| 3967 | status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3968 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3969 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 3970 | " already exists", |
| 3971 | MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3972 | return NULL; |
| 3973 | } |
| 3974 | |
| 3975 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3976 | case QDF_STA_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3977 | /* Reset locally administered bit if the device mode is STA */ |
| 3978 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr); |
Arunk Khandavalli | 794fdfc | 2017-09-13 18:00:40 +0530 | [diff] [blame] | 3979 | hdd_info("locally administered bit reset in sta mode: " |
| 3980 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3981 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3982 | case QDF_P2P_CLIENT_MODE: |
| 3983 | case QDF_P2P_DEVICE_MODE: |
| 3984 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 3985 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3986 | case QDF_MONITOR_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3987 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 3988 | name_assign_type, |
| 3989 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3990 | |
| 3991 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3992 | hdd_err("failed to allocate adapter for session %d", |
| 3993 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3994 | return NULL; |
| 3995 | } |
| 3996 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3997 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3998 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3999 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4000 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4001 | else if (QDF_MONITOR_MODE == session_type) |
| 4002 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4003 | else |
| 4004 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4005 | |
| 4006 | adapter->device_mode = session_type; |
| 4007 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4008 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4009 | /* |
| 4010 | * Workqueue which gets scheduled in IPv4 notification |
| 4011 | * callback |
| 4012 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4013 | INIT_WORK(&adapter->ipv4NotifierWorkQueue, |
| 4014 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4015 | |
| 4016 | #ifdef WLAN_NS_OFFLOAD |
| 4017 | /* |
| 4018 | * Workqueue which gets scheduled in IPv6 |
| 4019 | * notification callback. |
| 4020 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4021 | INIT_WORK(&adapter->ipv6NotifierWorkQueue, |
| 4022 | hdd_ipv6_notifier_work_queue); |
| 4023 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4024 | status = hdd_register_interface(adapter, rtnl_held); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4025 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4026 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 4027 | goto err_free_netdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4028 | } |
| 4029 | |
| 4030 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4031 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4032 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4033 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4034 | WLAN_CONTROL_PATH); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4035 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4036 | /* Initialize NAN Data Interface */ |
| 4037 | if (QDF_NDI_MODE == session_type) { |
| 4038 | status = hdd_init_nan_data_mode(adapter); |
| 4039 | if (QDF_STATUS_SUCCESS != status) |
| 4040 | goto err_free_netdev; |
| 4041 | } |
| 4042 | |
| 4043 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4044 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4045 | case QDF_P2P_GO_MODE: |
| 4046 | case QDF_SAP_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4047 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr, |
| 4048 | name_assign_type, |
| 4049 | (uint8_t *) iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4050 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4051 | hdd_err("failed to allocate adapter for session %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4052 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4053 | return NULL; |
| 4054 | } |
| 4055 | |
| 4056 | adapter->wdev.iftype = |
| 4057 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4058 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4059 | NL80211_IFTYPE_P2P_GO; |
| 4060 | adapter->device_mode = session_type; |
| 4061 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 4062 | status = hdd_register_interface(adapter, rtnl_held); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4063 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4064 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
| 4065 | goto err_free_netdev; |
| 4066 | } |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4067 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4068 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4069 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4070 | WLAN_CONTROL_PATH); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4071 | |
| 4072 | /* |
| 4073 | * Workqueue which gets scheduled in IPv4 notification |
| 4074 | * callback |
| 4075 | */ |
| 4076 | INIT_WORK(&adapter->ipv4NotifierWorkQueue, |
| 4077 | hdd_ipv4_notifier_work_queue); |
| 4078 | |
| 4079 | #ifdef WLAN_NS_OFFLOAD |
| 4080 | /* |
| 4081 | * Workqueue which gets scheduled in IPv6 |
| 4082 | * notification callback. |
| 4083 | */ |
| 4084 | INIT_WORK(&adapter->ipv6NotifierWorkQueue, |
| 4085 | hdd_ipv6_notifier_work_queue); |
| 4086 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4087 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4088 | case QDF_FTM_MODE: |
| 4089 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4090 | name_assign_type, |
| 4091 | "wlan0"); |
| 4092 | if (NULL == adapter) { |
| 4093 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 4094 | return NULL; |
| 4095 | } |
| 4096 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4097 | adapter->device_mode = session_type; |
| 4098 | status = hdd_register_interface(adapter, rtnl_held); |
| 4099 | if (QDF_STATUS_SUCCESS != status) { |
| 4100 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
| 4101 | goto err_free_netdev; |
| 4102 | } |
| 4103 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4104 | hdd_debug("Disabling queues"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4105 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4106 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4107 | WLAN_CONTROL_PATH); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4108 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4109 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4110 | hdd_err("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4111 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4112 | return NULL; |
| 4113 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4114 | |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 4115 | INIT_WORK(&adapter->scan_block_work, wlan_hdd_cfg80211_scan_block_cb); |
| 4116 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4117 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4118 | /* Add it to the hdd's session list. */ |
| 4119 | pHddAdapterNode = |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4120 | qdf_mem_malloc(sizeof(hdd_adapter_list_node_t)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4121 | if (NULL == pHddAdapterNode) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4122 | status = QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4123 | } else { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 4124 | pHddAdapterNode->adapter = adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4125 | status = hdd_add_adapter_back(hdd_ctx, pHddAdapterNode); |
| 4126 | } |
| 4127 | } |
| 4128 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4129 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4130 | if (NULL != adapter) { |
| 4131 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4132 | adapter = NULL; |
| 4133 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4134 | if (NULL != pHddAdapterNode) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4135 | qdf_mem_free(pHddAdapterNode); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4136 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4137 | return NULL; |
| 4138 | } |
| 4139 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4140 | if (QDF_STATUS_SUCCESS == status) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4141 | policy_mgr_set_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4142 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4143 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4144 | /* Adapter successfully added. Increment the vdev count */ |
| 4145 | hdd_ctx->current_intf_count++; |
| 4146 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4147 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4148 | hdd_ctx->current_intf_count); |
| 4149 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 4150 | hdd_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4151 | } |
| 4152 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4153 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 4154 | hdd_err("Interface %s wow debug_fs init failed", |
| 4155 | netdev_name(adapter->dev)); |
| 4156 | |
| 4157 | hdd_info("%s interface created. iftype: %d", netdev_name(adapter->dev), |
| 4158 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4159 | |
| 4160 | return adapter; |
| 4161 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4162 | err_free_netdev: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4163 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->macAddressCurrent.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 4164 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4165 | |
| 4166 | return NULL; |
| 4167 | } |
| 4168 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4169 | 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] | 4170 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4171 | { |
| 4172 | hdd_adapter_list_node_t *adapterNode, *pCurrent, *pNext; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4173 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4174 | |
| 4175 | status = hdd_get_front_adapter(hdd_ctx, &pCurrent); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4176 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4177 | hdd_warn("adapter list empty %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4178 | status); |
| 4179 | return status; |
| 4180 | } |
| 4181 | |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 4182 | while (pCurrent->adapter != adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4183 | status = hdd_get_next_adapter(hdd_ctx, pCurrent, &pNext); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4184 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4185 | break; |
| 4186 | |
| 4187 | pCurrent = pNext; |
| 4188 | } |
| 4189 | adapterNode = pCurrent; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4190 | if (QDF_STATUS_SUCCESS == status) { |
Lin Bai | c5c0688 | 2017-09-21 13:58:43 +0800 | [diff] [blame] | 4191 | /* |
| 4192 | * Here we are stopping global bus_bw timer & work per adapter. |
| 4193 | * |
| 4194 | * The reason is to fix one race condition between |
| 4195 | * bus bandwidth work and cleaning up an adapter. |
| 4196 | * Under some conditions, it is possible for the bus bandwidth |
| 4197 | * work to access a particularly destroyed adapter, leading to |
| 4198 | * use-after-free. |
| 4199 | */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4200 | hdd_debug("wait for bus bw work to flush"); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 4201 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
Lin Bai | c5c0688 | 2017-09-21 13:58:43 +0800 | [diff] [blame] | 4202 | hdd_bus_bw_cancel_work(hdd_ctx); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 4203 | |
| 4204 | /* cleanup adapter */ |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4205 | policy_mgr_clear_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4206 | adapter->device_mode); |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 4207 | hdd_cleanup_adapter(hdd_ctx, adapterNode->adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4208 | hdd_remove_adapter(hdd_ctx, adapterNode); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4209 | qdf_mem_free(adapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4210 | adapterNode = NULL; |
| 4211 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 4212 | /* conditionally restart the bw timer */ |
| 4213 | hdd_bus_bw_compute_timer_try_start(hdd_ctx); |
| 4214 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4215 | /* Adapter removed. Decrement vdev count */ |
| 4216 | if (hdd_ctx->current_intf_count != 0) |
| 4217 | hdd_ctx->current_intf_count--; |
| 4218 | |
| 4219 | /* Fw will take care incase of concurrency */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4220 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4221 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4222 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4223 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4224 | } |
| 4225 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4226 | /** |
| 4227 | * hdd_close_all_adapters - Close all open adapters |
| 4228 | * @hdd_ctx: Hdd context |
| 4229 | * rtnl_held: True if RTNL lock held |
| 4230 | * |
| 4231 | * Close all open adapters. |
| 4232 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4233 | * Return: QDF status code |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4234 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4235 | 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] | 4236 | { |
| 4237 | hdd_adapter_list_node_t *pHddAdapterNode; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4238 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4239 | |
| 4240 | ENTER(); |
| 4241 | |
| 4242 | do { |
| 4243 | status = hdd_remove_front_adapter(hdd_ctx, &pHddAdapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4244 | if (pHddAdapterNode && QDF_STATUS_SUCCESS == status) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4245 | wlan_hdd_release_intf_addr(hdd_ctx, |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 4246 | pHddAdapterNode->adapter->macAddressCurrent.bytes); |
| 4247 | hdd_cleanup_adapter(hdd_ctx, pHddAdapterNode->adapter, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4248 | rtnl_held); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4249 | qdf_mem_free(pHddAdapterNode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4250 | /* Adapter removed. Decrement vdev count */ |
| 4251 | if (hdd_ctx->current_intf_count != 0) |
| 4252 | hdd_ctx->current_intf_count--; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4253 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4254 | } while (NULL != pHddAdapterNode && QDF_STATUS_E_EMPTY != status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4255 | |
| 4256 | EXIT(); |
| 4257 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4258 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4259 | } |
| 4260 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4261 | void wlan_hdd_reset_prob_rspies(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4262 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4263 | struct qdf_mac_addr *bssid = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4264 | tSirUpdateIE updateIE; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4265 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4266 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4267 | case QDF_STA_MODE: |
| 4268 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4269 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4270 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4271 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4272 | bssid = &sta_ctx->conn_info.bssId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4273 | break; |
| 4274 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4275 | case QDF_SAP_MODE: |
| 4276 | case QDF_P2P_GO_MODE: |
| 4277 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4278 | { |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4279 | bssid = &adapter->macAddressCurrent; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4280 | break; |
| 4281 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4282 | case QDF_FTM_MODE: |
| 4283 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4284 | default: |
| 4285 | /* |
| 4286 | * wlan_hdd_reset_prob_rspies should not have been called |
| 4287 | * for these kind of devices |
| 4288 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4289 | hdd_err("Unexpected request for the current device type %d", |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4290 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4291 | return; |
| 4292 | } |
| 4293 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 4294 | qdf_copy_macaddr(&updateIE.bssid, bssid); |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4295 | updateIE.smeSessionId = adapter->sessionId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4296 | updateIE.ieBufferlength = 0; |
| 4297 | updateIE.pAdditionIEBuffer = NULL; |
| 4298 | updateIE.append = true; |
| 4299 | updateIE.notify = false; |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4300 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4301 | &updateIE, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4302 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4303 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4304 | } |
| 4305 | } |
| 4306 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4307 | QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4308 | const bool bCloseSession) |
| 4309 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4310 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Jeff Johnson | 2a72200 | 2017-09-30 20:02:35 -0700 | [diff] [blame] | 4311 | struct hdd_wext_state *pWextState = |
| 4312 | WLAN_HDD_GET_WEXT_STATE_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4313 | union iwreq_data wrqu; |
| 4314 | tSirUpdateIE updateIE; |
| 4315 | unsigned long rc; |
| 4316 | |
| 4317 | ENTER(); |
| 4318 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4319 | hdd_debug("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4320 | wlan_hdd_netif_queue_control(adapter, |
| 4321 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4322 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4323 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4324 | case QDF_STA_MODE: |
| 4325 | case QDF_P2P_CLIENT_MODE: |
| 4326 | case QDF_IBSS_MODE: |
| 4327 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4328 | case QDF_NDI_MODE: |
| 4329 | if ((QDF_NDI_MODE == adapter->device_mode) || |
| 4330 | hdd_conn_is_connected( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4331 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)) || |
| 4332 | hdd_is_connecting( |
| 4333 | WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4334 | INIT_COMPLETION(adapter->disconnect_comp_var); |
| 4335 | /* |
| 4336 | * For NDI do not use pWextState from sta_ctx, if needed |
| 4337 | * extract from ndi_ctx. |
| 4338 | */ |
| 4339 | if (QDF_NDI_MODE == adapter->device_mode) |
| 4340 | qdf_ret_status = sme_roam_disconnect( |
| 4341 | hdd_ctx->hHal, |
| 4342 | adapter->sessionId, |
| 4343 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
| 4344 | else if (pWextState->roamProfile.BSSType == |
| 4345 | eCSR_BSS_TYPE_START_IBSS) |
| 4346 | qdf_ret_status = sme_roam_disconnect( |
| 4347 | hdd_ctx->hHal, |
| 4348 | adapter->sessionId, |
| 4349 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4350 | else if (QDF_STA_MODE == adapter->device_mode) |
| 4351 | qdf_ret_status = |
| 4352 | wlan_hdd_try_disconnect(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4353 | else |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4354 | qdf_ret_status = sme_roam_disconnect( |
| 4355 | hdd_ctx->hHal, |
| 4356 | adapter->sessionId, |
| 4357 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4358 | /* success implies disconnect command got |
| 4359 | * queued up successfully |
| 4360 | */ |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4361 | if (qdf_ret_status == QDF_STATUS_SUCCESS && |
| 4362 | QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4363 | rc = wait_for_completion_timeout( |
| 4364 | &adapter->disconnect_comp_var, |
| 4365 | msecs_to_jiffies |
| 4366 | (WLAN_WAIT_TIME_DISCONNECT)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4367 | if (!rc) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4368 | hdd_warn("disconn_comp_var wait fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4369 | } |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4370 | if (qdf_ret_status != QDF_STATUS_SUCCESS) |
| 4371 | hdd_warn("failed to post disconnect"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4372 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 4373 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 4374 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 4375 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 4376 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 4377 | } |
Wu Gao | aceec6c | 2017-08-30 16:08:21 +0800 | [diff] [blame] | 4378 | wlan_hdd_scan_abort(adapter); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4379 | |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 4380 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 4381 | hdd_clear_fils_connection_info(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4382 | |
| 4383 | #ifdef WLAN_OPEN_SOURCE |
| 4384 | cancel_work_sync(&adapter->ipv4NotifierWorkQueue); |
| 4385 | #endif |
| 4386 | |
| 4387 | hdd_deregister_tx_flow_control(adapter); |
| 4388 | |
| 4389 | #ifdef WLAN_NS_OFFLOAD |
| 4390 | #ifdef WLAN_OPEN_SOURCE |
| 4391 | cancel_work_sync(&adapter->ipv6NotifierWorkQueue); |
| 4392 | #endif |
| 4393 | #endif |
| 4394 | |
Hanumanth Reddy Pothula | 0586014 | 2017-07-26 18:45:27 +0530 | [diff] [blame] | 4395 | if (adapter->device_mode == QDF_STA_MODE) |
| 4396 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 4397 | adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4398 | /* |
| 4399 | * It is possible that the caller of this function does not |
| 4400 | * wish to close the session |
| 4401 | */ |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 4402 | if (true == bCloseSession) { |
| 4403 | if (0 != wlan_hdd_try_disconnect(adapter)) { |
| 4404 | hdd_err("Error: Can't disconnect adapter"); |
| 4405 | return QDF_STATUS_E_FAILURE; |
| 4406 | } |
Dustin Brown | 0d2eeae | 2017-03-24 15:21:32 -0700 | [diff] [blame] | 4407 | hdd_vdev_destroy(adapter); |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 4408 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4409 | break; |
| 4410 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4411 | case QDF_SAP_MODE: |
Govind Singh | 1dab23b | 2017-08-12 13:31:00 +0530 | [diff] [blame] | 4412 | /* Flush IPA exception path packets */ |
| 4413 | hdd_ipa_flush(hdd_ctx); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 4414 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4415 | case QDF_P2P_GO_MODE: |
Kiran Kumar Lokere | 85cb36b | 2017-09-14 15:19:14 -0700 | [diff] [blame] | 4416 | if (QDF_SAP_MODE == adapter->device_mode) { |
| 4417 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 4418 | cds_flush_delayed_work( |
| 4419 | &adapter->acs_pending_work); |
| 4420 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 4421 | } |
| 4422 | } |
Krunal Soni | 2220839 | 2017-09-29 18:10:34 -0700 | [diff] [blame] | 4423 | cds_flush_work(&adapter->sap_stop_bss_work); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 4424 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4425 | /* Any softap specific cleanup here... */ |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 4426 | wlan_hdd_undo_acs(adapter); |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4427 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4428 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 4429 | |
| 4430 | hdd_deregister_tx_flow_control(adapter); |
| 4431 | |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 4432 | hdd_destroy_acs_timer(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4433 | mutex_lock(&hdd_ctx->sap_lock); |
| 4434 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4435 | QDF_STATUS status; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4436 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4437 | |
| 4438 | /* Stop Bss. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4439 | status = wlansap_stop_bss( |
| 4440 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4441 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4442 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 4443 | struct hdd_hostapd_state *hostapd_state = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4444 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4445 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4446 | qdf_stop_bss_event); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4447 | qdf_status = |
| 4448 | qdf_wait_single_event(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 4449 | qdf_stop_bss_event, |
| 4450 | SME_CMD_TIMEOUT_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4451 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4452 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4453 | hdd_err("failure waiting for wlansap_stop_bss %d", |
| 4454 | qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4455 | } |
| 4456 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4457 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4458 | } |
| 4459 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4460 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 4461 | adapter->device_mode, |
| 4462 | adapter->sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4463 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 4464 | qdf_copy_macaddr(&updateIE.bssid, |
Srinivas Girigowda | 8b98396 | 2015-11-18 22:14:34 -0800 | [diff] [blame] | 4465 | &adapter->macAddressCurrent); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4466 | updateIE.smeSessionId = adapter->sessionId; |
| 4467 | updateIE.ieBufferlength = 0; |
| 4468 | updateIE.pAdditionIEBuffer = NULL; |
| 4469 | updateIE.append = false; |
| 4470 | updateIE.notify = false; |
| 4471 | /* Probe bcn reset */ |
| 4472 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 4473 | &updateIE, eUPDATE_IE_PROBE_BCN) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4474 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4475 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4476 | } |
| 4477 | /* Assoc resp reset */ |
| 4478 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 4479 | &updateIE, |
| 4480 | eUPDATE_IE_ASSOC_RESP) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4481 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4482 | hdd_err("Could not pass on ASSOC_RSP data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4483 | } |
| 4484 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 4485 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4486 | } |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 4487 | qdf_mem_free(adapter->sessionCtx.ap.beacon); |
| 4488 | adapter->sessionCtx.ap.beacon = NULL; |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 4489 | /* |
| 4490 | * If Do_Not_Break_Stream was enabled clear avoid channel list. |
| 4491 | */ |
| 4492 | if (policy_mgr_is_dnsc_set(adapter->hdd_vdev)) |
| 4493 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0); |
| 4494 | |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 4495 | if (true == bCloseSession) |
Dustin Brown | 0d2eeae | 2017-03-24 15:21:32 -0700 | [diff] [blame] | 4496 | hdd_vdev_destroy(adapter); |
Manikandan Mohan | 5df7827 | 2017-03-22 16:28:50 -0700 | [diff] [blame] | 4497 | mutex_unlock(&hdd_ctx->sap_lock); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4498 | |
| 4499 | #ifdef WLAN_OPEN_SOURCE |
| 4500 | cancel_work_sync(&adapter->ipv4NotifierWorkQueue); |
| 4501 | #endif |
| 4502 | |
| 4503 | #ifdef WLAN_NS_OFFLOAD |
| 4504 | #ifdef WLAN_OPEN_SOURCE |
| 4505 | cancel_work_sync(&adapter->ipv6NotifierWorkQueue); |
| 4506 | #endif |
| 4507 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4508 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4509 | case QDF_OCB_MODE: |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 4510 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 4511 | (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX), |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 4512 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.staId[0]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4513 | break; |
| 4514 | default: |
| 4515 | break; |
| 4516 | } |
| 4517 | |
| 4518 | EXIT(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4519 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4520 | } |
| 4521 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4522 | /** |
| 4523 | * hdd_deinit_all_adapters - deinit all adapters |
| 4524 | * @hdd_ctx: HDD context |
| 4525 | * @rtnl_held: True if RTNL lock held |
| 4526 | * |
| 4527 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4528 | 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] | 4529 | { |
| 4530 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 4531 | QDF_STATUS status; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4532 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4533 | |
| 4534 | ENTER(); |
| 4535 | |
| 4536 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 4537 | |
| 4538 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 4539 | adapter = adapter_node->adapter; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4540 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
| 4541 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 4542 | adapter_node = next; |
| 4543 | } |
| 4544 | |
| 4545 | EXIT(); |
| 4546 | } |
| 4547 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 4548 | QDF_STATUS hdd_stop_all_adapters(struct hdd_context *hdd_ctx, |
| 4549 | bool close_session) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4550 | { |
| 4551 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4552 | QDF_STATUS status; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4553 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4554 | |
| 4555 | ENTER(); |
| 4556 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 4557 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 4558 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4559 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4560 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4561 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 4562 | adapter = adapterNode->adapter; |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 4563 | hdd_stop_adapter(hdd_ctx, adapter, close_session); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4564 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4565 | adapterNode = pNext; |
| 4566 | } |
| 4567 | |
| 4568 | EXIT(); |
| 4569 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4570 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4571 | } |
| 4572 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4573 | QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4574 | { |
| 4575 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4576 | QDF_STATUS status; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4577 | struct hdd_adapter *adapter; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4578 | struct hdd_station_ctx *sta_ctx; |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4579 | struct qdf_mac_addr peerMacAddr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4580 | |
| 4581 | ENTER(); |
| 4582 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 4583 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 4584 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4585 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4586 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4587 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 4588 | adapter = adapterNode->adapter; |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4589 | hdd_notice("Disabling queues for adapter type: %d", |
| 4590 | adapter->device_mode); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 4591 | |
| 4592 | if ((adapter->device_mode == QDF_STA_MODE) || |
Kabilan Kannan | 00d2041 | 2017-06-04 14:20:32 -0700 | [diff] [blame] | 4593 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 4594 | /* Stop tdls timers */ |
Kabilan Kannan | 00d2041 | 2017-06-04 14:20:32 -0700 | [diff] [blame] | 4595 | hdd_notify_tdls_reset_adapter(adapter->hdd_vdev); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 4596 | |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 4597 | if (hdd_ctx->config->sap_internal_restart && |
| 4598 | adapter->device_mode == QDF_SAP_MODE) { |
| 4599 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4600 | WLAN_STOP_ALL_NETIF_QUEUE, |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 4601 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 4602 | if (test_bit(SOFTAP_BSS_STARTED, |
| 4603 | &adapter->event_flags)) { |
| 4604 | hdd_sap_indicate_disconnect_for_sta(adapter); |
| 4605 | hdd_cleanup_actionframe(hdd_ctx, adapter); |
| 4606 | hdd_sap_destroy_events(adapter); |
| 4607 | } |
| 4608 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
| 4609 | } else { |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 4610 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4611 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4612 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 4613 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4614 | |
Jeff Johnson | 690fe95 | 2017-10-25 11:48:39 -0700 | [diff] [blame] | 4615 | adapter->sessionCtx.station.hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4616 | |
| 4617 | hdd_deinit_tx_rx(adapter); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4618 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 4619 | adapter->device_mode, adapter->sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4620 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 4621 | hdd_wmm_adapter_close(adapter); |
| 4622 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4623 | } |
| 4624 | |
Vignesh Viswanathan | 2eb1874 | 2017-09-08 11:18:59 +0530 | [diff] [blame] | 4625 | if (adapter->device_mode == QDF_STA_MODE) |
| 4626 | hdd_clear_fils_connection_info(adapter); |
| 4627 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 4628 | if (adapter->device_mode == QDF_SAP_MODE) { |
| 4629 | /* |
| 4630 | * If adapter is SAP, set session ID to invalid |
| 4631 | * since SAP session will be cleanup during SSR. |
| 4632 | */ |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 4633 | wlansap_set_invalid_session( |
| 4634 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 4635 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 4636 | wlansap_cleanup_cac_timer( |
| 4637 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 4638 | } |
| 4639 | |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4640 | /* Delete peers if any for STA and P2P client modes */ |
| 4641 | if (adapter->device_mode == QDF_STA_MODE || |
| 4642 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4643 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4644 | qdf_copy_macaddr(&peerMacAddr, |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4645 | &sta_ctx->conn_info.bssId); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4646 | |
| 4647 | hdd_objmgr_remove_peer_object(adapter->hdd_vdev, |
| 4648 | peerMacAddr.bytes); |
| 4649 | } |
| 4650 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 4651 | /* Destroy vdev which will be recreated during reinit. */ |
| 4652 | hdd_vdev_destroy(adapter); |
| 4653 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4654 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4655 | adapterNode = pNext; |
| 4656 | } |
| 4657 | |
| 4658 | EXIT(); |
| 4659 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4660 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4661 | } |
| 4662 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4663 | bool hdd_check_for_opened_interfaces(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 4664 | { |
| 4665 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 4666 | QDF_STATUS status; |
| 4667 | bool close_modules = true; |
| 4668 | |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 4669 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 4670 | hdd_info("FTM mode, don't close the module"); |
| 4671 | return false; |
| 4672 | } |
| 4673 | |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 4674 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 4675 | while ((NULL != adapter_node) && (QDF_STATUS_SUCCESS == status)) { |
| 4676 | if (test_bit(DEVICE_IFACE_OPENED, |
Yeshwanth Sriram Guntuka | 4ce0a1b | 2017-10-17 17:55:45 +0530 | [diff] [blame] | 4677 | &adapter_node->adapter->event_flags) || |
| 4678 | test_bit(SME_SESSION_OPENED, |
| 4679 | &adapter_node->adapter->event_flags)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4680 | hdd_debug("Still other ifaces are up cannot close modules"); |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 4681 | close_modules = false; |
| 4682 | break; |
| 4683 | } |
| 4684 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 4685 | adapter_node = next; |
| 4686 | } |
| 4687 | |
| 4688 | return close_modules; |
| 4689 | } |
| 4690 | |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 4691 | bool hdd_is_interface_up(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4692 | { |
| 4693 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 4694 | return true; |
| 4695 | else |
| 4696 | return false; |
| 4697 | } |
| 4698 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4699 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
bings | bdcd4a2 | 2017-06-20 09:27:00 +0800 | [diff] [blame] | 4700 | && !defined(WITH_BACKPORTS) && !defined(IEEE80211_PRIVACY) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4701 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 4702 | struct ieee80211_channel *channel, |
| 4703 | const u8 *bssid, const u8 *ssid, |
| 4704 | size_t ssid_len) |
| 4705 | { |
| 4706 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 4707 | ssid, ssid_len, |
| 4708 | WLAN_CAPABILITY_ESS, |
| 4709 | WLAN_CAPABILITY_ESS); |
| 4710 | } |
| 4711 | #else |
| 4712 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 4713 | struct ieee80211_channel *channel, |
| 4714 | const u8 *bssid, const u8 *ssid, |
| 4715 | size_t ssid_len) |
| 4716 | { |
| 4717 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 4718 | ssid, ssid_len, |
| 4719 | IEEE80211_BSS_TYPE_ESS, |
| 4720 | IEEE80211_PRIVACY_ANY); |
| 4721 | } |
| 4722 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4723 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 4724 | #if defined CFG80211_CONNECT_BSS || \ |
| 4725 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4726 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 4727 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4728 | /** |
| 4729 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 4730 | * @timeout_reason: reason for connect timeout |
| 4731 | * |
| 4732 | * This function is used to convert host timeout |
| 4733 | * reason enum to kernel specific enum. |
| 4734 | * |
| 4735 | * Return: nl timeout enum |
| 4736 | */ |
| 4737 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 4738 | tSirResultCodes timeout_reason) |
| 4739 | { |
| 4740 | switch (timeout_reason) { |
| 4741 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 4742 | return NL80211_TIMEOUT_SCAN; |
| 4743 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 4744 | return NL80211_TIMEOUT_AUTH; |
| 4745 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 4746 | return NL80211_TIMEOUT_ASSOC; |
| 4747 | default: |
| 4748 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 4749 | } |
| 4750 | } |
| 4751 | |
| 4752 | /** |
| 4753 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 4754 | * @dev: network device |
| 4755 | * @bssid: bssid to which we want to associate |
| 4756 | * @timeout_reason: reason for connect timeout |
| 4757 | * |
| 4758 | * This API is used to send connection timeout reason to supplicant |
| 4759 | * |
| 4760 | * Return: void |
| 4761 | */ |
| 4762 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 4763 | const u8 *bssid, |
| 4764 | tSirResultCodes timeout_reason) |
| 4765 | { |
| 4766 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4767 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4768 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 4769 | |
| 4770 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 4771 | nl_timeout_reason); |
| 4772 | } |
| 4773 | |
| 4774 | /** |
| 4775 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 4776 | * @dev: network device |
| 4777 | * @bssid: bssid to which we want to associate |
| 4778 | * @req_ie: Request Information Element |
| 4779 | * @req_ie_len: len of the req IE |
| 4780 | * @resp_ie: Response IE |
| 4781 | * @resp_ie_len: len of ht response IE |
| 4782 | * @status: status |
| 4783 | * @gfp: Kernel Flag |
| 4784 | * @timeout_reason: reason for connect timeout |
| 4785 | * |
| 4786 | * Return: void |
| 4787 | */ |
| 4788 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 4789 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 4790 | size_t req_ie_len, const u8 *resp_ie, |
| 4791 | size_t resp_ie_len, int status, gfp_t gfp, |
| 4792 | tSirResultCodes timeout_reason) |
| 4793 | { |
| 4794 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4795 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4796 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 4797 | |
| 4798 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 4799 | resp_ie, resp_ie_len, status, gfp, |
| 4800 | nl_timeout_reason); |
| 4801 | } |
| 4802 | #else |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 4803 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 4804 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4805 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 4806 | const u8 *bssid, |
| 4807 | tSirResultCodes timeout_reason) |
| 4808 | { |
| 4809 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 4810 | } |
| 4811 | #endif |
| 4812 | |
| 4813 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 4814 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 4815 | size_t req_ie_len, const u8 *resp_ie, |
| 4816 | size_t resp_ie_len, int status, gfp_t gfp, |
| 4817 | tSirResultCodes timeout_reason) |
| 4818 | { |
| 4819 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 4820 | resp_ie, resp_ie_len, status, gfp); |
| 4821 | } |
| 4822 | #endif |
| 4823 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4824 | /** |
| 4825 | * hdd_connect_bss() - API to send connection status to supplicant |
| 4826 | * @dev: network device |
| 4827 | * @bssid: bssid to which we want to associate |
| 4828 | * @req_ie: Request Information Element |
| 4829 | * @req_ie_len: len of the req IE |
| 4830 | * @resp_ie: Response IE |
| 4831 | * @resp_ie_len: len of ht response IE |
| 4832 | * @status: status |
| 4833 | * @gfp: Kernel Flag |
| 4834 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4835 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4836 | * |
| 4837 | * The API is a wrapper to send connection status to supplicant |
| 4838 | * |
| 4839 | * Return: Void |
| 4840 | */ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 4841 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 4842 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4843 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 4844 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 4845 | size_t req_ie_len, const u8 *resp_ie, |
| 4846 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4847 | bool connect_timeout, |
| 4848 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4849 | { |
| 4850 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4851 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4852 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4853 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 4854 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4855 | } |
| 4856 | #else |
| 4857 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 4858 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 4859 | size_t req_ie_len, const u8 *resp_ie, |
| 4860 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4861 | bool connect_timeout, |
| 4862 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4863 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4864 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 4865 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4866 | } |
| 4867 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4868 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 4869 | #if defined(WLAN_FEATURE_FILS_SK) |
| 4870 | #if defined(CFG80211_CONNECT_DONE) || \ |
| 4871 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
| 4872 | #if defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 4873 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 4874 | /** |
| 4875 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 4876 | * @fils_params: connect response to supplicant |
| 4877 | * @fils_kek: FILS kek |
| 4878 | * @fils_kek_len: FILS kek length |
| 4879 | * @pmk: FILS PMK |
| 4880 | * @pmk_len: FILS PMK length |
| 4881 | * @pmkid: PMKID |
| 4882 | * @fils_seq_num: FILS Seq number |
| 4883 | * |
| 4884 | * Return: None |
| 4885 | */ |
| 4886 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 4887 | *fils_params, const uint8_t *fils_kek, |
| 4888 | size_t fils_kek_len, const uint8_t *pmk, |
| 4889 | size_t pmk_len, const uint8_t *pmkid, |
| 4890 | uint16_t fils_seq_num) |
| 4891 | { |
| 4892 | /* Increament seq number to be used for next FILS */ |
| 4893 | fils_params->fils_erp_next_seq_num = fils_seq_num + 1; |
| 4894 | fils_params->update_erp_next_seq_num = true; |
| 4895 | fils_params->fils_kek = fils_kek; |
| 4896 | fils_params->fils_kek_len = fils_kek_len; |
| 4897 | fils_params->pmk = pmk; |
| 4898 | fils_params->pmk_len = pmk_len; |
| 4899 | fils_params->pmkid = pmkid; |
| 4900 | } |
| 4901 | #else |
| 4902 | static inline void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 4903 | *fils_params, const uint8_t |
| 4904 | *fils_kek, size_t fils_kek_len, |
| 4905 | const uint8_t *pmk, size_t pmk_len, |
| 4906 | const uint8_t *pmkid, |
| 4907 | uint16_t fils_seq_num) |
| 4908 | { } |
| 4909 | #endif |
| 4910 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 4911 | void hdd_update_hlp_info(struct net_device *dev, tCsrRoamInfo *roam_info) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 4912 | { |
| 4913 | struct sk_buff *skb; |
| 4914 | uint16_t skb_len; |
| 4915 | struct llc_snap_hdr_t *llc_hdr; |
| 4916 | QDF_STATUS status; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 4917 | uint8_t *hlp_data; |
| 4918 | uint16_t hlp_data_len; |
| 4919 | struct fils_join_rsp_params *roam_fils_params |
| 4920 | = roam_info->fils_join_rsp; |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 4921 | struct hdd_adapter *padapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4922 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 4923 | if (!roam_fils_params) { |
| 4924 | hdd_err("FILS Roam Param NULL"); |
| 4925 | return; |
| 4926 | } |
| 4927 | |
| 4928 | if (!roam_fils_params->hlp_data_len || !roam_fils_params->hlp_data) { |
| 4929 | hdd_err("FILS HLP Data NULL, len %d", |
| 4930 | roam_fils_params->hlp_data_len); |
| 4931 | return; |
| 4932 | } |
| 4933 | |
| 4934 | hlp_data = roam_fils_params->hlp_data; |
| 4935 | hlp_data_len = roam_fils_params->hlp_data_len; |
| 4936 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 4937 | /* Calculate skb length */ |
| 4938 | skb_len = (2 * ETH_ALEN) + hlp_data_len; |
| 4939 | skb = qdf_nbuf_alloc(NULL, skb_len, 0, 4, false); |
| 4940 | if (skb == NULL) { |
| 4941 | hdd_err("HLP packet nbuf alloc fails"); |
| 4942 | return; |
| 4943 | } |
| 4944 | |
| 4945 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->dst_mac.bytes, |
| 4946 | QDF_MAC_ADDR_SIZE); |
| 4947 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->src_mac.bytes, |
| 4948 | QDF_MAC_ADDR_SIZE); |
| 4949 | |
| 4950 | llc_hdr = (struct llc_snap_hdr_t *) hlp_data; |
| 4951 | if (IS_SNAP(llc_hdr)) { |
| 4952 | hlp_data += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 4953 | hlp_data_len += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 4954 | } |
| 4955 | |
| 4956 | qdf_mem_copy(skb_put(skb, hlp_data_len), hlp_data, hlp_data_len); |
| 4957 | |
| 4958 | /* |
| 4959 | * This HLP packet is formed from HLP info encapsulated |
| 4960 | * in assoc response frame which is AEAD encrypted. |
| 4961 | * Hence, this checksum validation can be set unnecessary. |
| 4962 | * i.e. network layer need not worry about checksum. |
| 4963 | */ |
| 4964 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 4965 | |
| 4966 | status = hdd_rx_packet_cbk(padapter, skb); |
| 4967 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4968 | hdd_err("Sending HLP packet fails"); |
| 4969 | return; |
| 4970 | } |
| 4971 | hdd_debug("send HLP packet to netif successfully"); |
| 4972 | } |
| 4973 | |
| 4974 | /** |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 4975 | * hdd_connect_done() - Wrapper API to call cfg80211_connect_done |
| 4976 | * @dev: network device |
| 4977 | * @bssid: bssid to which we want to associate |
| 4978 | * @bss: cfg80211 bss info |
| 4979 | * @roam_info: information about connected bss |
| 4980 | * @req_ie: Request Information Element |
| 4981 | * @req_ie_len: len of the req IE |
| 4982 | * @resp_ie: Response IE |
| 4983 | * @resp_ie_len: len of ht response IE |
| 4984 | * @status: status |
| 4985 | * @gfp: allocation flags |
| 4986 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 4987 | * @timeout_reason: reason for connect timeout |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 4988 | * |
| 4989 | * This API is used as wrapper to send FILS key/sequence number |
| 4990 | * params etc. to supplicant in case of FILS connection |
| 4991 | * |
| 4992 | * Return: None |
| 4993 | */ |
| 4994 | static void hdd_connect_done(struct net_device *dev, const u8 *bssid, |
| 4995 | struct cfg80211_bss *bss, tCsrRoamInfo *roam_info, |
| 4996 | const u8 *req_ie, size_t req_ie_len, |
| 4997 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 4998 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 4999 | tSirResultCodes timeout_reason) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5000 | { |
| 5001 | struct cfg80211_connect_resp_params fils_params; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5002 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5003 | struct fils_join_rsp_params *roam_fils_params = |
| 5004 | roam_info->fils_join_rsp; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5005 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5006 | qdf_mem_zero(&fils_params, sizeof(fils_params)); |
| 5007 | |
| 5008 | if (!roam_fils_params) { |
| 5009 | fils_params.status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 5010 | } else { |
| 5011 | fils_params.status = status; |
| 5012 | fils_params.bssid = bssid; |
| 5013 | fils_params.timeout_reason = timeout_reason; |
| 5014 | fils_params.req_ie = req_ie; |
| 5015 | fils_params.req_ie_len = req_ie_len; |
| 5016 | fils_params.resp_ie = resp_ie; |
| 5017 | fils_params.resp_ie_len = resp_ie_len; |
| 5018 | fils_params.bss = bss; |
| 5019 | hdd_populate_fils_params(&fils_params, roam_fils_params->kek, |
| 5020 | roam_fils_params->kek_len, |
| 5021 | roam_fils_params->fils_pmk, |
| 5022 | roam_fils_params->fils_pmk_len, |
| 5023 | roam_fils_params->fils_pmkid, |
| 5024 | roam_info->fils_seq_num); |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 5025 | hdd_save_gtk_params(adapter, roam_info, false); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5026 | } |
| 5027 | hdd_debug("FILS indicate connect status %d seq no %d", |
| 5028 | fils_params.status, |
| 5029 | fils_params.fils_erp_next_seq_num); |
| 5030 | |
| 5031 | cfg80211_connect_done(dev, &fils_params, gfp); |
| 5032 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5033 | if (roam_fils_params && roam_fils_params->hlp_data_len) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5034 | hdd_update_hlp_info(dev, roam_info); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5035 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5036 | /* Clear all the FILS key info */ |
| 5037 | if (roam_fils_params && roam_fils_params->fils_pmk) |
| 5038 | qdf_mem_free(roam_fils_params->fils_pmk); |
| 5039 | if (roam_fils_params) |
| 5040 | qdf_mem_free(roam_fils_params); |
| 5041 | roam_info->fils_join_rsp = NULL; |
| 5042 | } |
| 5043 | #else |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5044 | static inline void |
| 5045 | hdd_connect_done(struct net_device *dev, const u8 *bssid, |
| 5046 | struct cfg80211_bss *bss, tCsrRoamInfo *roam_info, |
| 5047 | const u8 *req_ie, size_t req_ie_len, |
| 5048 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
| 5049 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5050 | tSirResultCodes timeout_reason) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5051 | { } |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5052 | #endif |
| 5053 | #endif |
| 5054 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5055 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 5056 | (defined(CFG80211_CONNECT_DONE) || \ |
| 5057 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5058 | /** |
| 5059 | * hdd_fils_update_connect_results() - API to send fils connection status to |
| 5060 | * supplicant. |
| 5061 | * @dev: network device |
| 5062 | * @bssid: bssid to which we want to associate |
| 5063 | * @bss: cfg80211 bss info |
| 5064 | * @roam_info: information about connected bss |
| 5065 | * @req_ie: Request Information Element |
| 5066 | * @req_ie_len: len of the req IE |
| 5067 | * @resp_ie: Response IE |
| 5068 | * @resp_ie_len: len of ht response IE |
| 5069 | * @status: status |
| 5070 | * @gfp: allocation flags |
| 5071 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5072 | * @timeout_reason: reason for connect timeout |
| 5073 | * |
| 5074 | * The API is a wrapper to send connection status to supplicant |
| 5075 | * |
| 5076 | * Return: 0 if success else failure |
| 5077 | */ |
| 5078 | static int hdd_fils_update_connect_results(struct net_device *dev, |
| 5079 | const u8 *bssid, |
| 5080 | struct cfg80211_bss *bss, |
| 5081 | tCsrRoamInfo *roam_info, const u8 *req_ie, |
| 5082 | size_t req_ie_len, const u8 *resp_ie, |
| 5083 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5084 | bool connect_timeout, |
| 5085 | tSirResultCodes timeout_reason) |
| 5086 | { |
| 5087 | ENTER(); |
| 5088 | if (!roam_info || !roam_info->is_fils_connection) |
| 5089 | return -EINVAL; |
| 5090 | |
| 5091 | hdd_connect_done(dev, bssid, bss, roam_info, req_ie, req_ie_len, |
| 5092 | resp_ie, resp_ie_len, status, gfp, connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5093 | timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5094 | return 0; |
| 5095 | } |
| 5096 | #else |
| 5097 | static inline int hdd_fils_update_connect_results(struct net_device *dev, |
| 5098 | const u8 *bssid, |
| 5099 | struct cfg80211_bss *bss, |
| 5100 | tCsrRoamInfo *roam_info, const u8 *req_ie, |
| 5101 | size_t req_ie_len, const u8 *resp_ie, |
| 5102 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5103 | bool connect_timeout, |
| 5104 | tSirResultCodes timeout_reason) |
| 5105 | { |
| 5106 | return -EINVAL; |
| 5107 | } |
| 5108 | #endif |
| 5109 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5110 | /** |
| 5111 | * hdd_connect_result() - API to send connection status to supplicant |
| 5112 | * @dev: network device |
| 5113 | * @bssid: bssid to which we want to associate |
| 5114 | * @roam_info: information about connected bss |
| 5115 | * @req_ie: Request Information Element |
| 5116 | * @req_ie_len: len of the req IE |
| 5117 | * @resp_ie: Response IE |
| 5118 | * @resp_ie_len: len of ht response IE |
| 5119 | * @status: status |
| 5120 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5121 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5122 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5123 | * |
| 5124 | * The API is a wrapper to send connection status to supplicant |
| 5125 | * and allow runtime suspend |
| 5126 | * |
| 5127 | * Return: Void |
| 5128 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5129 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
| 5130 | tCsrRoamInfo *roam_info, const u8 *req_ie, |
| 5131 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5132 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5133 | bool connect_timeout, |
| 5134 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5135 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5136 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5137 | struct cfg80211_bss *bss = NULL; |
| 5138 | |
| 5139 | if (WLAN_STATUS_SUCCESS == status) { |
| 5140 | struct ieee80211_channel *chan; |
| 5141 | int freq; |
| 5142 | int chan_no = roam_info->pBssDesc->channelId; |
| 5143 | |
| 5144 | if (chan_no <= 14) |
| 5145 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5146 | HDD_NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5147 | else |
| 5148 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5149 | HDD_NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5150 | |
| 5151 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
| 5152 | bss = hdd_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
| 5153 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 5154 | roam_info->u.pConnectedProfile->SSID.length); |
| 5155 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5156 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5157 | if (hdd_fils_update_connect_results(dev, bssid, bss, |
| 5158 | roam_info, req_ie, req_ie_len, resp_ie, |
| 5159 | resp_ie_len, status, gfp, connect_timeout, |
| 5160 | timeout_reason) != 0) { |
| 5161 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 5162 | req_ie_len, resp_ie, resp_ie_len, |
| 5163 | status, gfp, connect_timeout, timeout_reason); |
| 5164 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5165 | |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 5166 | qdf_runtime_pm_allow_suspend(&padapter->connect_rpm_ctx.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5167 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5168 | } |
| 5169 | #else |
| 5170 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
| 5171 | tCsrRoamInfo *roam_info, const u8 *req_ie, |
| 5172 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5173 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5174 | bool connect_timeout, |
| 5175 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5176 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5177 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5178 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5179 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 5180 | resp_ie, resp_ie_len, status, gfp); |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 5181 | |
| 5182 | qdf_runtime_pm_allow_suspend(&padapter->connect_rpm_ctx.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5183 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5184 | } |
| 5185 | #endif |
| 5186 | |
| 5187 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5188 | QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5189 | { |
| 5190 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5191 | QDF_STATUS status; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5192 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5193 | #ifndef MSM_PLATFORM |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5194 | struct qdf_mac_addr bcastMac = QDF_MAC_ADDR_BROADCAST_INITIALIZER; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5195 | #endif |
| 5196 | eConnectionState connState; |
| 5197 | |
| 5198 | ENTER(); |
| 5199 | |
| 5200 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5201 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 5202 | adapter = adapterNode->adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5203 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5204 | if (!hdd_is_interface_up(adapter)) |
Hanumanth Reddy Pothula | c1c4d2b | 2016-09-22 15:45:16 +0530 | [diff] [blame] | 5205 | goto get_adapter; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5206 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5207 | hdd_wmm_init(adapter); |
| 5208 | |
Dustin Brown | a7e6a5c | 2017-07-07 12:52:24 -0700 | [diff] [blame] | 5209 | adapter->scan_info.mScanPending = false; |
| 5210 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5211 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5212 | case QDF_STA_MODE: |
| 5213 | case QDF_P2P_CLIENT_MODE: |
| 5214 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5215 | |
| 5216 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 5217 | ->conn_info.connState; |
| 5218 | |
| 5219 | hdd_init_station_mode(adapter); |
| 5220 | /* Open the gates for HDD to receive Wext commands */ |
| 5221 | adapter->isLinkUpSvcNeeded = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5222 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5223 | /* Indicate disconnect event to supplicant |
| 5224 | * if associated previously |
| 5225 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5226 | if (eConnectionState_Associated == connState || |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 5227 | eConnectionState_IbssConnected == connState || |
| 5228 | eConnectionState_NotConnected == connState || |
| 5229 | eConnectionState_IbssDisconnected == connState || |
| 5230 | eConnectionState_Disconnecting == connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5231 | union iwreq_data wrqu; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5232 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5233 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5234 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5235 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5236 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 5237 | &wrqu, NULL); |
| 5238 | adapter->sessionCtx.station. |
Jeff Johnson | 690fe95 | 2017-10-25 11:48:39 -0700 | [diff] [blame] | 5239 | hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5240 | |
| 5241 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 5242 | wlan_hdd_cfg80211_indicate_disconnect( |
| 5243 | adapter->dev, false, |
| 5244 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5245 | } else if (eConnectionState_Connecting == connState) { |
| 5246 | /* |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5247 | * Indicate connect failure to supplicant if we |
| 5248 | * were in the process of connecting |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5249 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5250 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5251 | NULL, 0, NULL, 0, |
| 5252 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5253 | GFP_KERNEL, false, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5254 | } |
| 5255 | |
| 5256 | hdd_register_tx_flow_control(adapter, |
| 5257 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 5258 | hdd_tx_resume_cb, |
| 5259 | hdd_tx_flow_control_is_pause); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5260 | |
| 5261 | break; |
| 5262 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5263 | case QDF_SAP_MODE: |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5264 | if (hdd_ctx->config->sap_internal_restart) |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5265 | hdd_init_ap_mode(adapter, true); |
| 5266 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5267 | break; |
| 5268 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5269 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5270 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5271 | hdd_debug("[SSR] send stop ap to supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5272 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 5273 | #else |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5274 | hdd_debug("[SSR] send restart supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5275 | /* event supplicant to restart */ |
| 5276 | cfg80211_del_sta(adapter->dev, |
| 5277 | (const u8 *)&bcastMac.bytes[0], |
| 5278 | GFP_KERNEL); |
| 5279 | #endif |
| 5280 | break; |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 5281 | case QDF_MONITOR_MODE: |
| 5282 | hdd_init_station_mode(adapter); |
| 5283 | hdd_set_mon_rx_cb(adapter->dev); |
| 5284 | wlan_hdd_set_mon_chan(adapter, adapter->mon_chan, |
| 5285 | adapter->mon_bandwidth); |
| 5286 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5287 | default: |
| 5288 | break; |
| 5289 | } |
Krunal Soni | 9c2ee03 | 2017-07-18 13:49:54 -0700 | [diff] [blame] | 5290 | /* |
| 5291 | * Action frame registered in one adapter which will |
| 5292 | * applicable to all interfaces |
| 5293 | */ |
| 5294 | wlan_hdd_cfg80211_register_frames(adapter); |
| 5295 | |
Hanumanth Reddy Pothula | c1c4d2b | 2016-09-22 15:45:16 +0530 | [diff] [blame] | 5296 | get_adapter: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5297 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 5298 | adapterNode = pNext; |
| 5299 | } |
| 5300 | |
| 5301 | EXIT(); |
| 5302 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5303 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5304 | } |
| 5305 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5306 | QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5307 | hdd_adapter_list_node_t **padapterNode) |
| 5308 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5309 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5310 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5311 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5312 | status = qdf_list_peek_front(&hdd_ctx->hddAdapters, |
| 5313 | (qdf_list_node_t **) padapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5314 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5315 | return status; |
| 5316 | } |
| 5317 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5318 | QDF_STATUS hdd_get_next_adapter(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5319 | hdd_adapter_list_node_t *adapterNode, |
| 5320 | hdd_adapter_list_node_t **pNextAdapterNode) |
| 5321 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5322 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5323 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5324 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5325 | status = qdf_list_peek_next(&hdd_ctx->hddAdapters, |
| 5326 | (qdf_list_node_t *) adapterNode, |
| 5327 | (qdf_list_node_t **) pNextAdapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5328 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5329 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5330 | return status; |
| 5331 | } |
| 5332 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5333 | QDF_STATUS hdd_remove_adapter(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5334 | hdd_adapter_list_node_t *adapterNode) |
| 5335 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5336 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5337 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5338 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5339 | status = qdf_list_remove_node(&hdd_ctx->hddAdapters, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5340 | &adapterNode->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5341 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5342 | return status; |
| 5343 | } |
| 5344 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5345 | QDF_STATUS hdd_remove_front_adapter(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5346 | hdd_adapter_list_node_t **padapterNode) |
| 5347 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5348 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5349 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5350 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5351 | status = qdf_list_remove_front(&hdd_ctx->hddAdapters, |
| 5352 | (qdf_list_node_t **) padapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5353 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5354 | return status; |
| 5355 | } |
| 5356 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5357 | QDF_STATUS hdd_add_adapter_back(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5358 | hdd_adapter_list_node_t *adapterNode) |
| 5359 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5360 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5361 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5362 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5363 | status = qdf_list_insert_back(&hdd_ctx->hddAdapters, |
| 5364 | (qdf_list_node_t *) adapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5365 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5366 | return status; |
| 5367 | } |
| 5368 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5369 | QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5370 | hdd_adapter_list_node_t *adapterNode) |
| 5371 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5372 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5373 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5374 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5375 | status = qdf_list_insert_front(&hdd_ctx->hddAdapters, |
| 5376 | (qdf_list_node_t *) adapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5377 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5378 | return status; |
| 5379 | } |
| 5380 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5381 | 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] | 5382 | tSirMacAddr macAddr) |
| 5383 | { |
| 5384 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5385 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5386 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5387 | |
| 5388 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 5389 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5390 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 5391 | adapter = adapterNode->adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5392 | |
| 5393 | if (adapter |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5394 | && !qdf_mem_cmp(adapter->macAddressCurrent.bytes, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5395 | macAddr, sizeof(tSirMacAddr))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5396 | return adapter; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5397 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5398 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 5399 | adapterNode = pNext; |
| 5400 | } |
| 5401 | |
| 5402 | return NULL; |
| 5403 | |
| 5404 | } |
| 5405 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5406 | 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] | 5407 | uint32_t vdev_id) |
| 5408 | { |
| 5409 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5410 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5411 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5412 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5413 | qdf_status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5414 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5415 | while ((NULL != adapterNode) && (QDF_STATUS_SUCCESS == qdf_status)) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 5416 | adapter = adapterNode->adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5417 | |
| 5418 | if (adapter->sessionId == vdev_id) |
| 5419 | return adapter; |
| 5420 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5421 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5422 | hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 5423 | adapterNode = pNext; |
| 5424 | } |
| 5425 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5426 | hdd_err("vdev_id %d does not exist with host", vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5427 | |
| 5428 | return NULL; |
| 5429 | } |
| 5430 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5431 | /** |
| 5432 | * hdd_get_adapter_by_sme_session_id() - Return adapter with |
| 5433 | * the sessionid |
| 5434 | * @hdd_ctx: hdd context. |
| 5435 | * @sme_session_id: sme session is for the adapter to get. |
| 5436 | * |
| 5437 | * This function is used to get the adapter with provided session id |
| 5438 | * |
| 5439 | * Return: adapter pointer if found |
| 5440 | * |
| 5441 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 5442 | struct hdd_adapter * |
| 5443 | hdd_get_adapter_by_sme_session_id(struct hdd_context *hdd_ctx, |
| 5444 | uint32_t sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5445 | { |
| 5446 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5447 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5448 | QDF_STATUS qdf_status; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5449 | |
| 5450 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5451 | qdf_status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5452 | |
| 5453 | while ((NULL != adapter_node) && |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5454 | (QDF_STATUS_SUCCESS == qdf_status)) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 5455 | adapter = adapter_node->adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5456 | |
| 5457 | if (adapter && |
| 5458 | adapter->sessionId == sme_session_id) |
| 5459 | return adapter; |
| 5460 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5461 | qdf_status = |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5462 | hdd_get_next_adapter(hdd_ctx, |
| 5463 | adapter_node, &next); |
| 5464 | adapter_node = next; |
| 5465 | } |
| 5466 | return NULL; |
| 5467 | } |
| 5468 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5469 | 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] | 5470 | const char *iface_name) |
| 5471 | { |
| 5472 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5473 | struct hdd_adapter *adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 5474 | QDF_STATUS qdf_status; |
| 5475 | |
| 5476 | qdf_status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 5477 | |
| 5478 | while ((NULL != adapter_node) && |
| 5479 | (QDF_STATUS_SUCCESS == qdf_status)) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 5480 | adapter = adapter_node->adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 5481 | |
| 5482 | if (adapter && |
| 5483 | !qdf_str_cmp(adapter->dev->name, iface_name)) |
| 5484 | return adapter; |
| 5485 | |
| 5486 | qdf_status = |
| 5487 | hdd_get_next_adapter(hdd_ctx, |
| 5488 | adapter_node, &next); |
| 5489 | adapter_node = next; |
| 5490 | } |
| 5491 | return NULL; |
| 5492 | } |
| 5493 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5494 | /** |
| 5495 | * hdd_get_adapter() - to get adapter matching the mode |
| 5496 | * @hdd_ctx: hdd context |
| 5497 | * @mode: adapter mode |
| 5498 | * |
| 5499 | * This routine will return the pointer to adapter matching |
| 5500 | * with the passed mode. |
| 5501 | * |
| 5502 | * Return: pointer to adapter or null |
| 5503 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5504 | struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx, |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5505 | enum tQDF_ADAPTER_MODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5506 | { |
| 5507 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5508 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5509 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5510 | |
| 5511 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 5512 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5513 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 5514 | adapter = adapterNode->adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5515 | |
| 5516 | if (adapter && (mode == adapter->device_mode)) |
| 5517 | return adapter; |
| 5518 | |
| 5519 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 5520 | adapterNode = pNext; |
| 5521 | } |
| 5522 | |
| 5523 | return NULL; |
| 5524 | |
| 5525 | } |
| 5526 | |
| 5527 | /** |
| 5528 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 5529 | * @hdd_ctx: Pointer to the HDD context. |
| 5530 | * @mode: Device mode for which operating channel is required. |
| 5531 | * Suported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5532 | * QDF_STA_MODE, |
| 5533 | * QDF_P2P_CLIENT_MODE, |
| 5534 | * QDF_SAP_MODE, |
| 5535 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5536 | * |
| 5537 | * This API returns the operating channel of the requested device mode |
| 5538 | * |
| 5539 | * Return: channel number. "0" id the requested device is not found OR it is |
| 5540 | * not connected. |
| 5541 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5542 | uint8_t hdd_get_operating_channel(struct hdd_context *hdd_ctx, |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5543 | enum tQDF_ADAPTER_MODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5544 | { |
| 5545 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5546 | QDF_STATUS status; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5547 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5548 | uint8_t operatingChannel = 0; |
| 5549 | |
| 5550 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 5551 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5552 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 5553 | adapter = adapterNode->adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5554 | |
| 5555 | if (mode == adapter->device_mode) { |
| 5556 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5557 | case QDF_STA_MODE: |
| 5558 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5559 | if (hdd_conn_is_connected |
| 5560 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 5561 | (adapter))) { |
| 5562 | operatingChannel = |
| 5563 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 5564 | (adapter))->conn_info. |
| 5565 | operationChannel; |
| 5566 | } |
| 5567 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5568 | case QDF_SAP_MODE: |
| 5569 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5570 | /* softap connection info */ |
| 5571 | if (test_bit |
| 5572 | (SOFTAP_BSS_STARTED, |
| 5573 | &adapter->event_flags)) |
| 5574 | operatingChannel = |
| 5575 | (WLAN_HDD_GET_AP_CTX_PTR |
| 5576 | (adapter))->operatingChannel; |
| 5577 | break; |
| 5578 | default: |
| 5579 | break; |
| 5580 | } |
| 5581 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5582 | /* Found the device of interest. break the loop */ |
| 5583 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5584 | } |
| 5585 | |
| 5586 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 5587 | adapterNode = pNext; |
| 5588 | } |
| 5589 | return operatingChannel; |
| 5590 | } |
| 5591 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5592 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5593 | hdd_ctx) |
| 5594 | { |
| 5595 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5596 | QDF_STATUS status; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5597 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5598 | |
| 5599 | ENTER(); |
| 5600 | |
| 5601 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 5602 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5603 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 5604 | adapter = adapterNode->adapter; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5605 | if ((adapter->device_mode == QDF_STA_MODE) || |
| 5606 | (adapter->device_mode == QDF_P2P_CLIENT_MODE) || |
| 5607 | (adapter->device_mode == QDF_IBSS_MODE) || |
| 5608 | (adapter->device_mode == QDF_P2P_DEVICE_MODE) || |
| 5609 | (adapter->device_mode == QDF_SAP_MODE) || |
| 5610 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5611 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 5612 | hdd_unregister_wext(adapter->dev); |
| 5613 | } |
| 5614 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 5615 | adapterNode = pNext; |
| 5616 | } |
| 5617 | |
| 5618 | EXIT(); |
| 5619 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5620 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5621 | } |
| 5622 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5623 | 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] | 5624 | { |
| 5625 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5626 | QDF_STATUS status; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5627 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5628 | |
| 5629 | ENTER(); |
| 5630 | |
| 5631 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 5632 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5633 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 5634 | adapter = adapterNode->adapter; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5635 | if ((adapter->device_mode == QDF_STA_MODE) || |
| 5636 | (adapter->device_mode == QDF_P2P_CLIENT_MODE) || |
| 5637 | (adapter->device_mode == QDF_IBSS_MODE) || |
| 5638 | (adapter->device_mode == QDF_P2P_DEVICE_MODE) || |
| 5639 | (adapter->device_mode == QDF_SAP_MODE) || |
| 5640 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 5641 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
| 5642 | adapter->sessionId, INVALID_SCAN_ID, |
| 5643 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5644 | } |
| 5645 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 5646 | adapterNode = pNext; |
| 5647 | } |
| 5648 | |
| 5649 | EXIT(); |
| 5650 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5651 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5652 | } |
| 5653 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5654 | /** |
| 5655 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 5656 | * adapters |
| 5657 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 5658 | * |
| 5659 | * return: QDF_STATUS_SUCCESS |
| 5660 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5661 | 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] | 5662 | { |
| 5663 | hdd_adapter_list_node_t *adapter_node = NULL, *next_node = NULL; |
| 5664 | QDF_STATUS status; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5665 | struct hdd_adapter *adapter; |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5666 | int err; |
| 5667 | |
| 5668 | ENTER(); |
| 5669 | |
| 5670 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 5671 | |
| 5672 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 5673 | adapter = adapter_node->adapter; |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5674 | if ((adapter->device_mode == QDF_STA_MODE) || |
| 5675 | (adapter->device_mode == QDF_P2P_CLIENT_MODE) || |
| 5676 | (adapter->device_mode == QDF_IBSS_MODE) || |
| 5677 | (adapter->device_mode == QDF_P2P_DEVICE_MODE) || |
| 5678 | (adapter->device_mode == QDF_SAP_MODE) || |
| 5679 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
| 5680 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 5681 | if (err) |
| 5682 | hdd_err("Unable to stop scheduled scan"); |
| 5683 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5684 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, |
| 5685 | &next_node); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5686 | adapter_node = next_node; |
| 5687 | } |
| 5688 | |
| 5689 | EXIT(); |
| 5690 | |
| 5691 | return QDF_STATUS_SUCCESS; |
| 5692 | } |
| 5693 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5694 | #ifdef WLAN_NS_OFFLOAD |
| 5695 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5696 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5697 | * @hdd_ctx: Pointer to hdd context |
| 5698 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5699 | * Unregister for IPv6 address change notifications. |
| 5700 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5701 | * Return: None |
| 5702 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5703 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5704 | { |
| 5705 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5706 | } |
| 5707 | |
| 5708 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5709 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5710 | * @hdd_ctx: Pointer to hdd context |
| 5711 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5712 | * Register for IPv6 address change notifications. |
| 5713 | * |
| 5714 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5715 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5716 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5717 | { |
| 5718 | int ret; |
| 5719 | |
| 5720 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 5721 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5722 | if (ret) { |
| 5723 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 5724 | goto out; |
| 5725 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5726 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5727 | hdd_debug("Registered IPv6 notifier"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5728 | out: |
| 5729 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5730 | } |
| 5731 | #else |
| 5732 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5733 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5734 | * @hdd_ctx: Pointer to hdd context |
| 5735 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5736 | * Unregister for IPv6 address change notifications. |
| 5737 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5738 | * Return: None |
| 5739 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5740 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5741 | { |
| 5742 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5743 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5744 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5745 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5746 | * @hdd_ctx: Pointer to hdd context |
| 5747 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5748 | * Register for IPv6 address change notifications. |
| 5749 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5750 | * Return: None |
| 5751 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5752 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5753 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5754 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5755 | } |
| 5756 | #endif |
| 5757 | |
| 5758 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5759 | * hdd_register_notifiers - Register netdev notifiers. |
| 5760 | * @hdd_ctx: HDD context |
| 5761 | * |
| 5762 | * Register netdev notifiers like IPv4 and IPv6. |
| 5763 | * |
| 5764 | * Return: 0 on success and errno on failure |
| 5765 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5766 | static int hdd_register_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5767 | { |
| 5768 | int ret; |
| 5769 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5770 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 5771 | if (ret) |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 5772 | goto out; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5773 | |
| 5774 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 5775 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 5776 | if (ret) { |
| 5777 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 5778 | goto unregister_ip6_notifier; |
| 5779 | } |
| 5780 | |
| 5781 | return 0; |
| 5782 | |
| 5783 | unregister_ip6_notifier: |
| 5784 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5785 | out: |
| 5786 | return ret; |
| 5787 | |
| 5788 | } |
| 5789 | |
| 5790 | /** |
| 5791 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 5792 | * @hdd_ctx: HDD context |
| 5793 | * |
| 5794 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 5795 | * |
| 5796 | * Return: None. |
| 5797 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5798 | void hdd_unregister_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5799 | { |
| 5800 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 5801 | |
| 5802 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5803 | } |
| 5804 | |
| 5805 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5806 | * hdd_exit_netlink_services - Exit netlink services |
| 5807 | * @hdd_ctx: HDD context |
| 5808 | * |
| 5809 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 5810 | * nl service. |
| 5811 | * |
| 5812 | * Return: None. |
| 5813 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5814 | static void hdd_exit_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5815 | { |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5816 | hdd_close_cesium_nl_sock(); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 5817 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5818 | ptt_sock_deactivate_svc(); |
| 5819 | |
| 5820 | nl_srv_exit(); |
| 5821 | } |
| 5822 | |
| 5823 | /** |
| 5824 | * hdd_init_netlink_services- Init netlink services |
| 5825 | * @hdd_ctx: HDD context |
| 5826 | * |
| 5827 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 5828 | * nl service. |
| 5829 | * |
| 5830 | * Return: 0 on success and errno on failure. |
| 5831 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5832 | static int hdd_init_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5833 | { |
| 5834 | int ret; |
| 5835 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 5836 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5837 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5838 | hdd_err("nl_srv_init failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5839 | goto out; |
| 5840 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 5841 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5842 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 5843 | ret = hdd_activate_wifi_pos(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5844 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5845 | hdd_err("hdd_activate_wifi_pos failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5846 | goto err_nl_srv; |
| 5847 | } |
| 5848 | |
| 5849 | ret = ptt_sock_activate_svc(); |
| 5850 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5851 | hdd_err("ptt_sock_activate_svc failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5852 | goto err_nl_srv; |
| 5853 | } |
| 5854 | |
| 5855 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 5856 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5857 | hdd_err("hdd_open_cesium_nl_sock failed ret: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5858 | |
| 5859 | ret = cnss_diag_activate_service(); |
| 5860 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5861 | hdd_err("cnss_diag_activate_service failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5862 | goto err_close_cesium; |
| 5863 | } |
| 5864 | |
| 5865 | return 0; |
| 5866 | |
| 5867 | err_close_cesium: |
| 5868 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5869 | ptt_sock_deactivate_svc(); |
| 5870 | err_nl_srv: |
| 5871 | nl_srv_exit(); |
| 5872 | out: |
| 5873 | return ret; |
| 5874 | } |
| 5875 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5876 | /** |
| 5877 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 5878 | * @hdd_ctx: HDD context. |
| 5879 | * |
| 5880 | * Destroy RX wakelock. |
| 5881 | * |
| 5882 | * Return: None. |
| 5883 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5884 | static void hdd_rx_wake_lock_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5885 | { |
| 5886 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 5887 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5888 | |
| 5889 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5890 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 5891 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5892 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5893 | * Create RX wakelock. |
| 5894 | * |
| 5895 | * Return: None. |
| 5896 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5897 | static void hdd_rx_wake_lock_create(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5898 | { |
| 5899 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 5900 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5901 | |
| 5902 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5903 | * hdd_context_deinit() - Deinitialize HDD context |
| 5904 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5905 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5906 | * Deinitialize HDD context along with all the feature specific contexts but |
| 5907 | * do not free hdd context itself. Caller of this API is supposed to free |
| 5908 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5909 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5910 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5911 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5912 | static int hdd_context_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5913 | { |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5914 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5915 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5916 | hdd_sap_context_destroy(hdd_ctx); |
| 5917 | |
| 5918 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 5919 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5920 | hdd_scan_context_destroy(hdd_ctx); |
| 5921 | |
| 5922 | qdf_list_destroy(&hdd_ctx->hddAdapters); |
| 5923 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5924 | return 0; |
| 5925 | } |
| 5926 | |
| 5927 | /** |
| 5928 | * hdd_context_destroy() - Destroy HDD context |
| 5929 | * @hdd_ctx: HDD context to be destroyed. |
| 5930 | * |
| 5931 | * Free config and HDD context as well as destroy all the resources. |
| 5932 | * |
| 5933 | * Return: None |
| 5934 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5935 | static void hdd_context_destroy(struct hdd_context *hdd_ctx) |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5936 | { |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 5937 | cds_set_context(QDF_MODULE_ID_HDD, NULL); |
Arunk Khandavalli | 3d267b4 | 2017-05-02 18:58:59 +0530 | [diff] [blame] | 5938 | |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 5939 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 5940 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5941 | hdd_context_deinit(hdd_ctx); |
| 5942 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5943 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5944 | hdd_ctx->config = NULL; |
| 5945 | |
| 5946 | wiphy_free(hdd_ctx->wiphy); |
| 5947 | } |
| 5948 | |
| 5949 | /** |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 5950 | * wlan_destroy_bug_report_lock() - Destroy bug report lock |
| 5951 | * |
| 5952 | * This function is used to destroy bug report lock |
| 5953 | * |
| 5954 | * Return: None |
| 5955 | */ |
| 5956 | static void wlan_destroy_bug_report_lock(void) |
| 5957 | { |
| 5958 | p_cds_contextType p_cds_context; |
| 5959 | |
| 5960 | p_cds_context = cds_get_global_context(); |
| 5961 | if (!p_cds_context) { |
| 5962 | hdd_err("cds context is NULL"); |
| 5963 | return; |
| 5964 | } |
| 5965 | |
| 5966 | qdf_spinlock_destroy(&p_cds_context->bug_report_lock); |
| 5967 | } |
| 5968 | |
| 5969 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5970 | * hdd_wlan_exit() - HDD WLAN exit function |
| 5971 | * @hdd_ctx: Pointer to the HDD Context |
| 5972 | * |
| 5973 | * This is the driver exit point (invoked during rmmod) |
| 5974 | * |
| 5975 | * Return: None |
| 5976 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5977 | static void hdd_wlan_exit(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5978 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5979 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5980 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5981 | int driver_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5982 | |
| 5983 | ENTER(); |
| 5984 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5985 | if (QDF_TIMER_STATE_RUNNING == |
| 5986 | qdf_mc_timer_get_current_state(&hdd_ctx->iface_change_timer)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5987 | hdd_debug("Stop interface change timer"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5988 | qdf_mc_timer_stop(&hdd_ctx->iface_change_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5989 | } |
| 5990 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5991 | if (!QDF_IS_STATUS_SUCCESS |
| 5992 | (qdf_mc_timer_destroy(&hdd_ctx->iface_change_timer))) |
| 5993 | hdd_err("Cannot delete interface change timer"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5994 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5995 | |
| 5996 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5997 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 5998 | hdd_bus_bandwidth_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5999 | |
| 6000 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6001 | if (QDF_TIMER_STATE_RUNNING == |
| 6002 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 6003 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6004 | } |
| 6005 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6006 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6007 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 6008 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6009 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6010 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6011 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6012 | hdd_ctx->last_acs_channel_list = NULL; |
| 6013 | hdd_ctx->num_of_channels = 0; |
| 6014 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6015 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6016 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6017 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 6018 | driver_status = hdd_ctx->driver_status; |
| 6019 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 6020 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6021 | /* |
| 6022 | * Powersave Offload Case |
| 6023 | * Disable Idle Power Save Mode |
| 6024 | */ |
| 6025 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 6026 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6027 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 6028 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 6029 | /* |
| 6030 | * Cancel any outstanding scan requests. We are about to close |
| 6031 | * all of our adapters, but an adapter structure is what SME |
| 6032 | * passes back to our callback function. Hence if there |
| 6033 | * are any outstanding scan requests then there is a |
| 6034 | * race condition between when the adapter is closed and |
| 6035 | * when the callback is invoked. We try to resolve that |
| 6036 | * race condition here by canceling any outstanding scans |
| 6037 | * before we close the adapters. |
| 6038 | * Note that the scans may be cancelled in an asynchronous |
| 6039 | * manner, so ideally there needs to be some kind of |
| 6040 | * synchronization. Rather than introduce a new |
| 6041 | * synchronization here, we will utilize the fact that we are |
| 6042 | * about to Request Full Power, and since that is synchronized, |
| 6043 | * the expectation is that by the time Request Full Power has |
| 6044 | * completed, all scans will be cancelled |
| 6045 | */ |
Sandeep Puligilla | 8de3c1c | 2017-04-13 17:56:18 -0700 | [diff] [blame] | 6046 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6047 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6048 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 6049 | hdd_stop_all_adapters(hdd_ctx, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6050 | } |
| 6051 | |
| 6052 | /* |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6053 | * Close the scheduler before calling cds_close to make sure |
| 6054 | * no thread is scheduled after the each module close is |
| 6055 | * is called i.e after all the data structures are freed. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6056 | */ |
Jeff Johnson | 7d56227 | 2017-09-13 15:12:54 -0700 | [diff] [blame] | 6057 | qdf_status = cds_sched_close(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6058 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 6059 | hdd_alert("Failed to close CDS Scheduler"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 6060 | QDF_ASSERT(QDF_IS_STATUS_SUCCESS(qdf_status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6061 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6062 | |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6063 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 6064 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 6065 | hdd_wlan_stop_modules(hdd_ctx, false); |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 6066 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 6067 | qdf_nbuf_deinit_replenish_timer(); |
| 6068 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 6069 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
| 6070 | qdf_spinlock_destroy(&hdd_ctx->sta_update_info_lock); |
| 6071 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
| 6072 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6073 | /* |
| 6074 | * Close CDS |
| 6075 | * This frees pMac(HAL) context. There should not be any call |
| 6076 | * that requires pMac access after this. |
| 6077 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6078 | |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 6079 | hdd_green_ap_deinit(hdd_ctx); |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 6080 | hdd_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6081 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6082 | hdd_close_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6083 | |
| 6084 | hdd_ipa_cleanup(hdd_ctx); |
| 6085 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 6086 | wlansap_global_deinit(); |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 6087 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6088 | /* |
| 6089 | * If there is re_init failure wiphy would have already de-registered |
| 6090 | * check the wiphy status before un-registering again |
| 6091 | */ |
Ashish Kumar Dhanotiya | e16feb7 | 2017-03-31 19:39:37 +0530 | [diff] [blame] | 6092 | if (wiphy && wiphy->registered) { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6093 | wiphy_unregister(wiphy); |
| 6094 | wlan_hdd_cfg80211_deinit(wiphy); |
| 6095 | hdd_lpass_notify_stop(hdd_ctx); |
| 6096 | } |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 6097 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6098 | hdd_exit_netlink_services(hdd_ctx); |
| 6099 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 6100 | #ifdef FEATURE_WLAN_CH_AVOID |
| 6101 | mutex_destroy(&hdd_ctx->avoid_freq_lock); |
| 6102 | #endif |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6103 | |
| 6104 | driver_status = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 6105 | if (driver_status) |
| 6106 | hdd_err("Pdev delete failed"); |
| 6107 | |
| 6108 | driver_status = hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 6109 | if (driver_status) |
| 6110 | hdd_err("Psoc delete failed"); |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 6111 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6112 | hdd_context_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6113 | } |
| 6114 | |
| 6115 | void __hdd_wlan_exit(void) |
| 6116 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6117 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6118 | |
| 6119 | ENTER(); |
| 6120 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6121 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6122 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6123 | hdd_err("Invalid HDD Context"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6124 | EXIT(); |
| 6125 | return; |
| 6126 | } |
| 6127 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 6128 | memdump_deinit(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 6129 | hdd_driver_memdump_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 6130 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6131 | /* Do all the cleanup before deregistering the driver */ |
| 6132 | hdd_wlan_exit(hdd_ctx); |
Mohit Khanna | ebf8a86 | 2016-04-28 17:53:59 -0700 | [diff] [blame] | 6133 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6134 | EXIT(); |
| 6135 | } |
| 6136 | |
| 6137 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6138 | /** |
| 6139 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6140 | * @data: pointer to struct hdd_context |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6141 | * |
| 6142 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 6143 | * Then new ACS request will do a fresh scan without reusing the cached |
| 6144 | * scan information. |
| 6145 | * |
| 6146 | * Return: void |
| 6147 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 6148 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6149 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6150 | struct hdd_context *hdd_ctx = (struct hdd_context *) data; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6151 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6152 | hdd_debug("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6153 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6154 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6155 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6156 | hdd_ctx->last_acs_channel_list = NULL; |
| 6157 | hdd_ctx->num_of_channels = 0; |
| 6158 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6159 | |
| 6160 | if (!hdd_ctx->hHal) |
| 6161 | return; |
| 6162 | sme_scan_flush_result(hdd_ctx->hHal); |
| 6163 | } |
| 6164 | #endif |
| 6165 | |
| 6166 | #ifdef QCA_HT_2040_COEX |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6167 | int hdd_wlan_set_ht2040_mode(struct hdd_adapter *adapter, uint16_t sta_id, |
| 6168 | struct qdf_mac_addr sta_mac, int channel_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6169 | { |
| 6170 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6171 | QDF_STATUS qdf_status; |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6172 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6173 | |
| 6174 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6175 | |
| 6176 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6177 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6178 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6179 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6180 | if (!hdd_ctx->hHal) |
| 6181 | return -EINVAL; |
| 6182 | |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6183 | qdf_status = sme_notify_ht2040_mode(hdd_ctx->hHal, sta_id, sta_mac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6184 | adapter->sessionId, channel_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6185 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6186 | hdd_err("Fail to send notification with ht2040 mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6187 | return -EINVAL; |
| 6188 | } |
| 6189 | |
| 6190 | return 0; |
| 6191 | } |
| 6192 | #endif |
| 6193 | |
| 6194 | /** |
| 6195 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 6196 | * @state: state |
| 6197 | * |
| 6198 | * This function notifies FW with modem power status |
| 6199 | * |
| 6200 | * Return: 0 if successful, error number otherwise |
| 6201 | */ |
| 6202 | int hdd_wlan_notify_modem_power_state(int state) |
| 6203 | { |
| 6204 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6205 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6206 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6207 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6208 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6209 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6210 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6211 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6212 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6213 | if (!hdd_ctx->hHal) |
| 6214 | return -EINVAL; |
| 6215 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6216 | qdf_status = sme_notify_modem_power_state(hdd_ctx->hHal, state); |
| 6217 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6218 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6219 | state); |
| 6220 | return -EINVAL; |
| 6221 | } |
| 6222 | return 0; |
| 6223 | } |
| 6224 | |
| 6225 | /** |
| 6226 | * |
| 6227 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 6228 | * @adapter - Pointer to the HDD |
| 6229 | * |
| 6230 | * Return: None |
| 6231 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6232 | QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6233 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6234 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6235 | |
| 6236 | /* |
| 6237 | * Send ready indication to the HDD. This will kick off the MAC |
| 6238 | * into a 'running' state and should kick off an initial scan. |
| 6239 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6240 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->hHal); |
| 6241 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6242 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 6243 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6244 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6245 | } |
| 6246 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6247 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6248 | } |
| 6249 | |
| 6250 | /* wake lock APIs for HDD */ |
| 6251 | void hdd_prevent_suspend(uint32_t reason) |
| 6252 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 6253 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6254 | } |
| 6255 | |
| 6256 | void hdd_allow_suspend(uint32_t reason) |
| 6257 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 6258 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6259 | } |
| 6260 | |
| 6261 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 6262 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 6263 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 6264 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6265 | } |
| 6266 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6267 | /* Initialize channel list in sme based on the country code */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6268 | QDF_STATUS hdd_set_sme_chan_list(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6269 | { |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 6270 | |
Amar Singhal | 6f8592b | 2017-04-26 14:31:58 -0700 | [diff] [blame] | 6271 | return sme_init_chan_list(hdd_ctx->hHal, |
| 6272 | hdd_ctx->reg.alpha2, |
| 6273 | hdd_ctx->reg.cc_src); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6274 | } |
| 6275 | |
| 6276 | /** |
| 6277 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 6278 | * @hdd_ctx: Pointer to the hdd context |
| 6279 | * |
| 6280 | * HDD function to know if hardware supports 5GHz |
| 6281 | * |
| 6282 | * Return: true if hardware supports 5GHz |
| 6283 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6284 | bool hdd_is_5g_supported(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6285 | { |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 6286 | if (!hdd_ctx) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 6287 | return true; |
| 6288 | |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 6289 | if (hdd_ctx->curr_band != eCSR_BAND_24) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 6290 | return true; |
| 6291 | else |
| 6292 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6293 | } |
| 6294 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6295 | static int hdd_wiphy_init(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6296 | { |
| 6297 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6298 | int ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6299 | |
| 6300 | wiphy = hdd_ctx->wiphy; |
| 6301 | |
| 6302 | /* |
| 6303 | * The channel information in |
| 6304 | * wiphy needs to be initialized before wiphy registration |
| 6305 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6306 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 6307 | if (ret_val) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6308 | hdd_err("regulatory init failed"); |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6309 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6310 | } |
| 6311 | |
| 6312 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 6313 | wiphy->wowlan = &wowlan_support_reg_init; |
| 6314 | #else |
| 6315 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 6316 | WIPHY_WOWLAN_MAGIC_PKT | |
| 6317 | WIPHY_WOWLAN_DISCONNECT | |
| 6318 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 6319 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 6320 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 6321 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 6322 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 6323 | |
| 6324 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 6325 | WOW_MAX_FILTERS_PER_LIST); |
| 6326 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 6327 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 6328 | #endif |
| 6329 | |
| 6330 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6331 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 6332 | if (0 > ret_val) { |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6333 | hdd_err("wiphy registration failed"); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 6334 | return ret_val; |
| 6335 | } |
| 6336 | |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 6337 | if (!hdd_ctx->reg_offload) |
| 6338 | hdd_program_country_code(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6339 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6340 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6341 | } |
| 6342 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6343 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6344 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6345 | * @hdd_ctx - handle to hdd context |
| 6346 | * @tx_packets - transmit packet count |
| 6347 | * @rx_packets - receive packet count |
| 6348 | * |
| 6349 | * The function controls the bus bandwidth and dynamic control of |
| 6350 | * tcp delayed ack configuration |
| 6351 | * |
| 6352 | * Returns: None |
| 6353 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6354 | #ifdef MSM_PLATFORM |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6355 | static void hdd_pld_request_bus_bandwidth(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 6356 | const uint64_t tx_packets, |
| 6357 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6358 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6359 | uint64_t total = tx_packets + rx_packets; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6360 | uint64_t temp_rx = 0; |
| 6361 | uint64_t temp_tx = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6362 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 6363 | static enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6364 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6365 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6366 | uint16_t index = 0; |
| 6367 | bool vote_level_change = false; |
| 6368 | bool rx_level_change = false; |
| 6369 | bool tx_level_change = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6370 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6371 | if (total > hdd_ctx->config->busBandwidthHighThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6372 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6373 | else if (total > hdd_ctx->config->busBandwidthMediumThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6374 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 6375 | else if (total > hdd_ctx->config->busBandwidthLowThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6376 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 6377 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6378 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6379 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6380 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6381 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 6382 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6383 | hdd_ctx->cur_vote_level = next_vote_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6384 | vote_level_change = true; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6385 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6386 | if (next_vote_level == PLD_BUS_WIDTH_LOW) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 6387 | if (hdd_ctx->hbw_requested) { |
| 6388 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 6389 | hdd_ctx->hbw_requested = false; |
| 6390 | } |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6391 | if (cds_sched_handle_throughput_req(false)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6392 | hdd_warn("low bandwidth set rx affinity fail"); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 6393 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 6394 | if (!hdd_ctx->hbw_requested) { |
| 6395 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 6396 | hdd_ctx->hbw_requested = true; |
| 6397 | } |
| 6398 | |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6399 | if (cds_sched_handle_throughput_req(true)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6400 | hdd_warn("high bandwidth set rx affinity fail"); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 6401 | } |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 6402 | hdd_napi_apply_throughput_policy(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6403 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6404 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 6405 | qdf_dp_trace_throttle_live_mode( |
| 6406 | (next_vote_level > PLD_BUS_WIDTH_NONE) ? true : false); |
| 6407 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6408 | /* fine-tuning parameters for RX Flows */ |
| 6409 | temp_rx = (rx_packets + hdd_ctx->prev_rx) / 2; |
| 6410 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6411 | hdd_ctx->prev_rx = rx_packets; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 6412 | |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 6413 | if (temp_rx < hdd_ctx->config->busBandwidthLowThreshold) |
| 6414 | hdd_disable_lro_for_low_tput(hdd_ctx, true); |
| 6415 | else |
| 6416 | hdd_disable_lro_for_low_tput(hdd_ctx, false); |
| 6417 | |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 6418 | if (temp_rx > hdd_ctx->config->tcpDelackThresholdHigh) { |
| 6419 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 6420 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 6421 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 6422 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6423 | } else { |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6424 | hdd_ctx->rx_high_ind_cnt = 0; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 6425 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6426 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6427 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6428 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6429 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6430 | next_rx_level, temp_rx); |
| 6431 | hdd_ctx->cur_rx_level = next_rx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6432 | rx_level_change = true; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6433 | /* Send throughput indication only if it is enabled. |
| 6434 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 6435 | * to default delayed ack. Note that this will disable the |
| 6436 | * dynamic delayed ack mechanism across the system |
| 6437 | */ |
| 6438 | if (hdd_ctx->config->enable_tcp_delack) |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 6439 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 6440 | WLAN_SVC_WLAN_TP_IND, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6441 | &next_rx_level, |
| 6442 | sizeof(next_rx_level)); |
| 6443 | } |
| 6444 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6445 | /* fine-tuning parameters for TX Flows */ |
| 6446 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 6447 | hdd_ctx->prev_tx = tx_packets; |
| 6448 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 6449 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 6450 | else |
| 6451 | next_tx_level = WLAN_SVC_TP_LOW; |
| 6452 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6453 | if (hdd_ctx->cur_tx_level != next_tx_level) { |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6454 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 6455 | next_tx_level, temp_tx); |
| 6456 | hdd_ctx->cur_tx_level = next_tx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6457 | tx_level_change = true; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 6458 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 6459 | WLAN_SVC_WLAN_TP_TX_IND, |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6460 | &next_tx_level, |
| 6461 | sizeof(next_tx_level)); |
| 6462 | } |
| 6463 | |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6464 | index = hdd_ctx->hdd_txrx_hist_idx; |
| 6465 | |
| 6466 | if (vote_level_change || tx_level_change || rx_level_change) { |
| 6467 | hdd_ctx->hdd_txrx_hist[index].next_tx_level = next_tx_level; |
| 6468 | hdd_ctx->hdd_txrx_hist[index].next_rx_level = next_rx_level; |
| 6469 | hdd_ctx->hdd_txrx_hist[index].next_vote_level = next_vote_level; |
| 6470 | hdd_ctx->hdd_txrx_hist[index].interval_rx = rx_packets; |
| 6471 | hdd_ctx->hdd_txrx_hist[index].interval_tx = tx_packets; |
| 6472 | hdd_ctx->hdd_txrx_hist[index].qtime = qdf_get_log_timestamp(); |
| 6473 | hdd_ctx->hdd_txrx_hist_idx++; |
| 6474 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
| 6475 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6476 | } |
| 6477 | |
| 6478 | #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] | 6479 | static void hdd_bus_bw_work_handler(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6480 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6481 | struct hdd_context *hdd_ctx = container_of(work, struct hdd_context, |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6482 | bus_bw_work); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6483 | struct hdd_adapter *adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6484 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 6485 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 6486 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6487 | uint64_t total_tx = 0, total_rx = 0; |
| 6488 | hdd_adapter_list_node_t *adapterNode = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6489 | QDF_STATUS status = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6490 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6491 | bool connected = false; |
| 6492 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 6493 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6494 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 6495 | return; |
| 6496 | |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 6497 | if (hdd_ctx->isWiphySuspended) |
| 6498 | goto restart_timer; |
| 6499 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6500 | for (status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6501 | NULL != adapterNode && QDF_STATUS_SUCCESS == status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6502 | status = |
| 6503 | hdd_get_next_adapter(hdd_ctx, adapterNode, &adapterNode)) { |
| 6504 | |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 6505 | if (adapterNode->adapter == NULL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6506 | continue; |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 6507 | adapter = adapterNode->adapter; |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 6508 | /* |
| 6509 | * Validate magic so we don't end up accessing |
| 6510 | * an invalid adapter. |
| 6511 | */ |
| 6512 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 6513 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6514 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6515 | if ((adapter->device_mode == QDF_STA_MODE || |
| 6516 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6517 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.connState |
| 6518 | != eConnectionState_Associated) { |
| 6519 | |
| 6520 | continue; |
| 6521 | } |
| 6522 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6523 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 6524 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6525 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->bApActive == false) { |
| 6526 | |
| 6527 | continue; |
| 6528 | } |
| 6529 | |
| 6530 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 6531 | adapter->prev_tx_packets); |
| 6532 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 6533 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6534 | |
| 6535 | if (adapter->device_mode == QDF_SAP_MODE || |
| 6536 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 6537 | adapter->device_mode == QDF_IBSS_MODE) { |
| 6538 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 6539 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 6540 | cds_get_context(QDF_MODULE_ID_SOC), |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6541 | adapter->sessionId, |
| 6542 | &fwd_tx_packets, &fwd_rx_packets); |
| 6543 | if (ret == A_OK) { |
| 6544 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 6545 | fwd_tx_packets, |
| 6546 | adapter->prev_fwd_tx_packets); |
| 6547 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 6548 | fwd_tx_packets, |
| 6549 | adapter->prev_fwd_rx_packets); |
| 6550 | } |
| 6551 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6552 | |
| 6553 | total_rx += adapter->stats.rx_packets; |
| 6554 | total_tx += adapter->stats.tx_packets; |
| 6555 | |
| 6556 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 6557 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 6558 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6559 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 6560 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6561 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 6562 | connected = true; |
| 6563 | } |
| 6564 | |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6565 | /* add intra bss forwarded tx and rx packets */ |
| 6566 | tx_packets += fwd_tx_packets_diff; |
| 6567 | rx_packets += fwd_rx_packets_diff; |
| 6568 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6569 | hdd_ipa_uc_stat_query(hdd_ctx, &ipa_tx_packets, &ipa_rx_packets); |
| 6570 | tx_packets += (uint64_t)ipa_tx_packets; |
| 6571 | rx_packets += (uint64_t)ipa_rx_packets; |
| 6572 | |
Yun Park | 2aa880c | 2017-08-22 10:58:10 -0700 | [diff] [blame] | 6573 | if (adapter) { |
| 6574 | adapter->stats.tx_packets += ipa_tx_packets; |
| 6575 | adapter->stats.rx_packets += ipa_rx_packets; |
| 6576 | } |
| 6577 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6578 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6579 | hdd_err("bus bandwidth timer running in disconnected state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6580 | return; |
| 6581 | } |
| 6582 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6583 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6584 | |
| 6585 | hdd_ipa_set_perf_level(hdd_ctx, tx_packets, rx_packets); |
| 6586 | hdd_ipa_uc_stat_request(adapter, 2); |
| 6587 | |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 6588 | restart_timer: |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 6589 | /* ensure periodic timer should still be running before restarting it */ |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6590 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 6591 | if (hdd_ctx->bus_bw_timer_running) |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 6592 | qdf_timer_mod(&hdd_ctx->bus_bw_timer, |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6593 | hdd_ctx->config->busBandwidthComputeInterval); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6594 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6595 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6596 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6597 | /** |
| 6598 | * __hdd_bus_bw_cbk() - Bus bandwidth data structure callback. |
| 6599 | * @arg: Argument of timer function |
| 6600 | * |
| 6601 | * Schedule a workqueue in this function where all the processing is done. |
| 6602 | * |
| 6603 | * Return: None. |
| 6604 | */ |
| 6605 | static void __hdd_bus_bw_cbk(void *arg) |
| 6606 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6607 | struct hdd_context *hdd_ctx = (struct hdd_context *) arg; |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6608 | |
| 6609 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 6610 | return; |
| 6611 | |
| 6612 | schedule_work(&hdd_ctx->bus_bw_work); |
| 6613 | } |
| 6614 | |
| 6615 | /** |
| 6616 | * hdd_bus_bw_cbk() - Wrapper for bus bw callback for SSR protection. |
| 6617 | * @arg: Argument of timer function |
| 6618 | * |
| 6619 | * Return: None. |
| 6620 | */ |
| 6621 | static void hdd_bus_bw_cbk(void *arg) |
| 6622 | { |
| 6623 | cds_ssr_protect(__func__); |
| 6624 | __hdd_bus_bw_cbk(arg); |
| 6625 | cds_ssr_unprotect(__func__); |
| 6626 | } |
| 6627 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6628 | int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6629 | { |
| 6630 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6631 | INIT_WORK(&hdd_ctx->bus_bw_work, |
| 6632 | hdd_bus_bw_work_handler); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6633 | hdd_ctx->bus_bw_timer_running = false; |
| 6634 | qdf_spinlock_create(&hdd_ctx->bus_bw_timer_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6635 | qdf_timer_init(NULL, |
| 6636 | &hdd_ctx->bus_bw_timer, |
| 6637 | hdd_bus_bw_cbk, (void *)hdd_ctx, |
| 6638 | QDF_TIMER_TYPE_SW); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6639 | |
| 6640 | return 0; |
| 6641 | } |
| 6642 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6643 | void hdd_bus_bandwidth_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6644 | { |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6645 | if (hdd_ctx->bus_bw_timer_running) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6646 | hdd_reset_tcp_delack(hdd_ctx); |
| 6647 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6648 | hdd_debug("wait for bus bw work to flush"); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6649 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 6650 | qdf_timer_free(&hdd_ctx->bus_bw_timer); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6651 | hdd_ctx->bus_bw_timer_running = false; |
| 6652 | qdf_spinlock_destroy(&hdd_ctx->bus_bw_timer_lock); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6653 | } |
Lin Bai | c5c0688 | 2017-09-21 13:58:43 +0800 | [diff] [blame] | 6654 | |
| 6655 | void hdd_bus_bw_cancel_work(struct hdd_context *hdd_ctx) |
| 6656 | { |
| 6657 | if (hdd_ctx) |
| 6658 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 6659 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6660 | #endif |
| 6661 | |
| 6662 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6663 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 6664 | * @hdd_ctx: hdd context |
| 6665 | * |
| 6666 | * Return: 0 for success or error code |
| 6667 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6668 | 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] | 6669 | { |
| 6670 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 6671 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
| 6672 | if (hdd_ctx->hdd_txrx_hist == NULL) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6673 | hdd_err("Failed malloc for hdd_txrx_hist"); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6674 | return -ENOMEM; |
| 6675 | } |
| 6676 | return 0; |
| 6677 | } |
| 6678 | |
| 6679 | /** |
| 6680 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 6681 | * @hdd_ctx: hdd context |
| 6682 | * |
| 6683 | * Return: none |
| 6684 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6685 | void wlan_hdd_deinit_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6686 | { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6687 | if (!hdd_ctx || hdd_ctx->hdd_txrx_hist == NULL) |
| 6688 | return; |
| 6689 | |
| 6690 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 6691 | hdd_ctx->hdd_txrx_hist = NULL; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6692 | } |
| 6693 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6694 | static uint8_t *convert_level_to_string(uint32_t level) |
| 6695 | { |
| 6696 | switch (level) { |
| 6697 | /* initialize the wlan sub system */ |
| 6698 | case WLAN_SVC_TP_NONE: |
| 6699 | return "NONE"; |
| 6700 | case WLAN_SVC_TP_LOW: |
| 6701 | return "LOW"; |
| 6702 | case WLAN_SVC_TP_MEDIUM: |
| 6703 | return "MED"; |
| 6704 | case WLAN_SVC_TP_HIGH: |
| 6705 | return "HIGH"; |
| 6706 | default: |
| 6707 | return "INVAL"; |
| 6708 | } |
| 6709 | } |
| 6710 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6711 | |
| 6712 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6713 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 6714 | * @hdd_ctx: hdd context |
| 6715 | * |
| 6716 | * Return: none |
| 6717 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6718 | void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6719 | { |
| 6720 | int i; |
| 6721 | |
| 6722 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6723 | hdd_debug("BW compute Interval: %dms", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6724 | hdd_ctx->config->busBandwidthComputeInterval); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6725 | hdd_debug("BW High TH: %d BW Med TH: %d BW Low TH: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6726 | hdd_ctx->config->busBandwidthHighThreshold, |
| 6727 | hdd_ctx->config->busBandwidthMediumThreshold, |
| 6728 | hdd_ctx->config->busBandwidthLowThreshold); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6729 | hdd_debug("Enable TCP DEL ACK: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6730 | hdd_ctx->config->enable_tcp_delack); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6731 | hdd_debug("TCP DEL High TH: %d TCP DEL Low TH: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6732 | hdd_ctx->config->tcpDelackThresholdHigh, |
| 6733 | hdd_ctx->config->tcpDelackThresholdLow); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6734 | hdd_debug("TCP TX HIGH TP TH: %d (Use to set tcp_output_bytes_limit)", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6735 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6736 | #endif |
| 6737 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6738 | hdd_debug("Total entries: %d Current index: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6739 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
| 6740 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6741 | hdd_debug("[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] | 6742 | |
| 6743 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6744 | /* using hdd_log to avoid printing function name */ |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6745 | if (hdd_ctx->hdd_txrx_hist[i].qtime > 0) |
Houston Hoffman | 0022711 | 2017-08-14 23:58:18 -0700 | [diff] [blame] | 6746 | hdd_log(QDF_TRACE_LEVEL_DEBUG, |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6747 | "[%3d][%15llu]: %6llu, %6llu, %s, %s, %s", |
| 6748 | i, hdd_ctx->hdd_txrx_hist[i].qtime, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6749 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6750 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
| 6751 | convert_level_to_string( |
| 6752 | hdd_ctx->hdd_txrx_hist[i]. |
| 6753 | next_vote_level), |
| 6754 | convert_level_to_string( |
| 6755 | hdd_ctx->hdd_txrx_hist[i]. |
| 6756 | next_rx_level), |
| 6757 | convert_level_to_string( |
| 6758 | hdd_ctx->hdd_txrx_hist[i]. |
| 6759 | next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6760 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6761 | } |
| 6762 | |
| 6763 | /** |
| 6764 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 6765 | * @hdd_ctx: hdd context |
| 6766 | * |
| 6767 | * Return: none |
| 6768 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6769 | void wlan_hdd_clear_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6770 | { |
| 6771 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6772 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 6773 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6774 | } |
| 6775 | |
| 6776 | /** |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6777 | * wlan_hdd_display_netif_queue_history() - display netif queue history |
Jeff Johnson | 58adbcf | 2017-09-03 08:53:31 -0700 | [diff] [blame] | 6778 | * @hdd_ctx: hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6779 | * |
| 6780 | * Return: none |
| 6781 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6782 | void wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6783 | { |
| 6784 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6785 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6786 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6787 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6788 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6789 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6790 | |
| 6791 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6792 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 6793 | adapter = adapter_node->adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6794 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6795 | hdd_debug("Netif queue operation statistics:"); |
| 6796 | hdd_debug("Session_id %d device mode %d", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6797 | adapter->sessionId, adapter->device_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6798 | hdd_debug("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6799 | curr_time = qdf_system_ticks(); |
| 6800 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6801 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6802 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6803 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6804 | unpause = adapter->total_unpause_time; |
| 6805 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6806 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6807 | pause = adapter->total_pause_time; |
| 6808 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6809 | hdd_debug("Total: %ums Pause: %ums Unpause: %ums", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6810 | qdf_system_ticks_to_msecs(total), |
| 6811 | qdf_system_ticks_to_msecs(pause), |
| 6812 | qdf_system_ticks_to_msecs(unpause)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6813 | hdd_debug("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6814 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6815 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 6816 | qdf_time_t pause_delta = 0; |
| 6817 | |
| 6818 | if (adapter->pause_map & (1 << i)) |
| 6819 | pause_delta = delta; |
| 6820 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6821 | /* using hdd_log to avoid printing function name */ |
Houston Hoffman | 0022711 | 2017-08-14 23:58:18 -0700 | [diff] [blame] | 6822 | hdd_log(QDF_TRACE_LEVEL_DEBUG, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6823 | "%s: %d: %d: %ums", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6824 | hdd_reason_type_to_string(i), |
| 6825 | adapter->queue_oper_stats[i].pause_count, |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6826 | adapter->queue_oper_stats[i].unpause_count, |
| 6827 | qdf_system_ticks_to_msecs( |
| 6828 | adapter->queue_oper_stats[i].total_pause_time + |
| 6829 | pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6830 | } |
| 6831 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6832 | hdd_debug("Netif queue operation history:"); |
| 6833 | hdd_debug("Total entries: %d current index %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6834 | WLAN_HDD_MAX_HISTORY_ENTRY, adapter->history_index); |
| 6835 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6836 | hdd_debug("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6837 | |
| 6838 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6839 | /* using hdd_log to avoid printing function name */ |
| 6840 | if (adapter->queue_oper_history[i].time == 0) |
| 6841 | continue; |
Houston Hoffman | 0022711 | 2017-08-14 23:58:18 -0700 | [diff] [blame] | 6842 | hdd_log(QDF_TRACE_LEVEL_DEBUG, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6843 | "%d: %u: %s: %s: %x", |
Anurag Chouhan | 50220ce | 2016-02-18 20:11:33 +0530 | [diff] [blame] | 6844 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6845 | adapter->queue_oper_history[i].time), |
| 6846 | hdd_action_type_to_string( |
| 6847 | adapter->queue_oper_history[i].netif_action), |
| 6848 | hdd_reason_type_to_string( |
| 6849 | adapter->queue_oper_history[i].netif_reason), |
| 6850 | adapter->queue_oper_history[i].pause_map); |
| 6851 | } |
| 6852 | |
| 6853 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 6854 | adapter_node = next; |
| 6855 | } |
| 6856 | |
| 6857 | |
| 6858 | } |
| 6859 | |
| 6860 | /** |
| 6861 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 6862 | * @hdd_ctx: hdd context |
| 6863 | * |
| 6864 | * Return: none |
| 6865 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6866 | void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6867 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6868 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6869 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6870 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6871 | |
| 6872 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6873 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 6874 | adapter = adapter_node->adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6875 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6876 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6877 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6878 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6879 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6880 | adapter->history_index = 0; |
| 6881 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 6882 | adapter->total_pause_time = 0; |
| 6883 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6884 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 6885 | adapter_node = next; |
| 6886 | } |
| 6887 | } |
| 6888 | |
| 6889 | /** |
| 6890 | * hdd_11d_scan_done() - callback for 11d scan completion of flushing results |
| 6891 | * @halHandle: Hal handle |
| 6892 | * @pContext: Pointer to the context |
| 6893 | * @sessionId: Session ID |
| 6894 | * @scanId: Scan ID |
| 6895 | * @status: Status |
| 6896 | * |
| 6897 | * This is the callback to be executed when 11d scan is completed to flush out |
| 6898 | * the scan results |
| 6899 | * |
| 6900 | * 11d scan is done during driver load and is a passive scan on all |
| 6901 | * channels supported by the device, 11d scans may find some APs on |
| 6902 | * frequencies which are forbidden to be used in the regulatory domain |
| 6903 | * the device is operating in. If these APs are notified to the supplicant |
| 6904 | * it may try to connect to these APs, thus flush out all the scan results |
| 6905 | * which are present in SME after 11d scan is done. |
| 6906 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6907 | * Return: QDF_STATUS_SUCCESS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6908 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6909 | static QDF_STATUS hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6910 | uint8_t sessionId, uint32_t scanId, |
| 6911 | eCsrScanStatus status) |
| 6912 | { |
| 6913 | ENTER(); |
| 6914 | |
| 6915 | sme_scan_flush_result(halHandle); |
| 6916 | |
| 6917 | EXIT(); |
| 6918 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6919 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6920 | } |
| 6921 | |
| 6922 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 6923 | /** |
| 6924 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 6925 | * @hdd_ctx: hdd global context |
| 6926 | * |
| 6927 | * Return: none |
| 6928 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6929 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6930 | { |
| 6931 | uint8_t i; |
| 6932 | |
| 6933 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 6934 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 6935 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 6936 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 6937 | } |
| 6938 | } |
| 6939 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6940 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6941 | { |
| 6942 | } |
| 6943 | #endif |
| 6944 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 6945 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 6946 | /** |
| 6947 | * 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] | 6948 | * @phddctx: struct hdd_context structure pointer |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 6949 | * @enable: enable or disable this behaviour |
| 6950 | * |
| 6951 | * Return: int |
| 6952 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6953 | 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] | 6954 | { |
| 6955 | struct hdd_config *pcfg_ini = phddctx->config; |
| 6956 | struct wow_pulse_mode wow_pulse_set_info; |
| 6957 | QDF_STATUS status; |
| 6958 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6959 | hdd_debug("wow pulse enable flag is %d", enable); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 6960 | |
| 6961 | if (false == phddctx->config->wow_pulse_support) |
| 6962 | return 0; |
| 6963 | |
| 6964 | /* prepare the request to send to SME */ |
| 6965 | if (enable == true) { |
| 6966 | wow_pulse_set_info.wow_pulse_enable = true; |
| 6967 | wow_pulse_set_info.wow_pulse_pin = |
| 6968 | pcfg_ini->wow_pulse_pin; |
| 6969 | wow_pulse_set_info.wow_pulse_interval_low = |
| 6970 | pcfg_ini->wow_pulse_interval_low; |
| 6971 | wow_pulse_set_info.wow_pulse_interval_high = |
| 6972 | pcfg_ini->wow_pulse_interval_high; |
| 6973 | } else { |
| 6974 | wow_pulse_set_info.wow_pulse_enable = false; |
| 6975 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 6976 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 6977 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 6978 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6979 | hdd_debug("enable %d pin %d low %d high %d", |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 6980 | wow_pulse_set_info.wow_pulse_enable, |
| 6981 | wow_pulse_set_info.wow_pulse_pin, |
| 6982 | wow_pulse_set_info.wow_pulse_interval_low, |
| 6983 | wow_pulse_set_info.wow_pulse_interval_high); |
| 6984 | |
| 6985 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 6986 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6987 | hdd_debug("sme_set_wow_pulse failure!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 6988 | return -EIO; |
| 6989 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6990 | hdd_debug("sme_set_wow_pulse success!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 6991 | return 0; |
| 6992 | } |
| 6993 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6994 | 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] | 6995 | { |
| 6996 | return 0; |
| 6997 | } |
| 6998 | #endif |
| 6999 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7000 | #ifdef WLAN_FEATURE_FASTPATH |
| 7001 | /** |
| 7002 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 7003 | * @hdd_cfg: hdd config |
| 7004 | * @context: lower layer context |
| 7005 | * |
| 7006 | * Return: none |
| 7007 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7008 | void hdd_enable_fastpath(struct hdd_config *hdd_cfg, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7009 | void *context) |
| 7010 | { |
| 7011 | if (hdd_cfg->fastpath_enable) |
| 7012 | hif_enable_fastpath(context); |
| 7013 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7014 | #endif |
| 7015 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7016 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7017 | /** |
| 7018 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7019 | * @context: hdd context pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7020 | * @level: thermal level |
| 7021 | * |
| 7022 | * Change IPA data path to SW path when the thermal throttle level greater |
| 7023 | * than 0, and restore the original data path when throttle level is 0 |
| 7024 | * |
| 7025 | * Return: none |
| 7026 | */ |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7027 | static void hdd_set_thermal_level_cb(void *context, u_int8_t level) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7028 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7029 | struct hdd_context *hdd_ctx = context; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7030 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7031 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 7032 | if (level > THROTTLE_LEVEL_0) |
| 7033 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, true); |
| 7034 | else |
| 7035 | /* restore original concurrency mode */ |
| 7036 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, hdd_ctx->mcc_mode); |
| 7037 | } |
| 7038 | |
| 7039 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7040 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 7041 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 7042 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7043 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7044 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 7045 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 7046 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7047 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7048 | * Return: Channel number to restart SAP in case of success. In case of any |
| 7049 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7050 | */ |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7051 | static uint8_t hdd_get_safe_channel_from_pcl_and_acs_range( |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7052 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7053 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7054 | struct sir_pcl_list pcl; |
| 7055 | QDF_STATUS status; |
| 7056 | uint32_t i, j; |
| 7057 | tHalHandle *hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7058 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7059 | bool found = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7060 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7061 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7062 | if (!hdd_ctx) { |
| 7063 | hdd_err("invalid HDD context"); |
| 7064 | return INVALID_CHANNEL_ID; |
| 7065 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7066 | |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 7067 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 7068 | if (!hal_handle) { |
| 7069 | hdd_err("invalid HAL handle"); |
| 7070 | return INVALID_CHANNEL_ID; |
| 7071 | } |
| 7072 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7073 | status = policy_mgr_get_pcl_for_existing_conn(hdd_ctx->hdd_psoc, |
| 7074 | PM_SAP_MODE, pcl.pcl_list, &pcl.pcl_len, |
bings | 37bd58f | 2017-07-20 16:49:26 +0800 | [diff] [blame] | 7075 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list), |
| 7076 | false); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7077 | if (QDF_IS_STATUS_ERROR(status)) { |
| 7078 | hdd_err("Get PCL failed"); |
| 7079 | return INVALID_CHANNEL_ID; |
| 7080 | } |
| 7081 | |
Frank Liu | dc2cefb | 2017-06-21 15:38:18 +0800 | [diff] [blame] | 7082 | /* |
| 7083 | * In some scenarios, like hw dbs disabled, sap+sap case, if operating |
| 7084 | * channel is unsafe channel, the pcl may be empty, instead of return, |
| 7085 | * try to choose a safe channel from acs range. |
| 7086 | */ |
| 7087 | if (!pcl.pcl_len) |
| 7088 | hdd_debug("pcl length is zero!"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7089 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7090 | hdd_debug("start:%d end:%d", |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7091 | adapter->sessionCtx.ap.sapConfig.acs_cfg.start_ch, |
| 7092 | adapter->sessionCtx.ap.sapConfig.acs_cfg.end_ch); |
| 7093 | |
| 7094 | /* PCL already takes unsafe channel into account */ |
| 7095 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7096 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7097 | if ((pcl.pcl_list[i] >= |
| 7098 | adapter->sessionCtx.ap.sapConfig.acs_cfg.start_ch) && |
| 7099 | (pcl.pcl_list[i] <= |
| 7100 | adapter->sessionCtx.ap.sapConfig.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7101 | hdd_debug("found PCL safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7102 | return pcl.pcl_list[i]; |
| 7103 | } |
| 7104 | } |
| 7105 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7106 | hdd_debug("no safe channel from PCL found in ACS range"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7107 | |
| 7108 | /* Try for safe channel from all valid channel */ |
| 7109 | pcl.pcl_len = MAX_NUM_CHAN; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7110 | status = sme_get_cfg_valid_channels(pcl.pcl_list, |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7111 | &pcl.pcl_len); |
| 7112 | if (QDF_IS_STATUS_ERROR(status)) { |
| 7113 | hdd_err("error in getting valid channel list"); |
| 7114 | return INVALID_CHANNEL_ID; |
| 7115 | } |
| 7116 | |
| 7117 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7118 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7119 | found = false; |
| 7120 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 7121 | if (pcl.pcl_list[i] == |
| 7122 | hdd_ctx->unsafe_channel_list[j]) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7123 | hdd_debug("unsafe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7124 | found = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7125 | break; |
| 7126 | } |
| 7127 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7128 | |
| 7129 | if (found) |
| 7130 | continue; |
| 7131 | |
| 7132 | if ((pcl.pcl_list[i] >= |
| 7133 | adapter->sessionCtx.ap.sapConfig.acs_cfg.start_ch) && |
| 7134 | (pcl.pcl_list[i] <= |
| 7135 | adapter->sessionCtx.ap.sapConfig.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7136 | hdd_debug("found safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7137 | return pcl.pcl_list[i]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7138 | } |
| 7139 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7140 | |
| 7141 | return INVALID_CHANNEL_ID; |
| 7142 | } |
| 7143 | |
| 7144 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 7145 | * hdd_switch_sap_channel() - Move SAP to the given channel |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7146 | * @adapter: AP adapter |
| 7147 | * @channel: Channel |
| 7148 | * |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 7149 | * Moves the SAP interface by invoking the function which |
| 7150 | * executes the callback to perform channel switch using (E)CSA. |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7151 | * |
| 7152 | * Return: None |
| 7153 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7154 | void hdd_switch_sap_channel(struct hdd_adapter *adapter, uint8_t channel) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7155 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 7156 | struct hdd_ap_ctx *hdd_ap_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7157 | tHalHandle *hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7158 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7159 | |
| 7160 | if (!adapter) { |
| 7161 | hdd_err("invalid adapter"); |
| 7162 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7163 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7164 | |
| 7165 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 7166 | |
| 7167 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 7168 | if (!hal_handle) { |
| 7169 | hdd_err("invalid HAL handle"); |
| 7170 | return; |
| 7171 | } |
| 7172 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7173 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7174 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7175 | hdd_ap_ctx->sapConfig.channel = channel; |
| 7176 | hdd_ap_ctx->sapConfig.ch_params.ch_width = |
| 7177 | hdd_ap_ctx->sapConfig.ch_width_orig; |
| 7178 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7179 | hdd_debug("chan:%d width:%d", |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7180 | channel, hdd_ap_ctx->sapConfig.ch_width_orig); |
| 7181 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 7182 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, |
| 7183 | hdd_ap_ctx->sapConfig.channel, |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7184 | hdd_ap_ctx->sapConfig.sec_ch, |
| 7185 | &hdd_ap_ctx->sapConfig.ch_params); |
| 7186 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7187 | policy_mgr_change_sap_channel_with_csa(hdd_ctx->hdd_psoc, |
| 7188 | adapter->sessionId, channel, |
| 7189 | hdd_ap_ctx->sapConfig.ch_width_orig); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7190 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7191 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7192 | 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] | 7193 | { |
| 7194 | struct hdd_external_acs_timer_context *timer_context; |
| 7195 | |
| 7196 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 7197 | |
| 7198 | if (QDF_TIMER_STATE_RUNNING == |
| 7199 | qdf_mc_timer_get_current_state(&adapter->sessionCtx. |
| 7200 | ap.vendor_acs_timer)) { |
| 7201 | qdf_mc_timer_stop(&adapter->sessionCtx.ap.vendor_acs_timer); |
| 7202 | } |
| 7203 | timer_context = (struct hdd_external_acs_timer_context *) |
| 7204 | adapter->sessionCtx.ap.vendor_acs_timer.user_data; |
| 7205 | timer_context->reason = reason; |
Nachiket Kukade | a485569 | 2017-08-21 21:19:09 +0530 | [diff] [blame] | 7206 | /* Update config to application and start the timer */ |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7207 | hdd_cfg80211_update_acs_config(adapter, reason); |
Nachiket Kukade | a485569 | 2017-08-21 21:19:09 +0530 | [diff] [blame] | 7208 | qdf_mc_timer_start(&adapter->sessionCtx.ap.vendor_acs_timer, |
| 7209 | WLAN_VENDOR_ACS_WAIT_TIME); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7210 | hdd_notice("Updated ACS config to nl with reason %d", reason); |
| 7211 | |
| 7212 | return 0; |
| 7213 | } |
| 7214 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7215 | /** |
| 7216 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 7217 | * @hdd_ctx: hdd context pointer |
| 7218 | * |
| 7219 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 7220 | * and if ACS is enabled, driver will ask userspace to restart the |
| 7221 | * sap. User space on LTE coex indication restart driver. |
| 7222 | * |
| 7223 | * Return - none |
| 7224 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7225 | void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7226 | { |
| 7227 | QDF_STATUS status; |
| 7228 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7229 | struct hdd_adapter *adapter_temp; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7230 | uint32_t i; |
| 7231 | bool found = false; |
| 7232 | uint8_t restart_chan; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7233 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7234 | status = hdd_get_front_adapter(hdd_ctxt, &adapter_node); |
| 7235 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 7236 | adapter_temp = adapter_node->adapter; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7237 | |
| 7238 | if (!adapter_temp) { |
| 7239 | hdd_err("adapter is NULL, moving to next one"); |
| 7240 | goto next_adapater; |
| 7241 | } |
| 7242 | |
| 7243 | if (!((adapter_temp->device_mode == QDF_SAP_MODE) && |
| 7244 | (adapter_temp->sessionCtx.ap.sapConfig.acs_cfg.acs_mode))) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7245 | hdd_debug("skip device mode:%d acs:%d", |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7246 | adapter_temp->device_mode, |
| 7247 | adapter_temp->sessionCtx.ap.sapConfig. |
| 7248 | acs_cfg.acs_mode); |
| 7249 | goto next_adapater; |
| 7250 | } |
| 7251 | |
| 7252 | found = false; |
| 7253 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 7254 | if (adapter_temp->sessionCtx.ap.operatingChannel == |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7255 | hdd_ctxt->unsafe_channel_list[i]) { |
| 7256 | found = true; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7257 | hdd_debug("operating ch:%d is unsafe", |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7258 | adapter_temp->sessionCtx.ap.operatingChannel); |
| 7259 | break; |
| 7260 | } |
| 7261 | } |
| 7262 | |
| 7263 | if (!found) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7264 | hdd_debug("ch:%d is safe. no need to change channel", |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7265 | adapter_temp->sessionCtx.ap.operatingChannel); |
| 7266 | goto next_adapater; |
| 7267 | } |
| 7268 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7269 | if (hdd_ctxt->config->vendor_acs_support && |
| 7270 | hdd_ctxt->config->acs_support_for_dfs_ltecoex) { |
| 7271 | hdd_update_acs_timer_reason(adapter_temp, |
| 7272 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
| 7273 | goto next_adapater; |
| 7274 | } else |
| 7275 | restart_chan = |
| 7276 | hdd_get_safe_channel_from_pcl_and_acs_range( |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7277 | adapter_temp); |
| 7278 | if (!restart_chan) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7279 | hdd_err("fail to restart SAP"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7280 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 7281 | /* |
| 7282 | * SAP restart due to unsafe channel. While |
| 7283 | * restarting the SAP, make sure to clear |
| 7284 | * acs_channel, channel to reset to |
| 7285 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 7286 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 7287 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 7288 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
| 7289 | adapter_temp->sessionCtx.ap.sapConfig.channel = |
| 7290 | AUTO_CHANNEL_SELECT; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7291 | hdd_debug("sending coex indication"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7292 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 7293 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 7294 | hdd_debug("driver to start sap: %d", |
| 7295 | hdd_ctxt->config->sap_internal_restart); |
| 7296 | if (hdd_ctxt->config->sap_internal_restart) |
| 7297 | hdd_switch_sap_channel(adapter_temp, restart_chan); |
| 7298 | else |
| 7299 | return; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7300 | } |
| 7301 | |
| 7302 | next_adapater: |
| 7303 | status = hdd_get_next_adapter(hdd_ctxt, adapter_node, &next); |
| 7304 | adapter_node = next; |
| 7305 | } |
| 7306 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 7307 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7308 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7309 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 7310 | * @hdd_ctx: HDD global context |
| 7311 | * |
| 7312 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7313 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7314 | * down to the lower layers. Then subscribe to subsequent channel |
| 7315 | * avoidance events. |
| 7316 | * |
| 7317 | * Return: None |
| 7318 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7319 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7320 | { |
| 7321 | uint16_t unsafe_channel_count; |
| 7322 | int index; |
| 7323 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7324 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 7325 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7326 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 7327 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7328 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7329 | hdd_debug("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7330 | hdd_ctx->unsafe_channel_count); |
| 7331 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7332 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 7333 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7334 | |
| 7335 | for (index = 0; index < unsafe_channel_count; index++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7336 | hdd_debug("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7337 | hdd_ctx->unsafe_channel_list[index]); |
| 7338 | |
| 7339 | } |
| 7340 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7341 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7342 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7343 | static void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7344 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7345 | { |
| 7346 | uint8_t restart_chan; |
| 7347 | |
| 7348 | restart_chan = hdd_get_safe_channel_from_pcl_and_acs_range(adapter); |
| 7349 | if (!restart_chan) { |
| 7350 | hdd_alert("fail to restart SAP"); |
| 7351 | return; |
| 7352 | } |
| 7353 | |
| 7354 | /* SAP restart due to unsafe channel. While restarting |
| 7355 | * the SAP, make sure to clear acs_channel, channel to |
| 7356 | * reset to 0. Otherwise these settings will override |
| 7357 | * the ACS while restart. |
| 7358 | */ |
| 7359 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
| 7360 | adapter->sessionCtx.ap.sapConfig.channel = AUTO_CHANNEL_SELECT; |
| 7361 | |
| 7362 | hdd_debug("sending coex indication"); |
| 7363 | |
| 7364 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7365 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
| 7366 | hdd_switch_sap_channel(adapter, restart_chan); |
| 7367 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 7368 | |
| 7369 | int hdd_clone_local_unsafe_chan(struct hdd_context *hdd_ctx, |
| 7370 | uint16_t **local_unsafe_list, uint16_t *local_unsafe_list_count) |
| 7371 | { |
| 7372 | uint32_t size; |
| 7373 | uint16_t *unsafe_list; |
| 7374 | uint16_t chan_count; |
| 7375 | |
| 7376 | if (!hdd_ctx || !local_unsafe_list_count || !local_unsafe_list_count) |
| 7377 | return -EINVAL; |
| 7378 | |
| 7379 | chan_count = QDF_MIN(hdd_ctx->unsafe_channel_count, |
| 7380 | NUM_CHANNELS); |
| 7381 | if (chan_count) { |
| 7382 | size = chan_count * sizeof(hdd_ctx->unsafe_channel_list[0]); |
| 7383 | unsafe_list = qdf_mem_malloc(size); |
| 7384 | if (!unsafe_list) { |
| 7385 | hdd_err("No memory for unsafe chan list size%d", |
| 7386 | size); |
| 7387 | return -ENOMEM; |
| 7388 | } |
| 7389 | qdf_mem_copy(unsafe_list, hdd_ctx->unsafe_channel_list, size); |
| 7390 | } else { |
| 7391 | unsafe_list = NULL; |
| 7392 | } |
| 7393 | |
| 7394 | *local_unsafe_list = unsafe_list; |
| 7395 | *local_unsafe_list_count = chan_count; |
| 7396 | |
| 7397 | return 0; |
| 7398 | } |
| 7399 | |
| 7400 | bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx, |
| 7401 | uint16_t *local_unsafe_list, uint16_t local_unsafe_list_count) |
| 7402 | { |
| 7403 | int i, j; |
| 7404 | |
| 7405 | if (local_unsafe_list_count != hdd_ctx->unsafe_channel_count) |
| 7406 | return true; |
| 7407 | if (local_unsafe_list_count == 0) |
| 7408 | return false; |
| 7409 | for (i = 0; i < local_unsafe_list_count; i++) { |
| 7410 | for (j = 0; j < local_unsafe_list_count; j++) |
| 7411 | if (local_unsafe_list[i] == |
| 7412 | hdd_ctx->unsafe_channel_list[j]) |
| 7413 | break; |
| 7414 | if (j >= local_unsafe_list_count) |
| 7415 | break; |
| 7416 | } |
| 7417 | if (i >= local_unsafe_list_count) { |
| 7418 | hdd_info("unsafe chan list same"); |
| 7419 | return false; |
| 7420 | } |
| 7421 | |
| 7422 | return true; |
| 7423 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7424 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7425 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7426 | { |
| 7427 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7428 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7429 | static void hdd_set_thermal_level_cb(void *context, u_int8_t level) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7430 | { |
| 7431 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7432 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7433 | static inline void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7434 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7435 | { |
| 7436 | hdd_debug("Channel avoidance is not enabled; Abort SAP restart"); |
| 7437 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7438 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7439 | |
| 7440 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7441 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 7442 | * user space |
| 7443 | * @frame_ind: Management frame data to be informed. |
| 7444 | * |
| 7445 | * This function is used to indicate management frame to |
| 7446 | * user space |
| 7447 | * |
| 7448 | * Return: None |
| 7449 | * |
| 7450 | */ |
| 7451 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 7452 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7453 | struct hdd_context *hdd_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7454 | struct hdd_adapter *adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7455 | int i; |
| 7456 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7457 | /* Get the HDD context.*/ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7458 | hdd_ctx = (struct hdd_context *)cds_get_context(QDF_MODULE_ID_HDD); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7459 | |
| 7460 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 7461 | return; |
| 7462 | |
| 7463 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
| 7464 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 7465 | adapter = |
| 7466 | hdd_get_adapter_by_sme_session_id(hdd_ctx, i); |
| 7467 | if (adapter) |
| 7468 | break; |
| 7469 | } |
| 7470 | } else { |
| 7471 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 7472 | frame_ind->sessionId); |
| 7473 | } |
| 7474 | |
| 7475 | if ((NULL != adapter) && |
| 7476 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 7477 | __hdd_indicate_mgmt_frame(adapter, |
| 7478 | frame_ind->frame_len, |
| 7479 | frame_ind->frameBuf, |
| 7480 | frame_ind->frameType, |
| 7481 | frame_ind->rxChan, |
| 7482 | frame_ind->rxRssi); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7483 | } |
| 7484 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7485 | void hdd_acs_response_timeout_handler(void *context) |
| 7486 | { |
| 7487 | struct hdd_external_acs_timer_context *timer_context = |
| 7488 | (struct hdd_external_acs_timer_context *)context; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7489 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7490 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7491 | uint8_t reason; |
| 7492 | |
| 7493 | ENTER(); |
| 7494 | if (!timer_context) { |
| 7495 | hdd_err("invlaid timer context"); |
| 7496 | return; |
| 7497 | } |
| 7498 | adapter = timer_context->adapter; |
| 7499 | reason = timer_context->reason; |
| 7500 | |
| 7501 | |
| 7502 | if ((!adapter) || |
| 7503 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 7504 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 7505 | return; |
| 7506 | } |
| 7507 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7508 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7509 | return; |
| 7510 | |
| 7511 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 7512 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 7513 | else |
| 7514 | return; |
| 7515 | |
| 7516 | hdd_err("ACS timeout happened for %s reason %d", |
| 7517 | adapter->dev->name, reason); |
| 7518 | switch (reason) { |
| 7519 | /* SAP init case */ |
| 7520 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 7521 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 7522 | false); |
| 7523 | wlan_hdd_cfg80211_start_acs(adapter); |
| 7524 | break; |
| 7525 | /* DFS detected on current channel */ |
| 7526 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 7527 | wlan_sap_update_next_channel( |
| 7528 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
| 7529 | sme_update_new_channel_event(WLAN_HDD_GET_HAL_CTX(adapter), |
| 7530 | adapter->sessionId); |
| 7531 | break; |
| 7532 | /* LTE coex event on current channel */ |
| 7533 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 7534 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 7535 | break; |
| 7536 | default: |
| 7537 | hdd_info("invalid reason for timer invoke"); |
| 7538 | |
| 7539 | } |
| 7540 | } |
| 7541 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7542 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7543 | * wlan_hdd_disable_all_dual_mac_features() - Disable dual mac features |
| 7544 | * @hdd_ctx: HDD context |
| 7545 | * |
| 7546 | * Disables all the dual mac features like DBS, Agile DFS etc. |
| 7547 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7548 | * Return: QDF_STATUS_SUCCESS on success |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7549 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7550 | static QDF_STATUS wlan_hdd_disable_all_dual_mac_features(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7551 | { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7552 | struct policy_mgr_dual_mac_config cfg = {0}; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7553 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7554 | |
| 7555 | if (!hdd_ctx) { |
| 7556 | hdd_err("HDD context is NULL"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7557 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7558 | } |
| 7559 | |
| 7560 | cfg.scan_config = 0; |
| 7561 | cfg.fw_mode_config = 0; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7562 | cfg.set_dual_mac_cb = policy_mgr_soc_set_dual_mac_cfg_cb; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7563 | |
| 7564 | hdd_debug("Disabling all dual mac features..."); |
| 7565 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7566 | status = sme_soc_set_dual_mac_config(cfg); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7567 | if (status != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7568 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 7569 | return status; |
| 7570 | } |
| 7571 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7572 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7573 | } |
| 7574 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 7575 | static QDF_STATUS |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7576 | wlan_hdd_update_dbs_scan_and_fw_mode_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 7577 | { |
| 7578 | struct policy_mgr_dual_mac_config cfg = {0}; |
| 7579 | QDF_STATUS status; |
| 7580 | |
| 7581 | if (!hdd_ctx) { |
| 7582 | hdd_err("HDD context is NULL"); |
| 7583 | return QDF_STATUS_E_FAILURE; |
| 7584 | } |
| 7585 | |
| 7586 | cfg.scan_config = 0; |
| 7587 | cfg.fw_mode_config = 0; |
| 7588 | cfg.set_dual_mac_cb = policy_mgr_soc_set_dual_mac_cfg_cb; |
| 7589 | status = policy_mgr_get_updated_scan_and_fw_mode_config( |
| 7590 | hdd_ctx->hdd_psoc, &cfg.scan_config, |
| 7591 | &cfg.fw_mode_config, |
| 7592 | hdd_ctx->config->dual_mac_feature_disable); |
| 7593 | |
| 7594 | if (status != QDF_STATUS_SUCCESS) { |
| 7595 | hdd_err("wma_get_updated_scan_and_fw_mode_config failed %d", |
| 7596 | status); |
| 7597 | return status; |
| 7598 | } |
| 7599 | |
| 7600 | hdd_debug("send scan_cfg: 0x%x fw_mode_cfg: 0x%x to fw", |
| 7601 | cfg.scan_config, cfg.fw_mode_config); |
| 7602 | |
| 7603 | status = sme_soc_set_dual_mac_config(cfg); |
| 7604 | if (status != QDF_STATUS_SUCCESS) { |
| 7605 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 7606 | return status; |
| 7607 | } |
| 7608 | |
| 7609 | return QDF_STATUS_SUCCESS; |
| 7610 | } |
| 7611 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7612 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7613 | * hdd_override_ini_config - Override INI config |
| 7614 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7615 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7616 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7617 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7618 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7619 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7620 | static void hdd_override_ini_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7621 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7622 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7623 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
| 7624 | hdd_ctx->config->enableDFSChnlScan = enable_dfs_chan_scan; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7625 | hdd_debug("Module enable_dfs_chan_scan set to %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7626 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7627 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7628 | if (0 == enable_11d || 1 == enable_11d) { |
| 7629 | hdd_ctx->config->Is11dSupportEnabled = enable_11d; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7630 | hdd_debug("Module enable_11d set to %d", enable_11d); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7631 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 7632 | |
| 7633 | if (!hdd_ipa_is_present(hdd_ctx)) |
| 7634 | hdd_ctx->config->IpaConfig = 0; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7635 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7636 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7637 | /** |
| 7638 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 7639 | * @hdd_ctx - HDD context |
| 7640 | * |
| 7641 | * Set trace level for each module based on INI config. |
| 7642 | * |
| 7643 | * Return: None |
| 7644 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7645 | 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] | 7646 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7647 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMI, |
| 7648 | hdd_ctx->config->qdf_trace_enable_wdi); |
| 7649 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD, |
| 7650 | hdd_ctx->config->qdf_trace_enable_hdd); |
| 7651 | hdd_qdf_trace_enable(QDF_MODULE_ID_SME, |
| 7652 | hdd_ctx->config->qdf_trace_enable_sme); |
| 7653 | hdd_qdf_trace_enable(QDF_MODULE_ID_PE, |
| 7654 | hdd_ctx->config->qdf_trace_enable_pe); |
| 7655 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMA, |
| 7656 | hdd_ctx->config->qdf_trace_enable_wma); |
| 7657 | hdd_qdf_trace_enable(QDF_MODULE_ID_SYS, |
| 7658 | hdd_ctx->config->qdf_trace_enable_sys); |
| 7659 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF, |
| 7660 | hdd_ctx->config->qdf_trace_enable_qdf); |
| 7661 | hdd_qdf_trace_enable(QDF_MODULE_ID_SAP, |
| 7662 | hdd_ctx->config->qdf_trace_enable_sap); |
| 7663 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SOFTAP, |
| 7664 | hdd_ctx->config->qdf_trace_enable_hdd_sap); |
| 7665 | hdd_qdf_trace_enable(QDF_MODULE_ID_BMI, |
| 7666 | hdd_ctx->config->qdf_trace_enable_bmi); |
| 7667 | hdd_qdf_trace_enable(QDF_MODULE_ID_CFG, |
| 7668 | hdd_ctx->config->qdf_trace_enable_cfg); |
| 7669 | hdd_qdf_trace_enable(QDF_MODULE_ID_EPPING, |
| 7670 | hdd_ctx->config->qdf_trace_enable_epping); |
| 7671 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF_DEVICE, |
| 7672 | hdd_ctx->config->qdf_trace_enable_qdf_devices); |
| 7673 | hdd_qdf_trace_enable(QDF_MODULE_ID_TXRX, |
Houston Hoffman | fbf0510 | 2017-08-28 11:37:01 -0700 | [diff] [blame] | 7674 | hdd_ctx->config->qdf_trace_enable_txrx); |
| 7675 | hdd_qdf_trace_enable(QDF_MODULE_ID_DP, |
| 7676 | hdd_ctx->config->qdf_trace_enable_dp); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7677 | hdd_qdf_trace_enable(QDF_MODULE_ID_HTC, |
| 7678 | hdd_ctx->config->qdf_trace_enable_htc); |
| 7679 | hdd_qdf_trace_enable(QDF_MODULE_ID_HIF, |
| 7680 | hdd_ctx->config->qdf_trace_enable_hif); |
| 7681 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SAP_DATA, |
| 7682 | hdd_ctx->config->qdf_trace_enable_hdd_sap_data); |
| 7683 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_DATA, |
| 7684 | hdd_ctx->config->qdf_trace_enable_hdd_data); |
Naveen Rawat | 7df3186 | 2017-03-01 17:09:30 -0800 | [diff] [blame] | 7685 | hdd_qdf_trace_enable(QDF_MODULE_ID_WIFIPOS, |
| 7686 | hdd_ctx->config->qdf_trace_enable_wifi_pos); |
Naveen Rawat | f2b0dbd | 2017-03-27 10:00:15 -0700 | [diff] [blame] | 7687 | hdd_qdf_trace_enable(QDF_MODULE_ID_NAN, |
| 7688 | hdd_ctx->config->qdf_trace_enable_nan); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 7689 | hdd_qdf_trace_enable(QDF_MODULE_ID_REGULATORY, |
| 7690 | hdd_ctx->config->qdf_trace_enable_regulatory); |
| 7691 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7692 | hdd_cfg_print(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7693 | } |
| 7694 | |
| 7695 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7696 | * hdd_context_init() - Initialize HDD context |
| 7697 | * @hdd_ctx: HDD context. |
| 7698 | * |
| 7699 | * Initialize HDD context along with all the feature specific contexts. |
| 7700 | * |
| 7701 | * return: 0 on success and errno on failure. |
| 7702 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7703 | static int hdd_context_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7704 | { |
| 7705 | int ret; |
| 7706 | |
| 7707 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 7708 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 7709 | |
| 7710 | hdd_init_ll_stats_ctx(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 7711 | hdd_init_nud_stats_ctx(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7712 | |
| 7713 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 7714 | init_completion(&hdd_ctx->ready_to_suspend); |
| 7715 | |
| 7716 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7717 | qdf_spinlock_create(&hdd_ctx->sta_update_info_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7718 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7719 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7720 | qdf_list_create(&hdd_ctx->hddAdapters, MAX_NUMBER_OF_ADAPTERS); |
| 7721 | |
| 7722 | init_completion(&hdd_ctx->set_antenna_mode_cmpl); |
| 7723 | |
| 7724 | ret = hdd_scan_context_init(hdd_ctx); |
| 7725 | if (ret) |
| 7726 | goto list_destroy; |
| 7727 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7728 | hdd_rx_wake_lock_create(hdd_ctx); |
| 7729 | |
| 7730 | ret = hdd_sap_context_init(hdd_ctx); |
| 7731 | if (ret) |
| 7732 | goto scan_destroy; |
| 7733 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7734 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 7735 | |
| 7736 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 7737 | |
| 7738 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 7739 | hdd_ctx->config); |
| 7740 | if (ret) |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 7741 | goto sap_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7742 | |
| 7743 | return 0; |
| 7744 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7745 | sap_destroy: |
| 7746 | hdd_sap_context_destroy(hdd_ctx); |
| 7747 | |
| 7748 | scan_destroy: |
| 7749 | hdd_scan_context_destroy(hdd_ctx); |
| 7750 | hdd_rx_wake_lock_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7751 | list_destroy: |
| 7752 | qdf_list_destroy(&hdd_ctx->hddAdapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 7753 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7754 | return ret; |
| 7755 | } |
| 7756 | |
| 7757 | /** |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 7758 | * ie_whitelist_attrs_init() - initialize ie whitelisting attributes |
| 7759 | * @hdd_ctx: pointer to hdd context |
| 7760 | * |
| 7761 | * Return: status of initialization |
| 7762 | * 0 - success |
| 7763 | * negative value - failure |
| 7764 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7765 | static int ie_whitelist_attrs_init(struct hdd_context *hdd_ctx) |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 7766 | { |
| 7767 | int ret; |
| 7768 | |
| 7769 | if (!hdd_ctx->config->probe_req_ie_whitelist) |
| 7770 | return 0; |
| 7771 | |
| 7772 | if (!hdd_validate_prb_req_ie_bitmap(hdd_ctx)) { |
| 7773 | hdd_err("invalid ie bitmap and ouis: disable ie whitelisting"); |
| 7774 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 7775 | return -EINVAL; |
| 7776 | } |
| 7777 | |
| 7778 | /* parse ini string probe req oui */ |
| 7779 | ret = hdd_parse_probe_req_ouis(hdd_ctx); |
| 7780 | if (ret) { |
| 7781 | hdd_err("parsing error: disable ie whitelisting"); |
| 7782 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 7783 | } |
| 7784 | |
| 7785 | return ret; |
| 7786 | } |
| 7787 | |
| 7788 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7789 | * hdd_context_create() - Allocate and inialize HDD context. |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7790 | * @dev: Device Pointer to the underlying device |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7791 | * |
| 7792 | * Allocate and initialize HDD context. HDD context is allocated as part of |
| 7793 | * wiphy allocation and then context is initialized. |
| 7794 | * |
| 7795 | * Return: HDD context on success and ERR_PTR on failure |
| 7796 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7797 | static struct hdd_context *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7798 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7799 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7800 | int ret = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7801 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7802 | |
| 7803 | ENTER(); |
| 7804 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7805 | hdd_ctx = hdd_cfg80211_wiphy_alloc(sizeof(struct hdd_context)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7806 | if (hdd_ctx == NULL) { |
| 7807 | ret = -ENOMEM; |
| 7808 | goto err_out; |
| 7809 | } |
| 7810 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7811 | hdd_ctx->parent_dev = dev; |
Sreelakshmi Konamki | b53c629 | 2017-03-01 13:13:23 +0530 | [diff] [blame] | 7812 | hdd_ctx->last_scan_reject_session_id = 0xFF; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7813 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7814 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7815 | if (hdd_ctx->config == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7816 | hdd_err("Failed to alloc memory for HDD config!"); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7817 | ret = -ENOMEM; |
| 7818 | goto err_free_hdd_context; |
| 7819 | } |
| 7820 | |
| 7821 | /* Read and parse the qcom_cfg.ini file */ |
| 7822 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7823 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7824 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7825 | WLAN_INI_FILE); |
| 7826 | ret = -EINVAL; |
| 7827 | goto err_free_config; |
| 7828 | } |
| 7829 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 7830 | ie_whitelist_attrs_init(hdd_ctx); |
| 7831 | |
Dustin Brown | 7f93993 | 2017-05-18 15:02:17 -0700 | [diff] [blame] | 7832 | hdd_debug("setting timer multiplier: %u", |
| 7833 | hdd_ctx->config->timer_multiplier); |
| 7834 | qdf_timer_set_multiplier(hdd_ctx->config->timer_multiplier); |
| 7835 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7836 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 7837 | if (hdd_ctx->config->fhostNSOffload) |
| 7838 | hdd_ctx->ns_offload_enable = true; |
| 7839 | |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 7840 | cds_set_fatal_event(hdd_ctx->config->enable_fatal_event); |
| 7841 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7842 | hdd_override_ini_config(hdd_ctx); |
| 7843 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7844 | ret = hdd_context_init(hdd_ctx); |
| 7845 | |
| 7846 | if (ret) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7847 | goto err_free_config; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7848 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7849 | /* Uses to enabled logging after SSR */ |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 7850 | hdd_ctx->fw_log_settings.enable = hdd_ctx->config->enable_fw_log; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7851 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7852 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7853 | goto skip_multicast_logging; |
| 7854 | |
| 7855 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 7856 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 7857 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 7858 | if (ret) |
| 7859 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7860 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 7861 | ret = hdd_init_netlink_services(hdd_ctx); |
| 7862 | if (ret) |
| 7863 | goto err_deinit_txrx_histogram; |
| 7864 | |
Dustin Brown | 7b3dea2 | 2017-07-10 13:02:47 -0700 | [diff] [blame] | 7865 | wlan_logging_set_log_to_console(hdd_ctx->config->wlanLoggingToConsole); |
| 7866 | wlan_logging_set_active(hdd_ctx->config->wlanLoggingEnable); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7867 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7868 | skip_multicast_logging: |
| 7869 | hdd_set_trace_level_for_each(hdd_ctx); |
| 7870 | |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 7871 | cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); |
| 7872 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 7873 | EXIT(); |
| 7874 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7875 | return hdd_ctx; |
| 7876 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 7877 | err_deinit_txrx_histogram: |
| 7878 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 7879 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 7880 | err_deinit_hdd_context: |
| 7881 | hdd_context_deinit(hdd_ctx); |
| 7882 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7883 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7884 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7885 | |
| 7886 | err_free_hdd_context: |
| 7887 | wiphy_free(hdd_ctx->wiphy); |
| 7888 | |
| 7889 | err_out: |
| 7890 | return ERR_PTR(ret); |
| 7891 | } |
| 7892 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7893 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 7894 | /** |
| 7895 | * hdd_open_p2p_interface - Open P2P interface |
| 7896 | * @hdd_ctx: HDD context |
| 7897 | * @rtnl_held: True if RTNL lock held |
| 7898 | * |
| 7899 | * Open P2P interface during probe. This function called to open the P2P |
| 7900 | * interface at probe along with STA interface. |
| 7901 | * |
| 7902 | * Return: 0 on success and errno on failure |
| 7903 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7904 | 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] | 7905 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7906 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7907 | uint8_t *p2p_dev_addr; |
| 7908 | |
| 7909 | if (hdd_ctx->config->isP2pDeviceAddrAdministrated && |
| 7910 | !(hdd_ctx->config->intfMacAddr[0].bytes[0] & 0x02)) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7911 | qdf_mem_copy(hdd_ctx->p2pDeviceAddress.bytes, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7912 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 7913 | sizeof(tSirMacAddr)); |
| 7914 | |
| 7915 | /* |
| 7916 | * Generate the P2P Device Address. This consists of |
| 7917 | * the device's primary MAC address with the locally |
| 7918 | * administered bit set. |
| 7919 | */ |
| 7920 | hdd_ctx->p2pDeviceAddress.bytes[0] |= 0x02; |
| 7921 | } else { |
| 7922 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx); |
| 7923 | if (p2p_dev_addr == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7924 | hdd_err("Failed to allocate mac_address for p2p_device"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7925 | return -ENOSPC; |
| 7926 | } |
| 7927 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7928 | qdf_mem_copy(&hdd_ctx->p2pDeviceAddress.bytes[0], p2p_dev_addr, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7929 | QDF_MAC_ADDR_SIZE); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7930 | } |
| 7931 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7932 | adapter = hdd_open_adapter(hdd_ctx, QDF_P2P_DEVICE_MODE, "p2p%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7933 | &hdd_ctx->p2pDeviceAddress.bytes[0], |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 7934 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7935 | |
| 7936 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7937 | hdd_err("Failed to do hdd_open_adapter for P2P Device Interface"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7938 | return -ENOSPC; |
| 7939 | } |
| 7940 | |
| 7941 | return 0; |
| 7942 | } |
| 7943 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7944 | static inline int hdd_open_p2p_interface(struct hdd_context *hdd_ctx, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7945 | bool rtnl_held) |
| 7946 | { |
| 7947 | return 0; |
| 7948 | } |
| 7949 | #endif |
| 7950 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7951 | 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] | 7952 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7953 | struct hdd_adapter *adapter; |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7954 | int ret = 0; |
| 7955 | |
| 7956 | adapter = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, "wlanocb%d", |
| 7957 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 7958 | NET_NAME_UNKNOWN, rtnl_held); |
| 7959 | if (adapter == NULL) { |
| 7960 | hdd_err("Failed to open 802.11p interface"); |
| 7961 | ret = -ENOSPC; |
| 7962 | } |
| 7963 | |
| 7964 | return ret; |
| 7965 | } |
| 7966 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7967 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 7968 | * hdd_start_station_adapter()- Start the Station Adapter |
| 7969 | * @adapter: HDD adapter |
| 7970 | * |
| 7971 | * This function initializes the adapter for the station mode. |
| 7972 | * |
| 7973 | * Return: 0 on success or errno on failure. |
| 7974 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7975 | int hdd_start_station_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 7976 | { |
| 7977 | QDF_STATUS status; |
| 7978 | |
| 7979 | ENTER_DEV(adapter->dev); |
| 7980 | |
| 7981 | status = hdd_init_station_mode(adapter); |
| 7982 | |
| 7983 | if (QDF_STATUS_SUCCESS != status) { |
| 7984 | hdd_err("Error Initializing station mode: %d", status); |
| 7985 | return qdf_status_to_os_return(status); |
| 7986 | } |
| 7987 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7988 | hdd_register_tx_flow_control(adapter, |
| 7989 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 7990 | hdd_tx_resume_cb, |
| 7991 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7992 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 7993 | EXIT(); |
| 7994 | return 0; |
| 7995 | } |
| 7996 | |
| 7997 | /** |
| 7998 | * hdd_start_ap_adapter()- Start AP Adapter |
| 7999 | * @adapter: HDD adapter |
| 8000 | * |
| 8001 | * This function initializes the adapter for the AP mode. |
| 8002 | * |
| 8003 | * Return: 0 on success errno on failure. |
| 8004 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8005 | int hdd_start_ap_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8006 | { |
| 8007 | QDF_STATUS status; |
| 8008 | |
| 8009 | ENTER(); |
| 8010 | |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 8011 | status = hdd_init_ap_mode(adapter, false); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8012 | |
| 8013 | if (QDF_STATUS_SUCCESS != status) { |
| 8014 | hdd_err("Error Initializing the AP mode: %d", status); |
| 8015 | return qdf_status_to_os_return(status); |
| 8016 | } |
| 8017 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8018 | hdd_register_tx_flow_control(adapter, |
| 8019 | hdd_softap_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 8020 | hdd_softap_tx_resume_cb, |
| 8021 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8022 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8023 | EXIT(); |
| 8024 | return 0; |
| 8025 | } |
| 8026 | |
| 8027 | /** |
| 8028 | * hdd_start_ftm_adapter()- Start FTM adapter |
| 8029 | * @adapter: HDD adapter |
| 8030 | * |
| 8031 | * This function initializes the adapter for the FTM mode. |
| 8032 | * |
| 8033 | * Return: 0 on success or errno on failure. |
| 8034 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8035 | int hdd_start_ftm_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8036 | { |
| 8037 | QDF_STATUS qdf_status; |
| 8038 | |
| 8039 | ENTER_DEV(adapter->dev); |
| 8040 | |
| 8041 | qdf_status = hdd_init_tx_rx(adapter); |
| 8042 | |
| 8043 | if (QDF_STATUS_SUCCESS != qdf_status) { |
| 8044 | hdd_err("Failed to start FTM adapter: %d", qdf_status); |
| 8045 | return qdf_status_to_os_return(qdf_status); |
| 8046 | } |
| 8047 | |
| 8048 | return 0; |
| 8049 | EXIT(); |
| 8050 | } |
| 8051 | |
| 8052 | /** |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8053 | * hdd_open_interfaces - Open all required interfaces |
| 8054 | * hdd_ctx: HDD context |
| 8055 | * rtnl_held: True if RTNL lock is held |
| 8056 | * |
| 8057 | * Open all the interfaces like STA, P2P and OCB based on the configuration. |
| 8058 | * |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8059 | * Return: 0 if all interfaces were created, otherwise negative errno |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8060 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8061 | 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] | 8062 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8063 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8064 | int ret; |
| 8065 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8066 | /* open monitor mode adapter if con_mode is monitor mode */ |
| 8067 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
| 8068 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
| 8069 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8070 | NET_NAME_UNKNOWN, rtnl_held); |
| 8071 | if (!adapter) { |
| 8072 | hdd_err("open adapter failed"); |
| 8073 | return -ENOSPC; |
| 8074 | } |
| 8075 | return 0; |
| 8076 | } |
| 8077 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8078 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_STANDALONE) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8079 | /* Create only 802.11p interface */ |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8080 | return hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8081 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8082 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, "wlan%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8083 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 8084 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8085 | |
| 8086 | if (adapter == NULL) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8087 | return -ENOSPC; |
| 8088 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 8089 | /* fast roaming is allowed only on first STA, i.e. wlan adapter */ |
| 8090 | adapter->fast_roaming_allowed = true; |
| 8091 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8092 | ret = hdd_open_p2p_interface(hdd_ctx, rtnl_held); |
| 8093 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8094 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8095 | |
| 8096 | /* Open 802.11p Interface */ |
| 8097 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_CONCURRENT) { |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8098 | ret = hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
| 8099 | if (ret) |
| 8100 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8101 | } |
| 8102 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8103 | return 0; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8104 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8105 | err_close_adapters: |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8106 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8107 | return ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8108 | } |
| 8109 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8110 | /** |
| 8111 | * hdd_update_country_code - Update country code |
| 8112 | * @hdd_ctx: HDD context |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8113 | * |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 8114 | * Update country code based on module parameter country_code |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8115 | * |
| 8116 | * Return: 0 on success and errno on failure |
| 8117 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8118 | static int hdd_update_country_code(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8119 | { |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 8120 | if (!country_code) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8121 | return 0; |
| 8122 | |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 8123 | return hdd_reg_set_country(hdd_ctx, country_code); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8124 | } |
| 8125 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8126 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 8127 | /** |
| 8128 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 8129 | * @cds_cfg: CDS Configuration |
| 8130 | * @hdd_ctx: Pointer to hdd context |
| 8131 | * |
| 8132 | * Return: none |
| 8133 | */ |
| 8134 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 8135 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8136 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8137 | { |
| 8138 | cds_cfg->tx_flow_stop_queue_th = |
| 8139 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 8140 | cds_cfg->tx_flow_start_queue_offset = |
| 8141 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 8142 | } |
| 8143 | #else |
| 8144 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 8145 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8146 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8147 | { |
| 8148 | } |
| 8149 | #endif |
| 8150 | |
| 8151 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 8152 | /** |
| 8153 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 8154 | * @cds_cfg: CDS Configuration |
| 8155 | * @hdd_ctx: Pointer to hdd context |
| 8156 | * |
| 8157 | * Return: none |
| 8158 | */ |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 8159 | 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] | 8160 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8161 | { |
| 8162 | cds_cfg->ra_ratelimit_interval = |
| 8163 | hdd_ctx->config->RArateLimitInterval; |
| 8164 | cds_cfg->is_ra_ratelimit_enabled = |
| 8165 | hdd_ctx->config->IsRArateLimitEnabled; |
| 8166 | } |
| 8167 | #else |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 8168 | 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] | 8169 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8170 | { |
| 8171 | } |
| 8172 | #endif |
| 8173 | |
| 8174 | /** |
| 8175 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 8176 | * @hdd_ctx: HDD Context |
| 8177 | * |
| 8178 | * Return: 0 for Success, errno on failure |
| 8179 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8180 | static int hdd_update_cds_config(struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8181 | { |
| 8182 | struct cds_config_info *cds_cfg; |
| 8183 | |
| 8184 | cds_cfg = (struct cds_config_info *)qdf_mem_malloc(sizeof(*cds_cfg)); |
| 8185 | if (!cds_cfg) { |
| 8186 | hdd_err("failed to allocate cds config"); |
| 8187 | return -ENOMEM; |
| 8188 | } |
| 8189 | |
Srinivas Girigowda | 35b0031 | 2017-06-27 21:52:03 -0700 | [diff] [blame] | 8190 | cds_cfg->driver_type = QDF_DRIVER_TYPE_PRODUCTION; |
Kiran Kumar Lokere | 7006e0a | 2017-03-07 19:28:36 -0800 | [diff] [blame] | 8191 | if (!hdd_ctx->config->nMaxPsPoll || |
| 8192 | !hdd_ctx->config->enablePowersaveOffload) { |
| 8193 | cds_cfg->powersave_offload_enabled = |
| 8194 | hdd_ctx->config->enablePowersaveOffload; |
| 8195 | } else { |
| 8196 | if ((hdd_ctx->config->enablePowersaveOffload == |
| 8197 | PS_QPOWER_NODEEPSLEEP) || |
| 8198 | (hdd_ctx->config->enablePowersaveOffload == |
| 8199 | PS_LEGACY_NODEEPSLEEP)) |
| 8200 | cds_cfg->powersave_offload_enabled = |
| 8201 | PS_LEGACY_NODEEPSLEEP; |
| 8202 | else |
| 8203 | cds_cfg->powersave_offload_enabled = |
| 8204 | PS_LEGACY_DEEPSLEEP; |
| 8205 | hdd_info("Qpower disabled in cds config, %d", |
| 8206 | cds_cfg->powersave_offload_enabled); |
| 8207 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8208 | cds_cfg->sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 8209 | cds_cfg->sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 8210 | cds_cfg->sta_maxlimod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 8211 | cds_cfg->wow_enable = hdd_ctx->config->wowEnable; |
| 8212 | cds_cfg->max_wow_filters = hdd_ctx->config->maxWoWFilters; |
| 8213 | |
| 8214 | /* Here ol_ini_info is used to store ini status of arp offload |
| 8215 | * ns offload and others. Currently 1st bit is used for arp |
| 8216 | * off load and 2nd bit for ns offload currently, rest bits are unused |
| 8217 | */ |
| 8218 | if (hdd_ctx->config->fhostArpOffload) |
| 8219 | cds_cfg->ol_ini_info = cds_cfg->ol_ini_info | 0x1; |
| 8220 | if (hdd_ctx->config->fhostNSOffload) |
| 8221 | cds_cfg->ol_ini_info = cds_cfg->ol_ini_info | 0x2; |
| 8222 | |
| 8223 | /* |
| 8224 | * Copy the DFS Phyerr Filtering Offload status. |
| 8225 | * This parameter reflects the value of the |
| 8226 | * dfs_phyerr_filter_offload flag as set in the ini. |
| 8227 | */ |
| 8228 | cds_cfg->dfs_phyerr_filter_offload = |
| 8229 | hdd_ctx->config->fDfsPhyerrFilterOffload; |
| 8230 | if (hdd_ctx->config->ssdp) |
| 8231 | cds_cfg->ssdp = hdd_ctx->config->ssdp; |
| 8232 | |
SaidiReddy Yenuga | cc733af | 2016-11-09 17:45:42 +0530 | [diff] [blame] | 8233 | cds_cfg->force_target_assert_enabled = |
| 8234 | hdd_ctx->config->crash_inject_enabled; |
| 8235 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8236 | cds_cfg->enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 8237 | cds_cfg->ap_maxoffload_peers = hdd_ctx->config->apMaxOffloadPeers; |
| 8238 | |
| 8239 | cds_cfg->ap_maxoffload_reorderbuffs = |
| 8240 | hdd_ctx->config->apMaxOffloadReorderBuffs; |
| 8241 | |
| 8242 | cds_cfg->ap_disable_intrabss_fwd = |
| 8243 | hdd_ctx->config->apDisableIntraBssFwd; |
| 8244 | |
| 8245 | cds_cfg->dfs_pri_multiplier = |
| 8246 | hdd_ctx->config->dfsRadarPriMultiplier; |
| 8247 | cds_cfg->reorder_offload = |
| 8248 | hdd_ctx->config->reorderOffloadSupport; |
| 8249 | |
| 8250 | /* IPA micro controller data path offload resource config item */ |
| 8251 | cds_cfg->uc_offload_enabled = hdd_ipa_uc_is_enabled(hdd_ctx); |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8252 | if (!is_power_of_2(hdd_ctx->config->IpaUcTxBufCount)) { |
| 8253 | /* IpaUcTxBufCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8254 | hdd_debug("Round down IpaUcTxBufCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8255 | hdd_ctx->config->IpaUcTxBufCount); |
| 8256 | hdd_ctx->config->IpaUcTxBufCount = |
| 8257 | rounddown_pow_of_two( |
| 8258 | hdd_ctx->config->IpaUcTxBufCount); |
| 8259 | if (!hdd_ctx->config->IpaUcTxBufCount) { |
| 8260 | hdd_err("Failed to round down IpaUcTxBufCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 8261 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8262 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8263 | hdd_debug("IpaUcTxBufCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8264 | hdd_ctx->config->IpaUcTxBufCount); |
| 8265 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8266 | cds_cfg->uc_txbuf_count = hdd_ctx->config->IpaUcTxBufCount; |
| 8267 | cds_cfg->uc_txbuf_size = hdd_ctx->config->IpaUcTxBufSize; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8268 | if (!is_power_of_2(hdd_ctx->config->IpaUcRxIndRingCount)) { |
| 8269 | /* IpaUcRxIndRingCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8270 | hdd_debug("Round down IpaUcRxIndRingCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8271 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 8272 | hdd_ctx->config->IpaUcRxIndRingCount = |
| 8273 | rounddown_pow_of_two( |
| 8274 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 8275 | if (!hdd_ctx->config->IpaUcRxIndRingCount) { |
| 8276 | hdd_err("Failed to round down IpaUcRxIndRingCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 8277 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8278 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8279 | hdd_debug("IpaUcRxIndRingCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8280 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 8281 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8282 | cds_cfg->uc_rxind_ringcount = |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8283 | hdd_ctx->config->IpaUcRxIndRingCount; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8284 | cds_cfg->uc_tx_partition_base = |
| 8285 | hdd_ctx->config->IpaUcTxPartitionBase; |
| 8286 | cds_cfg->max_scan = hdd_ctx->config->max_scan_count; |
| 8287 | |
| 8288 | cds_cfg->ip_tcp_udp_checksum_offload = |
| 8289 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 8290 | cds_cfg->enable_rxthread = hdd_ctx->enableRxThread; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8291 | cds_cfg->ce_classify_enabled = |
| 8292 | hdd_ctx->config->ce_classify_enabled; |
Dustin Brown | d3fc9ee | 2016-09-14 13:57:27 -0700 | [diff] [blame] | 8293 | cds_cfg->bpf_packet_filter_enable = |
| 8294 | hdd_ctx->config->bpf_packet_filter_enable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8295 | cds_cfg->tx_chain_mask_cck = hdd_ctx->config->tx_chain_mask_cck; |
| 8296 | cds_cfg->self_gen_frm_pwr = hdd_ctx->config->self_gen_frm_pwr; |
| 8297 | cds_cfg->max_station = hdd_ctx->config->maxNumberOfPeers; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 8298 | cds_cfg->sub_20_channel_width = WLAN_SUB_20_CH_WIDTH_NONE; |
Manjunathappa Prakash | fff753c | 2016-09-01 19:34:56 -0700 | [diff] [blame] | 8299 | cds_cfg->flow_steering_enabled = hdd_ctx->config->flow_steering_enable; |
Orhan K AKYILDIZ | 30e8cbc | 2017-08-11 18:00:28 -0700 | [diff] [blame] | 8300 | cds_cfg->max_msdus_per_rxinorderind = |
| 8301 | hdd_ctx->config->max_msdus_per_rxinorderind; |
Naveen Rawat | 91df30a | 2016-10-12 21:26:18 -0700 | [diff] [blame] | 8302 | cds_cfg->self_recovery_enabled = hdd_ctx->config->enableSelfRecovery; |
Sandeep Puligilla | afa5289 | 2016-10-26 19:03:16 -0700 | [diff] [blame] | 8303 | cds_cfg->fw_timeout_crash = hdd_ctx->config->fw_timeout_crash; |
Hanumanth Reddy Pothula | e87621b | 2017-04-12 20:53:35 +0530 | [diff] [blame] | 8304 | cds_cfg->active_uc_bpf_mode = hdd_ctx->config->active_uc_bpf_mode; |
| 8305 | cds_cfg->active_mc_bc_bpf_mode = hdd_ctx->config->active_mc_bc_bpf_mode; |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 8306 | cds_cfg->auto_power_save_fail_mode = |
| 8307 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8308 | |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 8309 | cds_cfg->ito_repeat_count = hdd_ctx->config->ito_repeat_count; |
Sandeep Puligilla | 819d94f | 2017-10-10 18:33:56 -0700 | [diff] [blame] | 8310 | cds_cfg->bandcapability = hdd_ctx->config->nBandCapability; |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 8311 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8312 | hdd_ra_populate_cds_config(cds_cfg, hdd_ctx); |
| 8313 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
| 8314 | hdd_nan_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 8315 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8316 | cds_init_ini_config(cds_cfg); |
| 8317 | return 0; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 8318 | |
| 8319 | exit: |
| 8320 | qdf_mem_free(cds_cfg); |
| 8321 | return -EINVAL; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8322 | } |
| 8323 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8324 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 8325 | * hdd_update_user_config() - API to update user configuration |
| 8326 | * parameters to obj mgr which are used by multiple components |
| 8327 | * @hdd_ctx: HDD Context |
| 8328 | * |
| 8329 | * Return: 0 for Success, errno on failure |
| 8330 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8331 | static int hdd_update_user_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 8332 | { |
| 8333 | struct wlan_objmgr_psoc_user_config *user_config; |
| 8334 | |
| 8335 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
| 8336 | if (user_config == NULL) { |
| 8337 | hdd_alert("Failed to alloc memory for user_config!"); |
| 8338 | return -ENOMEM; |
| 8339 | } |
| 8340 | |
| 8341 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
| 8342 | user_config->dual_mac_feature_disable = |
| 8343 | hdd_ctx->config->dual_mac_feature_disable; |
| 8344 | user_config->indoor_channel_support = |
| 8345 | hdd_ctx->config->indoor_channel_support; |
| 8346 | user_config->is_11d_support_enabled = |
| 8347 | hdd_ctx->config->Is11dSupportEnabled; |
| 8348 | user_config->is_11h_support_enabled = |
| 8349 | hdd_ctx->config->Is11hSupportEnabled; |
| 8350 | user_config->optimize_chan_avoid_event = |
| 8351 | hdd_ctx->config->goptimize_chan_avoid_event; |
| 8352 | user_config->skip_dfs_chnl_in_p2p_search = |
| 8353 | hdd_ctx->config->skipDfsChnlInP2pSearch; |
Naveen Rawat | 222b2e9 | 2017-03-16 09:52:21 -0700 | [diff] [blame] | 8354 | user_config->band_capability = hdd_ctx->config->nBandCapability; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 8355 | wlan_objmgr_psoc_set_user_config(hdd_ctx->hdd_psoc, user_config); |
| 8356 | |
| 8357 | qdf_mem_free(user_config); |
| 8358 | return 0; |
| 8359 | } |
| 8360 | |
| 8361 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8362 | * hdd_init_thermal_info - Initialize thermal level |
| 8363 | * @hdd_ctx: HDD context |
| 8364 | * |
| 8365 | * Initialize thermal level at SME layer and set the thermal level callback |
| 8366 | * which would be called when a configured thermal threshold is hit. |
| 8367 | * |
| 8368 | * Return: 0 on success and errno on failure |
| 8369 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8370 | static int hdd_init_thermal_info(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8371 | { |
| 8372 | tSmeThermalParams thermal_param; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8373 | QDF_STATUS status; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8374 | |
| 8375 | thermal_param.smeThermalMgmtEnabled = |
| 8376 | hdd_ctx->config->thermalMitigationEnable; |
| 8377 | thermal_param.smeThrottlePeriod = hdd_ctx->config->throttlePeriod; |
| 8378 | |
Poddar, Siddarth | 8390502 | 2016-04-16 17:56:08 -0700 | [diff] [blame] | 8379 | thermal_param.sme_throttle_duty_cycle_tbl[0] = |
| 8380 | hdd_ctx->config->throttle_dutycycle_level0; |
| 8381 | thermal_param.sme_throttle_duty_cycle_tbl[1] = |
| 8382 | hdd_ctx->config->throttle_dutycycle_level1; |
| 8383 | thermal_param.sme_throttle_duty_cycle_tbl[2] = |
| 8384 | hdd_ctx->config->throttle_dutycycle_level2; |
| 8385 | thermal_param.sme_throttle_duty_cycle_tbl[3] = |
| 8386 | hdd_ctx->config->throttle_dutycycle_level3; |
| 8387 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8388 | thermal_param.smeThermalLevels[0].smeMinTempThreshold = |
| 8389 | hdd_ctx->config->thermalTempMinLevel0; |
| 8390 | thermal_param.smeThermalLevels[0].smeMaxTempThreshold = |
| 8391 | hdd_ctx->config->thermalTempMaxLevel0; |
| 8392 | thermal_param.smeThermalLevels[1].smeMinTempThreshold = |
| 8393 | hdd_ctx->config->thermalTempMinLevel1; |
| 8394 | thermal_param.smeThermalLevels[1].smeMaxTempThreshold = |
| 8395 | hdd_ctx->config->thermalTempMaxLevel1; |
| 8396 | thermal_param.smeThermalLevels[2].smeMinTempThreshold = |
| 8397 | hdd_ctx->config->thermalTempMinLevel2; |
| 8398 | thermal_param.smeThermalLevels[2].smeMaxTempThreshold = |
| 8399 | hdd_ctx->config->thermalTempMaxLevel2; |
| 8400 | thermal_param.smeThermalLevels[3].smeMinTempThreshold = |
| 8401 | hdd_ctx->config->thermalTempMinLevel3; |
| 8402 | thermal_param.smeThermalLevels[3].smeMaxTempThreshold = |
| 8403 | hdd_ctx->config->thermalTempMaxLevel3; |
| 8404 | |
| 8405 | status = sme_init_thermal_info(hdd_ctx->hHal, thermal_param); |
| 8406 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8407 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 8408 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8409 | |
| 8410 | sme_add_set_thermal_level_callback(hdd_ctx->hHal, |
| 8411 | hdd_set_thermal_level_cb); |
| 8412 | |
| 8413 | return 0; |
| 8414 | |
| 8415 | } |
| 8416 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8417 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 8418 | /** |
| 8419 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 8420 | * |
| 8421 | * Hold RTNL lock |
| 8422 | * |
| 8423 | * Return: True if held and false otherwise |
| 8424 | */ |
| 8425 | static inline bool hdd_hold_rtnl_lock(void) |
| 8426 | { |
| 8427 | rtnl_lock(); |
| 8428 | return true; |
| 8429 | } |
| 8430 | |
| 8431 | /** |
| 8432 | * hdd_release_rtnl_lock - Release RTNL lock |
| 8433 | * |
| 8434 | * Release RTNL lock |
| 8435 | * |
| 8436 | * Return: None |
| 8437 | */ |
| 8438 | static inline void hdd_release_rtnl_lock(void) |
| 8439 | { |
| 8440 | rtnl_unlock(); |
| 8441 | } |
| 8442 | #else |
| 8443 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 8444 | static inline void hdd_release_rtnl_lock(void) { } |
| 8445 | #endif |
| 8446 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8447 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8448 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8449 | /* MAX iwpriv command support */ |
| 8450 | #define PKTLOG_SET_BUFF_SIZE 3 |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8451 | #define PKTLOG_CLEAR_BUFF 4 |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8452 | #define MAX_PKTLOG_SIZE 16 |
| 8453 | |
| 8454 | /** |
| 8455 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 8456 | * @hdd_ctx: hdd context |
| 8457 | * @set_value2: pktlog buffer size value |
| 8458 | * |
| 8459 | * |
| 8460 | * Return: 0 for success or error. |
| 8461 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8462 | 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] | 8463 | { |
| 8464 | struct sir_wifi_start_log start_log = { 0 }; |
| 8465 | QDF_STATUS status; |
| 8466 | |
| 8467 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 8468 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 8469 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 8470 | start_log.user_triggered = 1; |
| 8471 | start_log.size = set_value2; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8472 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8473 | |
| 8474 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 8475 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8476 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 8477 | EXIT(); |
| 8478 | return -EINVAL; |
| 8479 | } |
| 8480 | |
| 8481 | return 0; |
| 8482 | } |
| 8483 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8484 | /** |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8485 | * hdd_pktlog_clear_buff() - clear pktlog buffer |
| 8486 | * @hdd_ctx: hdd context |
| 8487 | * |
| 8488 | * Return: 0 for success or error. |
| 8489 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8490 | static int hdd_pktlog_clear_buff(struct hdd_context *hdd_ctx) |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8491 | { |
| 8492 | struct sir_wifi_start_log start_log; |
| 8493 | QDF_STATUS status; |
| 8494 | |
| 8495 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 8496 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 8497 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 8498 | start_log.user_triggered = 1; |
| 8499 | start_log.size = 0; |
| 8500 | start_log.is_pktlog_buff_clear = true; |
| 8501 | |
| 8502 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 8503 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8504 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 8505 | EXIT(); |
| 8506 | return -EINVAL; |
| 8507 | } |
| 8508 | |
| 8509 | return 0; |
| 8510 | } |
| 8511 | |
| 8512 | |
| 8513 | /** |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8514 | * hdd_process_pktlog_command() - process pktlog command |
| 8515 | * @hdd_ctx: hdd context |
| 8516 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8517 | * @set_value2: pktlog buffer size value |
| 8518 | * |
| 8519 | * This function process pktlog command. |
| 8520 | * set_value2 only matters when set_value is 3 (set buff size) |
| 8521 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8522 | * |
| 8523 | * Return: 0 for success or error. |
| 8524 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8525 | 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] | 8526 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8527 | { |
| 8528 | int ret; |
| 8529 | bool enable; |
| 8530 | uint8_t user_triggered = 0; |
| 8531 | |
| 8532 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 8533 | if (0 != ret) |
| 8534 | return ret; |
| 8535 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8536 | hdd_debug("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8537 | |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8538 | if (set_value > PKTLOG_CLEAR_BUFF) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8539 | hdd_err("invalid pktlog value %d", set_value); |
| 8540 | return -EINVAL; |
| 8541 | } |
| 8542 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8543 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 8544 | if (set_value2 <= 0) { |
| 8545 | hdd_err("invalid pktlog size %d", set_value2); |
| 8546 | return -EINVAL; |
| 8547 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
| 8548 | hdd_err("Pktlog buff size is too large. max value is 16MB.\n"); |
| 8549 | return -EINVAL; |
| 8550 | } |
| 8551 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8552 | } else if (set_value == PKTLOG_CLEAR_BUFF) { |
| 8553 | return hdd_pktlog_clear_buff(hdd_ctx); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8554 | } |
| 8555 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8556 | /* |
| 8557 | * set_value = 0 then disable packetlog |
| 8558 | * set_value = 1 enable packetlog forcefully |
| 8559 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 8560 | * enable packetlog with AUTO type. |
| 8561 | */ |
| 8562 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 8563 | true : false; |
| 8564 | |
| 8565 | if (1 == set_value) { |
| 8566 | enable = true; |
| 8567 | user_triggered = 1; |
| 8568 | } |
| 8569 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8570 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8571 | } |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 8572 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8573 | /** |
| 8574 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 8575 | * @hdd_ctx: HDD context |
| 8576 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8577 | * @user_triggered: triggered through iwpriv |
| 8578 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8579 | * |
| 8580 | * Return: 0 on success; error number otherwise |
| 8581 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8582 | int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8583 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8584 | { |
| 8585 | struct sir_wifi_start_log start_log; |
| 8586 | QDF_STATUS status; |
| 8587 | |
| 8588 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 8589 | start_log.verbose_level = |
| 8590 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8591 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 8592 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8593 | start_log.size = size; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8594 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 8595 | /* |
| 8596 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 8597 | * commands. Host uses this flag to decide whether to send pktlog |
| 8598 | * disable command to fw without sending pktlog enable command |
| 8599 | * previously. For eg, If vendor sends pktlog disable command without |
| 8600 | * sending pktlog enable command, then host discards the packet |
| 8601 | * but for iwpriv command, host will send it to fw. |
| 8602 | */ |
| 8603 | start_log.is_iwpriv_command = 1; |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8604 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 8605 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8606 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 8607 | EXIT(); |
| 8608 | return -EINVAL; |
| 8609 | } |
| 8610 | |
| 8611 | return 0; |
| 8612 | } |
| 8613 | #endif /* REMOVE_PKT_LOG */ |
| 8614 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8615 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 8616 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 8617 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8618 | * @dev: Device Pointer |
| 8619 | * @num: Number of Valid Mac address |
| 8620 | * |
| 8621 | * Return: Pointer to MAC address buffer |
| 8622 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 8623 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 8624 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8625 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 8626 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8627 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8628 | |
| 8629 | /** |
| 8630 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 8631 | * @hdd_ctx: HDD Context |
| 8632 | * @num: Number of random mac addresses needed |
| 8633 | * |
| 8634 | * Generate random addresses using bit manipulation on the base mac address |
| 8635 | * |
| 8636 | * Return: None |
| 8637 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8638 | 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] | 8639 | { |
| 8640 | uint32_t start_idx = QDF_MAX_CONCURRENCY_PERSONA - num; |
| 8641 | uint32_t iter; |
| 8642 | struct hdd_config *ini = hdd_ctx->config; |
| 8643 | uint8_t *buf = NULL; |
| 8644 | uint8_t macaddr_b3, tmp_br3; |
| 8645 | uint8_t *src = ini->intfMacAddr[0].bytes; |
| 8646 | |
| 8647 | for (iter = start_idx; iter < QDF_MAX_CONCURRENCY_PERSONA; ++iter) { |
| 8648 | buf = ini->intfMacAddr[iter].bytes; |
| 8649 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 8650 | macaddr_b3 = buf[3]; |
| 8651 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + iter) & |
| 8652 | INTF_MACADDR_MASK; |
| 8653 | macaddr_b3 += tmp_br3; |
| 8654 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 8655 | buf[0] |= 0x02; |
| 8656 | buf[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8657 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8658 | } |
| 8659 | } |
| 8660 | |
| 8661 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 8662 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8663 | * @hdd_ctx: HDD Context |
| 8664 | * |
| 8665 | * API to get mac addresses from platform driver and update the driver |
| 8666 | * structures and configure FW with the base mac address. |
| 8667 | * Return: int |
| 8668 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8669 | static int hdd_platform_wlan_mac(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8670 | { |
| 8671 | uint32_t no_of_mac_addr, iter; |
| 8672 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 8673 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 8674 | uint8_t *addr, *buf; |
| 8675 | struct device *dev = hdd_ctx->parent_dev; |
| 8676 | struct hdd_config *ini = hdd_ctx->config; |
| 8677 | tSirMacAddr mac_addr; |
| 8678 | QDF_STATUS status; |
| 8679 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 8680 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8681 | |
| 8682 | if (no_of_mac_addr == 0 || !addr) { |
| 8683 | hdd_warn("Platform Driver Doesn't have wlan mac addresses"); |
| 8684 | return -EINVAL; |
| 8685 | } |
| 8686 | |
| 8687 | if (no_of_mac_addr > max_mac_addr) |
| 8688 | no_of_mac_addr = max_mac_addr; |
| 8689 | |
| 8690 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 8691 | |
| 8692 | for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { |
| 8693 | buf = ini->intfMacAddr[iter].bytes; |
| 8694 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8695 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8696 | } |
| 8697 | |
| 8698 | status = sme_set_custom_mac_addr(mac_addr); |
| 8699 | |
| 8700 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8701 | return -EAGAIN; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 8702 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8703 | if (no_of_mac_addr < max_mac_addr) |
| 8704 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 8705 | no_of_mac_addr); |
| 8706 | return 0; |
| 8707 | } |
| 8708 | |
| 8709 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 8710 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 8711 | * @hdd_ctx: HDD Context |
| 8712 | * |
| 8713 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 8714 | * will generate its own MAC and update it to FW. |
| 8715 | * |
| 8716 | * Return: 0 for success |
| 8717 | * Non-zero error code for failure |
| 8718 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8719 | 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] | 8720 | { |
| 8721 | tSirMacAddr customMacAddr; |
| 8722 | QDF_STATUS status; |
| 8723 | |
| 8724 | qdf_mem_copy(&customMacAddr, |
| 8725 | &hdd_ctx->config->intfMacAddr[0].bytes[0], |
| 8726 | sizeof(tSirMacAddr)); |
| 8727 | status = sme_set_custom_mac_addr(customMacAddr); |
| 8728 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8729 | return -EAGAIN; |
| 8730 | return 0; |
| 8731 | } |
| 8732 | |
| 8733 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8734 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 8735 | * @hdd_ctx: HDD Context |
| 8736 | * |
| 8737 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 8738 | * is provisioned with mac addresses, driver uses it, else it will use |
| 8739 | * wlan_mac.bin to update HW MAC addresses. |
| 8740 | * |
| 8741 | * Return: None |
| 8742 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8743 | static void hdd_initialize_mac_address(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8744 | { |
| 8745 | QDF_STATUS status; |
| 8746 | int ret; |
| 8747 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 8748 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8749 | if (ret == 0) |
| 8750 | return; |
| 8751 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 8752 | hdd_info("MAC is not programmed in platform driver ret: %d, use wlan_mac.bin", |
| 8753 | ret); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8754 | |
| 8755 | status = hdd_update_mac_config(hdd_ctx); |
| 8756 | |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 8757 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 8758 | return; |
| 8759 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 8760 | hdd_info("MAC is not programmed in wlan_mac.bin ret %d, use default MAC", |
| 8761 | status); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 8762 | |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 8763 | if (hdd_ctx->update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 8764 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 8765 | if (ret != 0) { |
| 8766 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
| 8767 | QDF_ASSERT(ret); |
| 8768 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 8769 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8770 | } |
| 8771 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8772 | static int hdd_set_smart_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 8773 | { |
| 8774 | int vdev_id = 0; |
| 8775 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
| 8776 | int value = hdd_ctx->config->smart_chainmask_enabled; |
| 8777 | int vpdev = PDEV_CMD; |
| 8778 | int ret; |
| 8779 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 8780 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 8781 | if (ret) |
| 8782 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 8783 | |
| 8784 | return ret; |
| 8785 | } |
| 8786 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8787 | static int hdd_set_alternative_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 8788 | { |
| 8789 | int vdev_id = 0; |
| 8790 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
| 8791 | int value = hdd_ctx->config->alternative_chainmask_enabled; |
| 8792 | int vpdev = PDEV_CMD; |
| 8793 | int ret; |
| 8794 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 8795 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 8796 | if (ret) |
| 8797 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 8798 | ret); |
| 8799 | |
| 8800 | return ret; |
| 8801 | } |
| 8802 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8803 | static int hdd_set_ani_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 8804 | { |
| 8805 | int vdev_id = 0; |
| 8806 | int param_id = WMI_PDEV_PARAM_ANI_ENABLE; |
| 8807 | int value = hdd_ctx->config->ani_enabled; |
| 8808 | int vpdev = PDEV_CMD; |
| 8809 | int ret; |
| 8810 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 8811 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 8812 | if (ret) |
| 8813 | hdd_err("WMI_PDEV_PARAM_ANI_ENABLE failed %d", ret); |
| 8814 | |
| 8815 | return ret; |
| 8816 | } |
| 8817 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 8818 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8819 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 8820 | * @hdd_ctx: HDD context |
| 8821 | * |
| 8822 | * Pre configurations to be done at lower layer before calling cds enable. |
| 8823 | * |
| 8824 | * Return: 0 on success and errno on failure. |
| 8825 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8826 | static int hdd_pre_enable_configure(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8827 | { |
| 8828 | int ret; |
| 8829 | QDF_STATUS status; |
| 8830 | tSirRetStatus hal_status; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 8831 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8832 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 8833 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8834 | /* |
| 8835 | * Set 802.11p config |
| 8836 | * TODO-OCB: This has been temporarily added here to ensure this |
| 8837 | * parameter is set in CSR when we init the channel list. This should |
| 8838 | * be removed once the 5.9 GHz channels are added to the regulatory |
| 8839 | * domain. |
| 8840 | */ |
| 8841 | hdd_set_dot11p_config(hdd_ctx); |
| 8842 | |
| 8843 | /* |
| 8844 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 8845 | * The cfg download must occur before we update the SME config |
| 8846 | * since the SME config operation must access the cfg database |
| 8847 | */ |
| 8848 | status = hdd_set_sme_config(hdd_ctx); |
| 8849 | |
| 8850 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8851 | hdd_err("Failed hdd_set_sme_config: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8852 | ret = qdf_status_to_os_return(status); |
| 8853 | goto out; |
| 8854 | } |
| 8855 | |
Tushnim Bhattacharyya | ba8ee93 | 2017-03-23 09:27:40 -0700 | [diff] [blame] | 8856 | status = hdd_set_policy_mgr_user_cfg(hdd_ctx); |
| 8857 | if (QDF_STATUS_SUCCESS != status) { |
| 8858 | hdd_alert("Failed hdd_set_policy_mgr_user_cfg: %d", status); |
| 8859 | ret = qdf_status_to_os_return(status); |
| 8860 | goto out; |
| 8861 | } |
| 8862 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 8863 | 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] | 8864 | hdd_ctx->config->tx_chain_mask_1ss, |
| 8865 | PDEV_CMD); |
| 8866 | if (0 != ret) { |
| 8867 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 8868 | goto out; |
| 8869 | } |
| 8870 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 8871 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 8872 | if (ret) |
| 8873 | goto out; |
| 8874 | |
| 8875 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 8876 | if (ret) |
| 8877 | goto out; |
| 8878 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 8879 | ret = hdd_set_ani_enabled(hdd_ctx); |
| 8880 | if (ret) |
| 8881 | goto out; |
| 8882 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 8883 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 8884 | hdd_ctx->config->arp_ac_category, |
| 8885 | PDEV_CMD); |
| 8886 | if (0 != ret) { |
| 8887 | hdd_err("WMI_PDEV_PARAM_ARP_AC_OVERRIDE ac: %d ret: %d", |
| 8888 | hdd_ctx->config->arp_ac_category, ret); |
| 8889 | goto out; |
| 8890 | } |
| 8891 | |
| 8892 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8893 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 8894 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8895 | hdd_err("Failed to init channel list: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8896 | ret = qdf_status_to_os_return(status); |
| 8897 | goto out; |
| 8898 | } |
| 8899 | |
| 8900 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 8901 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8902 | hdd_err("config update failed"); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8903 | ret = -EINVAL; |
| 8904 | goto out; |
| 8905 | } |
| 8906 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8907 | /* |
| 8908 | * Set the MAC Address Currently this is used by HAL to add self sta. |
| 8909 | * Remove this once self sta is added as part of session open. |
| 8910 | */ |
| 8911 | hal_status = cfg_set_str(hdd_ctx->hHal, WNI_CFG_STA_ID, |
| 8912 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 8913 | sizeof(hdd_ctx->config->intfMacAddr[0])); |
| 8914 | |
| 8915 | if (!IS_SIR_STATUS_SUCCESS(hal_status)) { |
| 8916 | hdd_err("Failed to set MAC Address. HALStatus is %08d [x%08x]", |
| 8917 | hal_status, hal_status); |
| 8918 | ret = -EINVAL; |
| 8919 | goto out; |
| 8920 | } |
| 8921 | |
| 8922 | hdd_init_channel_avoidance(hdd_ctx); |
| 8923 | |
Ganesh Kondabattini | 408fb8d | 2017-08-08 22:00:20 +0530 | [diff] [blame] | 8924 | /* update enable sap mandatory chan list */ |
| 8925 | policy_mgr_enable_disable_sap_mandatory_chan_list(hdd_ctx->hdd_psoc, |
| 8926 | hdd_ctx->config->enable_sap_mandatory_chan_list); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8927 | out: |
| 8928 | return ret; |
| 8929 | } |
| 8930 | |
| 8931 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 8932 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
| 8933 | * @context_ptr - hdd context pointer |
| 8934 | * @event_ptr - event structure pointer |
| 8935 | * |
| 8936 | * This is the p2p listen offload stop event handler, it sends vendor |
| 8937 | * event back to supplicant to notify the stop reason. |
| 8938 | * |
| 8939 | * Return: None |
| 8940 | */ |
| 8941 | static void wlan_hdd_p2p_lo_event_callback(void *context_ptr, |
| 8942 | void *event_ptr) |
| 8943 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8944 | struct hdd_context *hdd_ctx = (struct hdd_context *)context_ptr; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 8945 | struct sir_p2p_lo_event *evt = event_ptr; |
| 8946 | struct sk_buff *vendor_event; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8947 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 8948 | |
| 8949 | ENTER(); |
| 8950 | |
| 8951 | if (hdd_ctx == NULL) { |
| 8952 | hdd_err("Invalid HDD context pointer"); |
| 8953 | return; |
| 8954 | } |
| 8955 | |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 8956 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id); |
| 8957 | if (!adapter) { |
| 8958 | hdd_err("Cannot find adapter by vdev_id = %d", |
| 8959 | evt->vdev_id); |
| 8960 | return; |
| 8961 | } |
| 8962 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 8963 | vendor_event = |
| 8964 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 8965 | &(adapter->wdev), sizeof(uint32_t) + NLMSG_HDRLEN, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 8966 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 8967 | GFP_KERNEL); |
| 8968 | |
| 8969 | if (!vendor_event) { |
| 8970 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 8971 | return; |
| 8972 | } |
| 8973 | |
| 8974 | if (nla_put_u32(vendor_event, |
| 8975 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 8976 | evt->reason_code)) { |
| 8977 | hdd_err("nla put failed"); |
| 8978 | kfree_skb(vendor_event); |
| 8979 | return; |
| 8980 | } |
| 8981 | |
| 8982 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 8983 | hdd_debug("Sent P2P_LISTEN_OFFLOAD_STOP event for vdev_id = %d", |
| 8984 | evt->vdev_id); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 8985 | } |
| 8986 | |
| 8987 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 8988 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 8989 | * @hdd_ctx: HDD context |
| 8990 | * |
| 8991 | * This function sends the adaptive dwell time config configuration to the |
| 8992 | * firmware via WMA |
| 8993 | * |
| 8994 | * Return: 0 - success, < 0 - failure |
| 8995 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8996 | static int hdd_adaptive_dwelltime_init(struct hdd_context *hdd_ctx) |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 8997 | { |
| 8998 | QDF_STATUS status; |
| 8999 | struct adaptive_dwelltime_params dwelltime_params; |
| 9000 | |
| 9001 | dwelltime_params.is_enabled = |
| 9002 | hdd_ctx->config->adaptive_dwell_mode_enabled; |
| 9003 | dwelltime_params.dwelltime_mode = |
| 9004 | hdd_ctx->config->global_adapt_dwelltime_mode; |
| 9005 | dwelltime_params.lpf_weight = |
| 9006 | hdd_ctx->config->adapt_dwell_lpf_weight; |
| 9007 | dwelltime_params.passive_mon_intval = |
| 9008 | hdd_ctx->config->adapt_dwell_passive_mon_intval; |
| 9009 | dwelltime_params.wifi_act_threshold = |
| 9010 | hdd_ctx->config->adapt_dwell_wifi_act_threshold; |
| 9011 | |
| 9012 | status = sme_set_adaptive_dwelltime_config(hdd_ctx->hHal, |
| 9013 | &dwelltime_params); |
| 9014 | |
| 9015 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 9016 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9017 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 9018 | return -EAGAIN; |
| 9019 | } |
| 9020 | return 0; |
| 9021 | } |
| 9022 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9023 | int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9024 | { |
| 9025 | QDF_STATUS status; |
| 9026 | struct wmi_dbs_scan_sel_params dbs_scan_params; |
| 9027 | uint32_t i = 0; |
| 9028 | uint8_t count = 0, numentries = 0; |
| 9029 | uint8_t dbs_scan_config[CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 9030 | * CDS_DBS_SCAN_CLIENTS_MAX]; |
| 9031 | |
| 9032 | /* check if DBS is enabled or supported */ |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 9033 | if (hdd_ctx->config->dual_mac_feature_disable == |
| 9034 | DISABLE_DBS_CXN_AND_SCAN) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9035 | return -EINVAL; |
| 9036 | |
| 9037 | hdd_string_to_u8_array(hdd_ctx->config->dbs_scan_selection, |
| 9038 | dbs_scan_config, &numentries, |
| 9039 | (CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 9040 | * CDS_DBS_SCAN_CLIENTS_MAX)); |
| 9041 | |
| 9042 | hdd_info("numentries %hu", numentries); |
| 9043 | if (!numentries) { |
| 9044 | hdd_info("Donot send scan_selection_config"); |
| 9045 | return 0; |
| 9046 | } |
| 9047 | |
| 9048 | /* hdd_set_fw_log_params */ |
| 9049 | dbs_scan_params.num_clients = 0; |
| 9050 | while (count < (numentries - 2)) { |
| 9051 | dbs_scan_params.module_id[i] = dbs_scan_config[count]; |
| 9052 | dbs_scan_params.num_dbs_scans[i] = dbs_scan_config[count + 1]; |
| 9053 | dbs_scan_params.num_non_dbs_scans[i] = |
| 9054 | dbs_scan_config[count + 2]; |
| 9055 | dbs_scan_params.num_clients++; |
| 9056 | hdd_debug("module:%d NDS:%d NNDS:%d", |
| 9057 | dbs_scan_params.module_id[i], |
| 9058 | dbs_scan_params.num_dbs_scans[i], |
| 9059 | dbs_scan_params.num_non_dbs_scans[i]); |
| 9060 | count += CDS_DBS_SCAN_PARAM_PER_CLIENT; |
| 9061 | i++; |
| 9062 | } |
| 9063 | |
| 9064 | dbs_scan_params.pdev_id = 0; |
| 9065 | |
| 9066 | hdd_debug("clients:%d pdev:%d", |
| 9067 | dbs_scan_params.num_clients, dbs_scan_params.pdev_id); |
| 9068 | |
| 9069 | status = sme_set_dbs_scan_selection_config(hdd_ctx->hHal, |
| 9070 | &dbs_scan_params); |
| 9071 | hdd_debug("Sending DBS Scan Selection Configuration to fw"); |
| 9072 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9073 | hdd_err("Failed to send DBS Scan selection configuration!"); |
| 9074 | return -EAGAIN; |
| 9075 | } |
| 9076 | return 0; |
| 9077 | } |
| 9078 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9079 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 9080 | /** |
| 9081 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 9082 | * @hdd_ctx: HDD context |
| 9083 | * |
| 9084 | * Set auto shutdown callback to get indications from firmware to indicate |
| 9085 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 9086 | * |
| 9087 | * Return: 0 on success and errno on failure. |
| 9088 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9089 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9090 | { |
| 9091 | QDF_STATUS status; |
| 9092 | |
| 9093 | if (!hdd_ctx->config->WlanAutoShutdown) |
| 9094 | return 0; |
| 9095 | |
| 9096 | status = sme_set_auto_shutdown_cb(hdd_ctx->hHal, |
| 9097 | wlan_hdd_auto_shutdown_cb); |
| 9098 | if (status != QDF_STATUS_SUCCESS) |
| 9099 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 9100 | status); |
| 9101 | |
| 9102 | return qdf_status_to_os_return(status); |
| 9103 | } |
| 9104 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9105 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9106 | { |
| 9107 | return 0; |
| 9108 | } |
| 9109 | #endif |
| 9110 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9111 | static QDF_STATUS hdd_set_dbs_scan_and_fw_mode_cfg(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 9112 | { |
| 9113 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 9114 | |
| 9115 | switch (hdd_ctx->config->dual_mac_feature_disable) { |
| 9116 | case DISABLE_DBS_CXN_AND_SCAN: |
| 9117 | status = wlan_hdd_disable_all_dual_mac_features(hdd_ctx); |
| 9118 | if (status != QDF_STATUS_SUCCESS) |
| 9119 | hdd_err("Failed to disable dual mac features"); |
| 9120 | break; |
| 9121 | case DISABLE_DBS_CXN_AND_ENABLE_DBS_SCAN: |
| 9122 | case DISABLE_DBS_CXN_AND_ENABLE_DBS_SCAN_WITH_ASYNC_SCAN_OFF: |
| 9123 | case ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF: |
| 9124 | status = wlan_hdd_update_dbs_scan_and_fw_mode_config(hdd_ctx); |
| 9125 | if (status != QDF_STATUS_SUCCESS) |
| 9126 | hdd_err("Failed to set dbs scan and fw mode config"); |
| 9127 | break; |
| 9128 | default: |
| 9129 | break; |
| 9130 | } |
| 9131 | |
| 9132 | return status; |
| 9133 | } |
| 9134 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9135 | /** |
| 9136 | * hdd_features_init() - Init features |
| 9137 | * @hdd_ctx: HDD context |
| 9138 | * @adapter: Primary adapter context |
| 9139 | * |
| 9140 | * Initialize features and their feature context after WLAN firmware is up. |
| 9141 | * |
| 9142 | * Return: 0 on success and errno on failure. |
| 9143 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9144 | static int hdd_features_init(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9145 | { |
| 9146 | tSirTxPowerLimit hddtxlimit; |
| 9147 | QDF_STATUS status; |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 9148 | struct sme_5g_band_pref_params band_pref_params; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9149 | int ret; |
| 9150 | |
| 9151 | ENTER(); |
| 9152 | |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 9153 | ret = hdd_update_country_code(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9154 | if (ret) { |
| 9155 | hdd_err("Failed to update country code: %d", ret); |
| 9156 | goto out; |
| 9157 | } |
| 9158 | |
| 9159 | /* FW capabilities received, Set the Dot11 mode */ |
| 9160 | sme_setdef_dot11mode(hdd_ctx->hHal); |
Kiran Kumar Lokere | 1aa9c9a | 2016-10-05 18:50:59 -0700 | [diff] [blame] | 9161 | sme_set_prefer_80MHz_over_160MHz(hdd_ctx->hHal, |
| 9162 | hdd_ctx->config->sta_prefer_80MHz_over_160MHz); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9163 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9164 | |
| 9165 | if (hdd_ctx->config->fIsImpsEnabled) |
| 9166 | hdd_set_idle_ps_config(hdd_ctx, true); |
| 9167 | else |
| 9168 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 9169 | |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 9170 | if (hdd_ctx->config->enable_go_cts2self_for_sta) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9171 | sme_set_cts2self_for_p2p_go(hdd_ctx->hHal); |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 9172 | |
Nachiket Kukade | 8983cf6 | 2017-10-12 18:14:48 +0530 | [diff] [blame] | 9173 | if (sme_set_vc_mode_config(hdd_ctx->config->vc_mode_cfg_bitmap)) |
| 9174 | hdd_warn("Error in setting Voltage Corner mode config to FW"); |
| 9175 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9176 | if (hdd_lro_init(hdd_ctx)) |
| 9177 | hdd_err("Unable to initialize LRO in fw"); |
| 9178 | |
| 9179 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 9180 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 9181 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9182 | if (hdd_dbs_scan_selection_init(hdd_ctx)) |
| 9183 | hdd_err("Unable to send DBS scan selection setting to FW"); |
| 9184 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9185 | ret = hdd_init_thermal_info(hdd_ctx); |
| 9186 | if (ret) { |
| 9187 | hdd_err("Error while initializing thermal information"); |
| 9188 | goto deregister_frames; |
| 9189 | } |
| 9190 | |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 9191 | if (cds_is_packet_log_enabled()) |
| 9192 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
| 9193 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9194 | hddtxlimit.txPower2g = hdd_ctx->config->TxPower2g; |
| 9195 | hddtxlimit.txPower5g = hdd_ctx->config->TxPower5g; |
| 9196 | status = sme_txpower_limit(hdd_ctx->hHal, &hddtxlimit); |
| 9197 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9198 | hdd_err("Error setting txlimit in sme: %d", status); |
| 9199 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9200 | wlan_hdd_tsf_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9201 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9202 | ret = hdd_register_cb(hdd_ctx); |
| 9203 | if (ret) { |
| 9204 | hdd_err("Failed to register HDD callbacks!"); |
| 9205 | goto deregister_frames; |
| 9206 | } |
| 9207 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 9208 | status = hdd_set_dbs_scan_and_fw_mode_cfg(hdd_ctx); |
| 9209 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9210 | hdd_err("Failed to set dbs scan and fw mode cfg"); |
| 9211 | goto deregister_cb; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9212 | } |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 9213 | |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 9214 | if (hdd_ctx->config->goptimize_chan_avoid_event) { |
| 9215 | status = sme_enable_disable_chanavoidind_event( |
| 9216 | hdd_ctx->hHal, 0); |
| 9217 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9218 | hdd_err("Failed to disable Chan Avoidance Indication"); |
| 9219 | goto deregister_cb; |
| 9220 | } |
| 9221 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9222 | |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 9223 | if (hdd_ctx->config->enable_5g_band_pref) { |
| 9224 | band_pref_params.rssi_boost_threshold_5g = |
| 9225 | hdd_ctx->config->rssi_boost_threshold_5g; |
| 9226 | band_pref_params.rssi_boost_factor_5g = |
| 9227 | hdd_ctx->config->rssi_boost_factor_5g; |
| 9228 | band_pref_params.max_rssi_boost_5g = |
| 9229 | hdd_ctx->config->max_rssi_boost_5g; |
| 9230 | band_pref_params.rssi_penalize_threshold_5g = |
| 9231 | hdd_ctx->config->rssi_penalize_threshold_5g; |
| 9232 | band_pref_params.rssi_penalize_factor_5g = |
| 9233 | hdd_ctx->config->rssi_penalize_factor_5g; |
| 9234 | band_pref_params.max_rssi_penalize_5g = |
| 9235 | hdd_ctx->config->max_rssi_penalize_5g; |
| 9236 | sme_set_5g_band_pref(hdd_ctx->hHal, &band_pref_params); |
| 9237 | } |
| 9238 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9239 | /* register P2P Listen Offload event callback */ |
| 9240 | if (wma_is_p2p_lo_capable()) |
| 9241 | sme_register_p2p_lo_event(hdd_ctx->hHal, hdd_ctx, |
| 9242 | wlan_hdd_p2p_lo_event_callback); |
| 9243 | |
| 9244 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 9245 | |
| 9246 | if (ret) |
| 9247 | goto deregister_cb; |
| 9248 | |
| 9249 | EXIT(); |
| 9250 | return 0; |
| 9251 | |
| 9252 | deregister_cb: |
| 9253 | hdd_deregister_cb(hdd_ctx); |
| 9254 | deregister_frames: |
| 9255 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 9256 | out: |
| 9257 | return -EINVAL; |
| 9258 | |
| 9259 | } |
| 9260 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9261 | /** |
| 9262 | * hdd_features_deinit() - Deinit features |
| 9263 | * @hdd_ctx: HDD context |
| 9264 | * |
| 9265 | * De-Initialize features and their feature context. |
| 9266 | * |
| 9267 | * Return: none. |
| 9268 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9269 | static void hdd_features_deinit(struct hdd_context *hdd_ctx) |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9270 | { |
| 9271 | wlan_hdd_tsf_deinit(hdd_ctx); |
| 9272 | } |
| 9273 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9274 | /** |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 9275 | * hdd_register_bcn_cb() - register scan beacon callback |
| 9276 | * @hdd_ctx - Pointer to the HDD context |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9277 | * |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 9278 | * Return: QDF_STATUS |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9279 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9280 | 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] | 9281 | { |
| 9282 | QDF_STATUS status; |
| 9283 | |
| 9284 | status = ucfg_scan_register_bcn_cb(hdd_ctx->hdd_psoc, |
| 9285 | wlan_cfg80211_inform_bss_frame, |
| 9286 | SCAN_CB_TYPE_INFORM_BCN); |
| 9287 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9288 | hdd_err("failed with status code %08d [x%08x]", |
| 9289 | status, status); |
| 9290 | return status; |
| 9291 | } |
| 9292 | |
| 9293 | return QDF_STATUS_SUCCESS; |
| 9294 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9295 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9296 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9297 | * hdd_configure_cds() - Configure cds modules |
| 9298 | * @hdd_ctx: HDD context |
| 9299 | * @adapter: Primary adapter context |
| 9300 | * |
| 9301 | * Enable Cds modules after WLAN firmware is up. |
| 9302 | * |
| 9303 | * Return: 0 on success and errno on failure. |
| 9304 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9305 | int hdd_configure_cds(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9306 | { |
| 9307 | int ret; |
| 9308 | QDF_STATUS status; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 9309 | int set_value; |
| 9310 | uint32_t num_abg_tx_chains = 0; |
| 9311 | uint32_t num_11b_tx_chains = 0; |
| 9312 | uint32_t num_11ag_tx_chains = 0; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 9313 | struct policy_mgr_dp_cbacks dp_cbs; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 9314 | |
| 9315 | if (hdd_ctx->config->sifs_burst_duration) { |
| 9316 | set_value = (SIFS_BURST_DUR_MULTIPLIER) * |
| 9317 | hdd_ctx->config->sifs_burst_duration; |
| 9318 | |
| 9319 | if ((set_value > 0) && (set_value <= SIFS_BURST_DUR_MAX)) |
| 9320 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_BURST_DUR, |
| 9321 | set_value, PDEV_CMD); |
| 9322 | } |
| 9323 | |
| 9324 | if (hdd_ctx->config->is_force_1x1) |
| 9325 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_SET_IOT_PATTERN, |
| 9326 | 1, PDEV_CMD); |
| 9327 | /* set chip power save failure detected callback */ |
| 9328 | sme_set_chip_pwr_save_fail_cb(hdd_ctx->hHal, |
| 9329 | hdd_chip_pwr_save_fail_detected_cb); |
| 9330 | |
| 9331 | if (hdd_ctx->config->max_mpdus_inampdu) { |
| 9332 | set_value = hdd_ctx->config->max_mpdus_inampdu; |
| 9333 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_MAX_MPDUS_IN_AMPDU, |
| 9334 | set_value, PDEV_CMD); |
| 9335 | } |
| 9336 | |
| 9337 | if (hdd_ctx->config->enable_rts_sifsbursting) { |
| 9338 | set_value = hdd_ctx->config->enable_rts_sifsbursting; |
| 9339 | sme_cli_set_command(0, |
| 9340 | (int)WMI_PDEV_PARAM_ENABLE_RTS_SIFS_BURSTING, |
| 9341 | set_value, PDEV_CMD); |
| 9342 | } |
| 9343 | |
| 9344 | if (hdd_ctx->config->sap_get_peer_info) { |
| 9345 | set_value = hdd_ctx->config->sap_get_peer_info; |
| 9346 | sme_cli_set_command(0, |
| 9347 | (int)WMI_PDEV_PARAM_PEER_STATS_INFO_ENABLE, |
| 9348 | set_value, PDEV_CMD); |
| 9349 | } |
| 9350 | |
| 9351 | num_11b_tx_chains = hdd_ctx->config->num_11b_tx_chains; |
| 9352 | num_11ag_tx_chains = hdd_ctx->config->num_11ag_tx_chains; |
| 9353 | if (!hdd_ctx->config->enable2x2) { |
| 9354 | if (num_11b_tx_chains > 1) |
| 9355 | num_11b_tx_chains = 1; |
| 9356 | if (num_11ag_tx_chains > 1) |
| 9357 | num_11ag_tx_chains = 1; |
| 9358 | } |
| 9359 | WMI_PDEV_PARAM_SET_11B_TX_CHAIN_NUM(num_abg_tx_chains, |
| 9360 | num_11b_tx_chains); |
| 9361 | WMI_PDEV_PARAM_SET_11AG_TX_CHAIN_NUM(num_abg_tx_chains, |
| 9362 | num_11ag_tx_chains); |
| 9363 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_ABG_MODE_TX_CHAIN_NUM, |
| 9364 | num_abg_tx_chains, PDEV_CMD); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9365 | |
| 9366 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 9367 | if (ret) { |
| 9368 | hdd_err("Failed to pre-configure cds"); |
| 9369 | goto out; |
| 9370 | } |
| 9371 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 9372 | /* Always get latest IPA resources allocated from cds_open and configure |
| 9373 | * IPA module before configuring them to FW. Sequence required as crash |
| 9374 | * observed otherwise. |
| 9375 | */ |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 9376 | if (hdd_ipa_uc_ol_init(hdd_ctx)) { |
| 9377 | hdd_err("Failed to setup pipes"); |
| 9378 | goto out; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 9379 | } |
| 9380 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9381 | /* |
| 9382 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 9383 | * else |
| 9384 | */ |
Jeff Johnson | 8f9dd5f | 2017-09-13 14:16:08 -0700 | [diff] [blame] | 9385 | status = cds_enable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9386 | |
| 9387 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9388 | hdd_err("cds_enable failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9389 | goto out; |
| 9390 | } |
| 9391 | |
| 9392 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 9393 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9394 | hdd_err("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9395 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9396 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9397 | status = hdd_register_bcn_cb(hdd_ctx); |
| 9398 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9399 | hdd_alert("hdd_post_cds_enable_config failed"); |
| 9400 | goto cds_disable; |
| 9401 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9402 | |
| 9403 | ret = hdd_features_init(hdd_ctx, adapter); |
| 9404 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9405 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9406 | |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 9407 | dp_cbs.hdd_disable_lro_in_concurrency = hdd_disable_lro_in_concurrency; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 9408 | dp_cbs.hdd_set_rx_mode_rps_cb = hdd_set_rx_mode_rps; |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 9409 | status = policy_mgr_register_dp_cb(hdd_ctx->hdd_psoc, &dp_cbs); |
| 9410 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 9411 | hdd_debug("Failed to register DP cb with Policy Manager"); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 9412 | goto cds_disable; |
| 9413 | } |
| 9414 | |
Nachiket Kukade | fbd1afc | 2017-07-12 17:41:54 +0530 | [diff] [blame] | 9415 | if (hdd_enable_egap(hdd_ctx)) |
| 9416 | hdd_debug("enhance green ap is not enabled"); |
| 9417 | |
Nachiket Kukade | dd30266 | 2017-07-13 17:31:44 +0530 | [diff] [blame] | 9418 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 9419 | hdd_debug("Failed to set wow pulse"); |
| 9420 | |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 9421 | sme_cli_set_command(0, WMI_PDEV_AUTO_DETECT_POWER_FAILURE, |
| 9422 | hdd_ctx->config->auto_pwr_save_fail_mode, PDEV_CMD); |
| 9423 | |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 9424 | |
| 9425 | if (hdd_ctx->config->enable_phy_reg_retention) |
| 9426 | wma_cli_set_command(0, WMI_PDEV_PARAM_FAST_PWR_TRANSITION, |
| 9427 | hdd_ctx->config->enable_phy_reg_retention, PDEV_CMD); |
| 9428 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9429 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9430 | |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9431 | cds_disable: |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 9432 | cds_disable(hdd_ctx->hdd_psoc); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9433 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9434 | out: |
| 9435 | return -EINVAL; |
| 9436 | } |
| 9437 | |
| 9438 | /** |
| 9439 | * hdd_deconfigure_cds() -De-Configure cds |
| 9440 | * @hdd_ctx: HDD context |
| 9441 | * |
| 9442 | * Deconfigure Cds modules before WLAN firmware is down. |
| 9443 | * |
| 9444 | * Return: 0 on success and errno on failure. |
| 9445 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9446 | static int hdd_deconfigure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9447 | { |
| 9448 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 9449 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9450 | |
| 9451 | ENTER(); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9452 | |
| 9453 | /* De-init features */ |
| 9454 | hdd_features_deinit(hdd_ctx); |
| 9455 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9456 | /* De-register the SME callbacks */ |
| 9457 | hdd_deregister_cb(hdd_ctx); |
| 9458 | |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 9459 | qdf_status = cds_disable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9460 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 9461 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 9462 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 9463 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9464 | } |
| 9465 | |
Sravan Kumar Kairam | 7112171 | 2017-04-15 00:34:42 +0530 | [diff] [blame] | 9466 | if (hdd_ipa_uc_ol_deinit(hdd_ctx)) { |
| 9467 | hdd_err("Failed to disconnect pipes"); |
| 9468 | ret = -EINVAL; |
| 9469 | } |
| 9470 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9471 | EXIT(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 9472 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9473 | } |
| 9474 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 9475 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 9476 | static void hdd_deregister_policy_manager_callback( |
| 9477 | struct wlan_objmgr_psoc *psoc) |
| 9478 | { |
| 9479 | if (QDF_STATUS_SUCCESS != |
| 9480 | policy_mgr_deregister_hdd_cb(psoc)) { |
| 9481 | hdd_err("HDD callback deregister with policy manager failed"); |
| 9482 | } |
| 9483 | } |
| 9484 | #else |
| 9485 | static void hdd_deregister_policy_manager_callback( |
| 9486 | struct wlan_objmgr_psoc *psoc) |
| 9487 | { |
| 9488 | } |
| 9489 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9490 | |
| 9491 | /** |
| 9492 | * hdd_wlan_stop_modules - Single driver state machine for stoping modules |
| 9493 | * @hdd_ctx: HDD context |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 9494 | * @ftm_mode: ftm mode |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9495 | * |
| 9496 | * This function maintains the driver state machine it will be invoked from |
| 9497 | * exit, shutdown and con_mode change handler. Depending on the driver state |
| 9498 | * shall perform the stopping/closing of the modules. |
| 9499 | * |
| 9500 | * Return: 0 for success; non-zero for failure |
| 9501 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9502 | 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] | 9503 | { |
| 9504 | void *hif_ctx; |
| 9505 | qdf_device_t qdf_ctx; |
| 9506 | QDF_STATUS qdf_status; |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9507 | int ret = 0; |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9508 | bool is_idle_stop = !cds_is_driver_unloading() && |
| 9509 | !cds_is_driver_recovering(); |
| 9510 | int active_threads; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9511 | |
| 9512 | ENTER(); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 9513 | hdd_alert("stop WLAN module: entering driver status=%d", |
| 9514 | hdd_ctx->driver_status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9515 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 9516 | hdd_deregister_policy_manager_callback(hdd_ctx->hdd_psoc); |
| 9517 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9518 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 9519 | if (!qdf_ctx) { |
| 9520 | hdd_err("QDF device context NULL"); |
| 9521 | return -EINVAL; |
| 9522 | } |
| 9523 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9524 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 9525 | hdd_ctx->stop_modules_in_progress = true; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 9526 | cds_set_module_stop_in_progress(true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9527 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9528 | active_threads = cds_return_external_threads_count(); |
| 9529 | if (active_threads > 0 || hdd_ctx->isWiphySuspended) { |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 9530 | hdd_warn("External threads %d wiphy suspend %d", |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9531 | active_threads, hdd_ctx->isWiphySuspended); |
| 9532 | |
| 9533 | cds_print_external_threads(); |
| 9534 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 9535 | if (is_idle_stop && !ftm_mode) { |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9536 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 9537 | qdf_mc_timer_start(&hdd_ctx->iface_change_timer, |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 9538 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 9539 | hdd_prevent_suspend_timeout( |
| 9540 | hdd_ctx->config->iface_change_wait_time, |
| 9541 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 9542 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 9543 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9544 | return 0; |
| 9545 | } |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 9546 | } |
| 9547 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9548 | hdd_info("Present Driver Status: %d", hdd_ctx->driver_status); |
| 9549 | |
| 9550 | switch (hdd_ctx->driver_status) { |
| 9551 | case DRIVER_MODULES_UNINITIALIZED: |
| 9552 | hdd_info("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9553 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9554 | case DRIVER_MODULES_CLOSED: |
| 9555 | hdd_info("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9556 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9557 | case DRIVER_MODULES_ENABLED: |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 9558 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9559 | if (hdd_deconfigure_cds(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9560 | hdd_err("Failed to de-configure CDS"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9561 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9562 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9563 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9564 | hdd_debug("successfully Disabled the CDS modules!"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9565 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
| 9566 | break; |
| 9567 | case DRIVER_MODULES_OPENED: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9568 | hdd_debug("Closing CDS modules!"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9569 | break; |
| 9570 | default: |
| 9571 | hdd_err("Trying to stop wlan in a wrong state: %d", |
| 9572 | hdd_ctx->driver_status); |
| 9573 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9574 | ret = -EINVAL; |
| 9575 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9576 | } |
| 9577 | |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 9578 | qdf_status = cds_post_disable(); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 9579 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 9580 | hdd_err("Failed to process post CDS disable Modules! :%d", |
| 9581 | qdf_status); |
| 9582 | ret = -EINVAL; |
| 9583 | QDF_ASSERT(0); |
| 9584 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 9585 | |
| 9586 | qdf_status = cds_dp_close(hdd_ctx->hdd_psoc); |
| 9587 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 9588 | hdd_warn("Failed to stop CDS DP: %d", qdf_status); |
| 9589 | ret = -EINVAL; |
| 9590 | QDF_ASSERT(0); |
| 9591 | } |
| 9592 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 9593 | qdf_status = cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9594 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9595 | hdd_warn("Failed to stop CDS: %d", qdf_status); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 9596 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9597 | QDF_ASSERT(0); |
| 9598 | } |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 9599 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9600 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 9601 | if (!hif_ctx) { |
| 9602 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9603 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9604 | } |
| 9605 | |
Sravan Kumar Kairam | 6457495 | 2017-06-22 11:48:18 +0530 | [diff] [blame] | 9606 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
| 9607 | |
Arunk Khandavalli | 4b40433 | 2017-09-26 12:46:00 +0530 | [diff] [blame] | 9608 | if (hdd_ctx->target_hw_name) { |
| 9609 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 9610 | hdd_ctx->target_hw_name = NULL; |
| 9611 | } |
| 9612 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 9613 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9614 | |
| 9615 | ol_cds_free(); |
| 9616 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9617 | if (is_idle_stop) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9618 | ret = pld_power_off(qdf_ctx->dev); |
| 9619 | if (ret) |
| 9620 | hdd_err("CNSS power down failed put device into Low power mode:%d", |
| 9621 | ret); |
| 9622 | } |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 9623 | |
| 9624 | /* Once the firmware sequence is completed reset this flag */ |
| 9625 | hdd_ctx->imps_enabled = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9626 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Sandeep Puligilla | 1cf6ebe | 2017-04-04 14:40:27 -0700 | [diff] [blame] | 9627 | /* |
| 9628 | * Reset total mac phy during module stop such that during |
| 9629 | * next module start same psoc is used to populate new service |
| 9630 | * ready data |
| 9631 | */ |
| 9632 | hdd_ctx->hdd_psoc->total_mac_phy = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9633 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9634 | done: |
| 9635 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 9636 | cds_set_module_stop_in_progress(false); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9637 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 9638 | hdd_alert("stop WLAN module: exit driver status=%d", |
| 9639 | hdd_ctx->driver_status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9640 | EXIT(); |
| 9641 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9642 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9643 | |
| 9644 | } |
| 9645 | |
| 9646 | /** |
| 9647 | * hdd_iface_change_callback() - Function invoked when stop modules expires |
| 9648 | * @priv: pointer to hdd context |
| 9649 | * |
| 9650 | * This function is invoked when the timer waiting for the interface change |
| 9651 | * expires, it shall cut-down the power to wlan and stop all the modules. |
| 9652 | * |
| 9653 | * Return: void |
| 9654 | */ |
| 9655 | static void hdd_iface_change_callback(void *priv) |
| 9656 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9657 | struct hdd_context *hdd_ctx = (struct hdd_context *) priv; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9658 | int ret; |
| 9659 | int status = wlan_hdd_validate_context(hdd_ctx); |
| 9660 | |
| 9661 | if (status) |
| 9662 | return; |
| 9663 | |
| 9664 | ENTER(); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9665 | hdd_debug("Interface change timer expired close the modules!"); |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 9666 | ret = hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9667 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9668 | hdd_err("Failed to stop modules"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9669 | EXIT(); |
| 9670 | } |
| 9671 | |
| 9672 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 9673 | * hdd_state_info_dump() - prints state information of hdd layer |
| 9674 | * @buf: buffer pointer |
| 9675 | * @size: size of buffer to be filled |
| 9676 | * |
| 9677 | * This function is used to dump state information of hdd layer |
| 9678 | * |
| 9679 | * Return: None |
| 9680 | */ |
| 9681 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 9682 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9683 | struct hdd_context *hdd_ctx; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 9684 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 9685 | QDF_STATUS status; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 9686 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9687 | struct hdd_adapter *adapter; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 9688 | uint16_t len = 0; |
| 9689 | char *buf = *buf_ptr; |
| 9690 | |
| 9691 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 9692 | if (!hdd_ctx) { |
| 9693 | hdd_err("Failed to get hdd context "); |
| 9694 | return; |
| 9695 | } |
| 9696 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9697 | hdd_debug("size of buffer: %d", *size); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 9698 | |
| 9699 | len += scnprintf(buf + len, *size - len, |
| 9700 | "\n isWiphySuspended %d", hdd_ctx->isWiphySuspended); |
| 9701 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 9702 | "\n is_scheduler_suspended %d", |
| 9703 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 9704 | |
| 9705 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 9706 | |
| 9707 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 9708 | adapter = adapter_node->adapter; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 9709 | if (adapter->dev) |
| 9710 | len += scnprintf(buf + len, *size - len, |
| 9711 | "\n device name: %s", adapter->dev->name); |
wadesong | 42968e9 | 2017-06-08 14:11:21 +0800 | [diff] [blame] | 9712 | len += scnprintf(buf + len, *size - len, |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 9713 | "\n device_mode: %d", adapter->device_mode); |
| 9714 | switch (adapter->device_mode) { |
| 9715 | case QDF_STA_MODE: |
| 9716 | case QDF_P2P_CLIENT_MODE: |
| 9717 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 9718 | len += scnprintf(buf + len, *size - len, |
| 9719 | "\n connState: %d", |
| 9720 | hdd_sta_ctx->conn_info.connState); |
| 9721 | break; |
| 9722 | |
| 9723 | default: |
| 9724 | break; |
| 9725 | } |
| 9726 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 9727 | adapter_node = next; |
| 9728 | } |
| 9729 | |
| 9730 | *size -= len; |
| 9731 | *buf_ptr += len; |
| 9732 | } |
| 9733 | |
| 9734 | /** |
| 9735 | * hdd_register_debug_callback() - registration function for hdd layer |
| 9736 | * to print hdd state information |
| 9737 | * |
| 9738 | * Return: None |
| 9739 | */ |
| 9740 | static void hdd_register_debug_callback(void) |
| 9741 | { |
| 9742 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 9743 | } |
| 9744 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 9745 | /* |
| 9746 | * wlan_init_bug_report_lock() - Initialize bug report lock |
| 9747 | * |
| 9748 | * This function is used to create bug report lock |
| 9749 | * |
| 9750 | * Return: None |
| 9751 | */ |
| 9752 | static void wlan_init_bug_report_lock(void) |
| 9753 | { |
| 9754 | p_cds_contextType p_cds_context; |
| 9755 | |
| 9756 | p_cds_context = cds_get_global_context(); |
| 9757 | if (!p_cds_context) { |
| 9758 | hdd_err("cds context is NULL"); |
| 9759 | return; |
| 9760 | } |
| 9761 | |
| 9762 | qdf_spinlock_create(&p_cds_context->bug_report_lock); |
| 9763 | } |
| 9764 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 9765 | void hdd_dp_trace_init(struct hdd_config *config) |
| 9766 | { |
| 9767 | |
| 9768 | bool live_mode = DP_TRACE_CONFIG_DEFAULT_LIVE_MODE; |
| 9769 | uint8_t thresh = DP_TRACE_CONFIG_DEFAULT_THRESH; |
| 9770 | uint16_t thresh_time_limit = DP_TRACE_CONFIG_DEFAULT_THRESH_TIME_LIMIT; |
| 9771 | uint8_t verbosity = DP_TRACE_CONFIG_DEFAULT_VERBOSTY; |
| 9772 | uint8_t proto_bitmap = DP_TRACE_CONFIG_DEFAULT_BITMAP; |
| 9773 | uint8_t config_params[DP_TRACE_CONFIG_NUM_PARAMS]; |
| 9774 | uint8_t num_entries = 0; |
| 9775 | |
| 9776 | hdd_string_to_u8_array(config->dp_trace_config, config_params, |
| 9777 | &num_entries, sizeof(config_params)); |
| 9778 | |
| 9779 | /* calculating, num bw timer intervals in a second (1000ms) */ |
| 9780 | if (config->busBandwidthComputeInterval) |
| 9781 | thresh_time_limit = |
| 9782 | (1000 / config->busBandwidthComputeInterval); |
| 9783 | else |
| 9784 | hdd_err("busBandwidthComputeInterval is 0, using defaults"); |
| 9785 | |
| 9786 | switch (num_entries) { |
| 9787 | case 4: |
| 9788 | proto_bitmap = config_params[3]; |
| 9789 | case 3: |
| 9790 | verbosity = config_params[2]; |
| 9791 | case 2: |
| 9792 | thresh = config_params[1]; |
| 9793 | case 1: |
| 9794 | live_mode = config_params[0]; |
| 9795 | default: |
| 9796 | hdd_info("live_mode %u thresh %u time_limit %u verbosity %u bitmap 0x%x", |
| 9797 | live_mode, thresh, thresh_time_limit, |
| 9798 | verbosity, proto_bitmap); |
| 9799 | }; |
| 9800 | |
| 9801 | qdf_dp_trace_init(live_mode, thresh, thresh_time_limit, |
| 9802 | verbosity, proto_bitmap); |
| 9803 | |
| 9804 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 9805 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9806 | * hdd_wlan_startup() - HDD init function |
| 9807 | * @dev: Pointer to the underlying device |
| 9808 | * |
| 9809 | * This is the driver startup code executed once a WLAN device has been detected |
| 9810 | * |
| 9811 | * Return: 0 for success, < 0 for failure |
| 9812 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9813 | int hdd_wlan_startup(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9814 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9815 | QDF_STATUS status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9816 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9817 | int ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9818 | bool rtnl_held; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9819 | |
| 9820 | ENTER(); |
| 9821 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9822 | hdd_ctx = hdd_context_create(dev); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9823 | |
| 9824 | if (IS_ERR(hdd_ctx)) |
| 9825 | return PTR_ERR(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9826 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 9827 | ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, |
| 9828 | DEFAULT_PSOC_ID); |
| 9829 | if (ret) { |
| 9830 | hdd_err("Psoc creation fails!"); |
| 9831 | QDF_BUG(0); |
| 9832 | goto err_hdd_free_context; |
| 9833 | } |
| 9834 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9835 | qdf_mc_timer_init(&hdd_ctx->iface_change_timer, QDF_TIMER_TYPE_SW, |
| 9836 | hdd_iface_change_callback, (void *)hdd_ctx); |
| 9837 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 9838 | qdf_nbuf_init_replenish_timer(); |
| 9839 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9840 | mutex_init(&hdd_ctx->iface_change_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 9841 | #ifdef FEATURE_WLAN_CH_AVOID |
| 9842 | mutex_init(&hdd_ctx->avoid_freq_lock); |
| 9843 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9844 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 9845 | hdd_request_manager_init(); |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 9846 | hdd_green_ap_init(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9847 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9848 | ret = hdd_wlan_start_modules(hdd_ctx, NULL, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9849 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9850 | hdd_err("Failed to start modules: %d", ret); |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 9851 | goto err_hdd_free_psoc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9852 | } |
| 9853 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 9854 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9855 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9856 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9857 | |
| 9858 | if (NULL == hdd_ctx->hHal) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9859 | hdd_err("HAL context is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9860 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9861 | } |
| 9862 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9863 | ret = hdd_wiphy_init(hdd_ctx); |
| 9864 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9865 | hdd_err("Failed to initialize wiphy: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9866 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9867 | } |
| 9868 | |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 9869 | if (hdd_ctx->config->enable_dp_trace) |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 9870 | hdd_dp_trace_init(hdd_ctx->config); |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 9871 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9872 | if (hdd_ipa_init(hdd_ctx) == QDF_STATUS_E_FAILURE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9873 | goto err_wiphy_unregister; |
| 9874 | |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 9875 | wlan_hdd_init_chan_info(hdd_ctx); |
| 9876 | |
Yuanyuan Liu | c98370e | 2016-10-13 11:22:13 -0700 | [diff] [blame] | 9877 | hdd_initialize_mac_address(hdd_ctx); |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 9878 | |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 9879 | ret = hdd_register_notifiers(hdd_ctx); |
| 9880 | if (ret) |
| 9881 | goto err_ipa_cleanup; |
| 9882 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9883 | rtnl_held = hdd_hold_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9884 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9885 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 9886 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9887 | hdd_err("Failed to open interfaces: %d", ret); |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 9888 | goto err_release_rtnl_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9889 | } |
| 9890 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9891 | hdd_release_rtnl_lock(); |
| 9892 | rtnl_held = false; |
| 9893 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 9894 | wlan_hdd_update_11n_mode(hdd_ctx->config); |
| 9895 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9896 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 9897 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9898 | QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9899 | hdd_skip_acs_scan_timer_handler, |
| 9900 | (void *)hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9901 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 9902 | hdd_err("Failed to init ACS Skip timer"); |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 9903 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9904 | #endif |
| 9905 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 9906 | hdd_bus_bandwidth_init(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9907 | |
Jeff Johnson | 9afc501 | 2016-09-23 13:56:27 -0700 | [diff] [blame] | 9908 | hdd_lpass_notify_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9909 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 9910 | if (hdd_ctx->rps) |
| 9911 | hdd_set_rps_cpu_mask(hdd_ctx); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9912 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 9913 | status = wlansap_global_init(); |
| 9914 | if (QDF_IS_STATUS_ERROR(status)) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9915 | goto err_close_adapters; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 9916 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9917 | memdump_init(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 9918 | hdd_driver_memdump_init(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9919 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9920 | if (hdd_ctx->config->fIsImpsEnabled) |
| 9921 | hdd_set_idle_ps_config(hdd_ctx, true); |
Kiran Kumar Lokere | b0f19c3 | 2017-10-13 12:23:26 -0700 | [diff] [blame] | 9922 | else |
| 9923 | hdd_set_idle_ps_config(hdd_ctx, false); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 9924 | |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 9925 | if (QDF_GLOBAL_FTM_MODE != hdd_get_conparam()) { |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 9926 | qdf_mc_timer_start(&hdd_ctx->iface_change_timer, |
Hanumanth Reddy Pothula | 42e714a | 2016-12-21 19:33:57 +0530 | [diff] [blame] | 9927 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 9928 | hdd_prevent_suspend_timeout( |
| 9929 | hdd_ctx->config->iface_change_wait_time, |
| 9930 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
| 9931 | } |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 9932 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 9933 | hdd_start_complete(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9934 | goto success; |
| 9935 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9936 | err_close_adapters: |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 9937 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9938 | |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 9939 | err_release_rtnl_lock: |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9940 | if (rtnl_held) |
| 9941 | hdd_release_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9942 | |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 9943 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 9944 | |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 9945 | err_ipa_cleanup: |
Anurag Chouhan | ce6a405 | 2016-09-14 18:20:42 +0530 | [diff] [blame] | 9946 | hdd_ipa_cleanup(hdd_ctx); |
Yun Park | 6a46ad8 | 2016-01-04 16:48:19 -0800 | [diff] [blame] | 9947 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9948 | err_wiphy_unregister: |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9949 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9950 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9951 | err_stop_modules: |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 9952 | hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9953 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 9954 | err_hdd_free_psoc: |
Arunk Khandavalli | fbc1ef0 | 2017-03-14 21:25:05 +0530 | [diff] [blame] | 9955 | if (DRIVER_MODULES_CLOSED == hdd_ctx->driver_status) { |
Jeff Johnson | 7d56227 | 2017-09-13 15:12:54 -0700 | [diff] [blame] | 9956 | status = cds_sched_close(); |
Arunk Khandavalli | fbc1ef0 | 2017-03-14 21:25:05 +0530 | [diff] [blame] | 9957 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9958 | hdd_err("Failed to close CDS Scheduler"); |
| 9959 | QDF_ASSERT(QDF_IS_STATUS_SUCCESS(status)); |
| 9960 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9961 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9962 | |
Houston Hoffman | 47a4a05 | 2016-11-14 23:22:44 -0800 | [diff] [blame] | 9963 | hdd_green_ap_deinit(hdd_ctx); |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 9964 | hdd_request_manager_deinit(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 9965 | hdd_exit_netlink_services(hdd_ctx); |
| 9966 | |
Dustin Brown | 2091246 | 2017-06-07 13:48:25 -0700 | [diff] [blame] | 9967 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 9968 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9969 | err_hdd_free_context: |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 9970 | if (cds_is_fw_down()) |
| 9971 | hdd_err("Not setting the complete event as fw is down"); |
| 9972 | else |
| 9973 | hdd_start_complete(ret); |
| 9974 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 9975 | qdf_nbuf_deinit_replenish_timer(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9976 | qdf_mc_timer_destroy(&hdd_ctx->iface_change_timer); |
| 9977 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9978 | hdd_context_destroy(hdd_ctx); |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 9979 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9980 | |
| 9981 | success: |
| 9982 | EXIT(); |
| 9983 | return 0; |
| 9984 | } |
| 9985 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9986 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9987 | * hdd_wlan_update_target_info() - update target type info |
| 9988 | * @hdd_ctx: HDD context |
| 9989 | * @context: hif context |
| 9990 | * |
| 9991 | * Update target info received from firmware in hdd context |
| 9992 | * Return:None |
| 9993 | */ |
| 9994 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9995 | 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] | 9996 | { |
| 9997 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 9998 | |
| 9999 | if (!tgt_info) { |
| 10000 | hdd_err("Target info is Null"); |
| 10001 | return; |
| 10002 | } |
| 10003 | |
| 10004 | hdd_ctx->target_type = tgt_info->target_type; |
| 10005 | } |
| 10006 | |
| 10007 | /** |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10008 | * hdd_get_nud_stats_cb() - callback api to update the stats |
| 10009 | * received from the firmware |
| 10010 | * @data: pointer to adapter. |
| 10011 | * @rsp: pointer to data received from FW. |
| 10012 | * |
| 10013 | * This is called when wlan driver received response event for |
| 10014 | * get arp stats to firmware. |
| 10015 | * |
| 10016 | * Return: None |
| 10017 | */ |
| 10018 | static void hdd_get_nud_stats_cb(void *data, struct rsp_stats *rsp) |
| 10019 | { |
| 10020 | struct hdd_context *hdd_ctx = (struct hdd_context *)data; |
| 10021 | struct hdd_nud_stats_context *context; |
| 10022 | int status; |
| 10023 | struct hdd_adapter *adapter = NULL; |
| 10024 | |
| 10025 | ENTER(); |
| 10026 | |
| 10027 | if (!rsp) { |
| 10028 | hdd_err("data is null"); |
| 10029 | return; |
| 10030 | } |
| 10031 | |
| 10032 | status = wlan_hdd_validate_context(hdd_ctx); |
| 10033 | if (0 != status) |
| 10034 | return; |
| 10035 | |
| 10036 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id); |
| 10037 | if ((NULL == adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
| 10038 | hdd_err("Invalid adapter or adapter has invalid magic"); |
| 10039 | return; |
| 10040 | } |
| 10041 | |
| 10042 | hdd_notice("rsp->arp_req_enqueue :%x", rsp->arp_req_enqueue); |
| 10043 | hdd_notice("rsp->arp_req_tx_success :%x", rsp->arp_req_tx_success); |
| 10044 | hdd_notice("rsp->arp_req_tx_failure :%x", rsp->arp_req_tx_failure); |
| 10045 | hdd_notice("rsp->arp_rsp_recvd :%x", rsp->arp_rsp_recvd); |
| 10046 | hdd_notice("rsp->out_of_order_arp_rsp_drop_cnt :%x", |
| 10047 | rsp->out_of_order_arp_rsp_drop_cnt); |
| 10048 | hdd_notice("rsp->dad_detected :%x", rsp->dad_detected); |
| 10049 | hdd_notice("rsp->connect_status :%x", rsp->connect_status); |
| 10050 | hdd_notice("rsp->ba_session_establishment_status :%x", |
| 10051 | rsp->ba_session_establishment_status); |
| 10052 | |
| 10053 | adapter->hdd_stats.hdd_arp_stats.tx_fw_cnt = rsp->arp_req_enqueue; |
| 10054 | adapter->hdd_stats.hdd_arp_stats.rx_fw_cnt = rsp->arp_rsp_recvd; |
| 10055 | adapter->hdd_stats.hdd_arp_stats.tx_ack_cnt = rsp->arp_req_tx_success; |
| 10056 | adapter->dad |= rsp->dad_detected; |
| 10057 | adapter->con_status = rsp->connect_status; |
| 10058 | |
| 10059 | spin_lock(&hdd_context_lock); |
| 10060 | context = &hdd_ctx->nud_stats_context; |
| 10061 | complete(&context->response_event); |
| 10062 | spin_unlock(&hdd_context_lock); |
| 10063 | |
| 10064 | EXIT(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10065 | } |
| 10066 | |
| 10067 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10068 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10069 | * @hdd_ctx: HDD context |
| 10070 | * |
| 10071 | * Register the HDD callbacks to CDS/SME. |
| 10072 | * |
| 10073 | * Return: 0 for success or Error code for failure |
| 10074 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10075 | int hdd_register_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10076 | { |
| 10077 | QDF_STATUS status; |
| 10078 | int ret = 0; |
| 10079 | |
| 10080 | ENTER(); |
| 10081 | |
| 10082 | sme_register11d_scan_done_callback(hdd_ctx->hHal, hdd_11d_scan_done); |
| 10083 | |
| 10084 | sme_register_oem_data_rsp_callback(hdd_ctx->hHal, |
| 10085 | hdd_send_oem_data_rsp_msg); |
| 10086 | |
| 10087 | status = sme_fw_mem_dump_register_cb(hdd_ctx->hHal, |
| 10088 | wlan_hdd_cfg80211_fw_mem_dump_cb); |
| 10089 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10090 | hdd_err("Failed to register memdump callback"); |
| 10091 | ret = -EINVAL; |
| 10092 | return ret; |
| 10093 | } |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 10094 | sme_register_mgmt_frame_ind_callback(hdd_ctx->hHal, |
| 10095 | hdd_indicate_mgmt_frame); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10096 | sme_set_tsfcb(hdd_ctx->hHal, hdd_get_tsf_cb, hdd_ctx); |
| 10097 | sme_nan_register_callback(hdd_ctx->hHal, |
| 10098 | wlan_hdd_cfg80211_nan_callback); |
| 10099 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 10100 | wlan_hdd_cfg80211_stats_ext_callback); |
| 10101 | |
| 10102 | sme_ext_scan_register_callback(hdd_ctx->hHal, |
| 10103 | wlan_hdd_cfg80211_extscan_callback); |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 10104 | sme_stats_ext2_register_callback(hdd_ctx->hHal, |
| 10105 | wlan_hdd_cfg80211_stats_ext2_callback); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10106 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10107 | sme_set_rssi_threshold_breached_cb(hdd_ctx->hHal, |
| 10108 | hdd_rssi_threshold_breached); |
| 10109 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10110 | sme_set_nud_debug_stats_cb(hdd_ctx->hHal, hdd_get_nud_stats_cb); |
| 10111 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10112 | sme_set_link_layer_stats_ind_cb(hdd_ctx->hHal, |
| 10113 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 10114 | |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 10115 | sme_rso_cmd_status_cb(hdd_ctx->hHal, wlan_hdd_rso_cmd_status_cb); |
| 10116 | |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 10117 | sme_set_link_layer_ext_cb(hdd_ctx->hHal, |
| 10118 | wlan_hdd_cfg80211_link_layer_stats_ext_callback); |
| 10119 | |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 10120 | status = sme_set_lost_link_info_cb(hdd_ctx->hHal, |
| 10121 | hdd_lost_link_info_cb); |
| 10122 | /* print error and not block the startup process */ |
| 10123 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10124 | hdd_err("set lost link info callback failed"); |
| 10125 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10126 | ret = hdd_register_data_stall_detect_cb(); |
| 10127 | if (ret) { |
| 10128 | hdd_err("Register data stall detect detect callback failed."); |
| 10129 | return ret; |
| 10130 | } |
| 10131 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10132 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 10133 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 10134 | sme_register_set_connection_info_cb(hdd_ctx->hHal, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10135 | hdd_set_connection_in_progress, |
| 10136 | hdd_is_connection_in_progress); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 10137 | |
| 10138 | status = sme_congestion_register_callback(hdd_ctx->hHal, |
| 10139 | hdd_update_cca_info_cb); |
| 10140 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10141 | hdd_err("set congestion callback failed"); |
| 10142 | |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 10143 | status = sme_set_bt_activity_info_cb(hdd_ctx->hHal, |
| 10144 | hdd_bt_activity_cb); |
| 10145 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10146 | hdd_err("set bt activity info callback failed"); |
| 10147 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10148 | EXIT(); |
| 10149 | |
| 10150 | return ret; |
| 10151 | } |
| 10152 | |
| 10153 | /** |
| 10154 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 10155 | * @hdd_ctx: HDD context |
| 10156 | * |
| 10157 | * De-Register the HDD callbacks to CDS/SME. |
| 10158 | * |
| 10159 | * Return: void |
| 10160 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10161 | void hdd_deregister_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10162 | { |
| 10163 | QDF_STATUS status; |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10164 | int ret; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10165 | |
| 10166 | ENTER(); |
| 10167 | |
| 10168 | status = sme_deregister_for_dcc_stats_event(hdd_ctx->hHal); |
| 10169 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10170 | hdd_err("De-register of dcc stats callback failed: %d", |
| 10171 | status); |
| 10172 | |
| 10173 | sme_reset_link_layer_stats_ind_cb(hdd_ctx->hHal); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10174 | sme_reset_rssi_threshold_breached_cb(hdd_ctx->hHal); |
| 10175 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10176 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 10177 | wlan_hdd_cfg80211_stats_ext_callback); |
| 10178 | |
| 10179 | sme_nan_deregister_callback(hdd_ctx->hHal); |
| 10180 | status = sme_reset_tsfcb(hdd_ctx->hHal); |
| 10181 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10182 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 10183 | status); |
| 10184 | status = sme_fw_mem_dump_unregister_cb(hdd_ctx->hHal); |
| 10185 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10186 | hdd_err("Failed to de-register the fw mem dump callback: %d", |
| 10187 | status); |
| 10188 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10189 | ret = hdd_deregister_data_stall_detect_cb(); |
| 10190 | if (ret) |
| 10191 | hdd_err("Failed to de-register data stall detect event callback"); |
| 10192 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10193 | sme_deregister_oem_data_rsp_callback(hdd_ctx->hHal); |
| 10194 | sme_deregister11d_scan_done_callback(hdd_ctx->hHal); |
| 10195 | |
| 10196 | EXIT(); |
| 10197 | } |
| 10198 | |
| 10199 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10200 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
| 10201 | * @adapter: Pointer to the HDD |
| 10202 | * @enable: bool value |
| 10203 | * |
| 10204 | * This to take counter measure to handle deauth req from HDD |
| 10205 | * |
| 10206 | * Return: None |
| 10207 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10208 | QDF_STATUS hdd_softap_sta_deauth(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10209 | struct tagCsrDelStaParams *pDelStaParams) |
| 10210 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10211 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10212 | |
| 10213 | ENTER(); |
| 10214 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10215 | /* Ignore request to deauth bcmc station */ |
| 10216 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10217 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10218 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10219 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10220 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 10221 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10222 | |
| 10223 | EXIT(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10224 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10225 | } |
| 10226 | |
| 10227 | /** |
| 10228 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
| 10229 | * @adapter: Pointer to the HDD |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10230 | * @p_del_sta_params: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10231 | * |
| 10232 | * This to take counter measure to handle deauth req from HDD |
| 10233 | * |
| 10234 | * Return: None |
| 10235 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10236 | void hdd_softap_sta_disassoc(struct hdd_adapter *adapter, |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10237 | struct tagCsrDelStaParams *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10238 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10239 | ENTER(); |
| 10240 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10241 | /* Ignore request to disassoc bcmc station */ |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10242 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10243 | return; |
| 10244 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10245 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10246 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10247 | } |
| 10248 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10249 | /** |
| 10250 | * hdd_issta_p2p_clientconnected() - check if sta or p2p client is connected |
| 10251 | * @hdd_ctx: HDD Context |
| 10252 | * |
| 10253 | * API to find if there is any STA or P2P-Client is connected |
| 10254 | * |
| 10255 | * Return: true if connected; false otherwise |
| 10256 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10257 | QDF_STATUS hdd_issta_p2p_clientconnected(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10258 | { |
| 10259 | return sme_is_sta_p2p_client_connected(hdd_ctx->hHal); |
| 10260 | } |
| 10261 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10262 | /** |
| 10263 | * wlan_hdd_disable_roaming() - disable roaming on all STAs except the input one |
| 10264 | * @adapter: HDD adapter pointer |
| 10265 | * |
| 10266 | * This function loop through each adapter and disable roaming on each STA |
| 10267 | * device mode except the input adapter. |
| 10268 | * |
| 10269 | * Note: On the input adapter roaming is not enabled yet hence no need to |
| 10270 | * disable. |
| 10271 | * |
| 10272 | * Return: None |
| 10273 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10274 | void wlan_hdd_disable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10275 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10276 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10277 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10278 | hdd_adapter_list_node_t *adapterNode = NULL; |
| 10279 | hdd_adapter_list_node_t *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10280 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10281 | |
| 10282 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10283 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 10284 | QDF_STA_MODE == adapter->device_mode && |
| 10285 | policy_mgr_is_sta_active_connection_exists( |
| 10286 | hdd_ctx->hdd_psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10287 | hdd_debug("Connect received on STA sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10288 | adapter->sessionId); |
| 10289 | /* |
| 10290 | * Loop through adapter and disable roaming for each STA device |
| 10291 | * mode except the input adapter. |
| 10292 | */ |
| 10293 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 10294 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10295 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 10296 | adapterIdx = adapterNode->adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10297 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 10298 | if (QDF_STA_MODE == adapterIdx->device_mode |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10299 | && adapter->sessionId != adapterIdx->sessionId) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10300 | hdd_debug("Disable Roaming on sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10301 | adapterIdx->sessionId); |
| 10302 | sme_stop_roaming(WLAN_HDD_GET_HAL_CTX |
| 10303 | (adapterIdx), |
| 10304 | adapterIdx->sessionId, 0); |
| 10305 | } |
| 10306 | |
| 10307 | status = hdd_get_next_adapter(hdd_ctx, |
| 10308 | adapterNode, |
| 10309 | &pNext); |
| 10310 | adapterNode = pNext; |
| 10311 | } |
| 10312 | } |
| 10313 | } |
| 10314 | |
| 10315 | /** |
| 10316 | * wlan_hdd_enable_roaming() - enable roaming on all STAs except the input one |
| 10317 | * @adapter: HDD adapter pointer |
| 10318 | * |
| 10319 | * This function loop through each adapter and enable roaming on each STA |
| 10320 | * device mode except the input adapter. |
| 10321 | * Note: On the input adapter no need to enable roaming because link got |
| 10322 | * disconnected on this. |
| 10323 | * |
| 10324 | * Return: None |
| 10325 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10326 | void wlan_hdd_enable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10327 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10328 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10329 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10330 | hdd_adapter_list_node_t *adapterNode = NULL; |
| 10331 | hdd_adapter_list_node_t *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10332 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10333 | |
| 10334 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10335 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 10336 | QDF_STA_MODE == adapter->device_mode && |
| 10337 | policy_mgr_is_sta_active_connection_exists( |
| 10338 | hdd_ctx->hdd_psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10339 | hdd_debug("Disconnect received on STA sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10340 | adapter->sessionId); |
| 10341 | /* |
| 10342 | * Loop through adapter and enable roaming for each STA device |
| 10343 | * mode except the input adapter. |
| 10344 | */ |
| 10345 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 10346 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10347 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 10348 | adapterIdx = adapterNode->adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10349 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 10350 | if (QDF_STA_MODE == adapterIdx->device_mode |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10351 | && adapter->sessionId != adapterIdx->sessionId) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10352 | hdd_debug("Enabling Roaming on sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10353 | adapterIdx->sessionId); |
| 10354 | sme_start_roaming(WLAN_HDD_GET_HAL_CTX |
| 10355 | (adapterIdx), |
| 10356 | adapterIdx->sessionId, |
| 10357 | REASON_CONNECT); |
| 10358 | } |
| 10359 | |
| 10360 | status = hdd_get_next_adapter(hdd_ctx, |
| 10361 | adapterNode, |
| 10362 | &pNext); |
| 10363 | adapterNode = pNext; |
| 10364 | } |
| 10365 | } |
| 10366 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10367 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 10368 | /** |
| 10369 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 10370 | * @skb: sk buffer pointer |
| 10371 | * |
| 10372 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 10373 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 10374 | * |
| 10375 | * Return: None |
| 10376 | */ |
| 10377 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 10378 | { |
| 10379 | #ifdef CNSS_GENL |
| 10380 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 10381 | #else |
| 10382 | nl_srv_bcast(skb); |
| 10383 | #endif |
| 10384 | } |
| 10385 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10386 | 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] | 10387 | { |
| 10388 | struct sk_buff *skb; |
| 10389 | struct nlmsghdr *nlh; |
| 10390 | tAniMsgHdr *ani_hdr; |
| 10391 | void *nl_data = NULL; |
| 10392 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10393 | struct radio_index_tlv *radio_info; |
| 10394 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10395 | |
| 10396 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 10397 | flags = GFP_ATOMIC; |
| 10398 | |
| 10399 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 10400 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 10401 | if (skb == NULL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10402 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10403 | |
| 10404 | nlh = (struct nlmsghdr *)skb->data; |
| 10405 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 10406 | nlh->nlmsg_flags = 0; |
| 10407 | nlh->nlmsg_seq = 0; |
| 10408 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 10409 | |
| 10410 | ani_hdr = NLMSG_DATA(nlh); |
| 10411 | ani_hdr->type = type; |
| 10412 | |
| 10413 | switch (type) { |
| 10414 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 10415 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10416 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10417 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 10418 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10419 | ani_hdr->length = 0; |
| 10420 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10421 | break; |
| 10422 | case WLAN_SVC_WLAN_STATUS_IND: |
| 10423 | case WLAN_SVC_WLAN_VERSION_IND: |
| 10424 | case WLAN_SVC_DFS_CAC_START_IND: |
| 10425 | case WLAN_SVC_DFS_CAC_END_IND: |
| 10426 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 10427 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 10428 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 10429 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 10430 | case WLAN_SVC_RPS_ENABLE_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10431 | ani_hdr->length = len; |
| 10432 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 10433 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 10434 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10435 | break; |
| 10436 | |
| 10437 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 10438 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10439 | type); |
| 10440 | kfree_skb(skb); |
| 10441 | return; |
| 10442 | } |
| 10443 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10444 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 10445 | * Add radio index at the end of the svc event in TLV format |
| 10446 | * to maintain the backward compatibility with userspace |
| 10447 | * applications. |
| 10448 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10449 | |
| 10450 | tlv_len = 0; |
| 10451 | |
| 10452 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 10453 | < WLAN_NL_MAX_PAYLOAD) { |
| 10454 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 10455 | sizeof(*ani_hdr) + len); |
| 10456 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 10457 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 10458 | radio_info->radio = radio; |
| 10459 | tlv_len = sizeof(*radio_info); |
Srinivas Girigowda | c06543c | 2017-03-09 15:10:03 -0800 | [diff] [blame] | 10460 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG, |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10461 | "Added radio index tlv - radio index %d", |
| 10462 | radio_info->radio); |
| 10463 | } |
| 10464 | |
| 10465 | nlh->nlmsg_len += tlv_len; |
| 10466 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 10467 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 10468 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10469 | } |
| 10470 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10471 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 10472 | void wlan_hdd_auto_shutdown_cb(void) |
| 10473 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10474 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10475 | |
| 10476 | if (!hdd_ctx) |
| 10477 | return; |
| 10478 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10479 | hdd_debug("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10480 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 10481 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10482 | } |
| 10483 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10484 | 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] | 10485 | { |
| 10486 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10487 | QDF_STATUS status; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10488 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10489 | bool ap_connected = false, sta_connected = false; |
| 10490 | tHalHandle hal_handle; |
| 10491 | |
| 10492 | hal_handle = hdd_ctx->hHal; |
| 10493 | if (hal_handle == NULL) |
| 10494 | return; |
| 10495 | |
| 10496 | if (hdd_ctx->config->WlanAutoShutdown == 0) |
| 10497 | return; |
| 10498 | |
| 10499 | if (enable == false) { |
| 10500 | if (sme_set_auto_shutdown_timer(hal_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10501 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10502 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10503 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10504 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 10505 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10506 | return; |
| 10507 | } |
| 10508 | |
| 10509 | /* To enable shutdown timer check conncurrency */ |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10510 | if (policy_mgr_concurrent_open_sessions_running( |
| 10511 | hdd_ctx->hdd_psoc)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10512 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 10513 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10514 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 10515 | adapter = adapterNode->adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10516 | if (adapter |
| 10517 | && adapter->device_mode == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 10518 | QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10519 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 10520 | conn_info.connState == |
| 10521 | eConnectionState_Associated) { |
| 10522 | sta_connected = true; |
| 10523 | break; |
| 10524 | } |
| 10525 | } |
| 10526 | if (adapter |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 10527 | && adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10528 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
| 10529 | bApActive == true) { |
| 10530 | ap_connected = true; |
| 10531 | break; |
| 10532 | } |
| 10533 | } |
| 10534 | status = hdd_get_next_adapter(hdd_ctx, |
| 10535 | adapterNode, |
| 10536 | &pNext); |
| 10537 | adapterNode = pNext; |
| 10538 | } |
| 10539 | } |
| 10540 | |
| 10541 | if (ap_connected == true || sta_connected == true) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10542 | hdd_debug("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10543 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10544 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 10545 | |
| 10546 | if (sme_set_auto_shutdown_timer(hal_handle, |
| 10547 | hdd_ctx->config->WlanAutoShutdown) |
| 10548 | != QDF_STATUS_SUCCESS) |
| 10549 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 10550 | else |
| 10551 | hdd_notice("Auto Shutdown timer for %d seconds enabled", |
| 10552 | hdd_ctx->config->WlanAutoShutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10553 | } |
| 10554 | #endif |
| 10555 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 10556 | struct hdd_adapter * |
| 10557 | hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, |
| 10558 | bool check_start_bss) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10559 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10560 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10561 | struct hdd_adapter *adapter, *con_sap_adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10562 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10563 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 10564 | |
| 10565 | con_sap_adapter = NULL; |
| 10566 | |
| 10567 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10568 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 10569 | adapter = adapterNode->adapter; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 10570 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 10571 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10572 | adapter != this_sap_adapter) { |
| 10573 | if (check_start_bss) { |
| 10574 | if (test_bit(SOFTAP_BSS_STARTED, |
| 10575 | &adapter->event_flags)) { |
| 10576 | con_sap_adapter = adapter; |
| 10577 | break; |
| 10578 | } |
| 10579 | } else { |
| 10580 | con_sap_adapter = adapter; |
| 10581 | break; |
| 10582 | } |
| 10583 | } |
| 10584 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 10585 | adapterNode = pNext; |
| 10586 | } |
| 10587 | |
| 10588 | return con_sap_adapter; |
| 10589 | } |
| 10590 | |
| 10591 | #ifdef MSM_PLATFORM |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10592 | static inline bool hdd_adapter_is_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10593 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10594 | return adapter->device_mode == QDF_STA_MODE || |
| 10595 | adapter->device_mode == QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10596 | } |
| 10597 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10598 | static inline bool hdd_adapter_is_ap(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10599 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10600 | return adapter->device_mode == QDF_SAP_MODE || |
| 10601 | adapter->device_mode == QDF_P2P_GO_MODE; |
| 10602 | } |
| 10603 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10604 | static bool hdd_any_adapter_is_assoc(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10605 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10606 | QDF_STATUS status; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10607 | hdd_adapter_list_node_t *node; |
| 10608 | |
| 10609 | status = hdd_get_front_adapter(hdd_ctx, &node); |
| 10610 | while (QDF_IS_STATUS_SUCCESS(status) && node) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 10611 | struct hdd_adapter *adapter = node->adapter; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10612 | |
| 10613 | if (adapter && |
| 10614 | hdd_adapter_is_sta(adapter) && |
| 10615 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 10616 | conn_info.connState == eConnectionState_Associated) { |
| 10617 | return true; |
| 10618 | } |
| 10619 | |
| 10620 | if (adapter && |
| 10621 | hdd_adapter_is_ap(adapter) && |
| 10622 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->bApActive) { |
| 10623 | return true; |
| 10624 | } |
| 10625 | |
| 10626 | status = hdd_get_next_adapter(hdd_ctx, node, &node); |
| 10627 | } |
| 10628 | |
| 10629 | return false; |
| 10630 | } |
| 10631 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10632 | 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] | 10633 | { |
| 10634 | bool is_running; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10635 | |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 10636 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10637 | is_running = hdd_ctx->bus_bw_timer_running; |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 10638 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10639 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10640 | return is_running; |
| 10641 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10642 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10643 | 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] | 10644 | { |
| 10645 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 10646 | hdd_ctx->bus_bw_timer_running = true; |
| 10647 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
| 10648 | hdd_ctx->config->busBandwidthComputeInterval); |
| 10649 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 10650 | } |
| 10651 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10652 | void hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10653 | { |
| 10654 | ENTER(); |
| 10655 | |
| 10656 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 10657 | hdd_debug("Bandwidth compute timer already started"); |
| 10658 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10659 | } |
| 10660 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10661 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 10662 | |
| 10663 | EXIT(); |
| 10664 | } |
| 10665 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10666 | 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] | 10667 | { |
| 10668 | ENTER(); |
| 10669 | |
| 10670 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 10671 | hdd_debug("Bandwidth compute timer already started"); |
| 10672 | return; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 10673 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10674 | |
| 10675 | if (hdd_any_adapter_is_assoc(hdd_ctx)) |
| 10676 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 10677 | |
| 10678 | EXIT(); |
| 10679 | } |
| 10680 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10681 | 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] | 10682 | { |
| 10683 | hdd_ipa_set_perf_level(hdd_ctx, 0, 0); |
| 10684 | |
| 10685 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 10686 | qdf_timer_stop(&hdd_ctx->bus_bw_timer); |
| 10687 | hdd_ctx->bus_bw_timer_running = false; |
| 10688 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 10689 | |
| 10690 | hdd_reset_tcp_delack(hdd_ctx); |
| 10691 | } |
| 10692 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10693 | void hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10694 | { |
| 10695 | ENTER(); |
| 10696 | |
| 10697 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 10698 | hdd_debug("Bandwidth compute timer already stopped"); |
| 10699 | return; |
| 10700 | } |
| 10701 | |
| 10702 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 10703 | |
| 10704 | EXIT(); |
| 10705 | } |
| 10706 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10707 | 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] | 10708 | { |
| 10709 | ENTER(); |
| 10710 | |
| 10711 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 10712 | hdd_debug("Bandwidth compute timer already stopped"); |
| 10713 | return; |
| 10714 | } |
| 10715 | |
| 10716 | if (!hdd_any_adapter_is_assoc(hdd_ctx)) |
| 10717 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 10718 | |
| 10719 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10720 | } |
| 10721 | #endif |
| 10722 | |
| 10723 | /** |
| 10724 | * wlan_hdd_check_custom_con_channel_rules() - This function checks the sap's |
| 10725 | * and sta's operating channel. |
| 10726 | * @sta_adapter: Describe the first argument to foobar. |
| 10727 | * @ap_adapter: Describe the second argument to foobar. |
| 10728 | * @roam_profile: Roam profile of AP to which STA wants to connect. |
| 10729 | * @concurrent_chnl_same: If both SAP and STA channels are same then |
| 10730 | * set this flag to true else false. |
| 10731 | * |
| 10732 | * This function checks the sap's operating channel and sta's operating channel. |
| 10733 | * if both are same then it will return false else it will restart the sap in |
| 10734 | * sta's channel and return true. |
| 10735 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10736 | * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10737 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 10738 | QDF_STATUS |
| 10739 | wlan_hdd_check_custom_con_channel_rules(struct hdd_adapter *sta_adapter, |
| 10740 | struct hdd_adapter *ap_adapter, |
| 10741 | tCsrRoamProfile *roam_profile, |
| 10742 | tScanResultHandle *scan_cache, |
| 10743 | bool *concurrent_chnl_same) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10744 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 10745 | struct hdd_ap_ctx *hdd_ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10746 | uint8_t channel_id; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10747 | QDF_STATUS status; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 10748 | enum tQDF_ADAPTER_MODE device_mode = ap_adapter->device_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10749 | *concurrent_chnl_same = true; |
| 10750 | |
| 10751 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 10752 | status = |
Archana Ramachandran | 2eb7a61 | 2017-03-23 22:58:42 -0700 | [diff] [blame] | 10753 | sme_get_ap_channel_from_scan_cache(roam_profile, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10754 | scan_cache, |
| 10755 | &channel_id); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 10756 | if (QDF_STATUS_SUCCESS == status) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 10757 | if ((QDF_SAP_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10758 | (channel_id < SIR_11A_CHANNEL_BEGIN)) { |
| 10759 | if (hdd_ap_ctx->operatingChannel != channel_id) { |
| 10760 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10761 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10762 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 10763 | } else if ((QDF_P2P_GO_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10764 | (channel_id >= SIR_11A_CHANNEL_BEGIN)) { |
| 10765 | if (hdd_ap_ctx->operatingChannel != channel_id) { |
| 10766 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10767 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10768 | } |
| 10769 | } |
| 10770 | } else { |
| 10771 | /* |
| 10772 | * Lets handle worst case scenario here, Scan cache lookup is |
| 10773 | * failed so we have to stop the SAP to avoid any channel |
| 10774 | * discrepancy between SAP's channel and STA's channel. |
| 10775 | * Return the status as failure so caller function could know |
| 10776 | * that scan look up is failed. |
| 10777 | */ |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10778 | hdd_err("Finding AP from scan cache failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10779 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10780 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10781 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10782 | } |
| 10783 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10784 | /** |
| 10785 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 10786 | * @ap_adapter: SAP adapter |
| 10787 | * |
| 10788 | * This function will process the stopping of sap adapter. |
| 10789 | * |
| 10790 | * Return: None |
| 10791 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10792 | void wlan_hdd_stop_sap(struct hdd_adapter *ap_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10793 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 10794 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 10795 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 10796 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10797 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10798 | |
| 10799 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10800 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10801 | return; |
| 10802 | } |
| 10803 | |
| 10804 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 10805 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 10806 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10807 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 10808 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10809 | mutex_lock(&hdd_ctx->sap_lock); |
| 10810 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 10811 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10812 | hdd_cleanup_actionframe(hdd_ctx, ap_adapter); |
| 10813 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10814 | hdd_debug("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 10815 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10816 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10817 | sapContext)) { |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 10818 | qdf_status = qdf_wait_single_event(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 10819 | qdf_stop_bss_event, |
| 10820 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 10821 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10822 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10823 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10824 | return; |
| 10825 | } |
| 10826 | } |
| 10827 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10828 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 10829 | ap_adapter->device_mode, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10830 | ap_adapter->sessionId); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10831 | hdd_debug("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10832 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10833 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10834 | } |
| 10835 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10836 | } |
| 10837 | |
| 10838 | /** |
| 10839 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 10840 | * @ap_adapter: SAP adapter |
| 10841 | * |
| 10842 | * This function will process the starting of sap adapter. |
| 10843 | * |
| 10844 | * Return: None |
| 10845 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10846 | void wlan_hdd_start_sap(struct hdd_adapter *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10847 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 10848 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 10849 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 10850 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10851 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10852 | tsap_Config_t *sap_config; |
| 10853 | |
| 10854 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10855 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10856 | return; |
| 10857 | } |
| 10858 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 10859 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 10860 | hdd_err("SoftAp role has not been enabled"); |
| 10861 | return; |
| 10862 | } |
| 10863 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10864 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 10865 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 10866 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 10867 | sap_config = &ap_adapter->sessionCtx.ap.sapConfig; |
| 10868 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10869 | mutex_lock(&hdd_ctx->sap_lock); |
| 10870 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 10871 | goto end; |
| 10872 | |
| 10873 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10874 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10875 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
| 10876 | goto end; |
| 10877 | } |
| 10878 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 10879 | qdf_event_reset(&hostapd_state->qdf_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10880 | if (wlansap_start_bss(hdd_ap_ctx->sapContext, hdd_hostapd_sap_event_cb, |
| 10881 | &hdd_ap_ctx->sapConfig, |
| 10882 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10883 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10884 | goto end; |
| 10885 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10886 | hdd_debug("Waiting for SAP to start"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 10887 | qdf_status = qdf_wait_single_event(&hostapd_state->qdf_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 10888 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 10889 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10890 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10891 | goto end; |
| 10892 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10893 | hdd_info("SAP Start Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10894 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Krunal Soni | b37bb35 | 2016-12-20 14:12:21 -0800 | [diff] [blame] | 10895 | if (hostapd_state->bssState == BSS_START) |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10896 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 10897 | ap_adapter->device_mode, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10898 | ap_adapter->sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10899 | end: |
| 10900 | mutex_unlock(&hdd_ctx->sap_lock); |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 10901 | /* SAP context and beacon cleanup will happen during driver unload |
| 10902 | * in hdd_stop_adapter |
| 10903 | */ |
| 10904 | hdd_err("SAP restart after SSR failed! Reload WLAN and try SAP again"); |
| 10905 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10906 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10907 | |
| 10908 | /** |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 10909 | * wlan_hdd_soc_set_antenna_mode_cb() - Callback for set dual |
| 10910 | * mac scan config |
| 10911 | * @status: Status of set antenna mode |
| 10912 | * |
| 10913 | * Callback on setting the dual mac configuration |
| 10914 | * |
| 10915 | * Return: None |
| 10916 | */ |
| 10917 | void wlan_hdd_soc_set_antenna_mode_cb( |
| 10918 | enum set_antenna_mode_status status) |
| 10919 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10920 | struct hdd_context *hdd_ctx; |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 10921 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10922 | hdd_debug("Status: %d", status); |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 10923 | |
| 10924 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10925 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 10926 | return; |
| 10927 | |
| 10928 | /* Signal the completion of set dual mac config */ |
| 10929 | complete(&hdd_ctx->set_antenna_mode_cmpl); |
| 10930 | } |
| 10931 | |
| 10932 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10933 | * hdd_get_fw_version() - Get FW version |
| 10934 | * @hdd_ctx: pointer to HDD context. |
| 10935 | * @major_spid: FW version - major spid. |
| 10936 | * @minor_spid: FW version - minor spid |
| 10937 | * @ssid: FW version - ssid |
| 10938 | * @crmid: FW version - crmid |
| 10939 | * |
| 10940 | * This function is called to get the firmware build version stored |
| 10941 | * as part of the HDD context |
| 10942 | * |
| 10943 | * Return: None |
| 10944 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10945 | void hdd_get_fw_version(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10946 | uint32_t *major_spid, uint32_t *minor_spid, |
| 10947 | uint32_t *siid, uint32_t *crmid) |
| 10948 | { |
| 10949 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 10950 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 10951 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 10952 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 10953 | } |
| 10954 | |
| 10955 | #ifdef QCA_CONFIG_SMP |
| 10956 | /** |
| 10957 | * wlan_hdd_get_cpu() - get cpu_index |
| 10958 | * |
| 10959 | * Return: cpu_index |
| 10960 | */ |
| 10961 | int wlan_hdd_get_cpu(void) |
| 10962 | { |
| 10963 | int cpu_index = get_cpu(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 10964 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10965 | put_cpu(); |
| 10966 | return cpu_index; |
| 10967 | } |
| 10968 | #endif |
| 10969 | |
| 10970 | /** |
| 10971 | * hdd_get_fwpath() - get framework path |
| 10972 | * |
| 10973 | * This function is used to get the string written by |
| 10974 | * userspace to start the wlan driver |
| 10975 | * |
| 10976 | * Return: string |
| 10977 | */ |
| 10978 | const char *hdd_get_fwpath(void) |
| 10979 | { |
| 10980 | return fwpath.string; |
| 10981 | } |
| 10982 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 10983 | static int hdd_qdf_print_init(void) |
| 10984 | { |
| 10985 | int qdf_print_idx; |
| 10986 | QDF_STATUS status; |
| 10987 | |
| 10988 | status = qdf_print_setup(); |
| 10989 | if (status != QDF_STATUS_SUCCESS) { |
| 10990 | pr_err("qdf_print_setup failed\n"); |
| 10991 | return -EINVAL; |
| 10992 | } |
| 10993 | |
| 10994 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, "MCL_WLAN"); |
| 10995 | |
| 10996 | if (qdf_print_idx < 0) { |
| 10997 | pr_err("qdf_print_ctrl_register failed, ret = %d\n", |
| 10998 | qdf_print_idx); |
| 10999 | return -EINVAL; |
| 11000 | } |
| 11001 | |
| 11002 | qdf_set_pidx(qdf_print_idx); |
| 11003 | |
| 11004 | return 0; |
| 11005 | } |
| 11006 | |
| 11007 | static void hdd_qdf_print_deinit(void) |
| 11008 | { |
| 11009 | int qdf_print_idx; |
| 11010 | |
| 11011 | qdf_print_idx = qdf_get_pidx(); |
| 11012 | qdf_print_ctrl_cleanup(qdf_print_idx); |
| 11013 | } |
| 11014 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11015 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11016 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11017 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11018 | * This function initilizes CDS global context with the help of cds_init. This |
| 11019 | * has to be the first function called after probe to get a valid global |
| 11020 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11021 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11022 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11023 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11024 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11025 | { |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 11026 | QDF_STATUS status; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11027 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11028 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 11029 | status = cds_init(); |
Hanumanth Reddy Pothula | 788a37e | 2017-08-17 18:40:11 +0530 | [diff] [blame] | 11030 | |
| 11031 | wlan_init_bug_report_lock(); |
| 11032 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11033 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 11034 | wlan_logging_sock_init_svc(); |
| 11035 | #endif |
| 11036 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 11037 | if (QDF_IS_STATUS_ERROR(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11038 | hdd_err("Failed to allocate CDS context"); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11039 | ret = -ENOMEM; |
| 11040 | goto err_out; |
| 11041 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11042 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 11043 | qdf_timer_init(NULL, &hdd_drv_ops_inactivity_timer, |
| 11044 | (void *)hdd_drv_ops_inactivity_handler, NULL, |
| 11045 | QDF_TIMER_TYPE_SW); |
| 11046 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11047 | hdd_trace_init(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11048 | hdd_qdf_print_init(); |
| 11049 | |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11050 | hdd_register_debug_callback(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11051 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11052 | err_out: |
| 11053 | return ret; |
| 11054 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11055 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11056 | /** |
| 11057 | * hdd_deinit() - Deinitialize Driver |
| 11058 | * |
| 11059 | * This function frees CDS global context with the help of cds_deinit. This |
| 11060 | * has to be the last function call in remove callback to free the global |
| 11061 | * context. |
| 11062 | */ |
| 11063 | void hdd_deinit(void) |
| 11064 | { |
Dustin Brown | edce4a5 | 2017-05-10 11:59:15 -0700 | [diff] [blame] | 11065 | hdd_deinit_wowl(); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 11066 | qdf_timer_free(&hdd_drv_ops_inactivity_timer); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11067 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 11068 | wlan_destroy_bug_report_lock(); |
| 11069 | cds_deinit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11070 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 11071 | hdd_qdf_print_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11072 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 11073 | wlan_logging_sock_deinit_svc(); |
| 11074 | #endif |
| 11075 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11076 | |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 11077 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 11078 | #define HDD_WLAN_START_WAIT_TIME ((CDS_WMA_TIMEOUT + 5000) * 100) |
| 11079 | #else |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11080 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 11081 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11082 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11083 | static int wlan_hdd_state_ctrl_param_open(struct inode *inode, |
| 11084 | struct file *file) |
| 11085 | { |
| 11086 | return 0; |
| 11087 | } |
| 11088 | |
| 11089 | static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, |
| 11090 | const char __user *user_buf, |
| 11091 | size_t count, |
| 11092 | loff_t *f_pos) |
| 11093 | { |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11094 | char buf[3]; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11095 | static const char wlan_off_str[] = "OFF"; |
| 11096 | static const char wlan_on_str[] = "ON"; |
| 11097 | int ret; |
| 11098 | unsigned long rc; |
| 11099 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11100 | if (copy_from_user(buf, user_buf, 3)) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11101 | pr_err("Failed to read buffer\n"); |
| 11102 | return -EINVAL; |
| 11103 | } |
| 11104 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11105 | if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11106 | pr_debug("Wifi turning off from UI\n"); |
| 11107 | goto exit; |
| 11108 | } |
| 11109 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11110 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11111 | pr_err("Invalid value received from framework"); |
| 11112 | goto exit; |
| 11113 | } |
| 11114 | |
| 11115 | if (!cds_is_driver_loaded()) { |
Sachin Ahuja | ee62b54 | 2017-04-21 14:14:16 +0530 | [diff] [blame] | 11116 | init_completion(&wlan_start_comp); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11117 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 11118 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 11119 | if (!rc) { |
| 11120 | hdd_alert("Timed-out waiting in wlan_hdd_state_ctrl_param_write"); |
| 11121 | ret = -EINVAL; |
| 11122 | hdd_start_complete(ret); |
| 11123 | return ret; |
| 11124 | } |
| 11125 | |
| 11126 | hdd_start_complete(0); |
| 11127 | } |
| 11128 | |
| 11129 | exit: |
| 11130 | return count; |
| 11131 | } |
| 11132 | |
| 11133 | |
| 11134 | const struct file_operations wlan_hdd_state_fops = { |
| 11135 | .owner = THIS_MODULE, |
| 11136 | .open = wlan_hdd_state_ctrl_param_open, |
| 11137 | .write = wlan_hdd_state_ctrl_param_write, |
| 11138 | }; |
| 11139 | |
| 11140 | static int wlan_hdd_state_ctrl_param_create(void) |
| 11141 | { |
| 11142 | unsigned int wlan_hdd_state_major = 0; |
| 11143 | int ret; |
| 11144 | struct device *dev; |
| 11145 | |
| 11146 | device = MKDEV(wlan_hdd_state_major, 0); |
| 11147 | |
| 11148 | ret = alloc_chrdev_region(&device, 0, dev_num, "qcwlanstate"); |
| 11149 | if (ret) { |
| 11150 | pr_err("Failed to register qcwlanstate"); |
| 11151 | goto dev_alloc_err; |
| 11152 | } |
| 11153 | wlan_hdd_state_major = MAJOR(device); |
| 11154 | |
| 11155 | class = class_create(THIS_MODULE, WLAN_MODULE_NAME); |
| 11156 | if (IS_ERR(class)) { |
| 11157 | pr_err("wlan_hdd_state class_create error"); |
| 11158 | goto class_err; |
| 11159 | } |
| 11160 | |
| 11161 | dev = device_create(class, NULL, device, NULL, WLAN_MODULE_NAME); |
| 11162 | if (IS_ERR(dev)) { |
| 11163 | pr_err("wlan_hdd_statedevice_create error"); |
| 11164 | goto err_class_destroy; |
| 11165 | } |
| 11166 | |
| 11167 | cdev_init(&wlan_hdd_state_cdev, &wlan_hdd_state_fops); |
| 11168 | ret = cdev_add(&wlan_hdd_state_cdev, device, dev_num); |
| 11169 | if (ret) { |
| 11170 | pr_err("Failed to add cdev error"); |
| 11171 | goto cdev_add_err; |
| 11172 | } |
| 11173 | |
| 11174 | pr_info("wlan_hdd_state %s major(%d) initialized", |
| 11175 | WLAN_MODULE_NAME, wlan_hdd_state_major); |
| 11176 | |
| 11177 | return 0; |
| 11178 | |
| 11179 | cdev_add_err: |
| 11180 | device_destroy(class, device); |
| 11181 | err_class_destroy: |
| 11182 | class_destroy(class); |
| 11183 | class_err: |
| 11184 | unregister_chrdev_region(device, dev_num); |
| 11185 | dev_alloc_err: |
| 11186 | return -ENODEV; |
| 11187 | } |
| 11188 | |
| 11189 | static void wlan_hdd_state_ctrl_param_destroy(void) |
| 11190 | { |
| 11191 | cdev_del(&wlan_hdd_state_cdev); |
| 11192 | device_destroy(class, device); |
| 11193 | class_destroy(class); |
| 11194 | unregister_chrdev_region(device, dev_num); |
| 11195 | |
| 11196 | pr_info("Device node unregistered"); |
| 11197 | } |
| 11198 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11199 | /** |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11200 | * component_init - API to init cld component's |
| 11201 | * |
| 11202 | * Return: None |
| 11203 | */ |
| 11204 | static void component_init(void) |
| 11205 | { |
| 11206 | pmo_init(); |
| 11207 | } |
| 11208 | |
| 11209 | /** |
| 11210 | * component_deinit - API to deinit cld component's |
| 11211 | * |
| 11212 | * Return: None |
| 11213 | */ |
| 11214 | static void component_deinit(void) |
| 11215 | { |
| 11216 | pmo_deinit(); |
| 11217 | } |
| 11218 | |
| 11219 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11220 | * __hdd_module_init - Module init helper |
| 11221 | * |
| 11222 | * Module init helper function used by both module and static driver. |
| 11223 | * |
| 11224 | * Return: 0 for success, errno on failure |
| 11225 | */ |
| 11226 | static int __hdd_module_init(void) |
| 11227 | { |
| 11228 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11229 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11230 | pr_err("%s: Loading driver v%s (%s)%s\n", |
| 11231 | WLAN_MODULE_NAME, |
| 11232 | QWLAN_VERSIONSTR, |
Naveen Rawat | 9383625 | 2017-06-20 16:30:59 -0700 | [diff] [blame] | 11233 | g_wlan_driver_timestamp, |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11234 | TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11235 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11236 | ret = wlan_hdd_state_ctrl_param_create(); |
| 11237 | if (ret) { |
| 11238 | pr_err("wlan_hdd_state_create:%x\n", ret); |
| 11239 | goto err_dev_state; |
| 11240 | } |
| 11241 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11242 | pld_init(); |
| 11243 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11244 | ret = hdd_init(); |
| 11245 | if (ret) { |
| 11246 | pr_err("hdd_init failed %x\n", ret); |
| 11247 | goto err_hdd_init; |
| 11248 | } |
| 11249 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11250 | dispatcher_init(); |
| 11251 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11252 | /* Ensure to call post objmgr init */ |
| 11253 | component_init(); |
| 11254 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 11255 | qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11256 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11257 | hdd_set_conparam((uint32_t) con_mode); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11258 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11259 | ret = wlan_hdd_register_driver(); |
| 11260 | if (ret) { |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 11261 | pr_err("%s: driver load failure, err %d\n", WLAN_MODULE_NAME, |
| 11262 | ret); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11263 | goto out; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11264 | } |
| 11265 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11266 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11267 | |
| 11268 | return 0; |
| 11269 | out: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 11270 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11271 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11272 | hdd_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11273 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11274 | err_hdd_init: |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11275 | pld_deinit(); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11276 | wlan_hdd_state_ctrl_param_destroy(); |
| 11277 | err_dev_state: |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11278 | return ret; |
| 11279 | } |
| 11280 | |
| 11281 | /** |
| 11282 | * __hdd_module_exit - Module exit helper |
| 11283 | * |
| 11284 | * Module exit helper function used by both module and static driver. |
| 11285 | */ |
| 11286 | static void __hdd_module_exit(void) |
| 11287 | { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 11288 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11289 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 11290 | QWLAN_VERSIONSTR); |
| 11291 | |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 11292 | hdd_wait_for_recovery_completion(); |
| 11293 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11294 | wlan_hdd_unregister_driver(); |
| 11295 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 11296 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11297 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11298 | /* Ensure to call prior to objmgr deinit */ |
| 11299 | component_deinit(); |
| 11300 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11301 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11302 | hdd_deinit(); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11303 | pld_deinit(); |
| 11304 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11305 | wlan_hdd_state_ctrl_param_destroy(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11306 | } |
| 11307 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11308 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11309 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11310 | * wlan_boot_cb() - Wlan boot callback |
| 11311 | * @kobj: object whose directory we're creating the link in. |
| 11312 | * @attr: attribute the user is interacting with |
| 11313 | * @buff: the buffer containing the user data |
| 11314 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11315 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11316 | * This callback is invoked when the fs is ready to start the |
| 11317 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11318 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11319 | * 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] | 11320 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11321 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11322 | struct kobj_attribute *attr, |
| 11323 | const char *buf, |
| 11324 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11325 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11326 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11327 | if (wlan_loader->loaded_state) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11328 | pr_err("%s: wlan driver already initialized\n", __func__); |
| 11329 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11330 | } |
| 11331 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11332 | if (__hdd_module_init()) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11333 | pr_err("%s: wlan driver initialization failed\n", __func__); |
| 11334 | return -EIO; |
| 11335 | } |
| 11336 | |
| 11337 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11338 | |
| 11339 | return count; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11340 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11341 | |
| 11342 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11343 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 11344 | * |
| 11345 | * Return: None |
| 11346 | * |
| 11347 | */ |
| 11348 | static void hdd_sysfs_cleanup(void) |
| 11349 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11350 | /* remove from group */ |
| 11351 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 11352 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 11353 | wlan_loader->attr_group); |
| 11354 | |
| 11355 | /* unlink the object from parent */ |
| 11356 | kobject_del(wlan_loader->boot_wlan_obj); |
| 11357 | |
| 11358 | /* free the object */ |
| 11359 | kobject_put(wlan_loader->boot_wlan_obj); |
| 11360 | |
| 11361 | kfree(wlan_loader->attr_group); |
| 11362 | kfree(wlan_loader); |
| 11363 | |
| 11364 | wlan_loader = NULL; |
| 11365 | } |
| 11366 | |
| 11367 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11368 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 11369 | * ready |
| 11370 | * |
| 11371 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 11372 | * when the filesystem is ready. |
| 11373 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11374 | * QDF API cannot be used here since this function is called even before |
| 11375 | * initializing WLAN driver. |
| 11376 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 11377 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11378 | */ |
| 11379 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11380 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11381 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11382 | |
| 11383 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11384 | if (!wlan_loader) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11385 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11386 | |
| 11387 | wlan_loader->boot_wlan_obj = NULL; |
| 11388 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 11389 | GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11390 | if (!wlan_loader->attr_group) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11391 | goto error_return; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11392 | |
| 11393 | wlan_loader->loaded_state = 0; |
| 11394 | wlan_loader->attr_group->attrs = attrs; |
| 11395 | |
| 11396 | wlan_loader->boot_wlan_obj = kobject_create_and_add("boot_wlan", |
| 11397 | kernel_kobj); |
| 11398 | if (!wlan_loader->boot_wlan_obj) { |
| 11399 | pr_err("%s: sysfs create and add failed\n", __func__); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11400 | goto error_return; |
| 11401 | } |
| 11402 | |
| 11403 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 11404 | wlan_loader->attr_group); |
| 11405 | if (ret) { |
| 11406 | pr_err("%s: sysfs create group failed %d\n", __func__, ret); |
| 11407 | goto error_return; |
| 11408 | } |
| 11409 | |
| 11410 | return 0; |
| 11411 | |
| 11412 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11413 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11414 | |
| 11415 | return ret; |
| 11416 | } |
| 11417 | |
| 11418 | /** |
| 11419 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 11420 | * |
| 11421 | * Return: 0 on success or errno on failure |
| 11422 | */ |
| 11423 | static int wlan_deinit_sysfs(void) |
| 11424 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11425 | if (!wlan_loader) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11426 | hdd_err("wlan loader context is Null!"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11427 | return -EINVAL; |
| 11428 | } |
| 11429 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11430 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11431 | return 0; |
| 11432 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11433 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11434 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11435 | |
| 11436 | #ifdef MODULE |
| 11437 | /** |
| 11438 | * __hdd_module_init - Module init helper |
| 11439 | * |
| 11440 | * Module init helper function used by both module and static driver. |
| 11441 | * |
| 11442 | * Return: 0 for success, errno on failure |
| 11443 | */ |
| 11444 | static int hdd_module_init(void) |
| 11445 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11446 | if (__hdd_module_init()) { |
| 11447 | pr_err("%s: Failed to register handler\n", __func__); |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11448 | return -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11449 | } |
| 11450 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11451 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11452 | } |
| 11453 | #else |
| 11454 | static int __init hdd_module_init(void) |
| 11455 | { |
| 11456 | int ret = -EINVAL; |
| 11457 | |
| 11458 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 11459 | if (ret) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11460 | pr_err("Failed to create sysfs entry for loading wlan"); |
| 11461 | |
| 11462 | return ret; |
| 11463 | } |
| 11464 | #endif |
| 11465 | |
| 11466 | |
| 11467 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11468 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11469 | * hdd_module_exit() - Exit function |
| 11470 | * |
| 11471 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 11472 | * |
| 11473 | * Return: None |
| 11474 | */ |
| 11475 | static void __exit hdd_module_exit(void) |
| 11476 | { |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11477 | __hdd_module_exit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11478 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11479 | #else |
| 11480 | static void __exit hdd_module_exit(void) |
| 11481 | { |
| 11482 | __hdd_module_exit(); |
| 11483 | wlan_deinit_sysfs(); |
| 11484 | } |
| 11485 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11486 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11487 | static int fwpath_changed_handler(const char *kmessage, struct kernel_param *kp) |
| 11488 | { |
| 11489 | return param_set_copystring(kmessage, kp); |
| 11490 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11491 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11492 | /** |
| 11493 | * is_con_mode_valid() check con mode is valid or not |
| 11494 | * @mode: global con mode |
| 11495 | * |
| 11496 | * Return: TRUE on success FALSE on failure |
| 11497 | */ |
| 11498 | static bool is_con_mode_valid(enum tQDF_GLOBAL_CON_MODE mode) |
| 11499 | { |
| 11500 | switch (mode) { |
| 11501 | case QDF_GLOBAL_MONITOR_MODE: |
| 11502 | case QDF_GLOBAL_FTM_MODE: |
| 11503 | case QDF_GLOBAL_EPPING_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11504 | case QDF_GLOBAL_MISSION_MODE: |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11505 | return true; |
| 11506 | default: |
| 11507 | return false; |
| 11508 | } |
| 11509 | } |
| 11510 | |
| 11511 | /** |
| 11512 | * hdd_get_adpter_mode() - returns adapter mode based on global con mode |
| 11513 | * @mode: global con mode |
| 11514 | * |
| 11515 | * Return: adapter mode |
| 11516 | */ |
| 11517 | static enum tQDF_ADAPTER_MODE hdd_get_adpter_mode( |
| 11518 | enum tQDF_GLOBAL_CON_MODE mode) |
| 11519 | { |
| 11520 | |
| 11521 | switch (mode) { |
| 11522 | case QDF_GLOBAL_MISSION_MODE: |
| 11523 | return QDF_STA_MODE; |
| 11524 | case QDF_GLOBAL_MONITOR_MODE: |
| 11525 | return QDF_MONITOR_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11526 | case QDF_GLOBAL_EPPING_MODE: |
| 11527 | return QDF_EPPING_MODE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11528 | case QDF_GLOBAL_FTM_MODE: |
| 11529 | return QDF_FTM_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11530 | case QDF_GLOBAL_QVIT_MODE: |
| 11531 | return QDF_QVIT_MODE; |
| 11532 | default: |
| 11533 | return QDF_MAX_NO_OF_MODE; |
| 11534 | } |
| 11535 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11536 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11537 | static void hdd_stop_present_mode(struct hdd_context *hdd_ctx, |
| 11538 | enum tQDF_GLOBAL_CON_MODE curr_mode) |
| 11539 | { |
| 11540 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) |
| 11541 | return; |
| 11542 | |
| 11543 | switch (curr_mode) { |
| 11544 | case QDF_GLOBAL_MISSION_MODE: |
| 11545 | case QDF_GLOBAL_MONITOR_MODE: |
| 11546 | case QDF_GLOBAL_FTM_MODE: |
| 11547 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
| 11548 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev); |
| 11549 | |
| 11550 | /* re-use the existing session */ |
| 11551 | hdd_stop_all_adapters(hdd_ctx, false); |
| 11552 | break; |
| 11553 | default: |
| 11554 | break; |
| 11555 | } |
| 11556 | } |
| 11557 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11558 | static void hdd_cleanup_present_mode(struct hdd_context *hdd_ctx, |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11559 | enum tQDF_GLOBAL_CON_MODE curr_mode) |
| 11560 | { |
Ashish Kumar Dhanotiya | 0024313 | 2017-01-24 16:37:34 +0530 | [diff] [blame] | 11561 | int driver_status; |
| 11562 | |
| 11563 | driver_status = hdd_ctx->driver_status; |
| 11564 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11565 | switch (curr_mode) { |
| 11566 | case QDF_GLOBAL_MISSION_MODE: |
| 11567 | case QDF_GLOBAL_MONITOR_MODE: |
| 11568 | case QDF_GLOBAL_FTM_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11569 | hdd_deinit_all_adapters(hdd_ctx, false); |
| 11570 | hdd_close_all_adapters(hdd_ctx, false); |
| 11571 | break; |
| 11572 | case QDF_GLOBAL_EPPING_MODE: |
| 11573 | epping_disable(); |
| 11574 | epping_close(); |
| 11575 | break; |
| 11576 | default: |
| 11577 | return; |
| 11578 | } |
| 11579 | } |
| 11580 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11581 | static int hdd_register_req_mode(struct hdd_context *hdd_ctx, |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11582 | enum tQDF_GLOBAL_CON_MODE mode) |
| 11583 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11584 | struct hdd_adapter *adapter; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11585 | int ret = 0; |
| 11586 | bool rtnl_held; |
| 11587 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 11588 | QDF_STATUS status; |
| 11589 | |
| 11590 | if (!qdf_dev) { |
| 11591 | hdd_err("qdf device context is Null return!"); |
| 11592 | return -EINVAL; |
| 11593 | } |
| 11594 | |
| 11595 | rtnl_held = hdd_hold_rtnl_lock(); |
| 11596 | switch (mode) { |
| 11597 | case QDF_GLOBAL_MISSION_MODE: |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 11598 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 11599 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11600 | hdd_err("Failed to open interfaces: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11601 | break; |
| 11602 | case QDF_GLOBAL_FTM_MODE: |
| 11603 | adapter = hdd_open_adapter(hdd_ctx, QDF_FTM_MODE, "wlan%d", |
| 11604 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 11605 | NET_NAME_UNKNOWN, rtnl_held); |
| 11606 | if (adapter == NULL) |
| 11607 | ret = -EINVAL; |
| 11608 | break; |
| 11609 | case QDF_GLOBAL_MONITOR_MODE: |
| 11610 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
| 11611 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 11612 | NET_NAME_UNKNOWN, rtnl_held); |
| 11613 | if (adapter == NULL) |
| 11614 | ret = -EINVAL; |
| 11615 | break; |
| 11616 | case QDF_GLOBAL_EPPING_MODE: |
| 11617 | status = epping_open(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11618 | if (status != QDF_STATUS_SUCCESS) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11619 | hdd_err("Failed to open in eeping mode: %d", status); |
| 11620 | ret = -EINVAL; |
| 11621 | break; |
| 11622 | } |
| 11623 | ret = epping_enable(qdf_dev->dev); |
| 11624 | if (ret) { |
| 11625 | hdd_err("Failed to enable in epping mode : %d", ret); |
| 11626 | epping_close(); |
| 11627 | } |
| 11628 | break; |
| 11629 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11630 | hdd_err("Mode not supported"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11631 | ret = -ENOTSUPP; |
| 11632 | break; |
| 11633 | } |
| 11634 | hdd_release_rtnl_lock(); |
| 11635 | rtnl_held = false; |
| 11636 | return ret; |
| 11637 | } |
| 11638 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11639 | /** |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11640 | * __con_mode_handler() - Handles module param con_mode change |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11641 | * @kmessage: con mode name on which driver to be bring up |
| 11642 | * @kp: The associated kernel parameter |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11643 | * @hdd_ctx: Pointer to the global HDD context |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11644 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11645 | * This function is invoked when user updates con mode using sys entry, |
| 11646 | * to initialize and bring-up driver in that specific mode. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11647 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11648 | * Return - 0 on success and failure code on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11649 | */ |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11650 | static int __con_mode_handler(const char *kmessage, struct kernel_param *kp, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11651 | struct hdd_context *hdd_ctx) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11652 | { |
| 11653 | int ret; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11654 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11655 | enum tQDF_GLOBAL_CON_MODE curr_mode; |
| 11656 | enum tQDF_ADAPTER_MODE adapter_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11657 | |
Dustin Brown | ab6029b | 2017-05-24 13:04:19 -0700 | [diff] [blame] | 11658 | hdd_info("con_mode handler: %s", kmessage); |
| 11659 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11660 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 11661 | if (ret) |
| 11662 | return ret; |
| 11663 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11664 | cds_set_load_in_progress(true); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11665 | |
| 11666 | ret = param_set_int(kmessage, kp); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11667 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11668 | if (!(is_con_mode_valid(con_mode))) { |
| 11669 | hdd_err("invlaid con_mode %d", con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11670 | ret = -EINVAL; |
| 11671 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11672 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11673 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11674 | curr_mode = hdd_get_conparam(); |
| 11675 | if (curr_mode == con_mode) { |
| 11676 | hdd_err("curr mode: %d is same as user triggered mode %d", |
| 11677 | curr_mode, con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11678 | ret = 0; |
| 11679 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11680 | } |
| 11681 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11682 | /* ensure adapters are stopped */ |
| 11683 | hdd_stop_present_mode(hdd_ctx, curr_mode); |
| 11684 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 11685 | ret = hdd_wlan_stop_modules(hdd_ctx, true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11686 | if (ret) { |
| 11687 | hdd_err("Stop wlan modules failed"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11688 | goto reset_flags; |
| 11689 | } |
| 11690 | |
Ashish Kumar Dhanotiya | cda5766 | 2017-08-14 14:45:25 +0530 | [diff] [blame] | 11691 | /* Cleanup present mode before switching to new mode */ |
| 11692 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
| 11693 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11694 | hdd_set_conparam(con_mode); |
| 11695 | |
| 11696 | /* Register for new con_mode & then kick_start modules again */ |
| 11697 | ret = hdd_register_req_mode(hdd_ctx, con_mode); |
| 11698 | if (ret) { |
| 11699 | hdd_err("Failed to register for new mode"); |
| 11700 | goto reset_flags; |
| 11701 | } |
| 11702 | |
| 11703 | adapter_mode = hdd_get_adpter_mode(con_mode); |
| 11704 | if (adapter_mode == QDF_MAX_NO_OF_MODE) { |
| 11705 | hdd_err("invalid adapter"); |
| 11706 | ret = -EINVAL; |
| 11707 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11708 | } |
| 11709 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11710 | adapter = hdd_get_adapter(hdd_ctx, adapter_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11711 | if (!adapter) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11712 | hdd_err("Failed to get adapter:%d", adapter_mode); |
| 11713 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11714 | } |
| 11715 | |
| 11716 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 11717 | if (ret) { |
| 11718 | hdd_err("Start wlan modules failed: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11719 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11720 | } |
| 11721 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11722 | if (con_mode == QDF_GLOBAL_MONITOR_MODE || |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11723 | con_mode == QDF_GLOBAL_FTM_MODE) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11724 | if (hdd_start_adapter(adapter)) { |
| 11725 | hdd_err("Failed to start %s adapter", kmessage); |
| 11726 | ret = -EINVAL; |
| 11727 | goto reset_flags; |
| 11728 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11729 | } |
| 11730 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11731 | hdd_info("Mode successfully changed to %s", kmessage); |
| 11732 | ret = 0; |
| 11733 | |
| 11734 | reset_flags: |
| 11735 | cds_set_load_in_progress(false); |
| 11736 | return ret; |
| 11737 | } |
| 11738 | |
| 11739 | |
| 11740 | static int con_mode_handler(const char *kmessage, struct kernel_param *kp) |
| 11741 | { |
| 11742 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11743 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11744 | |
| 11745 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11746 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 11747 | if (ret) |
| 11748 | return ret; |
| 11749 | |
| 11750 | cds_ssr_protect(__func__); |
| 11751 | ret = __con_mode_handler(kmessage, kp, hdd_ctx); |
| 11752 | cds_ssr_unprotect(__func__); |
| 11753 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11754 | return ret; |
| 11755 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11756 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 11757 | static int con_mode_handler_ftm(const char *kmessage, |
| 11758 | struct kernel_param *kp) |
| 11759 | { |
| 11760 | int ret; |
| 11761 | |
| 11762 | ret = param_set_int(kmessage, kp); |
| 11763 | |
| 11764 | if (con_mode_ftm != QDF_GLOBAL_FTM_MODE) { |
| 11765 | pr_err("Only FTM mode supported!"); |
| 11766 | return -ENOTSUPP; |
| 11767 | } |
| 11768 | |
| 11769 | hdd_set_conparam(con_mode_ftm); |
| 11770 | con_mode = con_mode_ftm; |
| 11771 | |
| 11772 | return ret; |
| 11773 | } |
| 11774 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 11775 | static int con_mode_handler_monitor(const char *kmessage, |
| 11776 | struct kernel_param *kp) |
| 11777 | { |
| 11778 | int ret; |
| 11779 | |
| 11780 | ret = param_set_int(kmessage, kp); |
| 11781 | |
| 11782 | if (con_mode_monitor != QDF_GLOBAL_MONITOR_MODE) { |
| 11783 | pr_err("Only Monitor mode supported!"); |
| 11784 | return -ENOTSUPP; |
| 11785 | } |
| 11786 | |
| 11787 | hdd_set_conparam(con_mode_monitor); |
| 11788 | con_mode = con_mode_monitor; |
| 11789 | |
| 11790 | return ret; |
| 11791 | } |
| 11792 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11793 | /** |
| 11794 | * hdd_get_conparam() - driver exit point |
| 11795 | * |
| 11796 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 11797 | * |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 11798 | * Return: enum tQDF_GLOBAL_CON_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11799 | */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 11800 | enum tQDF_GLOBAL_CON_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11801 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 11802 | return (enum tQDF_GLOBAL_CON_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11803 | } |
| 11804 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 11805 | void hdd_set_conparam(uint32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11806 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 11807 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11808 | } |
| 11809 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 11810 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 11811 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 11812 | * @hdd_ctx: HDD context |
| 11813 | * |
| 11814 | * Cleans up the pre cac interface, if it exists |
| 11815 | * |
| 11816 | * Return: None |
| 11817 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11818 | void hdd_clean_up_pre_cac_interface(struct hdd_context *hdd_ctx) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 11819 | { |
| 11820 | uint8_t session_id; |
| 11821 | QDF_STATUS status; |
Jeff Johnson | 85b5c11 | 2017-08-11 15:15:23 -0700 | [diff] [blame] | 11822 | struct hdd_adapter *precac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 11823 | |
| 11824 | status = wlan_sap_get_pre_cac_vdev_id(hdd_ctx->hHal, &session_id); |
| 11825 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11826 | hdd_err("failed to get pre cac vdev id"); |
| 11827 | return; |
| 11828 | } |
| 11829 | |
| 11830 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, session_id); |
| 11831 | if (!precac_adapter) { |
| 11832 | hdd_err("invalid pre cac adapater"); |
| 11833 | return; |
| 11834 | } |
| 11835 | |
| 11836 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 11837 | wlan_hdd_sap_pre_cac_failure, |
| 11838 | (void *)precac_adapter); |
| 11839 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 11840 | |
| 11841 | } |
| 11842 | |
| 11843 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11844 | * hdd_update_ol_config - API to update ol configuration parameters |
| 11845 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 11846 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 11847 | * Return: void |
| 11848 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11849 | static void hdd_update_ol_config(struct hdd_context *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 11850 | { |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11851 | struct ol_config_info cfg; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 11852 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 11853 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11854 | if (!ol_ctx) |
| 11855 | return; |
| 11856 | |
| 11857 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
| 11858 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 11859 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 11860 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 11861 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11862 | |
| 11863 | ol_init_ini_config(ol_ctx, &cfg); |
| 11864 | } |
| 11865 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 11866 | #ifdef FEATURE_RUNTIME_PM |
| 11867 | /** |
| 11868 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 11869 | * @hdd_ctx: hdd context |
| 11870 | * @cfg: pointer to the configuration memory being populated |
| 11871 | * |
| 11872 | * Return: void |
| 11873 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11874 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 11875 | struct hif_config_info *cfg) |
| 11876 | { |
| 11877 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
| 11878 | cfg->runtime_pm_delay = hdd_ctx->config->runtime_pm_delay; |
| 11879 | } |
| 11880 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11881 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 11882 | struct hif_config_info *cfg) |
| 11883 | { |
| 11884 | } |
| 11885 | #endif |
| 11886 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11887 | /** |
| 11888 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 11889 | * @hdd_ctx: HDD Context |
| 11890 | * |
| 11891 | * Return: void |
| 11892 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11893 | static void hdd_update_hif_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11894 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 11895 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11896 | struct hif_config_info cfg; |
| 11897 | |
| 11898 | if (!scn) |
| 11899 | return; |
| 11900 | |
| 11901 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 11902 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11903 | hif_init_ini_config(scn, &cfg); |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 11904 | |
| 11905 | if (hdd_ctx->config->prevent_link_down) |
| 11906 | hif_vote_link_up(scn); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11907 | } |
| 11908 | |
| 11909 | /** |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 11910 | * hdd_update_dp_config() - Propagate config parameters to Lithium |
| 11911 | * datapath |
| 11912 | * @hdd_ctx: HDD Context |
| 11913 | * |
| 11914 | * Return: 0 for success/errno for failure |
| 11915 | */ |
| 11916 | static int hdd_update_dp_config(struct hdd_context *hdd_ctx) |
| 11917 | { |
| 11918 | struct cdp_config_params params; |
| 11919 | QDF_STATUS status; |
| 11920 | |
| 11921 | params.tso_enable = hdd_ctx->config->tso_enable; |
| 11922 | params.lro_enable = hdd_ctx->config->lro_enable; |
| 11923 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 11924 | params.tx_flow_stop_queue_threshold = |
| 11925 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 11926 | params.tx_flow_start_queue_offset = |
| 11927 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 11928 | #endif |
| 11929 | params.flow_steering_enable = hdd_ctx->config->flow_steering_enable; |
| 11930 | params.napi_enable = hdd_ctx->napi_enable; |
| 11931 | params.tcp_udp_checksumoffload = |
| 11932 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
| 11933 | |
| 11934 | status = cdp_update_config_parameters( |
| 11935 | cds_get_context(QDF_MODULE_ID_SOC), |
| 11936 | ¶ms); |
| 11937 | if (status) { |
| 11938 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR, |
| 11939 | "%s: Failed to attach config parameters", __func__); |
| 11940 | return status; |
| 11941 | } |
| 11942 | |
| 11943 | return 0; |
| 11944 | } |
| 11945 | |
| 11946 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11947 | * hdd_update_config() - Initialize driver per module ini parameters |
| 11948 | * @hdd_ctx: HDD Context |
| 11949 | * |
| 11950 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 11951 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11952 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11953 | int hdd_update_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11954 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 11955 | int ret; |
| 11956 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11957 | hdd_update_ol_config(hdd_ctx); |
| 11958 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 11959 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 11960 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 11961 | else |
| 11962 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 11963 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 11964 | |
| 11965 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 11966 | } |
| 11967 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 11968 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 11969 | /** |
| 11970 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 11971 | * @psoc_cfg: pmo psoc Configuration |
| 11972 | * @hdd_ctx: Pointer to hdd context |
| 11973 | * |
| 11974 | * Return: none |
| 11975 | */ |
| 11976 | static inline void hdd_ra_populate_pmo_config( |
| 11977 | struct pmo_psoc_cfg *psoc_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11978 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 11979 | { |
| 11980 | psoc_cfg->ra_ratelimit_interval = |
| 11981 | hdd_ctx->config->RArateLimitInterval; |
| 11982 | psoc_cfg->ra_ratelimit_enable = |
| 11983 | hdd_ctx->config->IsRArateLimitEnabled; |
| 11984 | } |
| 11985 | #else |
| 11986 | static inline void hdd_ra_populate_pmo_config( |
| 11987 | struct cds_config_info *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11988 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 11989 | { |
| 11990 | } |
| 11991 | #endif |
| 11992 | /** |
| 11993 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 11994 | * @hdd_ctx: HDD context |
| 11995 | * |
| 11996 | * Return: void |
| 11997 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11998 | static int hdd_update_pmo_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 11999 | { |
| 12000 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 12001 | struct pmo_psoc_cfg psoc_cfg; |
| 12002 | QDF_STATUS status; |
| 12003 | |
| 12004 | /* |
| 12005 | * Value of hdd_ctx->wowEnable can be, |
| 12006 | * 0 - Disable both magic pattern match and pattern byte match. |
| 12007 | * 1 - Enable magic pattern match on all interfaces. |
| 12008 | * 2 - Enable pattern byte match on all interfaces. |
| 12009 | * 3 - Enable both magic patter and pattern byte match on |
| 12010 | * all interfaces. |
| 12011 | */ |
| 12012 | psoc_cfg.magic_ptrn_enable = |
| 12013 | (hdd_ctx->config->wowEnable & 0x01) ? true : false; |
| 12014 | psoc_cfg.ptrn_match_enable_all_vdev = |
| 12015 | (hdd_ctx->config->wowEnable & 0x02) ? true : false; |
Will Huang | fe64917 | 2017-09-06 16:52:18 +0800 | [diff] [blame] | 12016 | psoc_cfg.ptrn_id_per_vdev = wma_is_service_enabled( |
| 12017 | WMI_SERVICE_UNIFIED_WOW_CAPABILITY); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12018 | psoc_cfg.bpf_enable = |
| 12019 | hdd_ctx->config->bpf_packet_filter_enable; |
| 12020 | psoc_cfg.arp_offload_enable = hdd_ctx->config->fhostArpOffload; |
Dustin Brown | 1224e21 | 2017-05-12 14:02:12 -0700 | [diff] [blame] | 12021 | psoc_cfg.hw_filter_mode = hdd_ctx->config->hw_filter_mode; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12022 | psoc_cfg.ns_offload_enable_static = hdd_ctx->config->fhostNSOffload; |
| 12023 | if (hdd_ctx->config->fhostNSOffload) |
| 12024 | psoc_cfg.ns_offload_enable_dynamic = true; |
| 12025 | psoc_cfg.ssdp = hdd_ctx->config->ssdp; |
| 12026 | psoc_cfg.enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 12027 | psoc_cfg.active_mode_offload = |
| 12028 | hdd_ctx->config->active_mode_offload; |
| 12029 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
| 12030 | psoc_cfg.max_wow_filters = hdd_ctx->config->maxWoWFilters; |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 12031 | psoc_cfg.sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 12032 | psoc_cfg.sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 12033 | psoc_cfg.sta_max_li_mod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 12034 | psoc_cfg.power_save_mode = |
| 12035 | hdd_ctx->config->enablePowersaveOffload; |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 12036 | psoc_cfg.auto_power_save_fail_mode = |
| 12037 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12038 | |
| 12039 | hdd_ra_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 12040 | hdd_nan_populate_pmo_config(&psoc_cfg, hdd_ctx); |
| 12041 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12042 | status = pmo_ucfg_update_psoc_config(psoc, &psoc_cfg); |
| 12043 | if (status != QDF_STATUS_SUCCESS) { |
| 12044 | hdd_err("failed pmo psoc configuration"); |
| 12045 | return -EINVAL; |
| 12046 | } |
| 12047 | |
| 12048 | return 0; |
| 12049 | } |
| 12050 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12051 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 12052 | static inline void hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
| 12053 | struct hdd_config *cfg) |
| 12054 | { |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 12055 | struct nlo_mawc_params *mawc_cfg = &pno_cfg->mawc_params; |
| 12056 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12057 | pno_cfg->channel_prediction = cfg->pno_channel_prediction; |
| 12058 | pno_cfg->top_k_num_of_channels = cfg->top_k_num_of_channels; |
| 12059 | pno_cfg->stationary_thresh = cfg->stationary_thresh; |
| 12060 | pno_cfg->adaptive_dwell_mode = cfg->adaptive_dwell_mode_enabled; |
| 12061 | pno_cfg->channel_prediction_full_scan = |
| 12062 | cfg->channel_prediction_full_scan; |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 12063 | mawc_cfg->enable = cfg->MAWCEnabled && cfg->mawc_nlo_enabled; |
| 12064 | mawc_cfg->exp_backoff_ratio = cfg->mawc_nlo_exp_backoff_ratio; |
| 12065 | mawc_cfg->init_scan_interval = cfg->mawc_nlo_init_scan_interval; |
| 12066 | mawc_cfg->max_scan_interval = cfg->mawc_nlo_max_scan_interval; |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12067 | } |
| 12068 | #else |
| 12069 | static inline void |
| 12070 | hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
Jeff Johnson | 33a0792 | 2017-10-05 09:08:46 -0700 | [diff] [blame] | 12071 | struct hdd_config *cfg) |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12072 | { |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12073 | } |
| 12074 | #endif |
| 12075 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 12076 | void hdd_update_ie_whitelist_attr(struct probe_req_whitelist_attr *ie_whitelist, |
| 12077 | struct hdd_config *cfg) |
| 12078 | { |
| 12079 | uint8_t i = 0; |
| 12080 | |
| 12081 | ie_whitelist->white_list = cfg->probe_req_ie_whitelist; |
| 12082 | if (!ie_whitelist->white_list) |
| 12083 | return; |
| 12084 | |
| 12085 | ie_whitelist->ie_bitmap[0] = cfg->probe_req_ie_bitmap_0; |
| 12086 | ie_whitelist->ie_bitmap[1] = cfg->probe_req_ie_bitmap_1; |
| 12087 | ie_whitelist->ie_bitmap[2] = cfg->probe_req_ie_bitmap_2; |
| 12088 | ie_whitelist->ie_bitmap[3] = cfg->probe_req_ie_bitmap_3; |
| 12089 | ie_whitelist->ie_bitmap[4] = cfg->probe_req_ie_bitmap_4; |
| 12090 | ie_whitelist->ie_bitmap[5] = cfg->probe_req_ie_bitmap_5; |
| 12091 | ie_whitelist->ie_bitmap[6] = cfg->probe_req_ie_bitmap_6; |
| 12092 | ie_whitelist->ie_bitmap[7] = cfg->probe_req_ie_bitmap_7; |
| 12093 | |
| 12094 | ie_whitelist->num_vendor_oui = cfg->no_of_probe_req_ouis; |
| 12095 | for (i = 0; i < ie_whitelist->num_vendor_oui; i++) |
| 12096 | ie_whitelist->voui[i] = cfg->probe_req_voui[i]; |
| 12097 | } |
| 12098 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12099 | /** |
| 12100 | * hdd_update_scan_config - API to update scan configuration parameters |
| 12101 | * @hdd_ctx: HDD context |
| 12102 | * |
| 12103 | * Return: 0 if success else err |
| 12104 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12105 | static int hdd_update_scan_config(struct hdd_context *hdd_ctx) |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12106 | { |
| 12107 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 12108 | struct scan_user_cfg scan_cfg; |
| 12109 | struct hdd_config *cfg = hdd_ctx->config; |
| 12110 | QDF_STATUS status; |
| 12111 | |
| 12112 | scan_cfg.active_dwell = cfg->nActiveMaxChnTime; |
| 12113 | scan_cfg.passive_dwell = cfg->nPassiveMaxChnTime; |
| 12114 | scan_cfg.conc_active_dwell = cfg->nActiveMaxChnTimeConc; |
| 12115 | scan_cfg.conc_passive_dwell = cfg->nPassiveMaxChnTimeConc; |
| 12116 | scan_cfg.conc_max_rest_time = cfg->nRestTimeConc; |
| 12117 | scan_cfg.conc_min_rest_time = cfg->min_rest_time_conc; |
| 12118 | scan_cfg.conc_idle_time = cfg->idle_time_conc; |
Abhishek Singh | 158fe25 | 2017-03-23 11:09:34 +0530 | [diff] [blame] | 12119 | /* convert to ms */ |
| 12120 | scan_cfg.scan_cache_aging_time = |
| 12121 | cfg->scanAgingTimeout * 1000; |
| 12122 | scan_cfg.prefer_5ghz = cfg->nRoamPrefer5GHz; |
| 12123 | scan_cfg.select_5ghz_margin = cfg->nSelect5GHzMargin; |
| 12124 | scan_cfg.scan_bucket_threshold = cfg->first_scan_bucket_threshold; |
| 12125 | scan_cfg.rssi_cat_gap = cfg->nRssiCatGap; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12126 | scan_cfg.scan_dwell_time_mode = cfg->scan_adaptive_dwell_mode; |
Kapil Gupta | fa9a8c6 | 2017-04-10 15:25:40 +0530 | [diff] [blame] | 12127 | scan_cfg.is_snr_monitoring_enabled = cfg->fEnableSNRMonitoring; |
Abhishek Singh | b58164a | 2017-07-19 18:47:23 +0530 | [diff] [blame] | 12128 | scan_cfg.is_bssid_hint_priority = cfg->is_bssid_hint_priority; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12129 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12130 | hdd_update_pno_config(&scan_cfg.pno_cfg, cfg); |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 12131 | hdd_update_ie_whitelist_attr(&scan_cfg.ie_whitelist, cfg); |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12132 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12133 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 12134 | if (status != QDF_STATUS_SUCCESS) { |
| 12135 | hdd_err("failed pmo psoc configuration"); |
| 12136 | return -EINVAL; |
| 12137 | } |
| 12138 | |
| 12139 | return 0; |
| 12140 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12141 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12142 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 12143 | { |
| 12144 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 12145 | struct tdls_start_params tdls_cfg; |
| 12146 | struct tdls_user_config *config = &tdls_cfg.config; |
| 12147 | struct hdd_config *cfg = hdd_ctx->config; |
| 12148 | QDF_STATUS status; |
| 12149 | |
| 12150 | config->tdls_tx_states_period = cfg->fTDLSTxStatsPeriod; |
| 12151 | config->tdls_tx_pkt_threshold = cfg->fTDLSTxPacketThreshold; |
| 12152 | config->tdls_rx_pkt_threshold = cfg->fTDLSRxFrameThreshold; |
| 12153 | config->tdls_max_discovery_attempt = cfg->fTDLSMaxDiscoveryAttempt; |
| 12154 | config->tdls_idle_timeout = cfg->tdls_idle_timeout; |
| 12155 | config->tdls_idle_pkt_threshold = cfg->fTDLSIdlePacketThreshold; |
| 12156 | config->tdls_rssi_trigger_threshold = cfg->fTDLSRSSITriggerThreshold; |
| 12157 | config->tdls_rssi_teardown_threshold = cfg->fTDLSRSSITeardownThreshold; |
| 12158 | config->tdls_rssi_delta = cfg->fTDLSRSSIDelta; |
| 12159 | config->tdls_uapsd_mask = cfg->fTDLSUapsdMask; |
| 12160 | config->tdls_uapsd_inactivity_time = cfg->fTDLSPuapsdInactivityTimer; |
| 12161 | config->tdls_uapsd_pti_window = cfg->fTDLSPuapsdPTIWindow; |
| 12162 | config->tdls_uapsd_ptr_timeout = cfg->fTDLSPuapsdPTRTimeout; |
| 12163 | config->tdls_pre_off_chan_num = cfg->fTDLSPrefOffChanNum; |
| 12164 | config->tdls_pre_off_chan_bw = cfg->fTDLSPrefOffChanBandwidth; |
| 12165 | config->tdls_peer_kickout_threshold = cfg->tdls_peer_kickout_threshold; |
| 12166 | config->delayed_trig_framint = cfg->DelayedTriggerFrmInt; |
| 12167 | config->tdls_feature_flags = ((cfg->fEnableTDLSOffChannel ? |
| 12168 | 1 << TDLS_FEATURE_OFF_CHANNEL : 0) | |
| 12169 | (cfg->fEnableTDLSWmmMode ? 1 << TDLS_FEATURE_WMM : 0) | |
| 12170 | (cfg->fEnableTDLSBufferSta ? 1 << TDLS_FEATURE_BUFFER_STA : 0) | |
| 12171 | (cfg->fEnableTDLSSleepSta ? 1 << TDLS_FEATURE_SLEEP_STA : 0) | |
| 12172 | (cfg->enable_tdls_scan ? 1 << TDLS_FEATURE_SCAN : 0) | |
| 12173 | (cfg->fEnableTDLSSupport ? 1 << TDLS_FEATURE_ENABLE : 0) | |
| 12174 | (cfg->fEnableTDLSImplicitTrigger ? |
| 12175 | 1 << TDLS_FEAUTRE_IMPLICIT_TRIGGER : 0) | |
| 12176 | (cfg->fTDLSExternalControl ? |
| 12177 | 1 << TDLS_FEATURE_EXTERNAL_CONTROL : 0)); |
| 12178 | |
| 12179 | tdls_cfg.tdls_send_mgmt_req = eWNI_SME_TDLS_SEND_MGMT_REQ; |
| 12180 | tdls_cfg.tdls_add_sta_req = eWNI_SME_TDLS_ADD_STA_REQ; |
| 12181 | tdls_cfg.tdls_del_sta_req = eWNI_SME_TDLS_DEL_STA_REQ; |
| 12182 | tdls_cfg.tdls_update_peer_state = WMA_UPDATE_TDLS_PEER_STATE; |
Kabilan Kannan | 1c1c402 | 2017-04-06 22:49:26 -0700 | [diff] [blame] | 12183 | tdls_cfg.tdls_del_all_peers = eWNI_SME_DEL_ALL_TDLS_PEERS; |
Kabilan Kannan | 256e318 | 2017-05-02 16:02:37 -0700 | [diff] [blame] | 12184 | tdls_cfg.tdls_update_dp_vdev_flags = CDP_UPDATE_TDLS_FLAGS; |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 12185 | tdls_cfg.tdls_event_cb = wlan_cfg80211_tdls_event_callback; |
| 12186 | tdls_cfg.tdls_evt_cb_data = psoc; |
| 12187 | tdls_cfg.tdls_tl_peer_data = hdd_ctx; |
| 12188 | tdls_cfg.tdls_reg_tl_peer = hdd_tdls_register_tdls_peer; |
| 12189 | tdls_cfg.tdls_dereg_tl_peer = hdd_tdls_deregister_tdl_peer; |
Kabilan Kannan | f56f9d5 | 2017-04-05 03:31:34 -0700 | [diff] [blame] | 12190 | tdls_cfg.tdls_wmm_cb = hdd_wmm_is_acm_allowed; |
| 12191 | tdls_cfg.tdls_wmm_cb_data = psoc; |
| 12192 | tdls_cfg.tdls_rx_cb = wlan_cfg80211_tdls_rx_callback; |
| 12193 | tdls_cfg.tdls_rx_cb_data = psoc; |
Kabilan Kannan | 256e318 | 2017-05-02 16:02:37 -0700 | [diff] [blame] | 12194 | tdls_cfg.tdls_dp_vdev_update = hdd_update_dp_vdev_flags; |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 12195 | |
| 12196 | status = ucfg_tdls_update_config(psoc, &tdls_cfg); |
| 12197 | if (status != QDF_STATUS_SUCCESS) { |
| 12198 | hdd_err("failed pmo psoc configuration"); |
| 12199 | return -EINVAL; |
| 12200 | } |
| 12201 | |
Kabilan Kannan | 1c1c402 | 2017-04-06 22:49:26 -0700 | [diff] [blame] | 12202 | hdd_ctx->tdls_umac_comp_active = true; |
Kabilan Kannan | c0e3d58 | 2017-09-13 00:26:33 -0700 | [diff] [blame] | 12203 | /* enable napier specific tdls data path */ |
| 12204 | hdd_ctx->tdls_nap_active = true; |
Kabilan Kannan | 1c1c402 | 2017-04-06 22:49:26 -0700 | [diff] [blame] | 12205 | |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 12206 | return 0; |
| 12207 | } |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 12208 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12209 | int hdd_update_components_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12210 | { |
| 12211 | int ret; |
| 12212 | |
| 12213 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12214 | if (ret) |
| 12215 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12216 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12217 | ret = hdd_update_scan_config(hdd_ctx); |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 12218 | if (ret) |
| 12219 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12220 | |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 12221 | ret = hdd_update_tdls_config(hdd_ctx); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12222 | if (ret) |
| 12223 | return ret; |
| 12224 | |
| 12225 | ret = hdd_update_dp_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12226 | |
| 12227 | return ret; |
| 12228 | } |
| 12229 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12230 | /** |
| 12231 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 12232 | * @mode : cfg80211 DFS mode |
| 12233 | * |
| 12234 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 12235 | */ |
| 12236 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 12237 | { |
| 12238 | switch (mode) { |
| 12239 | case DFS_MODE_ENABLE: |
| 12240 | return ACS_DFS_MODE_ENABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12241 | case DFS_MODE_DISABLE: |
| 12242 | return ACS_DFS_MODE_DISABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12243 | case DFS_MODE_DEPRIORITIZE: |
| 12244 | return ACS_DFS_MODE_DEPRIORITIZE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12245 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12246 | hdd_debug("ACS dfs mode is NONE"); |
| 12247 | return ACS_DFS_MODE_NONE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12248 | } |
| 12249 | } |
| 12250 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 12251 | /** |
| 12252 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 12253 | * @hddctx: pointer to hdd context |
| 12254 | * @set_value: enable/disable |
| 12255 | * |
| 12256 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 12257 | * Host(even though it is duplicate). When Host send vendor command |
| 12258 | * disable,FW doesn't perform any action. Whenever any change in |
| 12259 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 12260 | * |
| 12261 | * return - 0 on success, appropriate error values on failure. |
| 12262 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12263 | int hdd_enable_disable_ca_event(struct hdd_context *hddctx, uint8_t set_value) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 12264 | { |
| 12265 | QDF_STATUS status; |
| 12266 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12267 | if (0 != wlan_hdd_validate_context(hddctx)) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 12268 | return -EAGAIN; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 12269 | |
| 12270 | if (!hddctx->config->goptimize_chan_avoid_event) { |
| 12271 | hdd_warn("goptimize_chan_avoid_event ini param disabled"); |
| 12272 | return -EINVAL; |
| 12273 | } |
| 12274 | |
| 12275 | status = sme_enable_disable_chanavoidind_event(hddctx->hHal, set_value); |
| 12276 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 12277 | hdd_err("Failed to send chan avoid command to SME"); |
| 12278 | return -EINVAL; |
| 12279 | } |
| 12280 | return 0; |
| 12281 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12282 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12283 | /** |
| 12284 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 12285 | * @value: value to set |
| 12286 | * |
| 12287 | * This function will set the passed value to roaming in progress flag. |
| 12288 | * |
| 12289 | * Return: None |
| 12290 | */ |
| 12291 | void hdd_set_roaming_in_progress(bool value) |
| 12292 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12293 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12294 | |
| 12295 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12296 | if (!hdd_ctx) { |
| 12297 | hdd_err("HDD context is NULL"); |
| 12298 | return; |
| 12299 | } |
| 12300 | |
| 12301 | hdd_ctx->roaming_in_progress = value; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12302 | hdd_debug("Roaming in Progress set to %d", value); |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12303 | } |
| 12304 | |
| 12305 | /** |
| 12306 | * hdd_is_roaming_in_progress() - check if roaming is in progress |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12307 | * @adapter - HDD adapter |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12308 | * |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12309 | * Return: true if roaming is in progress for STA type, else false |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12310 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12311 | bool hdd_is_roaming_in_progress(struct hdd_adapter *adapter) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12312 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12313 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12314 | bool ret_status = false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12315 | |
| 12316 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12317 | if (!hdd_ctx) { |
| 12318 | hdd_err("HDD context is NULL"); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12319 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12320 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12321 | hdd_debug("dev mode = %d, roaming_in_progress = %d", |
| 12322 | adapter->device_mode, hdd_ctx->roaming_in_progress); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12323 | ret_status = ((adapter->device_mode == QDF_STA_MODE) && |
| 12324 | hdd_ctx->roaming_in_progress); |
| 12325 | |
| 12326 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12327 | } |
| 12328 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12329 | /** |
| 12330 | * hdd_is_connection_in_progress() - check if connection is in |
| 12331 | * progress |
| 12332 | * @session_id: session id |
| 12333 | * @reason: scan reject reason |
| 12334 | * |
| 12335 | * Go through each adapter and check if Connection is in progress |
| 12336 | * |
| 12337 | * Return: true if connection is in progress else false |
| 12338 | */ |
| 12339 | bool hdd_is_connection_in_progress(uint8_t *session_id, |
| 12340 | enum scan_reject_states *reason) |
| 12341 | { |
| 12342 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 12343 | struct hdd_station_ctx *hdd_sta_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12344 | struct hdd_adapter *adapter = NULL; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12345 | QDF_STATUS status = 0; |
| 12346 | uint8_t sta_id = 0; |
| 12347 | uint8_t *sta_mac = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12348 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12349 | |
| 12350 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12351 | if (!hdd_ctx) { |
| 12352 | hdd_err("HDD context is NULL"); |
| 12353 | return false; |
| 12354 | } |
| 12355 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12356 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 12357 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
Jeff Johnson | 57eb273 | 2017-10-02 11:40:20 -0700 | [diff] [blame] | 12358 | adapter = adapter_node->adapter; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12359 | if (!adapter) |
| 12360 | goto end; |
| 12361 | |
| 12362 | hdd_info("Adapter with device mode %s(%d) exists", |
| 12363 | hdd_device_mode_to_string(adapter->device_mode), |
| 12364 | adapter->device_mode); |
| 12365 | if (((QDF_STA_MODE == adapter->device_mode) |
| 12366 | || (QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 12367 | || (QDF_P2P_DEVICE_MODE == adapter->device_mode)) |
| 12368 | && (eConnectionState_Connecting == |
| 12369 | (WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> |
| 12370 | conn_info.connState)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12371 | hdd_debug("%pK(%d) Connection is in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12372 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
| 12373 | adapter->sessionId); |
| 12374 | if (session_id && reason) { |
| 12375 | *session_id = adapter->sessionId; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12376 | *reason = CONNECTION_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12377 | } |
| 12378 | return true; |
| 12379 | } |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 12380 | /* |
| 12381 | * sme_neighbor_middle_of_roaming is for LFR2 |
| 12382 | * hdd_is_roaming_in_progress is for LFR3 |
| 12383 | */ |
| 12384 | if (((QDF_STA_MODE == adapter->device_mode) && |
| 12385 | sme_neighbor_middle_of_roaming( |
| 12386 | WLAN_HDD_GET_HAL_CTX(adapter), |
| 12387 | adapter->sessionId)) || |
| 12388 | hdd_is_roaming_in_progress(adapter)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12389 | hdd_debug("%pK(%d) Reassociation in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12390 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
| 12391 | adapter->sessionId); |
| 12392 | if (session_id && reason) { |
| 12393 | *session_id = adapter->sessionId; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12394 | *reason = REASSOC_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12395 | } |
| 12396 | return true; |
| 12397 | } |
| 12398 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 12399 | (QDF_P2P_CLIENT_MODE == adapter->device_mode) || |
| 12400 | (QDF_P2P_DEVICE_MODE == adapter->device_mode)) { |
| 12401 | hdd_sta_ctx = |
| 12402 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 12403 | if ((eConnectionState_Associated == |
| 12404 | hdd_sta_ctx->conn_info.connState) |
| 12405 | && (false == |
| 12406 | hdd_sta_ctx->conn_info.uIsAuthenticated)) { |
| 12407 | sta_mac = (uint8_t *) |
| 12408 | &(adapter->macAddressCurrent.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12409 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12410 | " is in middle of WPS/EAPOL exchange.", |
| 12411 | MAC_ADDR_ARRAY(sta_mac)); |
| 12412 | if (session_id && reason) { |
| 12413 | *session_id = adapter->sessionId; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12414 | *reason = EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12415 | } |
| 12416 | return true; |
| 12417 | } |
| 12418 | } else if ((QDF_SAP_MODE == adapter->device_mode) || |
| 12419 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
| 12420 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; |
| 12421 | sta_id++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 12422 | if (!((adapter->sta_info[sta_id].in_use) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12423 | && (OL_TXRX_PEER_STATE_CONN == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 12424 | adapter->sta_info[sta_id].peer_state))) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12425 | continue; |
| 12426 | |
| 12427 | sta_mac = (uint8_t *) |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 12428 | &(adapter->sta_info[sta_id]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 12429 | sta_mac.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12430 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12431 | " of SAP/GO is in middle of WPS/EAPOL exchange", |
| 12432 | MAC_ADDR_ARRAY(sta_mac)); |
| 12433 | if (session_id && reason) { |
| 12434 | *session_id = adapter->sessionId; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12435 | *reason = SAP_EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12436 | } |
| 12437 | return true; |
| 12438 | } |
| 12439 | if (hdd_ctx->connection_in_progress) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12440 | hdd_debug("AP/GO: connection is in progress"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12441 | return true; |
| 12442 | } |
| 12443 | } |
| 12444 | end: |
| 12445 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 12446 | adapter_node = next; |
| 12447 | } |
| 12448 | return false; |
| 12449 | } |
| 12450 | |
| 12451 | /** |
| 12452 | * hdd_restart_sap() - to restart SAP in driver internally |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12453 | * @ap_adapter: Pointer to SAP struct hdd_adapter structure |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12454 | * |
| 12455 | * Return: None |
| 12456 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12457 | void hdd_restart_sap(struct hdd_adapter *ap_adapter) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12458 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12459 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 12460 | struct hdd_hostapd_state *hostapd_state; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12461 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12462 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12463 | tsap_Config_t *sap_config; |
| 12464 | void *sap_ctx; |
| 12465 | |
| 12466 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 12467 | sap_config = &hdd_ap_ctx->sapConfig; |
| 12468 | sap_ctx = hdd_ap_ctx->sapContext; |
| 12469 | |
| 12470 | mutex_lock(&hdd_ctx->sap_lock); |
| 12471 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
| 12472 | wlan_hdd_del_station(ap_adapter); |
| 12473 | hdd_cleanup_actionframe(hdd_ctx, ap_adapter); |
| 12474 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 12475 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
| 12476 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(sap_ctx)) { |
| 12477 | qdf_status = |
| 12478 | qdf_wait_single_event(&hostapd_state-> |
| 12479 | qdf_stop_bss_event, |
| 12480 | SME_CMD_TIMEOUT_VALUE); |
| 12481 | |
| 12482 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12483 | hdd_err("SAP Stop Failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12484 | goto end; |
| 12485 | } |
| 12486 | } |
| 12487 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12488 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12489 | ap_adapter->device_mode, ap_adapter->sessionId); |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12490 | hdd_err("SAP Stop Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12491 | |
| 12492 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12493 | hdd_err("SAP Not able to set AP IEs"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12494 | wlansap_reset_sap_config_add_ie(sap_config, |
| 12495 | eUPDATE_IE_ALL); |
| 12496 | goto end; |
| 12497 | } |
| 12498 | |
| 12499 | qdf_event_reset(&hostapd_state->qdf_event); |
| 12500 | if (wlansap_start_bss(sap_ctx, hdd_hostapd_sap_event_cb, |
| 12501 | sap_config, |
| 12502 | ap_adapter->dev) != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12503 | hdd_err("SAP Start Bss fail"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12504 | wlansap_reset_sap_config_add_ie(sap_config, |
| 12505 | eUPDATE_IE_ALL); |
| 12506 | goto end; |
| 12507 | } |
| 12508 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12509 | hdd_info("Waiting for SAP to start"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12510 | qdf_status = |
| 12511 | qdf_wait_single_event(&hostapd_state->qdf_event, |
| 12512 | SME_CMD_TIMEOUT_VALUE); |
| 12513 | wlansap_reset_sap_config_add_ie(sap_config, |
| 12514 | eUPDATE_IE_ALL); |
| 12515 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12516 | hdd_err("SAP Start failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12517 | goto end; |
| 12518 | } |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12519 | hdd_err("SAP Start Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12520 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
| 12521 | if (hostapd_state->bssState == BSS_START) |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12522 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 12523 | ap_adapter->device_mode, |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12524 | ap_adapter->sessionId); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12525 | } |
| 12526 | end: |
| 12527 | mutex_unlock(&hdd_ctx->sap_lock); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12528 | } |
| 12529 | |
| 12530 | /** |
| 12531 | * hdd_check_and_restart_sap_with_non_dfs_acs() - Restart SAP |
| 12532 | * with non dfs acs |
| 12533 | * |
| 12534 | * Restarts SAP in non-DFS ACS mode when STA-AP mode DFS is not supported |
| 12535 | * |
| 12536 | * Return: None |
| 12537 | */ |
| 12538 | void hdd_check_and_restart_sap_with_non_dfs_acs(void) |
| 12539 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12540 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12541 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12542 | cds_context_type *cds_ctx; |
| 12543 | |
| 12544 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12545 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12546 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12547 | return; |
| 12548 | } |
| 12549 | |
| 12550 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 12551 | if (!cds_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12552 | hdd_err("Invalid CDS Context"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12553 | return; |
| 12554 | } |
| 12555 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12556 | if (policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc) |
| 12557 | != (QDF_STA_MASK | QDF_SAP_MASK)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12558 | hdd_info("Concurrency mode is not SAP"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12559 | return; |
| 12560 | } |
| 12561 | |
| 12562 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 12563 | if (ap_adapter != NULL && test_bit(SOFTAP_BSS_STARTED, |
| 12564 | &ap_adapter->event_flags) && |
| 12565 | wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
| 12566 | ap_adapter->sessionCtx.ap.operatingChannel)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12567 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12568 | hdd_warn("STA-AP Mode DFS not supported. Restart SAP with Non DFS ACS"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12569 | ap_adapter->sessionCtx.ap.sapConfig.channel = |
| 12570 | AUTO_CHANNEL_SELECT; |
| 12571 | ap_adapter->sessionCtx.ap.sapConfig. |
| 12572 | acs_cfg.acs_mode = true; |
| 12573 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12574 | hdd_restart_sap(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12575 | } |
| 12576 | } |
| 12577 | |
| 12578 | /** |
| 12579 | * hdd_set_connection_in_progress() - to set the connection in |
| 12580 | * progress flag |
| 12581 | * @value: value to set |
| 12582 | * |
| 12583 | * This function will set the passed value to connection in progress flag. |
| 12584 | * If value is previously being set to true then no need to set it again. |
| 12585 | * |
| 12586 | * Return: true if value is being set correctly and false otherwise. |
| 12587 | */ |
| 12588 | bool hdd_set_connection_in_progress(bool value) |
| 12589 | { |
| 12590 | bool status = true; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12591 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12592 | |
| 12593 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12594 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12595 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12596 | return false; |
| 12597 | } |
| 12598 | |
| 12599 | qdf_spin_lock(&hdd_ctx->connection_status_lock); |
| 12600 | /* |
| 12601 | * if the value is set to true previously and if someone is |
| 12602 | * trying to make it true again then it could be some race |
| 12603 | * condition being triggered. Avoid this situation by returning |
| 12604 | * false |
| 12605 | */ |
| 12606 | if (hdd_ctx->connection_in_progress && value) |
| 12607 | status = false; |
| 12608 | else |
| 12609 | hdd_ctx->connection_in_progress = value; |
| 12610 | qdf_spin_unlock(&hdd_ctx->connection_status_lock); |
| 12611 | return status; |
| 12612 | } |
| 12613 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12614 | 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] | 12615 | { |
| 12616 | if (!adapter) { |
| 12617 | hdd_err("Invalid adapter"); |
| 12618 | return -EINVAL; |
| 12619 | } |
| 12620 | hdd_info("Send MCC P2P QUOTA to WMA: %d", set_value); |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 12621 | sme_cli_set_command(adapter->sessionId, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 12622 | WMA_VDEV_MCC_SET_TIME_QUOTA, |
| 12623 | set_value, VDEV_CMD); |
| 12624 | return 0; |
| 12625 | |
| 12626 | } |
| 12627 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12628 | 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] | 12629 | { |
| 12630 | if (!adapter) { |
| 12631 | hdd_err("Invalid adapter"); |
| 12632 | return -EINVAL; |
| 12633 | } |
| 12634 | |
| 12635 | hdd_info("Send MCC latency WMA: %d", set_value); |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 12636 | sme_cli_set_command(adapter->sessionId, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 12637 | WMA_VDEV_MCC_SET_TIME_LATENCY, |
| 12638 | set_value, VDEV_CMD); |
| 12639 | return 0; |
| 12640 | } |
| 12641 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12642 | 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] | 12643 | *psoc, uint8_t vdev_id) |
| 12644 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12645 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12646 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 12647 | |
| 12648 | /* |
| 12649 | * Currently PSOC is not being used. But this logic will |
| 12650 | * change once we have the converged implementation of |
| 12651 | * HDD context per PSOC in place. This would break if |
| 12652 | * multiple vdev objects reuse the vdev id. |
| 12653 | */ |
| 12654 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 12655 | if (!adapter) |
| 12656 | hdd_err("Get adapter by vdev id failed"); |
| 12657 | |
| 12658 | return adapter; |
| 12659 | } |
| 12660 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12661 | 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] | 12662 | int8_t *rssi, int8_t *snr) |
| 12663 | { |
| 12664 | QDF_STATUS status; |
Jeff Johnson | 2a72200 | 2017-09-30 20:02:35 -0700 | [diff] [blame] | 12665 | struct hdd_wext_state *wext_state = |
| 12666 | WLAN_HDD_GET_WEXT_STATE_PTR(adapter); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 12667 | tCsrRoamProfile *profile = &wext_state->roamProfile; |
| 12668 | |
| 12669 | status = sme_get_rssi_snr_by_bssid(WLAN_HDD_GET_HAL_CTX(adapter), |
| 12670 | profile, bssid, rssi, snr); |
| 12671 | if (QDF_STATUS_SUCCESS != status) { |
| 12672 | hdd_warn("sme_get_rssi_snr_by_bssid failed"); |
| 12673 | return -EINVAL; |
| 12674 | } |
| 12675 | |
| 12676 | return 0; |
| 12677 | } |
| 12678 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 12679 | /** |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 12680 | * hdd_set_limit_off_chan_for_tos() - set limit off-channel command parameters |
| 12681 | * @adapter - HDD adapter |
| 12682 | * @tos - type of service |
| 12683 | * @status - status of the traffic |
| 12684 | * |
| 12685 | * Return: 0 on success and non zero value on failure |
| 12686 | */ |
| 12687 | |
| 12688 | int hdd_set_limit_off_chan_for_tos(struct hdd_adapter *adapter, enum tos tos, |
| 12689 | bool is_tos_active) |
| 12690 | { |
| 12691 | int ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 12692 | struct hdd_context *hdd_ctx; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 12693 | uint32_t max_off_chan_time = 0; |
| 12694 | QDF_STATUS status; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 12695 | int ret; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 12696 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 12697 | |
| 12698 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 12699 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12700 | |
| 12701 | if (ret < 0) { |
| 12702 | hdd_err("failed to set limit off chan params"); |
| 12703 | return ret; |
| 12704 | } |
| 12705 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 12706 | ac_bit = limit_off_chan_tbl[tos][HDD_AC_BIT_INDX]; |
| 12707 | |
| 12708 | if (is_tos_active) |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 12709 | adapter->active_ac |= ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 12710 | else |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 12711 | adapter->active_ac &= ~ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 12712 | |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 12713 | if (adapter->active_ac) { |
| 12714 | if (adapter->active_ac & HDD_AC_VO_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 12715 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 12716 | limit_off_chan_tbl[TOS_VO][HDD_DWELL_TIME_INDX]; |
| 12717 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 12718 | PM_LATENCY); |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 12719 | } else if (adapter->active_ac & HDD_AC_VI_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 12720 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 12721 | limit_off_chan_tbl[TOS_VI][HDD_DWELL_TIME_INDX]; |
| 12722 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 12723 | PM_LATENCY); |
| 12724 | } else { |
| 12725 | /*ignore this command if only BE/BK is active */ |
| 12726 | is_tos_active = false; |
| 12727 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 12728 | hdd_ctx->config->conc_system_pref); |
| 12729 | } |
| 12730 | } else { |
| 12731 | /* No active tos */ |
| 12732 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 12733 | hdd_ctx->config->conc_system_pref); |
| 12734 | } |
| 12735 | |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 12736 | status = sme_send_limit_off_channel_params(hal, adapter->sessionId, |
| 12737 | is_tos_active, max_off_chan_time, |
| 12738 | hdd_ctx->config->nRestTimeConc, true); |
| 12739 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 12740 | hdd_err("failed to set limit off chan params"); |
| 12741 | ret = -EINVAL; |
| 12742 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 12743 | |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 12744 | return ret; |
| 12745 | } |
| 12746 | |
| 12747 | /** |
| 12748 | * hdd_reset_limit_off_chan() - reset limit off-channel command parameters |
| 12749 | * @adapter - HDD adapter |
| 12750 | * |
| 12751 | * Return: 0 on success and non zero value on failure |
| 12752 | */ |
| 12753 | int hdd_reset_limit_off_chan(struct hdd_adapter *adapter) |
| 12754 | { |
| 12755 | struct hdd_context *hdd_ctx; |
| 12756 | int ret; |
| 12757 | QDF_STATUS status; |
| 12758 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 12759 | |
| 12760 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 12761 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12762 | if (ret < 0) |
| 12763 | return ret; |
| 12764 | |
| 12765 | /* set the system preferece to default */ |
| 12766 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 12767 | hdd_ctx->config->conc_system_pref); |
| 12768 | |
| 12769 | /* clear the bitmap */ |
| 12770 | adapter->active_ac = 0; |
| 12771 | |
| 12772 | hdd_debug("reset ac_bitmap for session %hu active_ac %0x", |
| 12773 | adapter->sessionId, adapter->active_ac); |
| 12774 | |
| 12775 | status = sme_send_limit_off_channel_params(hal, adapter->sessionId, |
| 12776 | false, 0, 0, false); |
| 12777 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 12778 | hdd_err("failed to reset limit off chan params"); |
| 12779 | ret = -EINVAL; |
| 12780 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 12781 | |
| 12782 | return ret; |
| 12783 | } |
| 12784 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 12785 | /** |
| 12786 | * hdd_start_driver_ops_timer() - Starts driver ops inactivity timer |
| 12787 | * @drv_op: Enum indicating driver op |
| 12788 | * |
| 12789 | * Return: none |
| 12790 | */ |
| 12791 | void hdd_start_driver_ops_timer(int drv_op) |
| 12792 | { |
| 12793 | memset(drv_ops_string, 0, MAX_OPS_NAME_STRING_SIZE); |
| 12794 | switch (drv_op) { |
| 12795 | case eHDD_DRV_OP_PROBE: |
| 12796 | memcpy(drv_ops_string, "probe", sizeof("probe")); |
| 12797 | break; |
| 12798 | case eHDD_DRV_OP_REMOVE: |
| 12799 | memcpy(drv_ops_string, "remove", sizeof("remove")); |
| 12800 | break; |
| 12801 | case eHDD_DRV_OP_SHUTDOWN: |
| 12802 | memcpy(drv_ops_string, "shutdown", sizeof("shutdown")); |
| 12803 | break; |
| 12804 | case eHDD_DRV_OP_REINIT: |
| 12805 | memcpy(drv_ops_string, "reinit", sizeof("reinit")); |
| 12806 | break; |
Arunk Khandavalli | e9ef42a | 2017-10-04 14:49:51 +0530 | [diff] [blame] | 12807 | case eHDD_DRV_OP_IFF_UP: |
| 12808 | memcpy(drv_ops_string, "iff_up", sizeof("iff_up")); |
| 12809 | break; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 12810 | } |
| 12811 | |
| 12812 | qdf_timer_start(&hdd_drv_ops_inactivity_timer, |
| 12813 | HDD_OPS_INACTIVITY_TIMEOUT); |
| 12814 | } |
| 12815 | |
| 12816 | /** |
| 12817 | * hdd_stop_driver_ops_timer() - Stops driver ops inactivity timer |
| 12818 | * |
| 12819 | * Return: none |
| 12820 | */ |
| 12821 | void hdd_stop_driver_ops_timer(void) |
| 12822 | { |
| 12823 | qdf_timer_sync_cancel(&hdd_drv_ops_inactivity_timer); |
| 12824 | } |
| 12825 | |
| 12826 | /** |
| 12827 | * hdd_drv_ops_inactivity_handler() - Timeout handler for driver ops |
| 12828 | * inactivity timer |
| 12829 | * |
| 12830 | * Return: None |
| 12831 | */ |
| 12832 | void hdd_drv_ops_inactivity_handler(void) |
| 12833 | { |
| 12834 | hdd_err("%s: %d Sec timer expired while in .%s", |
| 12835 | __func__, HDD_OPS_INACTIVITY_TIMEOUT/1000, drv_ops_string); |
| 12836 | |
| 12837 | /* Driver shutdown is stuck, no recovery possible at this point */ |
| 12838 | if (0 == qdf_mem_cmp(&drv_ops_string[0], "shutdown", |
| 12839 | sizeof("shutdown"))) |
| 12840 | QDF_BUG(0); |
| 12841 | |
| 12842 | if (cds_is_self_recovery_enabled()) |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 12843 | cds_trigger_recovery(QDF_REASON_UNSPECIFIED); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 12844 | else |
| 12845 | QDF_BUG(0); |
| 12846 | } |
| 12847 | |
Sravan Kumar Kairam | d80c766 | 2017-10-03 16:11:05 +0530 | [diff] [blame] | 12848 | void hdd_pld_ipa_uc_shutdown_pipes(void) |
| 12849 | { |
| 12850 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12851 | |
| 12852 | if (!hdd_ctx) |
| 12853 | return; |
| 12854 | |
| 12855 | hdd_ipa_uc_force_pipe_shutdown(hdd_ctx); |
| 12856 | } |
| 12857 | |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 12858 | /** |
| 12859 | * hdd_set_rx_mode_rps() - Enable/disable RPS in SAP mode |
| 12860 | * @struct hdd_context *hdd_ctx |
| 12861 | * @struct hdd_adapter *padapter |
| 12862 | * @bool enble |
| 12863 | * |
| 12864 | * Return: none |
| 12865 | */ |
| 12866 | void hdd_set_rx_mode_rps(bool enable) |
| 12867 | { |
| 12868 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
| 12869 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12870 | struct hdd_adapter *adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 12871 | |
| 12872 | if (adapter && hdd_ctx && |
| 12873 | !hdd_ctx->rps && cds_cfg->uc_offload_enabled) { |
| 12874 | if (enable && !cds_cfg->rps_enabled) |
| 12875 | hdd_send_rps_ind(adapter); |
| 12876 | else if (!enable && cds_cfg->rps_enabled) |
| 12877 | hdd_send_rps_disable_ind(adapter); |
| 12878 | } |
| 12879 | } |
| 12880 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12881 | /* Register the module init/exit functions */ |
| 12882 | module_init(hdd_module_init); |
| 12883 | module_exit(hdd_module_exit); |
| 12884 | |
| 12885 | MODULE_LICENSE("Dual BSD/GPL"); |
| 12886 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 12887 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 12888 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12889 | module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode, |
| 12890 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12891 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 12892 | module_param_call(con_mode_ftm, con_mode_handler_ftm, param_get_int, |
| 12893 | &con_mode_ftm, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 12894 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 12895 | module_param_call(con_mode_monitor, con_mode_handler_monitor, param_get_int, |
| 12896 | &con_mode_monitor, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 12897 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12898 | module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath, |
| 12899 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 12900 | |
| 12901 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 12902 | |
| 12903 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 12904 | |
| 12905 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |