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" |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 87 | #include "cdp_txrx_flow_ctrl_v2.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 88 | #endif /* FEATURE_WLAN_CH_AVOID */ |
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" |
| 96 | |
| 97 | #include <wlan_hdd_ipa.h> |
| 98 | #include "hif.h" |
| 99 | #include "wma.h" |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 100 | #include "wlan_policy_mgr_api.h" |
Manikandan Mohan | dcc21ba | 2016-03-15 14:31:56 -0700 | [diff] [blame] | 101 | #include "wlan_hdd_tsf.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 102 | #include "wlan_hdd_green_ap.h" |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 103 | #include "bmi.h" |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 104 | #include <wlan_hdd_regulatory.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 105 | #include "wlan_hdd_lpass.h" |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 106 | #include "nan_api.h" |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 107 | #include <wlan_hdd_napi.h> |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 108 | #include "wlan_hdd_disa.h" |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 109 | #include <dispatcher_init_deinit.h> |
Rajeev Kumar | 699debf | 2017-01-06 14:17:00 -0800 | [diff] [blame] | 110 | #include "wlan_hdd_object_manager.h" |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 111 | #include "cds_utils.h" |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 112 | #include <cdp_txrx_handle.h> |
Sandeep Puligilla | fdd201e | 2017-02-02 18:43:46 -0800 | [diff] [blame] | 113 | #include <qca_vendor.h> |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 114 | #include "wlan_pmo_ucfg_api.h" |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 115 | #include "sir_api.h" |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 116 | #include "os_if_wifi_pos.h" |
| 117 | #include "wifi_pos_api.h" |
| 118 | #include "wlan_hdd_oemdata.h" |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 119 | #include "wlan_hdd_he.h" |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 120 | #include "os_if_nan.h" |
| 121 | #include "nan_public_structs.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 122 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 123 | #ifdef CNSS_GENL |
| 124 | #include <net/cnss_nl.h> |
| 125 | #endif |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 126 | #include "wlan_reg_ucfg_api.h" |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 127 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 128 | #ifdef MODULE |
| 129 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 130 | #else |
| 131 | #define WLAN_MODULE_NAME "wlan" |
| 132 | #endif |
| 133 | |
| 134 | #ifdef TIMER_MANAGER |
| 135 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 136 | #else |
| 137 | #define TIMER_MANAGER_STR "" |
| 138 | #endif |
| 139 | |
| 140 | #ifdef MEMORY_DEBUG |
| 141 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 142 | #else |
| 143 | #define MEMORY_DEBUG_STR "" |
| 144 | #endif |
| 145 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 146 | int wlan_start_ret_val; |
| 147 | static DECLARE_COMPLETION(wlan_start_comp); |
| 148 | static unsigned int dev_num = 1; |
| 149 | static struct cdev wlan_hdd_state_cdev; |
| 150 | static struct class *class; |
| 151 | static dev_t device; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 152 | #ifndef MODULE |
| 153 | static struct gwlan_loader *wlan_loader; |
| 154 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 155 | struct kobj_attribute *attr, |
| 156 | const char *buf, size_t count); |
| 157 | struct gwlan_loader { |
| 158 | bool loaded_state; |
| 159 | struct kobject *boot_wlan_obj; |
| 160 | struct attribute_group *attr_group; |
| 161 | }; |
| 162 | |
| 163 | static struct kobj_attribute wlan_boot_attribute = |
| 164 | __ATTR(boot_wlan, 0220, NULL, wlan_boot_cb); |
| 165 | |
| 166 | static struct attribute *attrs[] = { |
| 167 | &wlan_boot_attribute.attr, |
| 168 | NULL, |
| 169 | }; |
| 170 | |
| 171 | #define MODULE_INITIALIZED 1 |
| 172 | #endif |
| 173 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 174 | /* the Android framework expects this param even though we don't use it */ |
| 175 | #define BUF_LEN 20 |
| 176 | static char fwpath_buffer[BUF_LEN]; |
| 177 | static struct kparam_string fwpath = { |
| 178 | .string = fwpath_buffer, |
| 179 | .maxlen = BUF_LEN, |
| 180 | }; |
| 181 | |
| 182 | static char *country_code; |
| 183 | static int enable_11d = -1; |
| 184 | static int enable_dfs_chan_scan = -1; |
| 185 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 186 | /* |
| 187 | * spinlock for synchronizing asynchronous request/response |
| 188 | * (full description of use in wlan_hdd_main.h) |
| 189 | */ |
| 190 | DEFINE_SPINLOCK(hdd_context_lock); |
| 191 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 192 | #define WLAN_NLINK_CESIUM 30 |
| 193 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 194 | static qdf_wake_lock_t wlan_wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 195 | |
| 196 | #define WOW_MAX_FILTER_LISTS 1 |
| 197 | #define WOW_MAX_FILTERS_PER_LIST 4 |
| 198 | #define WOW_MIN_PATTERN_SIZE 6 |
| 199 | #define WOW_MAX_PATTERN_SIZE 64 |
| 200 | |
| 201 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 202 | static const struct wiphy_wowlan_support wowlan_support_reg_init = { |
| 203 | .flags = WIPHY_WOWLAN_ANY | |
| 204 | WIPHY_WOWLAN_MAGIC_PKT | |
| 205 | WIPHY_WOWLAN_DISCONNECT | |
| 206 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 207 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 208 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 209 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 210 | WIPHY_WOWLAN_RFKILL_RELEASE, |
| 211 | .n_patterns = WOW_MAX_FILTER_LISTS * WOW_MAX_FILTERS_PER_LIST, |
| 212 | .pattern_min_len = WOW_MIN_PATTERN_SIZE, |
| 213 | .pattern_max_len = WOW_MAX_PATTERN_SIZE, |
| 214 | }; |
| 215 | #endif |
| 216 | |
| 217 | /* internal function declaration */ |
| 218 | |
| 219 | struct sock *cesium_nl_srv_sock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 220 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 221 | static void wlan_hdd_auto_shutdown_cb(void); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 222 | #endif |
| 223 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 224 | void hdd_start_complete(int ret) |
| 225 | { |
| 226 | wlan_start_ret_val = ret; |
| 227 | |
| 228 | complete(&wlan_start_comp); |
| 229 | } |
| 230 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 231 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 232 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
| 233 | * @hdd_ctx: pointer to hdd_context_t |
| 234 | * |
| 235 | * Return: none |
| 236 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 237 | static void hdd_set_rps_cpu_mask(hdd_context_t *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 238 | { |
| 239 | hdd_adapter_t *adapter; |
| 240 | hdd_adapter_list_node_t *adapter_node, *next; |
| 241 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 242 | |
| 243 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 244 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 245 | adapter = adapter_node->pAdapter; |
| 246 | if (NULL != adapter) |
| 247 | hdd_send_rps_ind(adapter); |
| 248 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 249 | adapter_node = next; |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 254 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 255 | * @vdev_id: vdev_id |
| 256 | * @action: action type |
| 257 | * @reason: reason type |
| 258 | * |
| 259 | * Return: none |
| 260 | */ |
| 261 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 262 | enum netif_action_type action, enum netif_reason_type reason) |
| 263 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 264 | hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 265 | hdd_adapter_t *adapter; |
| 266 | |
| 267 | if (!hdd_ctx) { |
| 268 | hdd_err("hdd ctx is NULL"); |
| 269 | return; |
| 270 | } |
| 271 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 272 | |
| 273 | wlan_hdd_netif_queue_control(adapter, action, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | /* |
| 277 | * Store WLAN driver version info in a global variable such that crash debugger |
| 278 | * can extract it from driver debug symbol and crashdump for post processing |
| 279 | */ |
| 280 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR; |
| 281 | |
| 282 | /** |
| 283 | * hdd_device_mode_to_string() - return string conversion of device mode |
| 284 | * @device_mode: device mode |
| 285 | * |
| 286 | * This utility function helps log string conversion of device mode. |
| 287 | * |
| 288 | * Return: string conversion of device mode, if match found; |
| 289 | * "Unknown" otherwise. |
| 290 | */ |
| 291 | const char *hdd_device_mode_to_string(uint8_t device_mode) |
| 292 | { |
| 293 | switch (device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 294 | CASE_RETURN_STRING(QDF_STA_MODE); |
| 295 | CASE_RETURN_STRING(QDF_SAP_MODE); |
| 296 | CASE_RETURN_STRING(QDF_P2P_CLIENT_MODE); |
| 297 | CASE_RETURN_STRING(QDF_P2P_GO_MODE); |
| 298 | CASE_RETURN_STRING(QDF_FTM_MODE); |
| 299 | CASE_RETURN_STRING(QDF_IBSS_MODE); |
| 300 | CASE_RETURN_STRING(QDF_P2P_DEVICE_MODE); |
| 301 | CASE_RETURN_STRING(QDF_OCB_MODE); |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 302 | CASE_RETURN_STRING(QDF_NDI_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 303 | default: |
| 304 | return "Unknown"; |
| 305 | } |
| 306 | } |
| 307 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 308 | /** |
| 309 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 310 | * @adapter: HDD adapter |
| 311 | * @chan_number: Channel number |
| 312 | * @chan_bw: Bandwidth |
| 313 | * |
| 314 | * Checks if the given bandwidth is valid for the given channel number. |
| 315 | * |
| 316 | * Return: 0 for success, non-zero for failure |
| 317 | */ |
| 318 | int hdd_validate_channel_and_bandwidth(hdd_adapter_t *adapter, |
| 319 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 320 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 321 | { |
| 322 | uint8_t chan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 323 | uint32_t len = WNI_CFG_VALID_CHANNEL_LIST_LEN, i; |
| 324 | bool found = false; |
| 325 | tHalHandle hal; |
| 326 | |
| 327 | hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 328 | if (!hal) { |
| 329 | hdd_err("Invalid HAL context"); |
| 330 | return -EINVAL; |
| 331 | } |
| 332 | |
| 333 | if (0 != sme_cfg_get_str(hal, WNI_CFG_VALID_CHANNEL_LIST, chan, &len)) { |
| 334 | hdd_err("No valid channel list"); |
| 335 | return -EOPNOTSUPP; |
| 336 | } |
| 337 | |
| 338 | for (i = 0; i < len; i++) { |
| 339 | if (chan[i] == chan_number) { |
| 340 | found = true; |
| 341 | break; |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | if (found == false) { |
| 346 | hdd_err("Channel not in driver's valid channel list"); |
| 347 | return -EOPNOTSUPP; |
| 348 | } |
| 349 | |
| 350 | if ((!CDS_IS_CHANNEL_24GHZ(chan_number)) && |
| 351 | (!CDS_IS_CHANNEL_5GHZ(chan_number))) { |
| 352 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 353 | return -EINVAL; |
| 354 | } |
| 355 | |
| 356 | if (CDS_IS_CHANNEL_24GHZ(chan_number)) { |
| 357 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 358 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 359 | return -EINVAL; |
| 360 | } |
| 361 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 362 | (chan_bw != CH_WIDTH_MAX)) { |
| 363 | hdd_err("Only BW20 possible on channel 14"); |
| 364 | return -EINVAL; |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | if (CDS_IS_CHANNEL_5GHZ(chan_number)) { |
| 369 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 370 | (chan_bw != CH_WIDTH_MAX)) { |
| 371 | hdd_err("Only BW20 possible on channel 165"); |
| 372 | return -EINVAL; |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | return 0; |
| 377 | } |
| 378 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 379 | static int __hdd_netdev_notifier_call(struct notifier_block *nb, |
| 380 | unsigned long state, void *data) |
| 381 | { |
| 382 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 383 | struct netdev_notifier_info *dev_notif_info = data; |
| 384 | struct net_device *dev = dev_notif_info->dev; |
| 385 | #else |
| 386 | struct net_device *dev = data; |
| 387 | #endif |
| 388 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 389 | hdd_context_t *hdd_ctx; |
| 390 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 391 | ENTER_DEV(dev); |
| 392 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 393 | /* Make sure that this callback corresponds to our device. */ |
| 394 | if ((strncmp(dev->name, "wlan", 4)) && (strncmp(dev->name, "p2p", 3))) |
| 395 | return NOTIFY_DONE; |
| 396 | |
Samuel Ahn | c9c48ca | 2016-09-19 15:46:36 +0530 | [diff] [blame] | 397 | if ((adapter->magic != WLAN_HDD_ADAPTER_MAGIC) || |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 398 | (adapter->dev != dev)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 399 | hdd_err("device adapter is not matching!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 400 | return NOTIFY_DONE; |
| 401 | } |
| 402 | |
| 403 | if (!dev->ieee80211_ptr) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 404 | hdd_err("ieee80211_ptr is NULL!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 405 | return NOTIFY_DONE; |
| 406 | } |
| 407 | |
| 408 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 409 | if (NULL == hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 410 | hdd_err("HDD Context Null Pointer"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 411 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 412 | return NOTIFY_DONE; |
| 413 | } |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 414 | if (cds_is_driver_recovering()) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 415 | return NOTIFY_DONE; |
| 416 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 417 | hdd_debug("%s New Net Device State = %lu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 418 | dev->name, state); |
| 419 | |
| 420 | switch (state) { |
| 421 | case NETDEV_REGISTER: |
| 422 | break; |
| 423 | |
| 424 | case NETDEV_UNREGISTER: |
| 425 | break; |
| 426 | |
| 427 | case NETDEV_UP: |
| 428 | sme_ch_avoid_update_req(hdd_ctx->hHal); |
| 429 | break; |
| 430 | |
| 431 | case NETDEV_DOWN: |
| 432 | break; |
| 433 | |
| 434 | case NETDEV_CHANGE: |
| 435 | if (true == adapter->isLinkUpSvcNeeded) |
| 436 | complete(&adapter->linkup_event_var); |
| 437 | break; |
| 438 | |
| 439 | case NETDEV_GOING_DOWN: |
| 440 | if (adapter->scan_info.mScanPending != false) { |
| 441 | unsigned long rc; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 442 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 443 | INIT_COMPLETION(adapter->scan_info. |
| 444 | abortscan_event_var); |
| 445 | hdd_abort_mac_scan(adapter->pHddCtx, |
| 446 | adapter->sessionId, |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 447 | INVALID_SCAN_ID, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 448 | eCSR_SCAN_ABORT_DEFAULT); |
| 449 | rc = wait_for_completion_timeout( |
| 450 | &adapter->scan_info.abortscan_event_var, |
| 451 | msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN)); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 452 | if (!rc) |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 453 | hdd_err("Timeout occurred while waiting for abortscan"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 454 | } else { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 455 | hdd_debug("Scan is not Pending from user"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 456 | } |
| 457 | break; |
| 458 | |
| 459 | default: |
| 460 | break; |
| 461 | } |
| 462 | |
| 463 | return NOTIFY_DONE; |
| 464 | } |
| 465 | |
| 466 | /** |
| 467 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 468 | * @nb: pointer to notifier block |
| 469 | * @state: state |
| 470 | * @ndev: ndev pointer |
| 471 | * |
| 472 | * Return: 0 on success, error number otherwise. |
| 473 | */ |
| 474 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 475 | unsigned long state, |
| 476 | void *ndev) |
| 477 | { |
| 478 | int ret; |
| 479 | |
| 480 | cds_ssr_protect(__func__); |
| 481 | ret = __hdd_netdev_notifier_call(nb, state, ndev); |
| 482 | cds_ssr_unprotect(__func__); |
| 483 | |
| 484 | return ret; |
| 485 | } |
| 486 | |
| 487 | struct notifier_block hdd_netdev_notifier = { |
| 488 | .notifier_call = hdd_netdev_notifier_call, |
| 489 | }; |
| 490 | |
| 491 | /* variable to hold the insmod parameters */ |
| 492 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 493 | |
| 494 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 495 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 496 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 497 | /** |
| 498 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 499 | * @ch_width: NL channel width |
| 500 | * |
| 501 | * Converts the NL channel width to the driver's internal representation |
| 502 | * |
| 503 | * Return: Converted channel width. In case of non matching NL channel width, |
| 504 | * CH_WIDTH_MAX will be returned. |
| 505 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 506 | 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] | 507 | { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 508 | uint8_t fw_ch_bw; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 509 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 510 | fw_ch_bw = wma_get_vht_ch_width(); |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 511 | switch (ch_width) { |
| 512 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 513 | case NL80211_CHAN_WIDTH_20: |
| 514 | return CH_WIDTH_20MHZ; |
| 515 | case NL80211_CHAN_WIDTH_40: |
| 516 | return CH_WIDTH_40MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 517 | case NL80211_CHAN_WIDTH_80: |
| 518 | return CH_WIDTH_80MHZ; |
| 519 | case NL80211_CHAN_WIDTH_80P80: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 520 | if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ) |
| 521 | return CH_WIDTH_80P80MHZ; |
| 522 | else if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 523 | return CH_WIDTH_160MHZ; |
| 524 | else |
| 525 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 526 | case NL80211_CHAN_WIDTH_160: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 527 | if (fw_ch_bw >= WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 528 | return CH_WIDTH_160MHZ; |
| 529 | else |
| 530 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 531 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 532 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 533 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 534 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 535 | default: |
| 536 | hdd_err("Invalid channel width %d, setting to default", |
| 537 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 538 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 539 | } |
| 540 | } |
| 541 | |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 542 | /* wlan_hdd_find_opclass() - Find operating class for a channel |
| 543 | * @hal: handler to HAL |
| 544 | * @channel: channel id |
| 545 | * @bw_offset: bandwidth offset |
| 546 | * |
| 547 | * Function invokes sme api to find the operating class |
| 548 | * |
| 549 | * Return: operating class |
| 550 | */ |
| 551 | uint8_t wlan_hdd_find_opclass(tHalHandle hal, uint8_t channel, |
| 552 | uint8_t bw_offset) |
| 553 | { |
| 554 | uint8_t opclass = 0; |
| 555 | |
| 556 | sme_get_opclass(hal, channel, bw_offset, &opclass); |
| 557 | return opclass; |
| 558 | } |
| 559 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 560 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 561 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 562 | * @module_id: Module whose trace level is being configured |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 563 | * @bitmask: Bitmask of log levels to be enabled |
| 564 | * |
| 565 | * Called immediately after the cfg.ini is read in order to configure |
| 566 | * the desired trace levels. |
| 567 | * |
| 568 | * Return: None |
| 569 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 570 | 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] | 571 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 572 | QDF_TRACE_LEVEL level; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 573 | int qdf_print_idx = -1; |
| 574 | int status = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 575 | /* |
| 576 | * if the bitmask is the default value, then a bitmask was not |
| 577 | * specified in cfg.ini, so leave the logging level alone (it |
| 578 | * will remain at the "compiled in" default value) |
| 579 | */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 580 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 581 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 582 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 583 | qdf_print_idx = qdf_get_pidx(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 584 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 585 | /* a mask was specified. start by disabling all logging */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 586 | status = qdf_print_set_category_verbose(qdf_print_idx, module_id, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 587 | QDF_TRACE_LEVEL_NONE, 0); |
| 588 | |
| 589 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 590 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 591 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 592 | level = QDF_TRACE_LEVEL_FATAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 593 | while (0 != bitmask) { |
| 594 | if (bitmask & 1) { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 595 | status = qdf_print_set_category_verbose(qdf_print_idx, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 596 | module_id, level, 1); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 597 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 598 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 599 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 600 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 601 | level++; |
| 602 | bitmask >>= 1; |
| 603 | } |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 604 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 605 | } |
| 606 | |
| 607 | /** |
| 608 | * wlan_hdd_validate_context() - check the HDD context |
| 609 | * @hdd_ctx: HDD context pointer |
| 610 | * |
| 611 | * Return: 0 if the context is valid. Error code otherwise |
| 612 | */ |
| 613 | int wlan_hdd_validate_context(hdd_context_t *hdd_ctx) |
| 614 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 615 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 616 | hdd_err("%pS HDD context is Null", (void *)_RET_IP_); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 617 | return -ENODEV; |
| 618 | } |
| 619 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 620 | if (cds_is_driver_recovering()) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 621 | hdd_debug("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 622 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 623 | return -EAGAIN; |
| 624 | } |
| 625 | |
Rajeev Kumar | fec3dbe | 2016-01-19 15:23:52 -0800 | [diff] [blame] | 626 | if (cds_is_load_or_unload_in_progress()) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 627 | hdd_debug("%pS Unloading/Loading in Progress. Ignore!!!: 0x%x", |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 628 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 629 | return -EAGAIN; |
| 630 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 631 | |
| 632 | if (hdd_ctx->start_modules_in_progress || |
| 633 | hdd_ctx->stop_modules_in_progress) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 634 | hdd_debug("%pS Start/Stop Modules in progress. Ignore!!!", |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 635 | (void *)_RET_IP_); |
| 636 | return -EAGAIN; |
| 637 | } |
| 638 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 639 | return 0; |
| 640 | } |
| 641 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 642 | /** |
| 643 | * hdd_set_ibss_power_save_params() - update IBSS Power Save params to WMA. |
| 644 | * @hdd_adapter_t Hdd adapter. |
| 645 | * |
| 646 | * This function sets the IBSS power save config parameters to WMA |
| 647 | * which will send it to firmware if FW supports IBSS power save |
| 648 | * before vdev start. |
| 649 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 650 | * 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] | 651 | * on failure. |
| 652 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 653 | QDF_STATUS hdd_set_ibss_power_save_params(hdd_adapter_t *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 654 | { |
| 655 | int ret; |
| 656 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 657 | |
| 658 | if (hdd_ctx == NULL) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 659 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 660 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 661 | } |
| 662 | |
| 663 | ret = wma_cli_set_command(adapter->sessionId, |
| 664 | WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE, |
| 665 | hdd_ctx->config->ibssATIMWinSize, |
| 666 | VDEV_CMD); |
| 667 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 668 | hdd_err("WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 669 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 670 | } |
| 671 | |
| 672 | ret = wma_cli_set_command(adapter->sessionId, |
| 673 | WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED, |
| 674 | hdd_ctx->config->isIbssPowerSaveAllowed, |
| 675 | VDEV_CMD); |
| 676 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 677 | hdd_err("WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED failed %d", |
| 678 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 679 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 680 | } |
| 681 | |
| 682 | ret = wma_cli_set_command(adapter->sessionId, |
| 683 | WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED, |
| 684 | hdd_ctx->config-> |
| 685 | isIbssPowerCollapseAllowed, VDEV_CMD); |
| 686 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 687 | hdd_err("WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED failed %d", |
| 688 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 689 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 690 | } |
| 691 | |
| 692 | ret = wma_cli_set_command(adapter->sessionId, |
| 693 | WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX, |
| 694 | hdd_ctx->config->isIbssAwakeOnTxRx, |
| 695 | VDEV_CMD); |
| 696 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 697 | 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] | 698 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 699 | } |
| 700 | |
| 701 | ret = wma_cli_set_command(adapter->sessionId, |
| 702 | WMA_VDEV_IBSS_SET_INACTIVITY_TIME, |
| 703 | hdd_ctx->config->ibssInactivityCount, |
| 704 | VDEV_CMD); |
| 705 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 706 | hdd_err("WMA_VDEV_IBSS_SET_INACTIVITY_TIME failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 707 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 708 | } |
| 709 | |
| 710 | ret = wma_cli_set_command(adapter->sessionId, |
| 711 | WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME, |
| 712 | hdd_ctx->config->ibssTxSpEndInactivityTime, |
| 713 | VDEV_CMD); |
| 714 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 715 | hdd_err("WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME failed %d", |
| 716 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 717 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 718 | } |
| 719 | |
| 720 | ret = wma_cli_set_command(adapter->sessionId, |
| 721 | WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS, |
| 722 | hdd_ctx->config->ibssPsWarmupTime, |
| 723 | VDEV_CMD); |
| 724 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 725 | hdd_err("WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS failed %d", |
| 726 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 727 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 728 | } |
| 729 | |
| 730 | ret = wma_cli_set_command(adapter->sessionId, |
| 731 | WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW, |
| 732 | hdd_ctx->config->ibssPs1RxChainInAtimEnable, |
| 733 | VDEV_CMD); |
| 734 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 735 | hdd_err("WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW failed %d", |
| 736 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 737 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 738 | } |
| 739 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 740 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 741 | } |
| 742 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 743 | #define INTF_MACADDR_MASK 0x7 |
| 744 | |
| 745 | /** |
| 746 | * hdd_update_macaddr() - update mac address |
| 747 | * @config: hdd configuration |
| 748 | * @hw_macaddr: mac address |
| 749 | * |
| 750 | * Mac address for multiple virtual interface is found as following |
| 751 | * i) The mac address of the first interface is just the actual hw mac address. |
| 752 | * ii) MSM 3 or 4 bits of byte5 of the actual mac address are used to |
| 753 | * define the mac address for the remaining interfaces and locally |
| 754 | * admistered bit is set. INTF_MACADDR_MASK is based on the number of |
| 755 | * supported virtual interfaces, right now this is 0x07 (meaning 8 |
| 756 | * interface). |
| 757 | * Byte[3] of second interface will be hw_macaddr[3](bit5..7) + 1, |
| 758 | * for third interface it will be hw_macaddr[3](bit5..7) + 2, etc. |
| 759 | * |
| 760 | * Return: None |
| 761 | */ |
| 762 | void hdd_update_macaddr(struct hdd_config *config, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 763 | struct qdf_mac_addr hw_macaddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 764 | { |
| 765 | int8_t i; |
| 766 | uint8_t macaddr_b3, tmp_br3; |
| 767 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 768 | qdf_mem_copy(config->intfMacAddr[0].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 769 | QDF_MAC_ADDR_SIZE); |
| 770 | for (i = 1; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 771 | qdf_mem_copy(config->intfMacAddr[i].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 772 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 773 | macaddr_b3 = config->intfMacAddr[i].bytes[3]; |
| 774 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 775 | INTF_MACADDR_MASK; |
| 776 | macaddr_b3 += tmp_br3; |
| 777 | |
| 778 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 779 | * mac address range before collision |
| 780 | */ |
| 781 | macaddr_b3 ^= (1 << 7); |
| 782 | |
| 783 | /* Set locally administered bit */ |
| 784 | config->intfMacAddr[i].bytes[0] |= 0x02; |
| 785 | config->intfMacAddr[i].bytes[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 786 | hdd_debug("config->intfMacAddr[%d]: " |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 787 | MAC_ADDRESS_STR, i, |
| 788 | MAC_ADDR_ARRAY(config->intfMacAddr[i].bytes)); |
| 789 | } |
| 790 | } |
| 791 | |
| 792 | static void hdd_update_tgt_services(hdd_context_t *hdd_ctx, |
| 793 | struct wma_tgt_services *cfg) |
| 794 | { |
| 795 | struct hdd_config *config = hdd_ctx->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 796 | |
| 797 | /* Set up UAPSD */ |
| 798 | config->apUapsdEnabled &= cfg->uapsd; |
| 799 | |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 800 | /* 11AX mode support */ |
| 801 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 802 | config->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) && !cfg->en_11ax) |
| 803 | config->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 804 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 805 | /* 11AC mode support */ |
| 806 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 807 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 808 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 809 | |
| 810 | /* ARP offload: override user setting if invalid */ |
| 811 | config->fhostArpOffload &= cfg->arp_offload; |
| 812 | |
| 813 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 814 | /* PNO offload */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 815 | hdd_debug("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 816 | if (cfg->pno_offload) |
| 817 | config->PnoOffload = true; |
| 818 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 819 | #ifdef FEATURE_WLAN_TDLS |
| 820 | config->fEnableTDLSSupport &= cfg->en_tdls; |
Manjeet Singh | fdd2ac7 | 2016-09-02 18:11:43 +0530 | [diff] [blame] | 821 | config->fEnableTDLSOffChannel = config->fEnableTDLSOffChannel && |
| 822 | cfg->en_tdls_offchan; |
| 823 | config->fEnableTDLSBufferSta = config->fEnableTDLSBufferSta && |
| 824 | cfg->en_tdls_uapsd_buf_sta; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 825 | if (config->fTDLSUapsdMask && cfg->en_tdls_uapsd_sleep_sta) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 826 | config->fEnableTDLSSleepSta = true; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 827 | else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 828 | config->fEnableTDLSSleepSta = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 829 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 830 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 831 | config->isRoamOffloadEnabled &= cfg->en_roam_offload; |
| 832 | #endif |
Krishna Kumaar Natarajan | 052c6e6 | 2015-09-28 15:32:55 -0700 | [diff] [blame] | 833 | sme_update_tgt_services(hdd_ctx->hHal, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 834 | |
| 835 | } |
| 836 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 837 | /** |
| 838 | * hdd_update_vdev_nss() - sets the vdev nss |
| 839 | * @hdd_ctx: HDD context |
| 840 | * |
| 841 | * Sets the Nss per vdev type based on INI |
| 842 | * |
| 843 | * Return: None |
| 844 | */ |
| 845 | static void hdd_update_vdev_nss(hdd_context_t *hdd_ctx) |
| 846 | { |
| 847 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 848 | uint8_t max_supp_nss = 1; |
| 849 | |
Naveen Rawat | 10b1c15 | 2017-01-18 11:16:06 -0800 | [diff] [blame] | 850 | if (cfg_ini->enable2x2 && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 851 | max_supp_nss = 2; |
| 852 | |
| 853 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
| 854 | cfg_ini->vdev_type_nss_2g, eCSR_BAND_24); |
| 855 | |
| 856 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
| 857 | cfg_ini->vdev_type_nss_5g, eCSR_BAND_5G); |
| 858 | } |
| 859 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 860 | /** |
| 861 | * hdd_update_hw_dbs_capable() - sets the dbs capability of the device |
| 862 | * @hdd_ctx: HDD context |
| 863 | * |
| 864 | * Sets the DBS capability as per INI and firmware capability |
| 865 | * |
| 866 | * Return: None |
| 867 | */ |
| 868 | static void hdd_update_hw_dbs_capable(hdd_context_t *hdd_ctx) |
| 869 | { |
| 870 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 871 | uint8_t hw_dbs_capable = 0; |
| 872 | |
| 873 | if ((!cfg_ini->dual_mac_feature_disable) |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 874 | && policy_mgr_is_hw_dbs_capable(hdd_ctx->hdd_psoc)) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 875 | hw_dbs_capable = 1; |
| 876 | |
| 877 | sme_update_hw_dbs_capable(hdd_ctx->hHal, hw_dbs_capable); |
| 878 | } |
| 879 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 880 | static void hdd_update_tgt_ht_cap(hdd_context_t *hdd_ctx, |
| 881 | struct wma_tgt_ht_cap *cfg) |
| 882 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 883 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 884 | uint32_t value, val32; |
| 885 | uint16_t val16; |
| 886 | struct hdd_config *pconfig = hdd_ctx->config; |
| 887 | tSirMacHTCapabilityInfo *phtCapInfo; |
| 888 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
| 889 | uint8_t enable_tx_stbc; |
| 890 | |
| 891 | /* check and update RX STBC */ |
| 892 | if (pconfig->enableRxSTBC && !cfg->ht_rx_stbc) |
| 893 | pconfig->enableRxSTBC = cfg->ht_rx_stbc; |
| 894 | |
| 895 | /* get the MPDU density */ |
| 896 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, &value); |
| 897 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 898 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 899 | hdd_err("could not get MPDU DENSITY"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 900 | value = 0; |
| 901 | } |
| 902 | |
| 903 | /* |
| 904 | * MPDU density: |
| 905 | * override user's setting if value is larger |
| 906 | * than the one supported by target |
| 907 | */ |
| 908 | if (value > cfg->mpdu_density) { |
| 909 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, |
| 910 | cfg->mpdu_density); |
| 911 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 912 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 913 | hdd_err("could not set MPDU DENSITY to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 914 | } |
| 915 | |
| 916 | /* get the HT capability info */ |
| 917 | 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] | 918 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 919 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 920 | return; |
| 921 | } |
| 922 | val16 = (uint16_t) val32; |
| 923 | phtCapInfo = (tSirMacHTCapabilityInfo *) &val16; |
| 924 | |
| 925 | /* Set the LDPC capability */ |
| 926 | phtCapInfo->advCodingCap = cfg->ht_rx_ldpc; |
| 927 | |
| 928 | if (pconfig->ShortGI20MhzEnable && !cfg->ht_sgi_20) |
| 929 | pconfig->ShortGI20MhzEnable = cfg->ht_sgi_20; |
| 930 | |
| 931 | if (pconfig->ShortGI40MhzEnable && !cfg->ht_sgi_40) |
| 932 | pconfig->ShortGI40MhzEnable = cfg->ht_sgi_40; |
| 933 | |
| 934 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 935 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 936 | |
| 937 | enable_tx_stbc = pconfig->enableTxSTBC; |
| 938 | |
| 939 | if (pconfig->enable2x2 && (cfg->num_rf_chains == 2)) { |
| 940 | pconfig->enable2x2 = 1; |
| 941 | } else { |
| 942 | pconfig->enable2x2 = 0; |
| 943 | enable_tx_stbc = 0; |
| 944 | |
| 945 | /* 1x1 */ |
| 946 | /* Update Rx Highest Long GI data Rate */ |
| 947 | if (sme_cfg_set_int(hdd_ctx->hHal, |
| 948 | WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 949 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 950 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 951 | 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] | 952 | } |
| 953 | |
| 954 | /* Update Tx Highest Long GI data Rate */ |
| 955 | if (sme_cfg_set_int |
| 956 | (hdd_ctx->hHal, |
| 957 | WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 958 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 959 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 960 | hdd_err("VHT_TX_HIGHEST_SUPP_RATE_1_1 to CCM fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 961 | } |
| 962 | } |
| 963 | if (!(cfg->ht_tx_stbc && pconfig->enable2x2)) |
| 964 | enable_tx_stbc = 0; |
| 965 | phtCapInfo->txSTBC = enable_tx_stbc; |
| 966 | |
| 967 | val32 = val16; |
| 968 | 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] | 969 | if (status != QDF_STATUS_SUCCESS) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 970 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 971 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
| 972 | value = SIZE_OF_SUPPORTED_MCS_SET; |
| 973 | 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] | 974 | &value) == QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 975 | hdd_debug("Read MCS rate set"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 976 | |
| 977 | if (pconfig->enable2x2) { |
| 978 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 979 | mcs_set[value] = |
| 980 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 981 | |
| 982 | status = |
| 983 | sme_cfg_set_str(hdd_ctx->hHal, |
| 984 | WNI_CFG_SUPPORTED_MCS_SET, |
| 985 | mcs_set, |
| 986 | SIZE_OF_SUPPORTED_MCS_SET); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 987 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 988 | hdd_err("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 989 | } |
| 990 | } |
| 991 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 992 | } |
| 993 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 994 | static void hdd_update_tgt_vht_cap(hdd_context_t *hdd_ctx, |
| 995 | struct wma_tgt_vht_cap *cfg) |
| 996 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 997 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 998 | uint32_t value = 0; |
| 999 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1000 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 1001 | struct ieee80211_supported_band *band_5g = |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 1002 | wiphy->bands[NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1003 | uint32_t temp = 0; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1004 | uint32_t ch_width = eHT_CHANNEL_WIDTH_80MHZ; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1005 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1006 | if (!band_5g) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1007 | hdd_debug("5GHz band disabled, skipping capability population"); |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1008 | return; |
| 1009 | } |
| 1010 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1011 | /* Get the current MPDU length */ |
| 1012 | status = |
| 1013 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1014 | &value); |
| 1015 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1016 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1017 | hdd_err("could not get MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1018 | value = 0; |
| 1019 | } |
| 1020 | |
| 1021 | /* |
| 1022 | * VHT max MPDU length: |
| 1023 | * override if user configured value is too high |
| 1024 | * that the target cannot support |
| 1025 | */ |
| 1026 | if (value > cfg->vht_max_mpdu) { |
| 1027 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1028 | WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1029 | cfg->vht_max_mpdu); |
| 1030 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1031 | if (status == QDF_STATUS_E_FAILURE) |
| 1032 | hdd_err("could not set VHT MAX MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1033 | } |
| 1034 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1035 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, &temp); |
| 1036 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1037 | |
| 1038 | if (pconfig->enable2x2) |
| 1039 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1040 | |
| 1041 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, temp) == |
| 1042 | QDF_STATUS_E_FAILURE) { |
| 1043 | hdd_err("Could not pass VHT_BASIC_MCS_SET to CCM"); |
| 1044 | } |
| 1045 | |
| 1046 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, &temp); |
| 1047 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1048 | if (pconfig->enable2x2) |
| 1049 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1050 | |
| 1051 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, temp) == |
| 1052 | QDF_STATUS_E_FAILURE) { |
| 1053 | hdd_err("Could not pass WNI_CFG_VHT_RX_MCS_MAP to CCM"); |
| 1054 | } |
| 1055 | |
| 1056 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, &temp); |
| 1057 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtTxMCS; |
| 1058 | if (pconfig->enable2x2) |
| 1059 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtTxMCS2x2 << 2); |
| 1060 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1061 | hdd_debug("vhtRxMCS2x2 - %x temp - %u enable2x2 %d", |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1062 | pconfig->vhtRxMCS2x2, temp, pconfig->enable2x2); |
| 1063 | |
| 1064 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, temp) == |
| 1065 | QDF_STATUS_E_FAILURE) { |
| 1066 | hdd_err("Could not pass WNI_CFG_VHT_TX_MCS_MAP to CCM"); |
| 1067 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1068 | /* Get the current RX LDPC setting */ |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1069 | 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] | 1070 | &value); |
| 1071 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1072 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1073 | hdd_err("could not get VHT LDPC CODING CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1074 | value = 0; |
| 1075 | } |
| 1076 | |
| 1077 | /* Set the LDPC capability */ |
| 1078 | if (value && !cfg->vht_rx_ldpc) { |
| 1079 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1080 | WNI_CFG_VHT_LDPC_CODING_CAP, |
| 1081 | cfg->vht_rx_ldpc); |
| 1082 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1083 | if (status == QDF_STATUS_E_FAILURE) |
| 1084 | hdd_err("could not set VHT LDPC CODING CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1085 | } |
| 1086 | |
| 1087 | /* Get current GI 80 value */ |
| 1088 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1089 | &value); |
| 1090 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1091 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1092 | hdd_err("could not get SHORT GI 80MHZ"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1093 | value = 0; |
| 1094 | } |
| 1095 | |
| 1096 | /* set the Guard interval 80MHz */ |
| 1097 | if (value && !cfg->vht_short_gi_80) { |
| 1098 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1099 | WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1100 | cfg->vht_short_gi_80); |
| 1101 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1102 | if (status == QDF_STATUS_E_FAILURE) |
| 1103 | hdd_err("could not set SHORT GI 80MHZ to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1104 | } |
| 1105 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1106 | /* Get VHT TX STBC cap */ |
| 1107 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, &value); |
| 1108 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1109 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1110 | hdd_err("could not get VHT TX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1111 | value = 0; |
| 1112 | } |
| 1113 | |
| 1114 | /* VHT TX STBC cap */ |
| 1115 | if (value && !cfg->vht_tx_stbc) { |
| 1116 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, |
| 1117 | cfg->vht_tx_stbc); |
| 1118 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1119 | if (status == QDF_STATUS_E_FAILURE) |
| 1120 | hdd_err("could not set the VHT TX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1121 | } |
| 1122 | |
| 1123 | /* Get VHT RX STBC cap */ |
| 1124 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, &value); |
| 1125 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1126 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1127 | hdd_err("could not get VHT RX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1128 | value = 0; |
| 1129 | } |
| 1130 | |
| 1131 | /* VHT RX STBC cap */ |
| 1132 | if (value && !cfg->vht_rx_stbc) { |
| 1133 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, |
| 1134 | cfg->vht_rx_stbc); |
| 1135 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1136 | if (status == QDF_STATUS_E_FAILURE) |
| 1137 | hdd_err("could not set the VHT RX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1138 | } |
| 1139 | |
| 1140 | /* Get VHT SU Beamformer cap */ |
| 1141 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1142 | &value); |
| 1143 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1144 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1145 | hdd_err("could not get VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1146 | value = 0; |
| 1147 | } |
| 1148 | |
| 1149 | /* set VHT SU Beamformer cap */ |
| 1150 | if (value && !cfg->vht_su_bformer) { |
| 1151 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1152 | WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1153 | cfg->vht_su_bformer); |
| 1154 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1155 | if (status == QDF_STATUS_E_FAILURE) |
| 1156 | hdd_err("could not set VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1157 | } |
| 1158 | |
| 1159 | /* check and update SU BEAMFORMEE capabality */ |
| 1160 | if (pconfig->enableTxBF && !cfg->vht_su_bformee) |
| 1161 | pconfig->enableTxBF = cfg->vht_su_bformee; |
| 1162 | |
| 1163 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1164 | WNI_CFG_VHT_SU_BEAMFORMEE_CAP, |
| 1165 | pconfig->enableTxBF); |
| 1166 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1167 | if (status == QDF_STATUS_E_FAILURE) |
| 1168 | hdd_err("could not set VHT SU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1169 | |
| 1170 | /* Get VHT MU Beamformer cap */ |
| 1171 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1172 | &value); |
| 1173 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1174 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1175 | hdd_err("could not get VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1176 | value = 0; |
| 1177 | } |
| 1178 | |
| 1179 | /* set VHT MU Beamformer cap */ |
| 1180 | if (value && !cfg->vht_mu_bformer) { |
| 1181 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1182 | WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1183 | cfg->vht_mu_bformer); |
| 1184 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1185 | if (status == QDF_STATUS_E_FAILURE) |
| 1186 | hdd_err("could not set the VHT MU BEAMFORMER CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1187 | } |
| 1188 | |
| 1189 | /* Get VHT MU Beamformee cap */ |
| 1190 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1191 | &value); |
| 1192 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1193 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1194 | hdd_err("could not get VHT MU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1195 | value = 0; |
| 1196 | } |
| 1197 | |
| 1198 | /* set VHT MU Beamformee cap */ |
| 1199 | if (value && !cfg->vht_mu_bformee) { |
| 1200 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1201 | WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1202 | cfg->vht_mu_bformee); |
| 1203 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1204 | if (status == QDF_STATUS_E_FAILURE) |
| 1205 | hdd_err("could not set VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1206 | } |
| 1207 | |
| 1208 | /* Get VHT MAX AMPDU Len exp */ |
| 1209 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1210 | &value); |
| 1211 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1212 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1213 | hdd_err("could not get VHT AMPDU LEN"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1214 | value = 0; |
| 1215 | } |
| 1216 | |
| 1217 | /* |
| 1218 | * VHT max AMPDU len exp: |
| 1219 | * override if user configured value is too high |
| 1220 | * that the target cannot support. |
| 1221 | * Even though Rome publish ampdu_len=7, it can |
| 1222 | * only support 4 because of some h/w bug. |
| 1223 | */ |
| 1224 | |
| 1225 | if (value > cfg->vht_max_ampdu_len_exp) { |
| 1226 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1227 | WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1228 | cfg->vht_max_ampdu_len_exp); |
| 1229 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1230 | if (status == QDF_STATUS_E_FAILURE) |
| 1231 | hdd_err("could not set the VHT AMPDU LEN EXP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1232 | } |
| 1233 | |
| 1234 | /* Get VHT TXOP PS CAP */ |
| 1235 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, &value); |
| 1236 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1237 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1238 | hdd_err("could not get VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1239 | value = 0; |
| 1240 | } |
| 1241 | |
| 1242 | /* set VHT TXOP PS cap */ |
| 1243 | if (value && !cfg->vht_txop_ps) { |
| 1244 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, |
| 1245 | cfg->vht_txop_ps); |
| 1246 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1247 | if (status == QDF_STATUS_E_FAILURE) |
| 1248 | hdd_err("could not set the VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1249 | } |
| 1250 | |
| 1251 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1252 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1253 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1254 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1255 | else |
| 1256 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1257 | |
| 1258 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1259 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) { |
| 1260 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1261 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1262 | VHT_CAP_160_AND_80P80_SUPP); |
| 1263 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1264 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1265 | band_5g->vht_cap.cap |= |
| 1266 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1267 | ch_width = eHT_CHANNEL_WIDTH_80P80MHZ; |
| 1268 | } else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) { |
| 1269 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1270 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1271 | VHT_CAP_160_SUPP); |
| 1272 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1273 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1274 | band_5g->vht_cap.cap |= |
| 1275 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1276 | ch_width = eHT_CHANNEL_WIDTH_160MHZ; |
| 1277 | } |
| 1278 | pconfig->vhtChannelWidth = QDF_MIN(pconfig->vhtChannelWidth, |
| 1279 | ch_width); |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1280 | /* Get the current GI 160 value */ |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1281 | status = sme_cfg_get_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1282 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1283 | &value); |
| 1284 | if (status != QDF_STATUS_SUCCESS) { |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1285 | hdd_err("could not get GI 80 & 160"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1286 | value = 0; |
| 1287 | } |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1288 | /* set the Guard interval 160MHz */ |
| 1289 | if (value && !cfg->vht_short_gi_160) { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1290 | status = sme_cfg_set_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1291 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
| 1292 | cfg->vht_short_gi_160); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1293 | |
| 1294 | if (status == QDF_STATUS_E_FAILURE) |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1295 | hdd_err("failed to set SHORT GI 160MHZ"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1296 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1297 | |
| 1298 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) |
| 1299 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1300 | |
| 1301 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1302 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1303 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1304 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1305 | |
| 1306 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1307 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1308 | |
| 1309 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1310 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1311 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1312 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1313 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1314 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1315 | |
| 1316 | band_5g->vht_cap.cap |= |
| 1317 | (cfg->vht_max_ampdu_len_exp << |
| 1318 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1319 | |
| 1320 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1321 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1322 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1323 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1324 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1325 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1326 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1327 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1328 | |
| 1329 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1330 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1331 | |
| 1332 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1333 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1334 | /** |
| 1335 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1336 | * @hdd_ctx: Pointer to the HDD context |
| 1337 | * |
| 1338 | * Auto-generate mac address using device serial number. |
| 1339 | * Keep the first 3 bytes of OUI as before and replace |
| 1340 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1341 | * |
| 1342 | * Return: 0 for success |
| 1343 | * Non zero failure code for errors |
| 1344 | */ |
| 1345 | static int hdd_generate_macaddr_auto(hdd_context_t *hdd_ctx) |
| 1346 | { |
| 1347 | unsigned int serialno = 0; |
| 1348 | struct qdf_mac_addr mac_addr = { |
| 1349 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1350 | }; |
| 1351 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1352 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1353 | if (serialno == 0) |
| 1354 | return -EINVAL; |
| 1355 | |
| 1356 | serialno &= 0x00ffffff; |
| 1357 | |
| 1358 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1359 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1360 | mac_addr.bytes[5] = serialno & 0xff; |
| 1361 | |
| 1362 | hdd_update_macaddr(hdd_ctx->config, mac_addr); |
| 1363 | return 0; |
| 1364 | } |
| 1365 | |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1366 | /** |
| 1367 | * hdd_update_ra_rate_limit() - Update RA rate limit from target |
| 1368 | * configuration to cfg_ini in HDD |
| 1369 | * @hdd_ctx: Pointer to hdd_ctx |
| 1370 | * @cfg: target configuration |
| 1371 | * |
| 1372 | * Return: None |
| 1373 | */ |
| 1374 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 1375 | static void hdd_update_ra_rate_limit(hdd_context_t *hdd_ctx, |
| 1376 | struct wma_tgt_cfg *cfg) |
| 1377 | { |
| 1378 | hdd_ctx->config->IsRArateLimitEnabled = cfg->is_ra_rate_limit_enabled; |
| 1379 | } |
| 1380 | #else |
| 1381 | static void hdd_update_ra_rate_limit(hdd_context_t *hdd_ctx, |
| 1382 | struct wma_tgt_cfg *cfg) |
| 1383 | { |
| 1384 | } |
| 1385 | #endif |
| 1386 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1387 | void hdd_update_tgt_cfg(void *context, void *param) |
| 1388 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1389 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1390 | hdd_context_t *hdd_ctx = (hdd_context_t *) context; |
| 1391 | struct wma_tgt_cfg *cfg = param; |
| 1392 | uint8_t temp_band_cap; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1393 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1394 | |
Sandeep Puligilla | 1cf6ebe | 2017-04-04 14:40:27 -0700 | [diff] [blame] | 1395 | /* Reuse same pdev for module stop and start */ |
| 1396 | if ((hdd_get_conparam() == QDF_GLOBAL_FTM_MODE) || |
| 1397 | (!cds_is_driver_loading())) { |
| 1398 | hdd_err("Reuse pdev for module start/stop"); |
| 1399 | } else { |
| 1400 | ret = hdd_objmgr_create_and_store_pdev(hdd_ctx); |
| 1401 | if (ret) { |
| 1402 | hdd_err("pdev creation fails!"); |
| 1403 | QDF_BUG(0); |
| 1404 | } |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1405 | } |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1406 | if (cds_cfg) { |
| 1407 | if (hdd_ctx->config->enable_sub_20_channel_width != |
| 1408 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
| 1409 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1410 | cds_cfg->sub_20_channel_width = |
| 1411 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1412 | } else { |
| 1413 | cds_cfg->sub_20_channel_width = |
| 1414 | hdd_ctx->config->enable_sub_20_channel_width; |
| 1415 | } |
| 1416 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1417 | |
| 1418 | /* first store the INI band capability */ |
| 1419 | temp_band_cap = hdd_ctx->config->nBandCapability; |
| 1420 | |
| 1421 | hdd_ctx->config->nBandCapability = cfg->band_cap; |
| 1422 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 1423 | /* |
| 1424 | * now overwrite the target band capability with INI |
| 1425 | * setting if INI setting is a subset |
| 1426 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1427 | |
| 1428 | if ((hdd_ctx->config->nBandCapability == eCSR_BAND_ALL) && |
| 1429 | (temp_band_cap != eCSR_BAND_ALL)) |
| 1430 | hdd_ctx->config->nBandCapability = temp_band_cap; |
| 1431 | else if ((hdd_ctx->config->nBandCapability != eCSR_BAND_ALL) && |
| 1432 | (temp_band_cap != eCSR_BAND_ALL) && |
| 1433 | (hdd_ctx->config->nBandCapability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1434 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1435 | } |
| 1436 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 1437 | if (!cds_is_driver_recovering()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1438 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 1439 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 1440 | } |
| 1441 | |
| 1442 | /* This can be extended to other configurations like ht, vht cap... */ |
| 1443 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 1444 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1445 | hdd_update_macaddr(hdd_ctx->config, cfg->hw_macaddr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1446 | hdd_ctx->update_mac_addr_to_fw = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1447 | } else { |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1448 | static struct qdf_mac_addr default_mac_addr = { |
| 1449 | {0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF} |
| 1450 | }; |
| 1451 | if (qdf_is_macaddr_equal(&hdd_ctx->config->intfMacAddr[0], |
| 1452 | &default_mac_addr)) { |
| 1453 | if (hdd_generate_macaddr_auto(hdd_ctx) != 0) |
| 1454 | hdd_err("Fail to auto-generate MAC, using MAC from ini file " |
| 1455 | MAC_ADDRESS_STR, |
| 1456 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1457 | intfMacAddr[0].bytes)); |
| 1458 | } else { |
| 1459 | hdd_err("Invalid MAC passed from target, using MAC from ini file " |
| 1460 | MAC_ADDRESS_STR, |
| 1461 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1462 | intfMacAddr[0].bytes)); |
| 1463 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1464 | hdd_ctx->update_mac_addr_to_fw = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1465 | } |
| 1466 | |
| 1467 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 1468 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1469 | |
| 1470 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 1471 | |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 1472 | hdd_lpass_target_config(hdd_ctx, cfg); |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 1473 | hdd_green_ap_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1474 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1475 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 1476 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 1477 | |
| 1478 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 1479 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1480 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame] | 1481 | if (cfg->services.en_11ax) { |
| 1482 | hdd_info("11AX: 11ax is enabled - update HDD config"); |
| 1483 | hdd_update_tgt_he_cap(hdd_ctx, cfg); |
| 1484 | } |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1485 | |
| 1486 | hdd_update_vdev_nss(hdd_ctx); |
| 1487 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1488 | hdd_update_hw_dbs_capable(hdd_ctx); |
| 1489 | |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1490 | hdd_ctx->config->fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 1491 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1492 | hdd_debug("fine_time_meas_cap: 0x%x", |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1493 | hdd_ctx->config->fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1494 | |
| 1495 | hdd_ctx->current_antenna_mode = |
| 1496 | (hdd_ctx->config->enable2x2 == 0x01) ? |
| 1497 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1498 | hdd_debug("Init current antenna mode: %d", |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1499 | hdd_ctx->current_antenna_mode); |
| 1500 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1501 | hdd_debug("Target BPF %d Host BPF %d", |
Rajeev Kumar | dd3bc60 | 2016-08-16 14:21:05 -0700 | [diff] [blame] | 1502 | cfg->bpf_enabled, hdd_ctx->config->bpf_packet_filter_enable); |
| 1503 | hdd_ctx->bpf_enabled = (cfg->bpf_enabled && |
| 1504 | hdd_ctx->config->bpf_packet_filter_enable); |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1505 | hdd_update_ra_rate_limit(hdd_ctx, cfg); |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1506 | |
Arun Khandavalli | d454d42 | 2016-08-17 12:47:05 +0530 | [diff] [blame] | 1507 | /* |
| 1508 | * If BPF is enabled, maxWowFilters set to WMA_STA_WOW_DEFAULT_PTRN_MAX |
| 1509 | * because we need atleast WMA_STA_WOW_DEFAULT_PTRN_MAX free slots to |
| 1510 | * configure the STA mode wow pattern. |
| 1511 | */ |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1512 | if (hdd_ctx->bpf_enabled) |
Arun Khandavalli | d454d42 | 2016-08-17 12:47:05 +0530 | [diff] [blame] | 1513 | hdd_ctx->config->maxWoWFilters = WMA_STA_WOW_DEFAULT_PTRN_MAX; |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1514 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 1515 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 1516 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 1517 | /* Configure NAN datapath features */ |
| 1518 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Arif Hussain | 759a023 | 2017-03-20 13:17:18 -0700 | [diff] [blame] | 1519 | hdd_ctx->dfs_cac_offload = cfg->dfs_cac_offload; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1520 | } |
| 1521 | |
| 1522 | /** |
| 1523 | * hdd_dfs_indicate_radar() - handle radar detection on current SAP channel |
| 1524 | * @context: HDD context pointer |
| 1525 | * @param: HDD radar indication pointer |
| 1526 | * |
Sandeep Puligilla | a8d4eec | 2016-06-30 15:13:11 -0700 | [diff] [blame] | 1527 | * This function is invoked in atomic context when a radar |
| 1528 | * is found on the SAP current operating channel and Data Tx |
| 1529 | * from netif has to be stopped to honor the DFS regulations. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1530 | * Actions: Stop the netif Tx queues,Indicate Radar present |
| 1531 | * in HDD context for future usage. |
| 1532 | * |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1533 | * Return: true to allow radar indication to host else false |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1534 | */ |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1535 | bool hdd_dfs_indicate_radar(void *context, void *param) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1536 | { |
| 1537 | hdd_context_t *hdd_ctx = (hdd_context_t *) context; |
| 1538 | struct wma_dfs_radar_ind *hdd_radar_event = |
| 1539 | (struct wma_dfs_radar_ind *)param; |
| 1540 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 1541 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1542 | QDF_STATUS status; |
Manishekar Chandrasekaran | 11ecd55 | 2016-08-31 12:44:05 +0530 | [diff] [blame] | 1543 | hdd_ap_ctx_t *ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1544 | |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1545 | if (!hdd_ctx || !hdd_radar_event || |
| 1546 | hdd_ctx->config->disableDFSChSwitch) |
| 1547 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1548 | |
| 1549 | if (true == hdd_radar_event->dfs_radar_status) { |
Arif Hussain | 2a7c1f3 | 2016-07-18 14:24:36 -0700 | [diff] [blame] | 1550 | if (qdf_atomic_inc_return(&hdd_ctx->dfs_radar_found) > 1) { |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1551 | /* |
| 1552 | * Application already triggered channel switch |
| 1553 | * on current channel, so return here. |
| 1554 | */ |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1555 | return false; |
| 1556 | } |
| 1557 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1558 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1559 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1560 | adapter = adapterNode->pAdapter; |
Manishekar Chandrasekaran | 11ecd55 | 2016-08-31 12:44:05 +0530 | [diff] [blame] | 1561 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 1562 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 1563 | QDF_P2P_GO_MODE == adapter->device_mode) && |
| 1564 | (CHANNEL_STATE_DFS == |
| 1565 | cds_get_channel_state(ap_ctx->operatingChannel))) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1566 | WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
| 1567 | dfs_cac_block_tx = true; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1568 | hdd_debug("tx blocked for session:%d", |
Manishekar Chandrasekaran | 11ecd55 | 2016-08-31 12:44:05 +0530 | [diff] [blame] | 1569 | adapter->sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1570 | } |
| 1571 | |
| 1572 | status = hdd_get_next_adapter(hdd_ctx, |
| 1573 | adapterNode, |
| 1574 | &pNext); |
| 1575 | adapterNode = pNext; |
| 1576 | } |
| 1577 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1578 | |
| 1579 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1580 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1581 | |
| 1582 | /** |
| 1583 | * hdd_is_valid_mac_address() - validate MAC address |
| 1584 | * @pMacAddr: Pointer to the input MAC address |
| 1585 | * |
| 1586 | * This function validates whether the given MAC address is valid or not |
| 1587 | * Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 1588 | * where X is the hexa decimal digit character and separated by ':' |
| 1589 | * This algorithm works even if MAC address is not separated by ':' |
| 1590 | * |
| 1591 | * This code checks given input string mac contains exactly 12 hexadecimal |
| 1592 | * digits and a separator colon : appears in the input string only after |
| 1593 | * an even number of hex digits. |
| 1594 | * |
| 1595 | * Return: 1 for valid and 0 for invalid |
| 1596 | */ |
| 1597 | bool hdd_is_valid_mac_address(const uint8_t *pMacAddr) |
| 1598 | { |
| 1599 | int xdigit = 0; |
| 1600 | int separator = 0; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1601 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1602 | while (*pMacAddr) { |
| 1603 | if (isxdigit(*pMacAddr)) { |
| 1604 | xdigit++; |
| 1605 | } else if (':' == *pMacAddr) { |
| 1606 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 1607 | break; |
| 1608 | |
| 1609 | ++separator; |
| 1610 | } else { |
| 1611 | /* Invalid MAC found */ |
| 1612 | return 0; |
| 1613 | } |
| 1614 | ++pMacAddr; |
| 1615 | } |
| 1616 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 1617 | } |
| 1618 | |
| 1619 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 1620 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 1621 | * @dev: Handle to struct net_device to be updated. |
| 1622 | * |
| 1623 | * Return: None |
| 1624 | */ |
| 1625 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 1626 | { |
| 1627 | dev->header_ops = NULL; |
| 1628 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 1629 | dev->hard_header_len = ETH_HLEN; |
| 1630 | dev->mtu = ETH_DATA_LEN; |
| 1631 | dev->addr_len = ETH_ALEN; |
| 1632 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 1633 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 1634 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 1635 | |
| 1636 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 1637 | } |
| 1638 | |
| 1639 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1640 | * __hdd__mon_open() - HDD Open function |
| 1641 | * @dev: Pointer to net_device structure |
| 1642 | * |
| 1643 | * This is called in response to ifconfig up |
| 1644 | * |
| 1645 | * Return: 0 for success; non-zero for failure |
| 1646 | */ |
| 1647 | static int __hdd_mon_open(struct net_device *dev) |
| 1648 | { |
| 1649 | int ret; |
| 1650 | |
| 1651 | ENTER_DEV(dev); |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 1652 | hdd_mon_mode_ether_setup(dev); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1653 | ret = hdd_set_mon_rx_cb(dev); |
| 1654 | return ret; |
| 1655 | } |
| 1656 | |
| 1657 | /** |
| 1658 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 1659 | * @dev: Pointer to net_device structure |
| 1660 | * |
| 1661 | * This is called in response to ifconfig up |
| 1662 | * |
| 1663 | * Return: 0 for success; non-zero for failure |
| 1664 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 1665 | static int hdd_mon_open(struct net_device *dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1666 | { |
| 1667 | int ret; |
| 1668 | |
| 1669 | cds_ssr_protect(__func__); |
| 1670 | ret = __hdd_mon_open(dev); |
| 1671 | cds_ssr_unprotect(__func__); |
| 1672 | |
| 1673 | return ret; |
| 1674 | } |
| 1675 | |
| 1676 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1677 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 1678 | * @adapter: pointer to HDD adapter |
| 1679 | * |
| 1680 | * This function is called to start the device specific adapter for |
| 1681 | * the mode passed in the adapter's device_mode. |
| 1682 | * |
| 1683 | * Return: 0 for success; non-zero for failure |
| 1684 | */ |
| 1685 | int hdd_start_adapter(hdd_adapter_t *adapter) |
| 1686 | { |
| 1687 | |
| 1688 | int ret; |
| 1689 | enum tQDF_ADAPTER_MODE device_mode = adapter->device_mode; |
| 1690 | |
| 1691 | ENTER_DEV(adapter->dev); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1692 | hdd_debug("Start_adapter for mode : %d", adapter->device_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1693 | |
| 1694 | switch (device_mode) { |
| 1695 | case QDF_P2P_CLIENT_MODE: |
| 1696 | case QDF_P2P_DEVICE_MODE: |
| 1697 | case QDF_OCB_MODE: |
| 1698 | case QDF_STA_MODE: |
| 1699 | case QDF_MONITOR_MODE: |
| 1700 | ret = hdd_start_station_adapter(adapter); |
| 1701 | if (ret) |
| 1702 | goto err_start_adapter; |
| 1703 | break; |
| 1704 | case QDF_P2P_GO_MODE: |
| 1705 | case QDF_SAP_MODE: |
| 1706 | ret = hdd_start_ap_adapter(adapter); |
| 1707 | if (ret) |
| 1708 | goto err_start_adapter; |
| 1709 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 1710 | case QDF_IBSS_MODE: |
| 1711 | /* |
| 1712 | * For IBSS interface is initialized as part of |
| 1713 | * hdd_init_station_mode() |
| 1714 | */ |
| 1715 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1716 | case QDF_FTM_MODE: |
| 1717 | ret = hdd_start_ftm_adapter(adapter); |
| 1718 | if (ret) |
| 1719 | goto err_start_adapter; |
| 1720 | break; |
| 1721 | default: |
| 1722 | hdd_err("Invalid session type %d", device_mode); |
| 1723 | QDF_ASSERT(0); |
| 1724 | goto err_start_adapter; |
| 1725 | } |
| 1726 | if (hdd_set_fw_params(adapter)) |
| 1727 | hdd_err("Failed to set the FW params for the adapter!"); |
| 1728 | |
| 1729 | /* |
| 1730 | * Action frame registered in one adapter which will |
| 1731 | * applicable to all interfaces |
| 1732 | */ |
| 1733 | wlan_hdd_cfg80211_register_frames(adapter); |
| 1734 | EXIT(); |
| 1735 | return 0; |
| 1736 | err_start_adapter: |
| 1737 | return -EINVAL; |
| 1738 | } |
| 1739 | |
| 1740 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 1741 | * hdd_enable_power_management() - API to Enable Power Management |
| 1742 | * |
| 1743 | * API invokes Bus Interface Layer power management functionality |
| 1744 | * |
| 1745 | * Return: None |
| 1746 | */ |
| 1747 | static void hdd_enable_power_management(void) |
| 1748 | { |
| 1749 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 1750 | |
| 1751 | if (!hif_ctx) { |
| 1752 | hdd_err("Bus Interface Context is Invalid"); |
| 1753 | return; |
| 1754 | } |
| 1755 | |
| 1756 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 1757 | } |
| 1758 | |
| 1759 | /** |
| 1760 | * hdd_disable_power_management() - API to disable Power Management |
| 1761 | * |
| 1762 | * API disable Bus Interface Layer Power management functionality |
| 1763 | * |
| 1764 | * Return: None |
| 1765 | */ |
| 1766 | static void hdd_disable_power_management(void) |
| 1767 | { |
| 1768 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 1769 | |
| 1770 | if (!hif_ctx) { |
| 1771 | hdd_err("Bus Interface Context is Invalid"); |
| 1772 | return; |
| 1773 | } |
| 1774 | |
| 1775 | hif_disable_power_management(hif_ctx); |
| 1776 | } |
| 1777 | |
| 1778 | /** |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 1779 | * hdd_update_hw_sw_info() - API to update the HW/SW information |
| 1780 | * |
| 1781 | * API to update the HW and SW information in the driver |
| 1782 | * |
| 1783 | * Return: None |
| 1784 | */ |
| 1785 | static void hdd_update_hw_sw_info(hdd_context_t *hdd_ctx) |
| 1786 | { |
| 1787 | void *hif_sc; |
| 1788 | |
| 1789 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
| 1790 | if (!hif_sc) { |
| 1791 | hdd_err("HIF context is NULL"); |
| 1792 | return; |
| 1793 | } |
| 1794 | |
| 1795 | /* |
| 1796 | * target hw version/revision would only be retrieved after firmware |
| 1797 | * download |
| 1798 | */ |
| 1799 | hif_get_hw_info(hif_sc, &hdd_ctx->target_hw_version, |
| 1800 | &hdd_ctx->target_hw_revision, |
| 1801 | &hdd_ctx->target_hw_name); |
| 1802 | |
| 1803 | /* Get the wlan hw/fw version */ |
| 1804 | hdd_wlan_get_version(hdd_ctx, NULL, NULL); |
| 1805 | |
| 1806 | return; |
| 1807 | } |
| 1808 | |
| 1809 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 1810 | * hdd_update_cds_ac_specs_params() - update cds ac_specs params |
| 1811 | * @hdd_ctx: Pointer to hdd context |
| 1812 | * |
| 1813 | * Return: none |
| 1814 | */ |
| 1815 | static void |
| 1816 | hdd_update_cds_ac_specs_params(hdd_context_t *hdd_ctx) |
| 1817 | { |
| 1818 | uint8_t num_entries = 0; |
| 1819 | uint8_t tx_sched_wrr_param[TX_SCHED_WRR_PARAMS_NUM]; |
| 1820 | uint8_t *tx_sched_wrr_ac; |
| 1821 | int i; |
| 1822 | cds_context_type *cds_ctx; |
| 1823 | |
| 1824 | if (NULL == hdd_ctx) |
| 1825 | return; |
| 1826 | |
| 1827 | if (NULL == hdd_ctx->config) { |
| 1828 | /* Do nothing if hdd_ctx is invalid */ |
| 1829 | hdd_err("%s: Warning: hdd_ctx->cfg_ini is NULL", __func__); |
| 1830 | return; |
| 1831 | } |
| 1832 | |
| 1833 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 1834 | |
| 1835 | if (!cds_ctx) { |
| 1836 | hdd_err("Invalid CDS Context"); |
| 1837 | return; |
| 1838 | } |
| 1839 | |
| 1840 | for (i = 0; i < OL_TX_NUM_WMM_AC; i++) { |
| 1841 | switch (i) { |
| 1842 | case OL_TX_WMM_AC_BE: |
| 1843 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_be; |
| 1844 | break; |
| 1845 | case OL_TX_WMM_AC_BK: |
| 1846 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_bk; |
| 1847 | break; |
| 1848 | case OL_TX_WMM_AC_VI: |
| 1849 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vi; |
| 1850 | break; |
| 1851 | case OL_TX_WMM_AC_VO: |
| 1852 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vo; |
| 1853 | break; |
| 1854 | default: |
| 1855 | tx_sched_wrr_ac = NULL; |
| 1856 | break; |
| 1857 | } |
| 1858 | |
| 1859 | hdd_string_to_u8_array(tx_sched_wrr_ac, |
| 1860 | tx_sched_wrr_param, |
| 1861 | &num_entries, |
| 1862 | sizeof(tx_sched_wrr_param)); |
| 1863 | |
| 1864 | if (num_entries == TX_SCHED_WRR_PARAMS_NUM) { |
| 1865 | cds_ctx->ac_specs[i].wrr_skip_weight = |
| 1866 | tx_sched_wrr_param[0]; |
| 1867 | cds_ctx->ac_specs[i].credit_threshold = |
| 1868 | tx_sched_wrr_param[1]; |
| 1869 | cds_ctx->ac_specs[i].send_limit = |
| 1870 | tx_sched_wrr_param[2]; |
| 1871 | cds_ctx->ac_specs[i].credit_reserve = |
| 1872 | tx_sched_wrr_param[3]; |
| 1873 | cds_ctx->ac_specs[i].discard_weight = |
| 1874 | tx_sched_wrr_param[4]; |
| 1875 | } |
| 1876 | |
| 1877 | num_entries = 0; |
| 1878 | } |
| 1879 | } |
| 1880 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 1881 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 1882 | static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev( |
| 1883 | struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) |
| 1884 | { |
| 1885 | hdd_adapter_t *adapter = NULL; |
| 1886 | hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 1887 | |
| 1888 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 1889 | if (!adapter) { |
| 1890 | hdd_err("Adapter is NULL"); |
| 1891 | return PM_MAX_NUM_OF_MODE; |
| 1892 | } |
| 1893 | |
| 1894 | return policy_mgr_convert_device_mode_to_qdf_type( |
| 1895 | adapter->device_mode); |
| 1896 | } |
| 1897 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 1898 | static void hdd_register_policy_manager_callback( |
| 1899 | struct wlan_objmgr_psoc *psoc) |
| 1900 | { |
| 1901 | struct policy_mgr_hdd_cbacks hdd_cbacks; |
| 1902 | hdd_cbacks.sap_restart_chan_switch_cb = |
| 1903 | sap_restart_chan_switch_cb; |
| 1904 | hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = |
| 1905 | wlan_hdd_get_channel_for_sap_restart; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 1906 | hdd_cbacks.get_mode_for_non_connected_vdev = |
| 1907 | wlan_hdd_get_mode_for_non_connected_vdev; |
| 1908 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 1909 | if (QDF_STATUS_SUCCESS != |
| 1910 | policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { |
| 1911 | hdd_err("HDD callback registration with policy manager failed"); |
| 1912 | } |
| 1913 | } |
| 1914 | #else |
| 1915 | static void hdd_register_policy_manager_callback( |
| 1916 | struct wlan_objmgr_psoc *psoc) |
| 1917 | { |
| 1918 | } |
| 1919 | #endif |
| 1920 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 1921 | #ifdef WLAN_FEATURE_NAN_CONVERGENCE |
| 1922 | static void hdd_nan_register_callbacks(hdd_context_t *hdd_ctx) |
| 1923 | { |
| 1924 | struct nan_callbacks cb_obj = {0}; |
| 1925 | |
| 1926 | cb_obj.ndi_open = hdd_ndi_open; |
| 1927 | cb_obj.ndi_close = hdd_ndi_close; |
| 1928 | cb_obj.ndi_start = hdd_ndi_start; |
| 1929 | cb_obj.ndi_delete = hdd_ndi_delete; |
| 1930 | cb_obj.drv_ndi_create_rsp_handler = hdd_ndi_drv_ndi_create_rsp_handler; |
| 1931 | cb_obj.drv_ndi_delete_rsp_handler = hdd_ndi_drv_ndi_delete_rsp_handler; |
| 1932 | |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 1933 | cb_obj.new_peer_ind = hdd_ndp_new_peer_handler; |
| 1934 | cb_obj.get_peer_idx = hdd_ndp_get_peer_idx; |
Naveen Rawat | b3143ea | 2017-03-26 22:25:46 -0700 | [diff] [blame] | 1935 | cb_obj.peer_departed_ind = hdd_ndp_peer_departed_handler; |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 1936 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 1937 | os_if_nan_register_hdd_callbacks(hdd_ctx->hdd_psoc, &cb_obj); |
| 1938 | } |
| 1939 | #else |
| 1940 | static void hdd_nan_register_callbacks(hdd_context_t *hdd_ctx) |
| 1941 | { |
| 1942 | } |
| 1943 | #endif |
| 1944 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 1945 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1946 | * hdd_wlan_start_modules() - Single driver state machine for starting modules |
| 1947 | * @hdd_ctx: HDD context |
| 1948 | * @adapter: HDD adapter |
| 1949 | * @reinit: flag to indicate from SSR or normal path |
| 1950 | * |
| 1951 | * This function maintains the driver state machine it will be invoked from |
| 1952 | * startup, reinit and change interface. Depending on the driver state shall |
| 1953 | * perform the opening of the modules. |
| 1954 | * |
| 1955 | * Return: 0 for success; non-zero for failure |
| 1956 | */ |
| 1957 | int hdd_wlan_start_modules(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, |
| 1958 | bool reinit) |
| 1959 | { |
| 1960 | int ret; |
| 1961 | qdf_device_t qdf_dev; |
| 1962 | QDF_STATUS status; |
| 1963 | p_cds_contextType p_cds_context; |
| 1964 | bool unint = false; |
| 1965 | void *hif_ctx; |
| 1966 | |
| 1967 | ENTER(); |
| 1968 | |
| 1969 | p_cds_context = cds_get_global_context(); |
| 1970 | if (!p_cds_context) { |
| 1971 | hdd_err("Global Context is NULL"); |
| 1972 | QDF_ASSERT(0); |
| 1973 | return -EINVAL; |
| 1974 | } |
| 1975 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1976 | hdd_debug("start modules called in state! :%d reinit: %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1977 | hdd_ctx->driver_status, reinit); |
| 1978 | |
| 1979 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 1980 | if (!qdf_dev) { |
| 1981 | hdd_err("QDF Device Context is Invalid return"); |
| 1982 | return -EINVAL; |
| 1983 | } |
| 1984 | |
| 1985 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 1986 | hdd_ctx->start_modules_in_progress = true; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1987 | |
| 1988 | if (QDF_TIMER_STATE_RUNNING == |
| 1989 | qdf_mc_timer_get_current_state(&hdd_ctx->iface_change_timer)) { |
| 1990 | |
| 1991 | hdd_set_idle_ps_config(hdd_ctx, false); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1992 | hdd_debug("Interface change Timer running Stop timer"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1993 | qdf_mc_timer_stop(&hdd_ctx->iface_change_timer); |
| 1994 | } |
| 1995 | |
| 1996 | switch (hdd_ctx->driver_status) { |
| 1997 | case DRIVER_MODULES_UNINITIALIZED: |
| 1998 | unint = true; |
| 1999 | /* Fall through dont add break here */ |
| 2000 | case DRIVER_MODULES_CLOSED: |
| 2001 | if (!reinit && !unint) { |
| 2002 | ret = pld_power_on(qdf_dev->dev); |
| 2003 | if (ret) { |
| 2004 | hdd_err("Failed to Powerup the device: %d", ret); |
| 2005 | goto release_lock; |
| 2006 | } |
| 2007 | } |
| 2008 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 2009 | qdf_dev->bus_type, |
| 2010 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 2011 | HIF_ENABLE_TYPE_PROBE); |
| 2012 | if (ret) { |
| 2013 | hdd_err("Failed to open hif: %d", ret); |
| 2014 | goto power_down; |
| 2015 | } |
| 2016 | |
| 2017 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2018 | if (!hif_ctx) { |
| 2019 | hdd_err("hif context is null!!"); |
| 2020 | goto power_down; |
| 2021 | } |
| 2022 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2023 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 2024 | if (status != QDF_STATUS_SUCCESS) { |
| 2025 | hdd_err("No Memory to Create BMI Context :%d", status); |
| 2026 | goto hif_close; |
| 2027 | } |
| 2028 | |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2029 | ret = hdd_update_config(hdd_ctx); |
| 2030 | if (ret) { |
| 2031 | hdd_err("Failed to update configuration :%d", ret); |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 2032 | goto ol_cds_free; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2033 | } |
| 2034 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2035 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 2036 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2037 | status = cds_open(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2038 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 2039 | hdd_err("Failed to Open CDS: %d", status); |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 2040 | goto ol_cds_free; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2041 | } |
| 2042 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2043 | /* initalize components configurations after psoc open */ |
| 2044 | ret = hdd_update_components_config(hdd_ctx); |
| 2045 | if (ret) { |
| 2046 | hdd_err("Failed to update components configs :%d", |
| 2047 | ret); |
| 2048 | goto close; |
| 2049 | } |
| 2050 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2051 | /* |
| 2052 | * NAN compoenet requires certian operations like, open adapter, |
| 2053 | * close adapter, etc. to be initiated by HDD, for those |
| 2054 | * register HDD callbacks with UMAC's NAN componenet. |
| 2055 | */ |
| 2056 | hdd_nan_register_callbacks(hdd_ctx); |
| 2057 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2058 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
| 2059 | |
| 2060 | status = cds_pre_enable(hdd_ctx->pcds_context); |
| 2061 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 2062 | hdd_err("Failed to pre-enable CDS: %d", status); |
| 2063 | goto close; |
| 2064 | } |
| 2065 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2066 | hdd_register_policy_manager_callback( |
| 2067 | hdd_ctx->hdd_psoc); |
| 2068 | |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2069 | hdd_update_hw_sw_info(hdd_ctx); |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 2070 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2071 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2072 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2073 | sme_register_ftm_msg_processor(hdd_ctx->hHal, |
| 2074 | hdd_ftm_mc_process_msg); |
| 2075 | break; |
| 2076 | } |
| 2077 | if (unint) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2078 | hdd_debug("In phase-1 initialization don't enable modules"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2079 | break; |
| 2080 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2081 | |
| 2082 | if (reinit) { |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 2083 | if (hdd_ipa_uc_ssr_reinit(hdd_ctx)) { |
| 2084 | hdd_err("HDD IPA UC reinit failed"); |
| 2085 | goto close; |
| 2086 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2087 | } |
| 2088 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2089 | /* Fall through dont add break here */ |
| 2090 | case DRIVER_MODULES_OPENED: |
| 2091 | if (!adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2092 | hdd_err("adapter is Null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2093 | goto close; |
| 2094 | } |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2095 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2096 | hdd_err("in ftm mode, no need to configure cds modules"); |
| 2097 | break; |
| 2098 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2099 | if (hdd_configure_cds(hdd_ctx, adapter)) { |
| 2100 | hdd_err("Failed to Enable cds modules"); |
| 2101 | goto close; |
| 2102 | } |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2103 | hdd_enable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2104 | hdd_info("Driver Modules Successfully Enabled"); |
| 2105 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
| 2106 | break; |
| 2107 | case DRIVER_MODULES_ENABLED: |
| 2108 | hdd_info("Driver modules already Enabled"); |
| 2109 | break; |
| 2110 | default: |
| 2111 | hdd_err("WLAN start invoked in wrong state! :%d\n", |
| 2112 | hdd_ctx->driver_status); |
| 2113 | goto release_lock; |
| 2114 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2115 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2116 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 2117 | EXIT(); |
| 2118 | return 0; |
| 2119 | |
| 2120 | close: |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2121 | cds_close(hdd_ctx->hdd_psoc, p_cds_context); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2122 | |
| 2123 | ol_cds_free: |
| 2124 | ol_cds_free(); |
| 2125 | |
| 2126 | hif_close: |
| 2127 | hdd_hif_close(p_cds_context->pHIFContext); |
| 2128 | power_down: |
| 2129 | if (!reinit && !unint) |
| 2130 | pld_power_off(qdf_dev->dev); |
| 2131 | release_lock: |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2132 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2133 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2134 | EXIT(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2135 | return -EINVAL; |
| 2136 | } |
| 2137 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2138 | #ifdef WIFI_POS_CONVERGED |
| 2139 | static int hdd_activate_wifi_pos(hdd_context_t *hdd_ctx) |
| 2140 | { |
| 2141 | int ret = os_if_wifi_pos_register_nl(); |
| 2142 | |
| 2143 | if (ret) |
| 2144 | hdd_err("os_if_wifi_pos_register_nl failed"); |
| 2145 | |
| 2146 | return ret; |
| 2147 | } |
| 2148 | |
| 2149 | static int hdd_deactivate_wifi_pos(void) |
| 2150 | { |
| 2151 | int ret = os_if_wifi_pos_deregister_nl(); |
| 2152 | |
| 2153 | if (ret) |
| 2154 | hdd_err("os_if_wifi_pos_deregister_nl failed"); |
| 2155 | |
| 2156 | return ret; |
| 2157 | } |
| 2158 | |
| 2159 | /** |
| 2160 | * hdd_populate_wifi_pos_cfg - populates wifi_pos parameters |
| 2161 | * @hdd_ctx: hdd context |
| 2162 | * |
| 2163 | * Return: status of operation |
| 2164 | */ |
| 2165 | static void hdd_populate_wifi_pos_cfg(hdd_context_t *hdd_ctx) |
| 2166 | { |
| 2167 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 2168 | struct hdd_config *cfg = hdd_ctx->config; |
| 2169 | |
| 2170 | wifi_pos_set_oem_target_type(psoc, hdd_ctx->target_type); |
| 2171 | wifi_pos_set_oem_fw_version(psoc, hdd_ctx->target_fw_version); |
| 2172 | wifi_pos_set_drv_ver_major(psoc, QWLAN_VERSION_MAJOR); |
| 2173 | wifi_pos_set_drv_ver_minor(psoc, QWLAN_VERSION_MINOR); |
| 2174 | wifi_pos_set_drv_ver_patch(psoc, QWLAN_VERSION_PATCH); |
| 2175 | wifi_pos_set_drv_ver_build(psoc, QWLAN_VERSION_BUILD); |
| 2176 | wifi_pos_set_dwell_time_min(psoc, cfg->nNeighborScanMinChanTime); |
| 2177 | wifi_pos_set_dwell_time_max(psoc, cfg->nNeighborScanMaxChanTime); |
| 2178 | } |
| 2179 | #else |
| 2180 | static int hdd_activate_wifi_pos(hdd_context_t *hdd_ctx) |
| 2181 | { |
| 2182 | return oem_activate_service(hdd_ctx); |
| 2183 | } |
| 2184 | |
| 2185 | static int hdd_deactivate_wifi_pos(void) |
| 2186 | { |
| 2187 | return 0; |
| 2188 | } |
| 2189 | |
| 2190 | static void hdd_populate_wifi_pos_cfg(hdd_context_t *hdd_ctx) |
| 2191 | { |
| 2192 | } |
| 2193 | #endif |
| 2194 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2195 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2196 | * __hdd_open() - HDD Open function |
| 2197 | * @dev: Pointer to net_device structure |
| 2198 | * |
| 2199 | * This is called in response to ifconfig up |
| 2200 | * |
| 2201 | * Return: 0 for success; non-zero for failure |
| 2202 | */ |
| 2203 | static int __hdd_open(struct net_device *dev) |
| 2204 | { |
| 2205 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2206 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2207 | int ret; |
| 2208 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2209 | ENTER_DEV(dev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2210 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2211 | adapter->sessionId, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2212 | |
| 2213 | ret = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2214 | if (ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2215 | return ret; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2216 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2217 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2218 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 2219 | if (ret) { |
| 2220 | hdd_err("Failed to start WLAN modules return"); |
| 2221 | return -ret; |
| 2222 | } |
| 2223 | |
| 2224 | |
| 2225 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2226 | ret = hdd_start_adapter(adapter); |
| 2227 | if (ret) { |
| 2228 | hdd_err("Failed to start adapter :%d", |
| 2229 | adapter->device_mode); |
| 2230 | return ret; |
| 2231 | } |
| 2232 | } |
| 2233 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2234 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2235 | if (hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2236 | hdd_info("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2237 | /* Enable TX queues only when we are connected */ |
| 2238 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2239 | WLAN_START_ALL_NETIF_QUEUE, |
| 2240 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2241 | } |
| 2242 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2243 | /* Enable carrier and transmit queues for NDI */ |
| 2244 | if (WLAN_HDD_IS_NDI(adapter)) { |
| 2245 | hdd_notice("Enabling Tx Queues"); |
| 2246 | wlan_hdd_netif_queue_control(adapter, |
| 2247 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 2248 | WLAN_CONTROL_PATH); |
| 2249 | } |
| 2250 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2251 | hdd_populate_wifi_pos_cfg(hdd_ctx); |
| 2252 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2253 | return ret; |
| 2254 | } |
| 2255 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2256 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2257 | /** |
| 2258 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 2259 | * @dev: Pointer to net_device structure |
| 2260 | * |
| 2261 | * This is called in response to ifconfig up |
| 2262 | * |
| 2263 | * Return: 0 for success; non-zero for failure |
| 2264 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2265 | static int hdd_open(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2266 | { |
| 2267 | int ret; |
| 2268 | |
| 2269 | cds_ssr_protect(__func__); |
| 2270 | ret = __hdd_open(dev); |
| 2271 | cds_ssr_unprotect(__func__); |
| 2272 | |
| 2273 | return ret; |
| 2274 | } |
| 2275 | |
| 2276 | /** |
| 2277 | * __hdd_stop() - HDD stop function |
| 2278 | * @dev: Pointer to net_device structure |
| 2279 | * |
| 2280 | * This is called in response to ifconfig down |
| 2281 | * |
| 2282 | * Return: 0 for success; non-zero for failure |
| 2283 | */ |
| 2284 | static int __hdd_stop(struct net_device *dev) |
| 2285 | { |
| 2286 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2287 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2288 | int ret; |
| 2289 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2290 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2291 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2292 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2293 | adapter->sessionId, adapter->device_mode)); |
| 2294 | |
| 2295 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 2296 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2297 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2298 | |
| 2299 | /* Nothing to be done if the interface is not opened */ |
| 2300 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2301 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2302 | return -ENODEV; |
| 2303 | } |
| 2304 | |
| 2305 | /* Make sure the interface is marked as closed */ |
| 2306 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2307 | hdd_notice("Disabling OS Tx queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2308 | |
| 2309 | /* |
| 2310 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 2311 | * be called on that interface |
| 2312 | */ |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2313 | hdd_notice("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 2314 | wlan_hdd_netif_queue_control(adapter, |
| 2315 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 2316 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2317 | |
| 2318 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2319 | * NAN data interface is different in some sense. The traffic on NDI is |
| 2320 | * bursty in nature and depends on the need to transfer. The service |
| 2321 | * layer may down the interface after the usage and up again when |
| 2322 | * required. In some sense, the NDI is expected to be available |
| 2323 | * (like SAP) iface until NDI delete request is issued by the service |
| 2324 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 2325 | * interface (NDI). |
| 2326 | */ |
| 2327 | if (WLAN_HDD_IS_NDI(adapter)) |
| 2328 | return 0; |
| 2329 | |
| 2330 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2331 | * The interface is marked as down for outside world (aka kernel) |
| 2332 | * But the driver is pretty much alive inside. The driver needs to |
| 2333 | * tear down the existing connection on the netdev (session) |
| 2334 | * cleanup the data pipes and wait until the control plane is stabilized |
| 2335 | * for this interface. The call also needs to wait until the above |
| 2336 | * mentioned actions are completed before returning to the caller. |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2337 | * Notice that hdd_stop_adapter is requested not to close the session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2338 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 2339 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2340 | hdd_stop_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2341 | |
| 2342 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 2343 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 2344 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2345 | |
| 2346 | /* |
| 2347 | * Find if any iface is up. If any iface is up then can't put device to |
| 2348 | * sleep/power save mode |
| 2349 | */ |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 2350 | if (hdd_check_for_opened_interfaces(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2351 | hdd_debug("Closing all modules from the hdd_stop"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2352 | qdf_mc_timer_start(&hdd_ctx->iface_change_timer, |
| 2353 | hdd_ctx->config->iface_change_wait_time |
| 2354 | * 50000); |
| 2355 | } |
| 2356 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2357 | EXIT(); |
| 2358 | return 0; |
| 2359 | } |
| 2360 | |
| 2361 | /** |
| 2362 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 2363 | * @dev: pointer to net_device structure |
| 2364 | * |
| 2365 | * This is called in response to ifconfig down |
| 2366 | * |
| 2367 | * Return: 0 for success and error number for failure |
| 2368 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2369 | static int hdd_stop(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2370 | { |
| 2371 | int ret; |
| 2372 | |
| 2373 | cds_ssr_protect(__func__); |
| 2374 | ret = __hdd_stop(dev); |
| 2375 | cds_ssr_unprotect(__func__); |
| 2376 | |
| 2377 | return ret; |
| 2378 | } |
| 2379 | |
| 2380 | /** |
| 2381 | * __hdd_uninit() - HDD uninit function |
| 2382 | * @dev: Pointer to net_device structure |
| 2383 | * |
| 2384 | * This is called during the netdev unregister to uninitialize all data |
| 2385 | * associated with the device |
| 2386 | * |
| 2387 | * Return: None |
| 2388 | */ |
| 2389 | static void __hdd_uninit(struct net_device *dev) |
| 2390 | { |
| 2391 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2392 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2393 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2394 | |
| 2395 | do { |
| 2396 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2397 | hdd_err("Invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2398 | break; |
| 2399 | } |
| 2400 | |
| 2401 | if (NULL == adapter->pHddCtx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2402 | hdd_err("NULL hdd_ctx"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2403 | break; |
| 2404 | } |
| 2405 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2406 | if (dev != adapter->dev) |
| 2407 | hdd_err("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2408 | |
| 2409 | hdd_deinit_adapter(adapter->pHddCtx, adapter, true); |
| 2410 | |
| 2411 | /* after uninit our adapter structure will no longer be valid */ |
| 2412 | adapter->dev = NULL; |
| 2413 | adapter->magic = 0; |
| 2414 | } while (0); |
| 2415 | |
| 2416 | EXIT(); |
| 2417 | } |
| 2418 | |
| 2419 | /** |
| 2420 | * hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 2421 | * @dev: pointer to net_device structure |
| 2422 | * |
| 2423 | * This is called during the netdev unregister to uninitialize all data |
| 2424 | * associated with the device |
| 2425 | * |
| 2426 | * Return: none |
| 2427 | */ |
| 2428 | static void hdd_uninit(struct net_device *dev) |
| 2429 | { |
| 2430 | cds_ssr_protect(__func__); |
| 2431 | __hdd_uninit(dev); |
| 2432 | cds_ssr_unprotect(__func__); |
| 2433 | } |
| 2434 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2435 | static int hdd_open_cesium_nl_sock(void) |
| 2436 | { |
| 2437 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 2438 | struct netlink_kernel_cfg cfg = { |
| 2439 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 2440 | .input = NULL |
| 2441 | }; |
| 2442 | #endif |
| 2443 | int ret = 0; |
| 2444 | |
| 2445 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 2446 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 2447 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 2448 | THIS_MODULE, |
| 2449 | #endif |
| 2450 | &cfg); |
| 2451 | #else |
| 2452 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 2453 | WLAN_NLINK_MCAST_GRP_ID, |
| 2454 | NULL, NULL, THIS_MODULE); |
| 2455 | #endif |
| 2456 | |
| 2457 | if (cesium_nl_srv_sock == NULL) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2458 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2459 | ret = -ECONNREFUSED; |
| 2460 | } |
| 2461 | |
| 2462 | return ret; |
| 2463 | } |
| 2464 | |
| 2465 | static void hdd_close_cesium_nl_sock(void) |
| 2466 | { |
| 2467 | if (NULL != cesium_nl_srv_sock) { |
| 2468 | netlink_kernel_release(cesium_nl_srv_sock); |
| 2469 | cesium_nl_srv_sock = NULL; |
| 2470 | } |
| 2471 | } |
| 2472 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2473 | /** |
| 2474 | * __hdd_set_mac_address() - set the user specified mac address |
| 2475 | * @dev: Pointer to the net device. |
| 2476 | * @addr: Pointer to the sockaddr. |
| 2477 | * |
| 2478 | * This function sets the user specified mac address using |
| 2479 | * the command ifconfig wlanX hw ether <mac adress>. |
| 2480 | * |
| 2481 | * Return: 0 for success, non zero for failure |
| 2482 | */ |
| 2483 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 2484 | { |
| 2485 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2486 | hdd_context_t *hdd_ctx; |
| 2487 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2488 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2489 | int ret; |
| 2490 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2491 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2492 | |
| 2493 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2494 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2495 | if (0 != ret) |
| 2496 | return ret; |
| 2497 | |
| 2498 | memcpy(&adapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN); |
| 2499 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 2500 | |
| 2501 | EXIT(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2502 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2503 | } |
| 2504 | |
| 2505 | /** |
| 2506 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
| 2507 | * function from SSR |
| 2508 | * @dev: pointer to net_device structure |
| 2509 | * @addr: Pointer to the sockaddr |
| 2510 | * |
| 2511 | * This function sets the user specified mac address using |
| 2512 | * the command ifconfig wlanX hw ether <mac adress>. |
| 2513 | * |
| 2514 | * Return: 0 for success. |
| 2515 | */ |
| 2516 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 2517 | { |
| 2518 | int ret; |
| 2519 | |
| 2520 | cds_ssr_protect(__func__); |
| 2521 | ret = __hdd_set_mac_address(dev, addr); |
| 2522 | cds_ssr_unprotect(__func__); |
| 2523 | |
| 2524 | return ret; |
| 2525 | } |
| 2526 | |
| 2527 | uint8_t *wlan_hdd_get_intf_addr(hdd_context_t *hdd_ctx) |
| 2528 | { |
| 2529 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2530 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2531 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2532 | if (0 == ((hdd_ctx->config->intfAddrMask) & (1 << i))) |
| 2533 | break; |
| 2534 | } |
| 2535 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2536 | if (QDF_MAX_CONCURRENCY_PERSONA == i) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2537 | return NULL; |
| 2538 | |
| 2539 | hdd_ctx->config->intfAddrMask |= (1 << i); |
| 2540 | return &hdd_ctx->config->intfMacAddr[i].bytes[0]; |
| 2541 | } |
| 2542 | |
| 2543 | void wlan_hdd_release_intf_addr(hdd_context_t *hdd_ctx, uint8_t *releaseAddr) |
| 2544 | { |
| 2545 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2546 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2547 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2548 | if (!memcmp(releaseAddr, |
| 2549 | &hdd_ctx->config->intfMacAddr[i].bytes[0], |
| 2550 | 6)) { |
| 2551 | hdd_ctx->config->intfAddrMask &= ~(1 << i); |
| 2552 | break; |
| 2553 | } |
| 2554 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2555 | } |
| 2556 | |
| 2557 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 2558 | /** |
| 2559 | * __hdd_set_multicast_list() - set the multicast address list |
| 2560 | * @dev: Pointer to the WLAN device. |
| 2561 | * @skb: Pointer to OS packet (sk_buff). |
| 2562 | * |
| 2563 | * This funciton sets the multicast address list. |
| 2564 | * |
| 2565 | * Return: None |
| 2566 | */ |
| 2567 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 2568 | { |
| 2569 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2570 | int i = 0, status; |
| 2571 | struct netdev_hw_addr *ha; |
| 2572 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2573 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
| 2574 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 2575 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2576 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2577 | ENTER_DEV(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2578 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2579 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 2580 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2581 | status = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 2582 | if (0 != status) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2583 | goto out; |
| 2584 | |
| 2585 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
| 2586 | if (!mc_list_request) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2587 | hdd_err("Cannot allocate mc_list_request"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2588 | goto out; |
| 2589 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2590 | |
| 2591 | if (dev->flags & IFF_ALLMULTI) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2592 | hdd_debug("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2593 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 2594 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2595 | } else { |
| 2596 | mc_count = netdev_mc_count(dev); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2597 | if (mc_count > pmo_ucfg_max_mc_addr_supported(psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2598 | 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] | 2599 | pmo_ucfg_max_mc_addr_supported(psoc)); |
| 2600 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 2601 | pmo_mc_list_change_notify); |
| 2602 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2603 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2604 | netdev_for_each_mc_addr(ha, dev) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2605 | hdd_debug("ha_addr[%d] "MAC_ADDRESS_STR, |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 2606 | i, MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2607 | if (i == mc_count) |
| 2608 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2609 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 2610 | 0, ETH_ALEN); |
| 2611 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 2612 | ha->addr, ETH_ALEN); |
| 2613 | hdd_info("mlist[%d] = %pM", i, |
| 2614 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2615 | i++; |
| 2616 | } |
| 2617 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2618 | |
| 2619 | mc_list_request->psoc = psoc; |
| 2620 | mc_list_request->vdev_id = adapter->sessionId; |
| 2621 | mc_list_request->count = mc_count; |
| 2622 | status = hdd_cache_mc_addr_list(mc_list_request); |
| 2623 | if (status == 0) { |
| 2624 | hdd_enable_mc_addr_filtering(adapter, |
| 2625 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2626 | } else { |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2627 | hdd_err("error while caching mc list"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2628 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2629 | out: |
| 2630 | if (mc_list_request) |
| 2631 | qdf_mem_free(mc_list_request); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 2632 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2633 | } |
| 2634 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2635 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2636 | /** |
| 2637 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
| 2638 | * @dev: pointer to net_device |
| 2639 | * |
| 2640 | * Return: none |
| 2641 | */ |
| 2642 | static void hdd_set_multicast_list(struct net_device *dev) |
| 2643 | { |
| 2644 | cds_ssr_protect(__func__); |
| 2645 | __hdd_set_multicast_list(dev); |
| 2646 | cds_ssr_unprotect(__func__); |
| 2647 | } |
| 2648 | #endif |
| 2649 | |
| 2650 | /** |
| 2651 | * hdd_select_queue() - used by Linux OS to decide which queue to use first |
| 2652 | * @dev: Pointer to the WLAN device. |
| 2653 | * @skb: Pointer to OS packet (sk_buff). |
| 2654 | * |
| 2655 | * This function is registered with the Linux OS for network |
| 2656 | * core to decide which queue to use first. |
| 2657 | * |
| 2658 | * Return: ac, Queue Index/access category corresponding to UP in IP header |
| 2659 | */ |
| 2660 | static uint16_t hdd_select_queue(struct net_device *dev, struct sk_buff *skb |
| 2661 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) |
| 2662 | , void *accel_priv |
| 2663 | #endif |
| 2664 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 2665 | , select_queue_fallback_t fallback |
| 2666 | #endif |
| 2667 | ) |
| 2668 | { |
| 2669 | return hdd_wmm_select_queue(dev, skb); |
| 2670 | } |
| 2671 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2672 | static const struct net_device_ops wlan_drv_ops = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2673 | .ndo_open = hdd_open, |
| 2674 | .ndo_stop = hdd_stop, |
| 2675 | .ndo_uninit = hdd_uninit, |
| 2676 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 2677 | .ndo_tx_timeout = hdd_tx_timeout, |
| 2678 | .ndo_get_stats = hdd_get_stats, |
| 2679 | .ndo_do_ioctl = hdd_ioctl, |
| 2680 | .ndo_set_mac_address = hdd_set_mac_address, |
| 2681 | .ndo_select_queue = hdd_select_queue, |
| 2682 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2683 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2684 | #endif |
| 2685 | }; |
| 2686 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2687 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2688 | static const struct net_device_ops wlan_mon_drv_ops = { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2689 | .ndo_open = hdd_mon_open, |
| 2690 | .ndo_stop = hdd_stop, |
| 2691 | .ndo_get_stats = hdd_get_stats, |
| 2692 | }; |
| 2693 | |
| 2694 | /** |
| 2695 | * hdd_set_station_ops() - update net_device ops for monitor mode |
| 2696 | * @pWlanDev: Handle to struct net_device to be updated. |
| 2697 | * Return: None |
| 2698 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2699 | void hdd_set_station_ops(struct net_device *pWlanDev) |
| 2700 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2701 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
| 2702 | pWlanDev->netdev_ops = &wlan_mon_drv_ops; |
| 2703 | else |
| 2704 | pWlanDev->netdev_ops = &wlan_drv_ops; |
| 2705 | } |
| 2706 | |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 2707 | #ifdef FEATURE_RUNTIME_PM |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 2708 | /** |
| 2709 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 2710 | * @hdd_ctx: HDD context |
| 2711 | * |
| 2712 | * Return: None |
| 2713 | */ |
| 2714 | static void hdd_runtime_suspend_context_init(hdd_context_t *hdd_ctx) |
| 2715 | { |
| 2716 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 2717 | |
| 2718 | ctx->scan = qdf_runtime_lock_init("scan"); |
Komal Seelam | aa75f26 | 2016-09-29 12:32:13 +0530 | [diff] [blame] | 2719 | ctx->roc = qdf_runtime_lock_init("roc"); |
Komal Seelam | 81cb166 | 2016-09-29 12:39:08 +0530 | [diff] [blame] | 2720 | ctx->dfs = qdf_runtime_lock_init("dfs"); |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 2721 | } |
| 2722 | |
| 2723 | /** |
| 2724 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 2725 | * @hdd_ctx: HDD Context |
| 2726 | * |
| 2727 | * Return: None |
| 2728 | */ |
| 2729 | static void hdd_runtime_suspend_context_deinit(hdd_context_t *hdd_ctx) |
| 2730 | { |
| 2731 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 2732 | |
| 2733 | qdf_runtime_lock_deinit(ctx->scan); |
| 2734 | ctx->scan = NULL; |
Komal Seelam | aa75f26 | 2016-09-29 12:32:13 +0530 | [diff] [blame] | 2735 | qdf_runtime_lock_deinit(ctx->roc); |
| 2736 | ctx->roc = NULL; |
Komal Seelam | 81cb166 | 2016-09-29 12:39:08 +0530 | [diff] [blame] | 2737 | qdf_runtime_lock_deinit(ctx->dfs); |
| 2738 | ctx->dfs = NULL; |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 2739 | } |
| 2740 | |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 2741 | static void hdd_adapter_runtime_suspend_init(hdd_adapter_t *adapter) |
| 2742 | { |
| 2743 | struct hdd_connect_pm_context *ctx = &adapter->connect_rpm_ctx; |
| 2744 | |
| 2745 | ctx->connect = qdf_runtime_lock_init("connect"); |
| 2746 | } |
| 2747 | |
| 2748 | static void hdd_adapter_runtime_suspend_denit(hdd_adapter_t *adapter) |
| 2749 | { |
| 2750 | struct hdd_connect_pm_context *ctx = &adapter->connect_rpm_ctx; |
| 2751 | |
| 2752 | qdf_runtime_lock_deinit(ctx->connect); |
| 2753 | ctx->connect = NULL; |
| 2754 | } |
| 2755 | #else /* FEATURE_RUNTIME_PM */ |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 2756 | static void hdd_runtime_suspend_context_init(hdd_context_t *hdd_ctx) {} |
| 2757 | static void hdd_runtime_suspend_context_deinit(hdd_context_t *hdd_ctx) {} |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 2758 | static inline void hdd_adapter_runtime_suspend_init(hdd_adapter_t *adapter) {} |
| 2759 | static inline void hdd_adapter_runtime_suspend_denit(hdd_adapter_t *adapter) {} |
| 2760 | #endif /* FEATURE_RUNTIME_PM */ |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2761 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 2762 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 2763 | * @hdd_ctx: global hdd context |
| 2764 | * @macAddr: mac address to assign to the interface |
| 2765 | * @name: User-visible name of the interface |
| 2766 | * |
| 2767 | * hdd adapter pointer would point to the netdev->priv space, this function |
| 2768 | * would retrive the pointer, and setup the hdd adapter configuration. |
| 2769 | * |
| 2770 | * Return: the pointer to hdd adapter, otherwise NULL |
| 2771 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2772 | static hdd_adapter_t *hdd_alloc_station_adapter(hdd_context_t *hdd_ctx, |
| 2773 | tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 2774 | unsigned char name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2775 | const char *name) |
| 2776 | { |
| 2777 | struct net_device *pWlanDev = NULL; |
| 2778 | hdd_adapter_t *adapter = NULL; |
| 2779 | /* |
| 2780 | * cfg80211 initialization and registration.... |
| 2781 | */ |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 2782 | pWlanDev = alloc_netdev_mq(sizeof(hdd_adapter_t), name, |
| 2783 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
| 2784 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2785 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2786 | (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam() ? |
| 2787 | hdd_mon_mode_ether_setup : ether_setup), |
| 2788 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2789 | |
| 2790 | if (pWlanDev != NULL) { |
| 2791 | |
| 2792 | /* Save the pointer to the net_device in the HDD adapter */ |
| 2793 | adapter = (hdd_adapter_t *) netdev_priv(pWlanDev); |
| 2794 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2795 | qdf_mem_zero(adapter, sizeof(hdd_adapter_t)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2796 | |
| 2797 | adapter->dev = pWlanDev; |
| 2798 | adapter->pHddCtx = hdd_ctx; |
| 2799 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Arun Khandavalli | 9ad88f0 | 2016-09-01 19:03:37 +0530 | [diff] [blame] | 2800 | adapter->sessionId = HDD_SESSION_ID_INVALID; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2801 | |
| 2802 | init_completion(&adapter->session_open_comp_var); |
| 2803 | init_completion(&adapter->session_close_comp_var); |
| 2804 | init_completion(&adapter->disconnect_comp_var); |
| 2805 | init_completion(&adapter->linkup_event_var); |
| 2806 | init_completion(&adapter->cancel_rem_on_chan_var); |
| 2807 | init_completion(&adapter->rem_on_chan_ready_event); |
| 2808 | init_completion(&adapter->sta_authorized_event); |
| 2809 | init_completion(&adapter->offchannel_tx_event); |
| 2810 | init_completion(&adapter->tx_action_cnf_event); |
| 2811 | #ifdef FEATURE_WLAN_TDLS |
| 2812 | init_completion(&adapter->tdls_add_station_comp); |
| 2813 | init_completion(&adapter->tdls_del_station_comp); |
| 2814 | init_completion(&adapter->tdls_mgmt_comp); |
| 2815 | init_completion(&adapter->tdls_link_establish_req_comp); |
| 2816 | #endif |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2817 | init_completion(&adapter->ibss_peer_info_comp); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2818 | init_completion(&adapter->change_country_code); |
| 2819 | |
| 2820 | |
| 2821 | init_completion(&adapter->scan_info.abortscan_event_var); |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 2822 | init_completion(&adapter->lfr_fw_status.disable_lfr_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2823 | |
| 2824 | adapter->offloads_configured = false; |
| 2825 | adapter->isLinkUpSvcNeeded = false; |
| 2826 | adapter->higherDtimTransition = true; |
| 2827 | /* Init the net_device structure */ |
| 2828 | strlcpy(pWlanDev->name, name, IFNAMSIZ); |
| 2829 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2830 | qdf_mem_copy(pWlanDev->dev_addr, (void *)macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2831 | sizeof(tSirMacAddr)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2832 | qdf_mem_copy(adapter->macAddressCurrent.bytes, macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2833 | sizeof(tSirMacAddr)); |
| 2834 | pWlanDev->watchdog_timeo = HDD_TX_TIMEOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2835 | |
| 2836 | if (hdd_ctx->config->enable_ip_tcp_udp_checksum_offload) |
| 2837 | pWlanDev->features |= |
| 2838 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
| 2839 | pWlanDev->features |= NETIF_F_RXCSUM; |
| 2840 | |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 2841 | hdd_set_tso_flags(hdd_ctx, pWlanDev); |
| 2842 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2843 | hdd_set_station_ops(adapter->dev); |
| 2844 | |
| 2845 | pWlanDev->destructor = free_netdev; |
| 2846 | pWlanDev->ieee80211_ptr = &adapter->wdev; |
Mohit Khanna | ee9e80f | 2015-11-10 11:32:49 -0800 | [diff] [blame] | 2847 | pWlanDev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2848 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
| 2849 | adapter->wdev.netdev = pWlanDev; |
| 2850 | /* set pWlanDev's parent to underlying device */ |
| 2851 | SET_NETDEV_DEV(pWlanDev, hdd_ctx->parent_dev); |
| 2852 | hdd_wmm_init(adapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 2853 | hdd_adapter_runtime_suspend_init(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2854 | spin_lock_init(&adapter->pause_map_lock); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 2855 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2856 | } |
| 2857 | |
| 2858 | return adapter; |
| 2859 | } |
| 2860 | |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2861 | static QDF_STATUS hdd_register_interface(hdd_adapter_t *adapter, |
| 2862 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2863 | { |
| 2864 | struct net_device *pWlanDev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2865 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 2866 | if (rtnl_held) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2867 | if (strnchr(pWlanDev->name, strlen(pWlanDev->name), '%')) { |
| 2868 | if (dev_alloc_name(pWlanDev, pWlanDev->name) < 0) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2869 | hdd_err("Failed:dev_alloc_name"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2870 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2871 | } |
| 2872 | } |
| 2873 | if (register_netdevice(pWlanDev)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2874 | hdd_err("Failed:register_netdev"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2875 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2876 | } |
| 2877 | } else { |
| 2878 | if (register_netdev(pWlanDev)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2879 | hdd_err("Failed:register_netdev"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2880 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2881 | } |
| 2882 | } |
| 2883 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 2884 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2885 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2886 | } |
| 2887 | |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 2888 | QDF_STATUS hdd_sme_close_session_callback(void *pContext) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2889 | { |
| 2890 | hdd_adapter_t *adapter = pContext; |
| 2891 | |
| 2892 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2893 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2894 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2895 | } |
| 2896 | |
| 2897 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2898 | hdd_err("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2899 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2900 | } |
| 2901 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 2902 | /* |
| 2903 | * For NAN Data interface, the close session results in the final |
| 2904 | * indication to the userspace |
| 2905 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 2906 | if (adapter->device_mode == QDF_NDI_MODE) |
| 2907 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 2908 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2909 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 2910 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2911 | /* |
| 2912 | * We can be blocked while waiting for scheduled work to be |
| 2913 | * flushed, and the adapter structure can potentially be freed, in |
| 2914 | * which case the magic will have been reset. So make sure the |
| 2915 | * magic is still good, and hence the adapter structure is still |
| 2916 | * valid, before signaling completion |
| 2917 | */ |
| 2918 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
| 2919 | complete(&adapter->session_close_comp_var); |
| 2920 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2921 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2922 | } |
| 2923 | |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 2924 | /** |
| 2925 | * hdd_check_and_init_tdls() - check and init TDLS operation for desired mode |
| 2926 | * @adapter: pointer to device adapter |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 2927 | * |
| 2928 | * This routine will check the mode of adapter and if it is required then it |
| 2929 | * will initialize the TDLS operations |
| 2930 | * |
| 2931 | * Return: QDF_STATUS |
| 2932 | */ |
| 2933 | #ifdef FEATURE_WLAN_TDLS |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 2934 | static QDF_STATUS hdd_check_and_init_tdls(hdd_adapter_t *adapter) |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 2935 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 2936 | if (adapter->device_mode == QDF_IBSS_MODE) |
| 2937 | return QDF_STATUS_SUCCESS; |
| 2938 | |
| 2939 | if (wlan_hdd_tdls_init(adapter)) { |
| 2940 | hdd_err("wlan_hdd_tdls_init failed"); |
| 2941 | return QDF_STATUS_E_FAILURE; |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 2942 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 2943 | set_bit(TDLS_INIT_DONE, &adapter->event_flags); |
| 2944 | |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 2945 | return QDF_STATUS_SUCCESS; |
| 2946 | } |
| 2947 | #else |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 2948 | static QDF_STATUS hdd_check_and_init_tdls(hdd_adapter_t *adapter) |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 2949 | { |
| 2950 | return QDF_STATUS_SUCCESS; |
| 2951 | } |
| 2952 | #endif |
| 2953 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 2954 | int hdd_vdev_ready(hdd_adapter_t *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2955 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 2956 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2957 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 2958 | status = pmo_vdev_ready(adapter->hdd_vdev); |
| 2959 | |
| 2960 | return qdf_status_to_os_return(status); |
| 2961 | } |
| 2962 | |
| 2963 | int hdd_vdev_destroy(hdd_adapter_t *adapter) |
| 2964 | { |
| 2965 | QDF_STATUS status; |
| 2966 | int errno; |
| 2967 | hdd_context_t *hdd_ctx; |
| 2968 | unsigned long rc; |
| 2969 | |
| 2970 | hdd_info("destroying vdev %d", adapter->sessionId); |
| 2971 | |
| 2972 | /* vdev created sanity check */ |
| 2973 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2974 | hdd_err("vdev for Id %d does not exist", adapter->sessionId); |
| 2975 | return -EINVAL; |
| 2976 | } |
| 2977 | |
Dustin Brown | 0d2eeae | 2017-03-24 15:21:32 -0700 | [diff] [blame] | 2978 | /* do vdev logical destroy via objmgr */ |
| 2979 | errno = hdd_objmgr_destroy_vdev(adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 2980 | if (errno) { |
| 2981 | hdd_err("failed to destroy objmgr vdev: %d", errno); |
| 2982 | return errno; |
| 2983 | } |
| 2984 | |
| 2985 | /* close sme session (destroy vdev in firmware via legacy API) */ |
| 2986 | INIT_COMPLETION(adapter->session_close_comp_var); |
| 2987 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2988 | status = sme_close_session(hdd_ctx->hHal, adapter->sessionId, |
| 2989 | hdd_sme_close_session_callback, adapter); |
| 2990 | if (QDF_IS_STATUS_ERROR(status)) { |
| 2991 | hdd_err("failed to close sme session: %d", status); |
| 2992 | return qdf_status_to_os_return(status); |
| 2993 | } |
| 2994 | |
| 2995 | /* block on a completion variable until sme session is closed */ |
| 2996 | rc = wait_for_completion_timeout( |
| 2997 | &adapter->session_close_comp_var, |
| 2998 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
| 2999 | if (!rc) { |
| 3000 | hdd_err("timed out waiting for close sme session: %ld", rc); |
| 3001 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3002 | hdd_ndp_session_end_handler(adapter); |
| 3003 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3004 | return -ETIMEDOUT; |
| 3005 | } |
| 3006 | |
Dustin Brown | 0d2eeae | 2017-03-24 15:21:32 -0700 | [diff] [blame] | 3007 | /* now that sme session is closed, allow physical vdev destroy */ |
| 3008 | errno = hdd_objmgr_release_vdev(adapter); |
| 3009 | if (errno) { |
| 3010 | hdd_err("failed to release objmgr vdev: %d", errno); |
| 3011 | return errno; |
| 3012 | } |
| 3013 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3014 | hdd_info("vdev destroyed successfully"); |
| 3015 | |
| 3016 | return 0; |
| 3017 | } |
| 3018 | |
| 3019 | int hdd_vdev_create(hdd_adapter_t *adapter) |
| 3020 | { |
| 3021 | QDF_STATUS status; |
| 3022 | int errno; |
| 3023 | hdd_context_t *hdd_ctx; |
| 3024 | uint32_t type; |
| 3025 | uint32_t sub_type; |
| 3026 | unsigned long rc; |
| 3027 | |
| 3028 | hdd_info("creating new vdev"); |
| 3029 | |
| 3030 | /* determine vdev (sub)type */ |
| 3031 | status = cds_get_vdev_types(adapter->device_mode, &type, &sub_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3032 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3033 | hdd_err("failed to get vdev type: %d", status); |
| 3034 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3035 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3036 | |
| 3037 | /* do vdev create via objmgr */ |
| 3038 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3039 | errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->hdd_pdev, adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3040 | if (errno) { |
| 3041 | hdd_err("failed to create objmgr vdev: %d", errno); |
| 3042 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3043 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3044 | |
| 3045 | /* Open a SME session (prepare vdev in firmware via legacy API) */ |
| 3046 | INIT_COMPLETION(adapter->session_open_comp_var); |
| 3047 | status = sme_open_session(hdd_ctx->hHal, hdd_sme_roam_callback, adapter, |
| 3048 | (uint8_t *)&adapter->macAddressCurrent, |
| 3049 | adapter->sessionId, type, sub_type); |
| 3050 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3051 | hdd_err("failed to open sme session: %d", status); |
| 3052 | errno = qdf_status_to_os_return(status); |
| 3053 | goto objmgr_vdev_destroy; |
| 3054 | } |
| 3055 | |
| 3056 | /* block on a completion variable until sme session is opened */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3057 | rc = wait_for_completion_timeout( |
| 3058 | &adapter->session_open_comp_var, |
| 3059 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
| 3060 | if (!rc) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3061 | hdd_err("timed out waiting for open sme session: %ld", rc); |
| 3062 | errno = -ETIMEDOUT; |
| 3063 | goto objmgr_vdev_destroy; |
| 3064 | } |
| 3065 | |
| 3066 | /* firmware ready for component communication, raise vdev_ready event */ |
| 3067 | errno = hdd_vdev_ready(adapter); |
| 3068 | if (errno) { |
| 3069 | hdd_err("failed to dispatch vdev ready event: %d", errno); |
| 3070 | goto hdd_vdev_destroy; |
| 3071 | } |
| 3072 | |
| 3073 | hdd_info("vdev %d created successfully", adapter->sessionId); |
| 3074 | |
| 3075 | return 0; |
| 3076 | |
| 3077 | /* |
| 3078 | * Due to legacy constraints, we need to destroy in the same order as |
| 3079 | * create. So, split error handling into 2 cases to accommodate. |
| 3080 | */ |
| 3081 | |
| 3082 | objmgr_vdev_destroy: |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3083 | QDF_BUG(!hdd_objmgr_release_and_destroy_vdev(adapter)); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3084 | |
| 3085 | return errno; |
| 3086 | |
| 3087 | hdd_vdev_destroy: |
| 3088 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
| 3089 | |
| 3090 | return errno; |
| 3091 | } |
| 3092 | |
| 3093 | QDF_STATUS hdd_init_station_mode(hdd_adapter_t *adapter) |
| 3094 | { |
| 3095 | hdd_station_ctx_t *pHddStaCtx = &adapter->sessionCtx.station; |
| 3096 | hdd_context_t *hdd_ctx; |
| 3097 | QDF_STATUS status; |
| 3098 | int ret_val; |
| 3099 | |
| 3100 | ret_val = hdd_vdev_create(adapter); |
| 3101 | if (ret_val) { |
| 3102 | hdd_err("failed to create vdev: %d", ret_val); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 3103 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3104 | } |
| 3105 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3106 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3107 | sme_set_curr_device_mode(hdd_ctx->hHal, adapter->device_mode); |
| 3108 | 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] | 3109 | sme_set_vdev_ies_per_band(hdd_ctx->hHal, adapter->sessionId); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3110 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3111 | /* Register wireless extensions */ |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3112 | status = hdd_register_wext(adapter->dev); |
| 3113 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3114 | hdd_err("failed to register wireless extensions: %d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3115 | goto error_register_wext; |
| 3116 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3117 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3118 | /* Set the Connection State to Not Connected */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3119 | hdd_debug("Set HDD connState to eConnectionState_NotConnected"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3120 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 3121 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 3122 | /* set fast roaming capability in sme session */ |
| 3123 | status = sme_config_fast_roaming(hdd_ctx->hHal, adapter->sessionId, |
| 3124 | adapter->fast_roaming_allowed); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3125 | /* Set the default operation channel */ |
| 3126 | pHddStaCtx->conn_info.operationChannel = |
| 3127 | hdd_ctx->config->OperatingChannel; |
| 3128 | |
| 3129 | /* Make the default Auth Type as OPEN */ |
| 3130 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 3131 | |
| 3132 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3133 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3134 | hdd_err("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3135 | status, status); |
| 3136 | goto error_init_txrx; |
| 3137 | } |
| 3138 | |
| 3139 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3140 | |
| 3141 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3142 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3143 | hdd_err("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3144 | status, status); |
| 3145 | goto error_wmm_init; |
| 3146 | } |
| 3147 | |
| 3148 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3149 | |
| 3150 | ret_val = wma_cli_set_command(adapter->sessionId, |
| 3151 | WMI_PDEV_PARAM_BURST_ENABLE, |
| 3152 | hdd_ctx->config->enableSifsBurst, |
| 3153 | PDEV_CMD); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3154 | if (ret_val) |
| 3155 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", ret_val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3156 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3157 | status = hdd_check_and_init_tdls(adapter); |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 3158 | if (status != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3159 | goto error_tdls_init; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3160 | |
Himanshu Agarwal | 3d95b90 | 2016-08-24 16:27:03 +0530 | [diff] [blame] | 3161 | status = hdd_lro_enable(hdd_ctx, adapter); |
| 3162 | if (status != QDF_STATUS_SUCCESS) |
| 3163 | goto error_lro_enable; |
| 3164 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3165 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3166 | |
Himanshu Agarwal | 3d95b90 | 2016-08-24 16:27:03 +0530 | [diff] [blame] | 3167 | error_lro_enable: |
| 3168 | wlan_hdd_tdls_exit(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3169 | error_tdls_init: |
| 3170 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3171 | hdd_wmm_adapter_close(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3172 | error_wmm_init: |
| 3173 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3174 | hdd_deinit_tx_rx(adapter); |
| 3175 | error_init_txrx: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3176 | hdd_unregister_wext(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3177 | error_register_wext: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3178 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3179 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3180 | return status; |
| 3181 | } |
| 3182 | |
| 3183 | void hdd_cleanup_actionframe(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter) |
| 3184 | { |
| 3185 | hdd_cfg80211_state_t *cfgState; |
| 3186 | |
| 3187 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR(adapter); |
| 3188 | |
| 3189 | if (NULL != cfgState->buf) { |
| 3190 | unsigned long rc; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3191 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3192 | rc = wait_for_completion_timeout( |
| 3193 | &adapter->tx_action_cnf_event, |
| 3194 | msecs_to_jiffies(ACTION_FRAME_TX_TIMEOUT)); |
| 3195 | if (!rc) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3196 | hdd_err("HDD Wait for Action Confirmation Failed!!"); |
Masti, Narayanraddi | f8f6e7e | 2015-08-25 10:22:46 +0530 | [diff] [blame] | 3197 | /* |
| 3198 | * Inform tx status as FAILURE to upper layer and free |
| 3199 | * cfgState->buf |
| 3200 | */ |
| 3201 | hdd_send_action_cnf(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3202 | } |
| 3203 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3204 | } |
| 3205 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3206 | /** |
| 3207 | * hdd_station_adapter_deinit() - De-initialize the station adapter |
| 3208 | * @hdd_ctx: global hdd context |
| 3209 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3210 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 3211 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3212 | * |
| 3213 | * This function De-initializes the STA/P2P/OCB adapter. |
| 3214 | * |
| 3215 | * Return: None. |
| 3216 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3217 | static void hdd_station_adapter_deinit(hdd_context_t *hdd_ctx, |
| 3218 | hdd_adapter_t *adapter, |
| 3219 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3220 | { |
| 3221 | ENTER_DEV(adapter->dev); |
| 3222 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 3223 | if (adapter->dev) { |
| 3224 | if (rtnl_held) |
| 3225 | adapter->dev->wireless_handlers = NULL; |
| 3226 | else { |
| 3227 | rtnl_lock(); |
| 3228 | adapter->dev->wireless_handlers = NULL; |
| 3229 | rtnl_unlock(); |
| 3230 | } |
| 3231 | } |
| 3232 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3233 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 3234 | hdd_deinit_tx_rx(adapter); |
| 3235 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3236 | } |
| 3237 | |
| 3238 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 3239 | hdd_wmm_adapter_close(adapter); |
| 3240 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3241 | } |
| 3242 | |
| 3243 | hdd_cleanup_actionframe(hdd_ctx, adapter); |
| 3244 | wlan_hdd_tdls_exit(adapter); |
| 3245 | |
| 3246 | EXIT(); |
| 3247 | } |
| 3248 | |
| 3249 | /** |
| 3250 | * hdd_ap_adapter_deinit() - De-initialize the ap adapter |
| 3251 | * @hdd_ctx: global hdd context |
| 3252 | * @adapter: HDD adapter |
| 3253 | * @rtnl_held: the rtnl lock hold flag |
| 3254 | * This function De-initializes the AP/P2PGo adapter. |
| 3255 | * |
| 3256 | * Return: None. |
| 3257 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3258 | static void hdd_ap_adapter_deinit(hdd_context_t *hdd_ctx, |
| 3259 | hdd_adapter_t *adapter, |
| 3260 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3261 | { |
| 3262 | ENTER_DEV(adapter->dev); |
| 3263 | |
| 3264 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 3265 | hdd_wmm_adapter_close(adapter); |
| 3266 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3267 | } |
Liangwei Dong | 8baf7c8 | 2016-10-11 01:26:59 -0400 | [diff] [blame] | 3268 | wlan_hdd_undo_acs(adapter); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3269 | |
| 3270 | hdd_cleanup_actionframe(hdd_ctx, adapter); |
| 3271 | |
| 3272 | hdd_unregister_hostapd(adapter, rtnl_held); |
| 3273 | |
| 3274 | EXIT(); |
| 3275 | } |
| 3276 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3277 | void hdd_deinit_adapter(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, |
| 3278 | bool rtnl_held) |
| 3279 | { |
| 3280 | ENTER(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3281 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3282 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3283 | case QDF_STA_MODE: |
| 3284 | case QDF_P2P_CLIENT_MODE: |
| 3285 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3286 | { |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 3287 | hdd_station_adapter_deinit(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3288 | break; |
| 3289 | } |
| 3290 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3291 | case QDF_SAP_MODE: |
| 3292 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3293 | { |
| 3294 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3295 | hdd_ap_adapter_deinit(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3296 | break; |
| 3297 | } |
| 3298 | |
| 3299 | default: |
| 3300 | break; |
| 3301 | } |
| 3302 | |
| 3303 | EXIT(); |
| 3304 | } |
| 3305 | |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3306 | static void hdd_cleanup_adapter(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, |
| 3307 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3308 | { |
| 3309 | struct net_device *pWlanDev = NULL; |
| 3310 | |
| 3311 | if (adapter) |
| 3312 | pWlanDev = adapter->dev; |
| 3313 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3314 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3315 | return; |
| 3316 | } |
| 3317 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 3318 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 3319 | |
| 3320 | if (adapter->scan_info.default_scan_ies) { |
| 3321 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 3322 | adapter->scan_info.default_scan_ies = NULL; |
| 3323 | } |
| 3324 | |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3325 | hdd_adapter_runtime_suspend_denit(adapter); |
| 3326 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3327 | /* |
| 3328 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 3329 | * the driver is almost closed and cannot handle either control |
| 3330 | * messages or data. However, unregister_netdevice() call above will |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3331 | * eventually invoke hdd_stop(ndo_close) driver callback, which attempts |
| 3332 | * to close the active connections(basically excites control path) which |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3333 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 3334 | * the interface is closed and restricts any operations on that |
| 3335 | */ |
| 3336 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 3337 | |
| 3338 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3339 | if (rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3340 | unregister_netdevice(pWlanDev); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3341 | else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3342 | unregister_netdev(pWlanDev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3343 | /* |
| 3344 | * Note that the adapter is no longer valid at this point |
| 3345 | * since the memory has been reclaimed |
| 3346 | */ |
| 3347 | } |
| 3348 | } |
| 3349 | |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3350 | static QDF_STATUS hdd_check_for_existing_macaddr(hdd_context_t *hdd_ctx, |
| 3351 | tSirMacAddr macAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3352 | { |
| 3353 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 3354 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3355 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3356 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3357 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3358 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3359 | adapter = adapterNode->pAdapter; |
| 3360 | if (adapter |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3361 | && !qdf_mem_cmp(adapter->macAddressCurrent.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3362 | macAddr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3363 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3364 | } |
| 3365 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 3366 | adapterNode = pNext; |
| 3367 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3368 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3369 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3370 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3371 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 3372 | /** |
| 3373 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 3374 | * @hdd_ctx: HDD Context |
| 3375 | * @adapter: HDD Adapter |
| 3376 | * |
| 3377 | * This function set the FW Debug log level based on the INI. |
| 3378 | * |
| 3379 | * Return: None |
| 3380 | */ |
| 3381 | static void hdd_set_fw_log_params(hdd_context_t *hdd_ctx, |
| 3382 | hdd_adapter_t *adapter) |
| 3383 | { |
| 3384 | uint8_t count = 0, numentries = 0, |
| 3385 | moduleloglevel[FW_MODULE_LOG_LEVEL_STRING_LENGTH]; |
| 3386 | uint32_t value = 0; |
| 3387 | int ret; |
| 3388 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3389 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 3390 | (!hdd_ctx->config->enable_fw_log)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3391 | 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] | 3392 | return; |
| 3393 | } |
| 3394 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3395 | /* Enable FW logs based on INI configuration */ |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3396 | hdd_ctx->fw_log_settings.dl_type = |
| 3397 | hdd_ctx->config->enableFwLogType; |
| 3398 | ret = wma_cli_set_command(adapter->sessionId, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3399 | WMI_DBGLOG_TYPE, |
| 3400 | hdd_ctx->config->enableFwLogType, |
| 3401 | DBG_CMD); |
| 3402 | if (ret != 0) |
| 3403 | hdd_err("Failed to enable FW log type ret %d", |
| 3404 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3405 | |
| 3406 | hdd_ctx->fw_log_settings.dl_loglevel = |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3407 | hdd_ctx->config->enableFwLogLevel; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3408 | ret = wma_cli_set_command(adapter->sessionId, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3409 | WMI_DBGLOG_LOG_LEVEL, |
| 3410 | hdd_ctx->config->enableFwLogLevel, |
| 3411 | DBG_CMD); |
| 3412 | if (ret != 0) |
| 3413 | hdd_err("Failed to enable FW log level ret %d", |
| 3414 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3415 | |
| 3416 | hdd_string_to_u8_array( |
| 3417 | hdd_ctx->config->enableFwModuleLogLevel, |
| 3418 | moduleloglevel, |
| 3419 | &numentries, |
| 3420 | FW_MODULE_LOG_LEVEL_STRING_LENGTH); |
| 3421 | |
| 3422 | while (count < numentries) { |
| 3423 | /* |
| 3424 | * FW module log level input string looks like |
| 3425 | * below: |
| 3426 | * gFwDebugModuleLoglevel=<FW Module ID>, |
| 3427 | * <Log Level>,... |
| 3428 | * For example: |
| 3429 | * gFwDebugModuleLoglevel= |
| 3430 | * 1,0,2,1,3,2,4,3,5,4,6,5,7,6 |
| 3431 | * Above input string means : |
| 3432 | * For FW module ID 1 enable log level 0 |
| 3433 | * For FW module ID 2 enable log level 1 |
| 3434 | * For FW module ID 3 enable log level 2 |
| 3435 | * For FW module ID 4 enable log level 3 |
| 3436 | * For FW module ID 5 enable log level 4 |
| 3437 | * For FW module ID 6 enable log level 5 |
| 3438 | * For FW module ID 7 enable log level 6 |
| 3439 | */ |
| 3440 | |
Nishank Aggarwal | e239d96 | 2017-03-03 12:26:02 +0530 | [diff] [blame] | 3441 | if ((moduleloglevel[count] > WLAN_MODULE_ID_MAX) |
| 3442 | || (moduleloglevel[count + 1] > DBGLOG_LVL_MAX)) { |
| 3443 | hdd_err("Module id %d and dbglog level %d input length is more than max", |
| 3444 | moduleloglevel[count], |
| 3445 | moduleloglevel[count + 1]); |
| 3446 | return; |
| 3447 | } |
| 3448 | |
| 3449 | value = moduleloglevel[count] << 16; |
| 3450 | value |= moduleloglevel[count + 1]; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3451 | ret = wma_cli_set_command(adapter->sessionId, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3452 | WMI_DBGLOG_MOD_LOG_LEVEL, |
| 3453 | value, DBG_CMD); |
| 3454 | if (ret != 0) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3455 | hdd_err("Failed to enable FW module log level %d ret %d", |
| 3456 | value, ret); |
| 3457 | |
| 3458 | count += 2; |
| 3459 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3460 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3461 | } |
| 3462 | #else |
| 3463 | static void hdd_set_fw_log_params(hdd_context_t *hdd_ctx, |
| 3464 | hdd_adapter_t *adapter) |
| 3465 | { |
| 3466 | } |
| 3467 | |
| 3468 | #endif |
| 3469 | |
| 3470 | /** |
| 3471 | * hdd_set_fw_params() - Set parameters to firmware |
| 3472 | * @adapter: HDD adapter |
| 3473 | * |
| 3474 | * This function Sets various parameters to fw once the |
| 3475 | * adapter is started. |
| 3476 | * |
| 3477 | * Return: 0 on success or errno on failure |
| 3478 | */ |
| 3479 | int hdd_set_fw_params(hdd_adapter_t *adapter) |
| 3480 | { |
| 3481 | int ret; |
| 3482 | hdd_context_t *hdd_ctx; |
| 3483 | |
| 3484 | ENTER_DEV(adapter->dev); |
| 3485 | |
| 3486 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3487 | if (!hdd_ctx) |
| 3488 | return -EINVAL; |
| 3489 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3490 | if ((cds_get_conparam() != QDF_GLOBAL_FTM_MODE) && |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3491 | (!hdd_ctx->config->enable2x2)) { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3492 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 3493 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3494 | /* |
| 3495 | * Disable DTIM 1 chain Rx when in 1x1, |
| 3496 | * we are passing two value |
| 3497 | * as param_id << 29 | param_value. |
| 3498 | * Below param_value = 0(disable) |
| 3499 | */ |
| 3500 | ret = wma_cli_set_command(adapter->sessionId, |
| 3501 | WMI_STA_SMPS_PARAM_CMDID, |
| 3502 | HDD_DTIM_1CHAIN_RX_ID << |
| 3503 | HDD_SMPS_PARAM_VALUE_S, |
| 3504 | VDEV_CMD); |
| 3505 | if (ret) { |
| 3506 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 3507 | goto error; |
| 3508 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3509 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3510 | ret = wma_cli_set_command(adapter->sessionId, |
| 3511 | WMI_PDEV_PARAM_TX_CHAIN_MASK, |
| 3512 | hdd_ctx->config->txchainmask1x1, |
| 3513 | PDEV_CMD); |
| 3514 | if (ret) { |
| 3515 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK set failed %d", |
| 3516 | ret); |
| 3517 | goto error; |
| 3518 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3519 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3520 | ret = wma_cli_set_command(adapter->sessionId, |
| 3521 | WMI_PDEV_PARAM_RX_CHAIN_MASK, |
| 3522 | hdd_ctx->config->rxchainmask1x1, |
| 3523 | PDEV_CMD); |
| 3524 | if (ret) { |
| 3525 | hdd_err("WMI_PDEV_PARAM_RX_CHAIN_MASK set failed %d", |
| 3526 | ret); |
| 3527 | goto error; |
| 3528 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3529 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 3530 | #undef HDD_SMPS_PARAM_VALUE_S |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3531 | } else { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3532 | hdd_debug("FTM Mode or 2x2 mode - Do not set 1x1 params"); |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3533 | } |
| 3534 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3535 | if (QDF_GLOBAL_FTM_MODE != cds_get_conparam()) { |
| 3536 | ret = wma_cli_set_command(adapter->sessionId, |
| 3537 | WMI_PDEV_PARAM_HYST_EN, |
| 3538 | hdd_ctx->config->enableMemDeepSleep, |
| 3539 | PDEV_CMD); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3540 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3541 | if (ret) { |
| 3542 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", |
| 3543 | ret); |
| 3544 | goto error; |
| 3545 | } |
Rajeev Kumar Sirasanagandla | 2dab3ec | 2016-10-18 16:10:15 +0530 | [diff] [blame] | 3546 | |
| 3547 | ret = wma_cli_set_command(adapter->sessionId, |
| 3548 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
| 3549 | hdd_ctx->config->rts_profile, |
| 3550 | VDEV_CMD); |
| 3551 | if (ret) { |
| 3552 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 3553 | goto error; |
| 3554 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3555 | } |
| 3556 | |
| 3557 | hdd_set_fw_log_params(hdd_ctx, adapter); |
| 3558 | |
| 3559 | EXIT(); |
| 3560 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3561 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3562 | error: |
| 3563 | return -EINVAL; |
| 3564 | } |
| 3565 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3566 | /** |
| 3567 | * hdd_open_adapter() - open and setup the hdd adatper |
| 3568 | * @hdd_ctx: global hdd context |
| 3569 | * @session_type: type of the interface to be created |
| 3570 | * @iface_name: User-visible name of the interface |
| 3571 | * @macAddr: MAC address to assign to the interface |
| 3572 | * @name_assign_type: the name of assign type of the netdev |
| 3573 | * @rtnl_held: the rtnl lock hold flag |
| 3574 | * |
| 3575 | * This function open and setup the hdd adpater according to the device |
| 3576 | * type request, assign the name, the mac address assigned, and then prepared |
| 3577 | * the hdd related parameters, queue, lock and ready to start. |
| 3578 | * |
| 3579 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 3580 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3581 | hdd_adapter_t *hdd_open_adapter(hdd_context_t *hdd_ctx, uint8_t session_type, |
| 3582 | const char *iface_name, tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3583 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3584 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3585 | { |
| 3586 | hdd_adapter_t *adapter = NULL; |
| 3587 | hdd_adapter_list_node_t *pHddAdapterNode = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3588 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3589 | hdd_cfg80211_state_t *cfgState; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3590 | |
Srinivas Girigowda | c06543c | 2017-03-09 15:10:03 -0800 | [diff] [blame] | 3591 | hdd_info("%s interface created. iftype: %d", iface_name, session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3592 | |
| 3593 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 3594 | /* |
| 3595 | * Max limit reached on the number of vdevs configured by the |
| 3596 | * host. Return error |
| 3597 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3598 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 3599 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3600 | return NULL; |
| 3601 | } |
| 3602 | |
| 3603 | if (macAddr == NULL) { |
| 3604 | /* Not received valid macAddr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3605 | 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] | 3606 | return NULL; |
| 3607 | } |
| 3608 | status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3609 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3610 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 3611 | " already exists", |
| 3612 | MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3613 | return NULL; |
| 3614 | } |
| 3615 | |
| 3616 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3617 | case QDF_STA_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3618 | /* Reset locally administered bit if the device mode is STA */ |
| 3619 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr); |
| 3620 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3621 | case QDF_P2P_CLIENT_MODE: |
| 3622 | case QDF_P2P_DEVICE_MODE: |
| 3623 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 3624 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3625 | case QDF_MONITOR_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3626 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 3627 | name_assign_type, |
| 3628 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3629 | |
| 3630 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3631 | hdd_err("failed to allocate adapter for session %d", |
| 3632 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3633 | return NULL; |
| 3634 | } |
| 3635 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3636 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3637 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3638 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3639 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3640 | else if (QDF_MONITOR_MODE == session_type) |
| 3641 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3642 | else |
| 3643 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 3644 | |
| 3645 | adapter->device_mode = session_type; |
| 3646 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3647 | if (QDF_NDI_MODE == session_type) { |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 3648 | status = hdd_init_nan_data_mode(adapter); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3649 | if (QDF_STATUS_SUCCESS != status) |
| 3650 | goto err_free_netdev; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3651 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3652 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3653 | /* |
| 3654 | * Workqueue which gets scheduled in IPv4 notification |
| 3655 | * callback |
| 3656 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3657 | INIT_WORK(&adapter->ipv4NotifierWorkQueue, |
| 3658 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3659 | |
| 3660 | #ifdef WLAN_NS_OFFLOAD |
| 3661 | /* |
| 3662 | * Workqueue which gets scheduled in IPv6 |
| 3663 | * notification callback. |
| 3664 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3665 | INIT_WORK(&adapter->ipv6NotifierWorkQueue, |
| 3666 | hdd_ipv6_notifier_work_queue); |
| 3667 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3668 | status = hdd_register_interface(adapter, rtnl_held); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3669 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3670 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 3671 | goto err_free_netdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3672 | } |
| 3673 | |
| 3674 | /* Stop the Interface TX queue. */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3675 | hdd_info("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3676 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 3677 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 3678 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3679 | break; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3680 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3681 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3682 | case QDF_P2P_GO_MODE: |
| 3683 | case QDF_SAP_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3684 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr, |
| 3685 | name_assign_type, |
| 3686 | (uint8_t *) iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3687 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3688 | hdd_err("failed to allocate adapter for session %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3689 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3690 | return NULL; |
| 3691 | } |
| 3692 | |
| 3693 | adapter->wdev.iftype = |
| 3694 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3695 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3696 | NL80211_IFTYPE_P2P_GO; |
| 3697 | adapter->device_mode = session_type; |
| 3698 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3699 | status = hdd_register_hostapd(adapter, rtnl_held); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3700 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3701 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
| 3702 | goto err_free_netdev; |
| 3703 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3704 | hdd_info("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3705 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 3706 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 3707 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3708 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3709 | case QDF_FTM_MODE: |
| 3710 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 3711 | name_assign_type, |
| 3712 | "wlan0"); |
| 3713 | if (NULL == adapter) { |
| 3714 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 3715 | return NULL; |
| 3716 | } |
| 3717 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 3718 | adapter->device_mode = session_type; |
| 3719 | status = hdd_register_interface(adapter, rtnl_held); |
| 3720 | if (QDF_STATUS_SUCCESS != status) { |
| 3721 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
| 3722 | goto err_free_netdev; |
| 3723 | } |
| 3724 | /* Stop the Interface TX queue. */ |
| 3725 | hdd_info("Disabling queues"); |
| 3726 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 3727 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 3728 | WLAN_CONTROL_PATH); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3729 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3730 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3731 | hdd_err("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3732 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3733 | return NULL; |
| 3734 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3735 | |
| 3736 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR(adapter); |
| 3737 | mutex_init(&cfgState->remain_on_chan_ctx_lock); |
| 3738 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3739 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3740 | /* Add it to the hdd's session list. */ |
| 3741 | pHddAdapterNode = |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3742 | qdf_mem_malloc(sizeof(hdd_adapter_list_node_t)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3743 | if (NULL == pHddAdapterNode) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3744 | status = QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3745 | } else { |
| 3746 | pHddAdapterNode->pAdapter = adapter; |
| 3747 | status = hdd_add_adapter_back(hdd_ctx, pHddAdapterNode); |
| 3748 | } |
| 3749 | } |
| 3750 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3751 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3752 | if (NULL != adapter) { |
| 3753 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 3754 | adapter = NULL; |
| 3755 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3756 | if (NULL != pHddAdapterNode) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3757 | qdf_mem_free(pHddAdapterNode); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3758 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3759 | return NULL; |
| 3760 | } |
| 3761 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3762 | if (QDF_STATUS_SUCCESS == status) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 3763 | policy_mgr_set_concurrency_mode(hdd_ctx->hdd_psoc, |
| 3764 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3765 | |
| 3766 | /* Initialize the WoWL service */ |
| 3767 | if (!hdd_init_wowl(adapter)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3768 | hdd_err("hdd_init_wowl failed"); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 3769 | goto err_close_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3770 | } |
| 3771 | |
| 3772 | /* Adapter successfully added. Increment the vdev count */ |
| 3773 | hdd_ctx->current_intf_count++; |
| 3774 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3775 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3776 | hdd_ctx->current_intf_count); |
| 3777 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 3778 | hdd_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3779 | } |
| 3780 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 3781 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
| 3782 | hdd_err("Interface %s wow debug_fs init failed", iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3783 | |
| 3784 | return adapter; |
| 3785 | |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 3786 | err_close_adapter: |
| 3787 | hdd_close_adapter(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3788 | err_free_netdev: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3789 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->macAddressCurrent.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 3790 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3791 | |
| 3792 | return NULL; |
| 3793 | } |
| 3794 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3795 | QDF_STATUS hdd_close_adapter(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3796 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3797 | { |
| 3798 | hdd_adapter_list_node_t *adapterNode, *pCurrent, *pNext; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3799 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3800 | |
| 3801 | status = hdd_get_front_adapter(hdd_ctx, &pCurrent); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3802 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3803 | hdd_warn("adapter list empty %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3804 | status); |
| 3805 | return status; |
| 3806 | } |
| 3807 | |
| 3808 | while (pCurrent->pAdapter != adapter) { |
| 3809 | status = hdd_get_next_adapter(hdd_ctx, pCurrent, &pNext); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3810 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3811 | break; |
| 3812 | |
| 3813 | pCurrent = pNext; |
| 3814 | } |
| 3815 | adapterNode = pCurrent; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3816 | if (QDF_STATUS_SUCCESS == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3817 | hdd_debug("wait for bus bw work to flush"); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 3818 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 3819 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 3820 | |
| 3821 | /* cleanup adapter */ |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 3822 | policy_mgr_clear_concurrency_mode(hdd_ctx->hdd_psoc, |
| 3823 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3824 | hdd_cleanup_adapter(hdd_ctx, adapterNode->pAdapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3825 | hdd_remove_adapter(hdd_ctx, adapterNode); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3826 | qdf_mem_free(adapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3827 | adapterNode = NULL; |
| 3828 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 3829 | /* conditionally restart the bw timer */ |
| 3830 | hdd_bus_bw_compute_timer_try_start(hdd_ctx); |
| 3831 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3832 | /* Adapter removed. Decrement vdev count */ |
| 3833 | if (hdd_ctx->current_intf_count != 0) |
| 3834 | hdd_ctx->current_intf_count--; |
| 3835 | |
| 3836 | /* Fw will take care incase of concurrency */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3837 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3838 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3839 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3840 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3841 | } |
| 3842 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3843 | /** |
| 3844 | * hdd_close_all_adapters - Close all open adapters |
| 3845 | * @hdd_ctx: Hdd context |
| 3846 | * rtnl_held: True if RTNL lock held |
| 3847 | * |
| 3848 | * Close all open adapters. |
| 3849 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3850 | * Return: QDF status code |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3851 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3852 | QDF_STATUS hdd_close_all_adapters(hdd_context_t *hdd_ctx, bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3853 | { |
| 3854 | hdd_adapter_list_node_t *pHddAdapterNode; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3855 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3856 | |
| 3857 | ENTER(); |
| 3858 | |
| 3859 | do { |
| 3860 | status = hdd_remove_front_adapter(hdd_ctx, &pHddAdapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3861 | if (pHddAdapterNode && QDF_STATUS_SUCCESS == status) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3862 | wlan_hdd_release_intf_addr(hdd_ctx, |
| 3863 | pHddAdapterNode->pAdapter->macAddressCurrent.bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3864 | hdd_cleanup_adapter(hdd_ctx, pHddAdapterNode->pAdapter, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3865 | rtnl_held); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3866 | qdf_mem_free(pHddAdapterNode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3867 | /* Adapter removed. Decrement vdev count */ |
| 3868 | if (hdd_ctx->current_intf_count != 0) |
| 3869 | hdd_ctx->current_intf_count--; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3870 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3871 | } while (NULL != pHddAdapterNode && QDF_STATUS_E_EMPTY != status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3872 | |
| 3873 | EXIT(); |
| 3874 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3875 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3876 | } |
| 3877 | |
| 3878 | void wlan_hdd_reset_prob_rspies(hdd_adapter_t *pHostapdAdapter) |
| 3879 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3880 | struct qdf_mac_addr *bssid = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3881 | tSirUpdateIE updateIE; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3882 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3883 | switch (pHostapdAdapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3884 | case QDF_STA_MODE: |
| 3885 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3886 | { |
| 3887 | hdd_station_ctx_t *pHddStaCtx = |
| 3888 | WLAN_HDD_GET_STATION_CTX_PTR(pHostapdAdapter); |
Srinivas Girigowda | 8b98396 | 2015-11-18 22:14:34 -0800 | [diff] [blame] | 3889 | bssid = &pHddStaCtx->conn_info.bssId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3890 | break; |
| 3891 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3892 | case QDF_SAP_MODE: |
| 3893 | case QDF_P2P_GO_MODE: |
| 3894 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3895 | { |
Srinivas Girigowda | 8b98396 | 2015-11-18 22:14:34 -0800 | [diff] [blame] | 3896 | bssid = &pHostapdAdapter->macAddressCurrent; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3897 | break; |
| 3898 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3899 | case QDF_FTM_MODE: |
| 3900 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3901 | default: |
| 3902 | /* |
| 3903 | * wlan_hdd_reset_prob_rspies should not have been called |
| 3904 | * for these kind of devices |
| 3905 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3906 | hdd_err("Unexpected request for the current device type %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3907 | pHostapdAdapter->device_mode); |
| 3908 | return; |
| 3909 | } |
| 3910 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 3911 | qdf_copy_macaddr(&updateIE.bssid, bssid); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3912 | updateIE.smeSessionId = pHostapdAdapter->sessionId; |
| 3913 | updateIE.ieBufferlength = 0; |
| 3914 | updateIE.pAdditionIEBuffer = NULL; |
| 3915 | updateIE.append = true; |
| 3916 | updateIE.notify = false; |
| 3917 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(pHostapdAdapter), |
| 3918 | &updateIE, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3919 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3920 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3921 | } |
| 3922 | } |
| 3923 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3924 | QDF_STATUS hdd_stop_adapter(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3925 | const bool bCloseSession) |
| 3926 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3927 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3928 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(adapter); |
| 3929 | union iwreq_data wrqu; |
| 3930 | tSirUpdateIE updateIE; |
| 3931 | unsigned long rc; |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 3932 | hdd_scaninfo_t *scan_info = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3933 | |
| 3934 | ENTER(); |
| 3935 | |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 3936 | scan_info = &adapter->scan_info; |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3937 | hdd_notice("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 3938 | wlan_hdd_netif_queue_control(adapter, |
| 3939 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 3940 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3941 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3942 | case QDF_STA_MODE: |
| 3943 | case QDF_P2P_CLIENT_MODE: |
| 3944 | case QDF_IBSS_MODE: |
| 3945 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3946 | case QDF_NDI_MODE: |
| 3947 | if ((QDF_NDI_MODE == adapter->device_mode) || |
| 3948 | hdd_conn_is_connected( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3949 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)) || |
| 3950 | hdd_is_connecting( |
| 3951 | WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3952 | INIT_COMPLETION(adapter->disconnect_comp_var); |
| 3953 | /* |
| 3954 | * For NDI do not use pWextState from sta_ctx, if needed |
| 3955 | * extract from ndi_ctx. |
| 3956 | */ |
| 3957 | if (QDF_NDI_MODE == adapter->device_mode) |
| 3958 | qdf_ret_status = sme_roam_disconnect( |
| 3959 | hdd_ctx->hHal, |
| 3960 | adapter->sessionId, |
| 3961 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
| 3962 | else if (pWextState->roamProfile.BSSType == |
| 3963 | eCSR_BSS_TYPE_START_IBSS) |
| 3964 | qdf_ret_status = sme_roam_disconnect( |
| 3965 | hdd_ctx->hHal, |
| 3966 | adapter->sessionId, |
| 3967 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3968 | else |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3969 | qdf_ret_status = sme_roam_disconnect( |
| 3970 | hdd_ctx->hHal, |
| 3971 | adapter->sessionId, |
| 3972 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3973 | /* success implies disconnect command got |
| 3974 | * queued up successfully |
| 3975 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3976 | if (qdf_ret_status == QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3977 | rc = wait_for_completion_timeout( |
| 3978 | &adapter->disconnect_comp_var, |
| 3979 | msecs_to_jiffies |
| 3980 | (WLAN_WAIT_TIME_DISCONNECT)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3981 | if (!rc) |
| 3982 | hdd_warn("wait on disconnect_comp_var failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3983 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3984 | hdd_err("failed to post disconnect event to SME"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3985 | } |
| 3986 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 3987 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 3988 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 3989 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 3990 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 3991 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3992 | if (scan_info != NULL && scan_info->mScanPending) |
Mahesh A Saptasagar | ebb47fa | 2016-07-21 18:11:38 +0530 | [diff] [blame] | 3993 | wlan_hdd_scan_abort(adapter); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3994 | |
Himanshu Agarwal | 3d95b90 | 2016-08-24 16:27:03 +0530 | [diff] [blame] | 3995 | hdd_lro_disable(hdd_ctx, adapter); |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 3996 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3997 | |
| 3998 | #ifdef WLAN_OPEN_SOURCE |
| 3999 | cancel_work_sync(&adapter->ipv4NotifierWorkQueue); |
| 4000 | #endif |
| 4001 | |
| 4002 | hdd_deregister_tx_flow_control(adapter); |
| 4003 | |
| 4004 | #ifdef WLAN_NS_OFFLOAD |
| 4005 | #ifdef WLAN_OPEN_SOURCE |
| 4006 | cancel_work_sync(&adapter->ipv6NotifierWorkQueue); |
| 4007 | #endif |
| 4008 | #endif |
| 4009 | |
| 4010 | /* |
| 4011 | * It is possible that the caller of this function does not |
| 4012 | * wish to close the session |
| 4013 | */ |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 4014 | if (true == bCloseSession) { |
| 4015 | if (0 != wlan_hdd_try_disconnect(adapter)) { |
| 4016 | hdd_err("Error: Can't disconnect adapter"); |
| 4017 | return QDF_STATUS_E_FAILURE; |
| 4018 | } |
Dustin Brown | 0d2eeae | 2017-03-24 15:21:32 -0700 | [diff] [blame] | 4019 | hdd_vdev_destroy(adapter); |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 4020 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4021 | break; |
| 4022 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4023 | case QDF_SAP_MODE: |
| 4024 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4025 | /* Any softap specific cleanup here... */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4026 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4027 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 4028 | |
| 4029 | hdd_deregister_tx_flow_control(adapter); |
| 4030 | |
| 4031 | mutex_lock(&hdd_ctx->sap_lock); |
| 4032 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4033 | QDF_STATUS status; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4034 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4035 | |
| 4036 | /* Stop Bss. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4037 | status = wlansap_stop_bss( |
| 4038 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4039 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4040 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4041 | hdd_hostapd_state_t *hostapd_state = |
| 4042 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4043 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4044 | qdf_stop_bss_event); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4045 | qdf_status = |
| 4046 | qdf_wait_single_event(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 4047 | qdf_stop_bss_event, |
| 4048 | SME_CMD_TIMEOUT_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4049 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4050 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4051 | hdd_err("failure waiting for wlansap_stop_bss %d", |
| 4052 | qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4053 | } |
| 4054 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4055 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4056 | } |
| 4057 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4058 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 4059 | adapter->device_mode, |
| 4060 | adapter->sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4061 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 4062 | qdf_copy_macaddr(&updateIE.bssid, |
Srinivas Girigowda | 8b98396 | 2015-11-18 22:14:34 -0800 | [diff] [blame] | 4063 | &adapter->macAddressCurrent); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4064 | updateIE.smeSessionId = adapter->sessionId; |
| 4065 | updateIE.ieBufferlength = 0; |
| 4066 | updateIE.pAdditionIEBuffer = NULL; |
| 4067 | updateIE.append = false; |
| 4068 | updateIE.notify = false; |
| 4069 | /* Probe bcn reset */ |
| 4070 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 4071 | &updateIE, eUPDATE_IE_PROBE_BCN) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4072 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4073 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4074 | } |
| 4075 | /* Assoc resp reset */ |
| 4076 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 4077 | &updateIE, |
| 4078 | eUPDATE_IE_ASSOC_RESP) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4079 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4080 | hdd_err("Could not pass on ASSOC_RSP data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4081 | } |
| 4082 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 4083 | wlan_hdd_reset_prob_rspies(adapter); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 4084 | qdf_mem_free(adapter->sessionCtx.ap.beacon); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4085 | adapter->sessionCtx.ap.beacon = NULL; |
| 4086 | } |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 4087 | if (true == bCloseSession) |
Dustin Brown | 0d2eeae | 2017-03-24 15:21:32 -0700 | [diff] [blame] | 4088 | hdd_vdev_destroy(adapter); |
Manikandan Mohan | 5df7827 | 2017-03-22 16:28:50 -0700 | [diff] [blame] | 4089 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4090 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4091 | case QDF_OCB_MODE: |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 4092 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 4093 | (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX), |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 4094 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.staId[0]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4095 | break; |
| 4096 | default: |
| 4097 | break; |
| 4098 | } |
| 4099 | |
| 4100 | EXIT(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4101 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4102 | } |
| 4103 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4104 | /** |
| 4105 | * hdd_deinit_all_adapters - deinit all adapters |
| 4106 | * @hdd_ctx: HDD context |
| 4107 | * @rtnl_held: True if RTNL lock held |
| 4108 | * |
| 4109 | */ |
| 4110 | void hdd_deinit_all_adapters(hdd_context_t *hdd_ctx, bool rtnl_held) |
| 4111 | { |
| 4112 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 4113 | QDF_STATUS status; |
| 4114 | hdd_adapter_t *adapter; |
| 4115 | |
| 4116 | ENTER(); |
| 4117 | |
| 4118 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 4119 | |
| 4120 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 4121 | adapter = adapter_node->pAdapter; |
| 4122 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
| 4123 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 4124 | adapter_node = next; |
| 4125 | } |
| 4126 | |
| 4127 | EXIT(); |
| 4128 | } |
| 4129 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4130 | QDF_STATUS hdd_stop_all_adapters(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4131 | { |
| 4132 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4133 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4134 | hdd_adapter_t *adapter; |
| 4135 | |
| 4136 | ENTER(); |
| 4137 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 4138 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 4139 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4140 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4141 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4142 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4143 | adapter = adapterNode->pAdapter; |
| 4144 | hdd_stop_adapter(hdd_ctx, adapter, true); |
| 4145 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4146 | adapterNode = pNext; |
| 4147 | } |
| 4148 | |
| 4149 | EXIT(); |
| 4150 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4151 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4152 | } |
| 4153 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4154 | QDF_STATUS hdd_reset_all_adapters(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4155 | { |
| 4156 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4157 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4158 | hdd_adapter_t *adapter; |
| 4159 | |
| 4160 | ENTER(); |
| 4161 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 4162 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 4163 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4164 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4165 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4166 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4167 | adapter = adapterNode->pAdapter; |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4168 | hdd_notice("Disabling queues"); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 4169 | if (hdd_ctx->config->sap_internal_restart && |
| 4170 | adapter->device_mode == QDF_SAP_MODE) { |
| 4171 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4172 | WLAN_STOP_ALL_NETIF_QUEUE, |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 4173 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 4174 | if (test_bit(SOFTAP_BSS_STARTED, |
| 4175 | &adapter->event_flags)) { |
| 4176 | hdd_sap_indicate_disconnect_for_sta(adapter); |
| 4177 | hdd_cleanup_actionframe(hdd_ctx, adapter); |
| 4178 | hdd_sap_destroy_events(adapter); |
| 4179 | } |
| 4180 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
| 4181 | } else { |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 4182 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4183 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4184 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 4185 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4186 | |
| 4187 | adapter->sessionCtx.station.hdd_ReassocScenario = false; |
| 4188 | |
| 4189 | hdd_deinit_tx_rx(adapter); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4190 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 4191 | adapter->device_mode, adapter->sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4192 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 4193 | hdd_wmm_adapter_close(adapter); |
| 4194 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4195 | } |
| 4196 | |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 4197 | /* |
| 4198 | * If adapter is SAP, set session ID to invalid since SAP |
| 4199 | * session will be cleanup during SSR. |
| 4200 | */ |
| 4201 | if (adapter->device_mode == QDF_SAP_MODE) |
| 4202 | wlansap_set_invalid_session( |
| 4203 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 4204 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4205 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4206 | adapterNode = pNext; |
| 4207 | } |
| 4208 | |
| 4209 | EXIT(); |
| 4210 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4211 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4212 | } |
| 4213 | |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 4214 | bool hdd_check_for_opened_interfaces(hdd_context_t *hdd_ctx) |
| 4215 | { |
| 4216 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 4217 | QDF_STATUS status; |
| 4218 | bool close_modules = true; |
| 4219 | |
| 4220 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 4221 | while ((NULL != adapter_node) && (QDF_STATUS_SUCCESS == status)) { |
| 4222 | if (test_bit(DEVICE_IFACE_OPENED, |
| 4223 | &adapter_node->pAdapter->event_flags)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4224 | hdd_debug("Still other ifaces are up cannot close modules"); |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 4225 | close_modules = false; |
| 4226 | break; |
| 4227 | } |
| 4228 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 4229 | adapter_node = next; |
| 4230 | } |
| 4231 | |
| 4232 | return close_modules; |
| 4233 | } |
| 4234 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4235 | /** |
| 4236 | * hdd_is_interface_up()- Checkfor interface up before ssr |
| 4237 | * @hdd_ctx: HDD context |
| 4238 | * |
| 4239 | * check if there are any wlan interfaces before SSR accordingly start |
| 4240 | * the interface. |
| 4241 | * |
| 4242 | * Return: 0 if interface was opened else false |
| 4243 | */ |
| 4244 | static bool hdd_is_interface_up(hdd_adapter_t *adapter) |
| 4245 | { |
| 4246 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 4247 | return true; |
| 4248 | else |
| 4249 | return false; |
| 4250 | } |
| 4251 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4252 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
Abhishek Singh | b5e38ef | 2017-01-02 12:09:34 +0530 | [diff] [blame] | 4253 | && !defined(WITH_BACKPORTS) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4254 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 4255 | struct ieee80211_channel *channel, |
| 4256 | const u8 *bssid, const u8 *ssid, |
| 4257 | size_t ssid_len) |
| 4258 | { |
| 4259 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 4260 | ssid, ssid_len, |
| 4261 | WLAN_CAPABILITY_ESS, |
| 4262 | WLAN_CAPABILITY_ESS); |
| 4263 | } |
| 4264 | #else |
| 4265 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 4266 | struct ieee80211_channel *channel, |
| 4267 | const u8 *bssid, const u8 *ssid, |
| 4268 | size_t ssid_len) |
| 4269 | { |
| 4270 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 4271 | ssid, ssid_len, |
| 4272 | IEEE80211_BSS_TYPE_ESS, |
| 4273 | IEEE80211_PRIVACY_ANY); |
| 4274 | } |
| 4275 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4276 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4277 | #if defined CFG80211_CONNECT_BSS |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4278 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
| 4279 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)) |
| 4280 | /** |
| 4281 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 4282 | * @timeout_reason: reason for connect timeout |
| 4283 | * |
| 4284 | * This function is used to convert host timeout |
| 4285 | * reason enum to kernel specific enum. |
| 4286 | * |
| 4287 | * Return: nl timeout enum |
| 4288 | */ |
| 4289 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 4290 | tSirResultCodes timeout_reason) |
| 4291 | { |
| 4292 | switch (timeout_reason) { |
| 4293 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 4294 | return NL80211_TIMEOUT_SCAN; |
| 4295 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 4296 | return NL80211_TIMEOUT_AUTH; |
| 4297 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 4298 | return NL80211_TIMEOUT_ASSOC; |
| 4299 | default: |
| 4300 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 4301 | } |
| 4302 | } |
| 4303 | |
| 4304 | /** |
| 4305 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 4306 | * @dev: network device |
| 4307 | * @bssid: bssid to which we want to associate |
| 4308 | * @timeout_reason: reason for connect timeout |
| 4309 | * |
| 4310 | * This API is used to send connection timeout reason to supplicant |
| 4311 | * |
| 4312 | * Return: void |
| 4313 | */ |
| 4314 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 4315 | const u8 *bssid, |
| 4316 | tSirResultCodes timeout_reason) |
| 4317 | { |
| 4318 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4319 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4320 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 4321 | |
| 4322 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 4323 | nl_timeout_reason); |
| 4324 | } |
| 4325 | |
| 4326 | /** |
| 4327 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 4328 | * @dev: network device |
| 4329 | * @bssid: bssid to which we want to associate |
| 4330 | * @req_ie: Request Information Element |
| 4331 | * @req_ie_len: len of the req IE |
| 4332 | * @resp_ie: Response IE |
| 4333 | * @resp_ie_len: len of ht response IE |
| 4334 | * @status: status |
| 4335 | * @gfp: Kernel Flag |
| 4336 | * @timeout_reason: reason for connect timeout |
| 4337 | * |
| 4338 | * Return: void |
| 4339 | */ |
| 4340 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 4341 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 4342 | size_t req_ie_len, const u8 *resp_ie, |
| 4343 | size_t resp_ie_len, int status, gfp_t gfp, |
| 4344 | tSirResultCodes timeout_reason) |
| 4345 | { |
| 4346 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4347 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4348 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 4349 | |
| 4350 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 4351 | resp_ie, resp_ie_len, status, gfp, |
| 4352 | nl_timeout_reason); |
| 4353 | } |
| 4354 | #else |
| 4355 | #if defined CFG80211_CONNECT_TIMEOUT |
| 4356 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 4357 | const u8 *bssid, |
| 4358 | tSirResultCodes timeout_reason) |
| 4359 | { |
| 4360 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 4361 | } |
| 4362 | #endif |
| 4363 | |
| 4364 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 4365 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 4366 | size_t req_ie_len, const u8 *resp_ie, |
| 4367 | size_t resp_ie_len, int status, gfp_t gfp, |
| 4368 | tSirResultCodes timeout_reason) |
| 4369 | { |
| 4370 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 4371 | resp_ie, resp_ie_len, status, gfp); |
| 4372 | } |
| 4373 | #endif |
| 4374 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4375 | /** |
| 4376 | * hdd_connect_bss() - API to send connection status to supplicant |
| 4377 | * @dev: network device |
| 4378 | * @bssid: bssid to which we want to associate |
| 4379 | * @req_ie: Request Information Element |
| 4380 | * @req_ie_len: len of the req IE |
| 4381 | * @resp_ie: Response IE |
| 4382 | * @resp_ie_len: len of ht response IE |
| 4383 | * @status: status |
| 4384 | * @gfp: Kernel Flag |
| 4385 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4386 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4387 | * |
| 4388 | * The API is a wrapper to send connection status to supplicant |
| 4389 | * |
| 4390 | * Return: Void |
| 4391 | */ |
| 4392 | #if defined CFG80211_CONNECT_TIMEOUT |
| 4393 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 4394 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 4395 | size_t req_ie_len, const u8 *resp_ie, |
| 4396 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4397 | bool connect_timeout, |
| 4398 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4399 | { |
| 4400 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4401 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4402 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4403 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 4404 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4405 | } |
| 4406 | #else |
| 4407 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 4408 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 4409 | size_t req_ie_len, const u8 *resp_ie, |
| 4410 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4411 | bool connect_timeout, |
| 4412 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4413 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4414 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 4415 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4416 | } |
| 4417 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4418 | |
| 4419 | /** |
| 4420 | * hdd_connect_result() - API to send connection status to supplicant |
| 4421 | * @dev: network device |
| 4422 | * @bssid: bssid to which we want to associate |
| 4423 | * @roam_info: information about connected bss |
| 4424 | * @req_ie: Request Information Element |
| 4425 | * @req_ie_len: len of the req IE |
| 4426 | * @resp_ie: Response IE |
| 4427 | * @resp_ie_len: len of ht response IE |
| 4428 | * @status: status |
| 4429 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4430 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4431 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4432 | * |
| 4433 | * The API is a wrapper to send connection status to supplicant |
| 4434 | * and allow runtime suspend |
| 4435 | * |
| 4436 | * Return: Void |
| 4437 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4438 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
| 4439 | tCsrRoamInfo *roam_info, const u8 *req_ie, |
| 4440 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4441 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4442 | bool connect_timeout, |
| 4443 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4444 | { |
| 4445 | hdd_adapter_t *padapter = (hdd_adapter_t *) netdev_priv(dev); |
| 4446 | struct cfg80211_bss *bss = NULL; |
| 4447 | |
| 4448 | if (WLAN_STATUS_SUCCESS == status) { |
| 4449 | struct ieee80211_channel *chan; |
| 4450 | int freq; |
| 4451 | int chan_no = roam_info->pBssDesc->channelId; |
| 4452 | |
| 4453 | if (chan_no <= 14) |
| 4454 | freq = ieee80211_channel_to_frequency(chan_no, |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 4455 | NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4456 | else |
| 4457 | freq = ieee80211_channel_to_frequency(chan_no, |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 4458 | NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4459 | |
| 4460 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
| 4461 | bss = hdd_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
| 4462 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 4463 | roam_info->u.pConnectedProfile->SSID.length); |
| 4464 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 4465 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4466 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 4467 | req_ie_len, resp_ie, resp_ie_len, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4468 | status, gfp, connect_timeout, timeout_reason); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 4469 | |
| 4470 | qdf_runtime_pm_allow_suspend(padapter->connect_rpm_ctx.connect); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4471 | } |
| 4472 | #else |
| 4473 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
| 4474 | tCsrRoamInfo *roam_info, const u8 *req_ie, |
| 4475 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4476 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4477 | bool connect_timeout, |
| 4478 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4479 | { |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 4480 | hdd_adapter_t *padapter = (hdd_adapter_t *) netdev_priv(dev); |
| 4481 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4482 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 4483 | resp_ie, resp_ie_len, status, gfp); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 4484 | qdf_runtime_pm_allow_suspend(padapter->connect_rpm_ctx.connect); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4485 | } |
| 4486 | #endif |
| 4487 | |
| 4488 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4489 | QDF_STATUS hdd_start_all_adapters(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4490 | { |
| 4491 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4492 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4493 | hdd_adapter_t *adapter; |
| 4494 | #ifndef MSM_PLATFORM |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4495 | struct qdf_mac_addr bcastMac = QDF_MAC_ADDR_BROADCAST_INITIALIZER; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4496 | #endif |
| 4497 | eConnectionState connState; |
| 4498 | |
| 4499 | ENTER(); |
| 4500 | |
| 4501 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4502 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4503 | adapter = adapterNode->pAdapter; |
| 4504 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4505 | if (!hdd_is_interface_up(adapter)) |
Hanumanth Reddy Pothula | c1c4d2b | 2016-09-22 15:45:16 +0530 | [diff] [blame] | 4506 | goto get_adapter; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4507 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4508 | hdd_wmm_init(adapter); |
| 4509 | |
| 4510 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4511 | case QDF_STA_MODE: |
| 4512 | case QDF_P2P_CLIENT_MODE: |
| 4513 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4514 | |
| 4515 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 4516 | ->conn_info.connState; |
| 4517 | |
| 4518 | hdd_init_station_mode(adapter); |
| 4519 | /* Open the gates for HDD to receive Wext commands */ |
| 4520 | adapter->isLinkUpSvcNeeded = false; |
| 4521 | adapter->scan_info.mScanPending = false; |
| 4522 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4523 | /* Indicate disconnect event to supplicant |
| 4524 | * if associated previously |
| 4525 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4526 | if (eConnectionState_Associated == connState || |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 4527 | eConnectionState_IbssConnected == connState || |
| 4528 | eConnectionState_NotConnected == connState || |
| 4529 | eConnectionState_IbssDisconnected == connState || |
| 4530 | eConnectionState_Disconnecting == connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4531 | union iwreq_data wrqu; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4532 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4533 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 4534 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 4535 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 4536 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 4537 | &wrqu, NULL); |
| 4538 | adapter->sessionCtx.station. |
| 4539 | hdd_ReassocScenario = false; |
| 4540 | |
| 4541 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 4542 | wlan_hdd_cfg80211_indicate_disconnect( |
| 4543 | adapter->dev, false, |
| 4544 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4545 | } else if (eConnectionState_Connecting == connState) { |
| 4546 | /* |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4547 | * Indicate connect failure to supplicant if we |
| 4548 | * were in the process of connecting |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4549 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4550 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4551 | NULL, 0, NULL, 0, |
| 4552 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4553 | GFP_KERNEL, false, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4554 | } |
| 4555 | |
| 4556 | hdd_register_tx_flow_control(adapter, |
| 4557 | hdd_tx_resume_timer_expired_handler, |
| 4558 | hdd_tx_resume_cb); |
| 4559 | |
| 4560 | break; |
| 4561 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4562 | case QDF_SAP_MODE: |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4563 | if (hdd_ctx->config->sap_internal_restart) |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 4564 | hdd_init_ap_mode(adapter, true); |
| 4565 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4566 | break; |
| 4567 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4568 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4569 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4570 | hdd_debug("[SSR] send stop ap to supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4571 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 4572 | #else |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4573 | hdd_debug("[SSR] send restart supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4574 | /* event supplicant to restart */ |
| 4575 | cfg80211_del_sta(adapter->dev, |
| 4576 | (const u8 *)&bcastMac.bytes[0], |
| 4577 | GFP_KERNEL); |
| 4578 | #endif |
| 4579 | break; |
| 4580 | |
| 4581 | default: |
| 4582 | break; |
| 4583 | } |
Hanumanth Reddy Pothula | c1c4d2b | 2016-09-22 15:45:16 +0530 | [diff] [blame] | 4584 | get_adapter: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4585 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4586 | adapterNode = pNext; |
| 4587 | } |
| 4588 | |
| 4589 | EXIT(); |
| 4590 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4591 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4592 | } |
| 4593 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4594 | QDF_STATUS hdd_get_front_adapter(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4595 | hdd_adapter_list_node_t **padapterNode) |
| 4596 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4597 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4598 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4599 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4600 | status = qdf_list_peek_front(&hdd_ctx->hddAdapters, |
| 4601 | (qdf_list_node_t **) padapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4602 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4603 | return status; |
| 4604 | } |
| 4605 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4606 | QDF_STATUS hdd_get_next_adapter(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4607 | hdd_adapter_list_node_t *adapterNode, |
| 4608 | hdd_adapter_list_node_t **pNextAdapterNode) |
| 4609 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4610 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4611 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4612 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4613 | status = qdf_list_peek_next(&hdd_ctx->hddAdapters, |
| 4614 | (qdf_list_node_t *) adapterNode, |
| 4615 | (qdf_list_node_t **) pNextAdapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4616 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4617 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4618 | return status; |
| 4619 | } |
| 4620 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4621 | QDF_STATUS hdd_remove_adapter(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4622 | hdd_adapter_list_node_t *adapterNode) |
| 4623 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4624 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4625 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4626 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4627 | status = qdf_list_remove_node(&hdd_ctx->hddAdapters, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4628 | &adapterNode->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4629 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4630 | return status; |
| 4631 | } |
| 4632 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4633 | QDF_STATUS hdd_remove_front_adapter(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4634 | hdd_adapter_list_node_t **padapterNode) |
| 4635 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4636 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4637 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4638 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4639 | status = qdf_list_remove_front(&hdd_ctx->hddAdapters, |
| 4640 | (qdf_list_node_t **) padapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4641 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4642 | return status; |
| 4643 | } |
| 4644 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4645 | QDF_STATUS hdd_add_adapter_back(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4646 | hdd_adapter_list_node_t *adapterNode) |
| 4647 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4648 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4649 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4650 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4651 | status = qdf_list_insert_back(&hdd_ctx->hddAdapters, |
| 4652 | (qdf_list_node_t *) adapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4653 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4654 | return status; |
| 4655 | } |
| 4656 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4657 | QDF_STATUS hdd_add_adapter_front(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4658 | hdd_adapter_list_node_t *adapterNode) |
| 4659 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4660 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4661 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4662 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4663 | status = qdf_list_insert_front(&hdd_ctx->hddAdapters, |
| 4664 | (qdf_list_node_t *) adapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4665 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4666 | return status; |
| 4667 | } |
| 4668 | |
| 4669 | hdd_adapter_t *hdd_get_adapter_by_macaddr(hdd_context_t *hdd_ctx, |
| 4670 | tSirMacAddr macAddr) |
| 4671 | { |
| 4672 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 4673 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4674 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4675 | |
| 4676 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4677 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4678 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4679 | adapter = adapterNode->pAdapter; |
| 4680 | |
| 4681 | if (adapter |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4682 | && !qdf_mem_cmp(adapter->macAddressCurrent.bytes, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4683 | macAddr, sizeof(tSirMacAddr))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4684 | return adapter; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4685 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4686 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4687 | adapterNode = pNext; |
| 4688 | } |
| 4689 | |
| 4690 | return NULL; |
| 4691 | |
| 4692 | } |
| 4693 | |
| 4694 | hdd_adapter_t *hdd_get_adapter_by_vdev(hdd_context_t *hdd_ctx, |
| 4695 | uint32_t vdev_id) |
| 4696 | { |
| 4697 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 4698 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4699 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4700 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4701 | qdf_status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4702 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4703 | while ((NULL != adapterNode) && (QDF_STATUS_SUCCESS == qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4704 | adapter = adapterNode->pAdapter; |
| 4705 | |
| 4706 | if (adapter->sessionId == vdev_id) |
| 4707 | return adapter; |
| 4708 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4709 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4710 | hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4711 | adapterNode = pNext; |
| 4712 | } |
| 4713 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4714 | hdd_err("vdev_id %d does not exist with host", vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4715 | |
| 4716 | return NULL; |
| 4717 | } |
| 4718 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 4719 | /** |
| 4720 | * hdd_get_adapter_by_sme_session_id() - Return adapter with |
| 4721 | * the sessionid |
| 4722 | * @hdd_ctx: hdd context. |
| 4723 | * @sme_session_id: sme session is for the adapter to get. |
| 4724 | * |
| 4725 | * This function is used to get the adapter with provided session id |
| 4726 | * |
| 4727 | * Return: adapter pointer if found |
| 4728 | * |
| 4729 | */ |
| 4730 | hdd_adapter_t *hdd_get_adapter_by_sme_session_id(hdd_context_t *hdd_ctx, |
| 4731 | uint32_t sme_session_id) |
| 4732 | { |
| 4733 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 4734 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4735 | QDF_STATUS qdf_status; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 4736 | |
| 4737 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4738 | qdf_status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 4739 | |
| 4740 | while ((NULL != adapter_node) && |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4741 | (QDF_STATUS_SUCCESS == qdf_status)) { |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 4742 | adapter = adapter_node->pAdapter; |
| 4743 | |
| 4744 | if (adapter && |
| 4745 | adapter->sessionId == sme_session_id) |
| 4746 | return adapter; |
| 4747 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4748 | qdf_status = |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 4749 | hdd_get_next_adapter(hdd_ctx, |
| 4750 | adapter_node, &next); |
| 4751 | adapter_node = next; |
| 4752 | } |
| 4753 | return NULL; |
| 4754 | } |
| 4755 | |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 4756 | hdd_adapter_t *hdd_get_adapter_by_iface_name(hdd_context_t *hdd_ctx, |
| 4757 | const char *iface_name) |
| 4758 | { |
| 4759 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 4760 | hdd_adapter_t *adapter; |
| 4761 | QDF_STATUS qdf_status; |
| 4762 | |
| 4763 | qdf_status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 4764 | |
| 4765 | while ((NULL != adapter_node) && |
| 4766 | (QDF_STATUS_SUCCESS == qdf_status)) { |
| 4767 | adapter = adapter_node->pAdapter; |
| 4768 | |
| 4769 | if (adapter && |
| 4770 | !qdf_str_cmp(adapter->dev->name, iface_name)) |
| 4771 | return adapter; |
| 4772 | |
| 4773 | qdf_status = |
| 4774 | hdd_get_next_adapter(hdd_ctx, |
| 4775 | adapter_node, &next); |
| 4776 | adapter_node = next; |
| 4777 | } |
| 4778 | return NULL; |
| 4779 | } |
| 4780 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4781 | /** |
| 4782 | * hdd_get_adapter() - to get adapter matching the mode |
| 4783 | * @hdd_ctx: hdd context |
| 4784 | * @mode: adapter mode |
| 4785 | * |
| 4786 | * This routine will return the pointer to adapter matching |
| 4787 | * with the passed mode. |
| 4788 | * |
| 4789 | * Return: pointer to adapter or null |
| 4790 | */ |
| 4791 | hdd_adapter_t *hdd_get_adapter(hdd_context_t *hdd_ctx, |
| 4792 | enum tQDF_ADAPTER_MODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4793 | { |
| 4794 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 4795 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4796 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4797 | |
| 4798 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4799 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4800 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4801 | adapter = adapterNode->pAdapter; |
| 4802 | |
| 4803 | if (adapter && (mode == adapter->device_mode)) |
| 4804 | return adapter; |
| 4805 | |
| 4806 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4807 | adapterNode = pNext; |
| 4808 | } |
| 4809 | |
| 4810 | return NULL; |
| 4811 | |
| 4812 | } |
| 4813 | |
| 4814 | /** |
| 4815 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 4816 | * @hdd_ctx: Pointer to the HDD context. |
| 4817 | * @mode: Device mode for which operating channel is required. |
| 4818 | * Suported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4819 | * QDF_STA_MODE, |
| 4820 | * QDF_P2P_CLIENT_MODE, |
| 4821 | * QDF_SAP_MODE, |
| 4822 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4823 | * |
| 4824 | * This API returns the operating channel of the requested device mode |
| 4825 | * |
| 4826 | * Return: channel number. "0" id the requested device is not found OR it is |
| 4827 | * not connected. |
| 4828 | */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4829 | uint8_t hdd_get_operating_channel(hdd_context_t *hdd_ctx, |
| 4830 | enum tQDF_ADAPTER_MODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4831 | { |
| 4832 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4833 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4834 | hdd_adapter_t *adapter; |
| 4835 | uint8_t operatingChannel = 0; |
| 4836 | |
| 4837 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4838 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4839 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4840 | adapter = adapterNode->pAdapter; |
| 4841 | |
| 4842 | if (mode == adapter->device_mode) { |
| 4843 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4844 | case QDF_STA_MODE: |
| 4845 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4846 | if (hdd_conn_is_connected |
| 4847 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 4848 | (adapter))) { |
| 4849 | operatingChannel = |
| 4850 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 4851 | (adapter))->conn_info. |
| 4852 | operationChannel; |
| 4853 | } |
| 4854 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4855 | case QDF_SAP_MODE: |
| 4856 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4857 | /* softap connection info */ |
| 4858 | if (test_bit |
| 4859 | (SOFTAP_BSS_STARTED, |
| 4860 | &adapter->event_flags)) |
| 4861 | operatingChannel = |
| 4862 | (WLAN_HDD_GET_AP_CTX_PTR |
| 4863 | (adapter))->operatingChannel; |
| 4864 | break; |
| 4865 | default: |
| 4866 | break; |
| 4867 | } |
| 4868 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4869 | /* Found the device of interest. break the loop */ |
| 4870 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4871 | } |
| 4872 | |
| 4873 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4874 | adapterNode = pNext; |
| 4875 | } |
| 4876 | return operatingChannel; |
| 4877 | } |
| 4878 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4879 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(hdd_context_t * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4880 | hdd_ctx) |
| 4881 | { |
| 4882 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4883 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4884 | hdd_adapter_t *adapter; |
| 4885 | |
| 4886 | ENTER(); |
| 4887 | |
| 4888 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4889 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4890 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4891 | adapter = adapterNode->pAdapter; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4892 | if ((adapter->device_mode == QDF_STA_MODE) || |
| 4893 | (adapter->device_mode == QDF_P2P_CLIENT_MODE) || |
| 4894 | (adapter->device_mode == QDF_IBSS_MODE) || |
| 4895 | (adapter->device_mode == QDF_P2P_DEVICE_MODE) || |
| 4896 | (adapter->device_mode == QDF_SAP_MODE) || |
| 4897 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4898 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 4899 | hdd_unregister_wext(adapter->dev); |
| 4900 | } |
| 4901 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4902 | adapterNode = pNext; |
| 4903 | } |
| 4904 | |
| 4905 | EXIT(); |
| 4906 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4907 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4908 | } |
| 4909 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4910 | QDF_STATUS hdd_abort_mac_scan_all_adapters(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4911 | { |
| 4912 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4913 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4914 | hdd_adapter_t *adapter; |
| 4915 | |
| 4916 | ENTER(); |
| 4917 | |
| 4918 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4919 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4920 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4921 | adapter = adapterNode->pAdapter; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4922 | if ((adapter->device_mode == QDF_STA_MODE) || |
| 4923 | (adapter->device_mode == QDF_P2P_CLIENT_MODE) || |
| 4924 | (adapter->device_mode == QDF_IBSS_MODE) || |
| 4925 | (adapter->device_mode == QDF_P2P_DEVICE_MODE) || |
| 4926 | (adapter->device_mode == QDF_SAP_MODE) || |
| 4927 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4928 | hdd_abort_mac_scan(hdd_ctx, adapter->sessionId, |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4929 | INVALID_SCAN_ID, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4930 | eCSR_SCAN_ABORT_DEFAULT); |
| 4931 | } |
| 4932 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4933 | adapterNode = pNext; |
| 4934 | } |
| 4935 | |
| 4936 | EXIT(); |
| 4937 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4938 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4939 | } |
| 4940 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 4941 | /** |
| 4942 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 4943 | * adapters |
| 4944 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 4945 | * |
| 4946 | * return: QDF_STATUS_SUCCESS |
| 4947 | */ |
| 4948 | static QDF_STATUS hdd_abort_sched_scan_all_adapters(hdd_context_t *hdd_ctx) |
| 4949 | { |
| 4950 | hdd_adapter_list_node_t *adapter_node = NULL, *next_node = NULL; |
| 4951 | QDF_STATUS status; |
| 4952 | hdd_adapter_t *adapter; |
| 4953 | int err; |
| 4954 | |
| 4955 | ENTER(); |
| 4956 | |
| 4957 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 4958 | |
| 4959 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 4960 | adapter = adapter_node->pAdapter; |
| 4961 | if ((adapter->device_mode == QDF_STA_MODE) || |
| 4962 | (adapter->device_mode == QDF_P2P_CLIENT_MODE) || |
| 4963 | (adapter->device_mode == QDF_IBSS_MODE) || |
| 4964 | (adapter->device_mode == QDF_P2P_DEVICE_MODE) || |
| 4965 | (adapter->device_mode == QDF_SAP_MODE) || |
| 4966 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
| 4967 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 4968 | if (err) |
| 4969 | hdd_err("Unable to stop scheduled scan"); |
| 4970 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4971 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, |
| 4972 | &next_node); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 4973 | adapter_node = next_node; |
| 4974 | } |
| 4975 | |
| 4976 | EXIT(); |
| 4977 | |
| 4978 | return QDF_STATUS_SUCCESS; |
| 4979 | } |
| 4980 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4981 | #ifdef WLAN_NS_OFFLOAD |
| 4982 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4983 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4984 | * @hdd_ctx: Pointer to hdd context |
| 4985 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4986 | * Unregister for IPv6 address change notifications. |
| 4987 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4988 | * Return: None |
| 4989 | */ |
| 4990 | static void hdd_wlan_unregister_ip6_notifier(hdd_context_t *hdd_ctx) |
| 4991 | { |
| 4992 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4993 | } |
| 4994 | |
| 4995 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4996 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4997 | * @hdd_ctx: Pointer to hdd context |
| 4998 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4999 | * Register for IPv6 address change notifications. |
| 5000 | * |
| 5001 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5002 | */ |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5003 | static int hdd_wlan_register_ip6_notifier(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5004 | { |
| 5005 | int ret; |
| 5006 | |
| 5007 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 5008 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5009 | if (ret) { |
| 5010 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 5011 | goto out; |
| 5012 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5013 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5014 | hdd_debug("Registered IPv6 notifier"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5015 | out: |
| 5016 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5017 | } |
| 5018 | #else |
| 5019 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5020 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5021 | * @hdd_ctx: Pointer to hdd context |
| 5022 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5023 | * Unregister for IPv6 address change notifications. |
| 5024 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5025 | * Return: None |
| 5026 | */ |
| 5027 | static void hdd_wlan_unregister_ip6_notifier(hdd_context_t *hdd_ctx) |
| 5028 | { |
| 5029 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5030 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5031 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5032 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5033 | * @hdd_ctx: Pointer to hdd context |
| 5034 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5035 | * Register for IPv6 address change notifications. |
| 5036 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5037 | * Return: None |
| 5038 | */ |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5039 | static int hdd_wlan_register_ip6_notifier(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5040 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5041 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5042 | } |
| 5043 | #endif |
| 5044 | |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 5045 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 5046 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5047 | * hdd_logging_sock_activate_svc() - Activate logging |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 5048 | * @hdd_ctx: HDD context |
| 5049 | * |
| 5050 | * Activates the logging service |
| 5051 | * |
| 5052 | * Return: Zero in case of success, negative value otherwise |
| 5053 | */ |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5054 | static int hdd_logging_sock_activate_svc(hdd_context_t *hdd_ctx) |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 5055 | { |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5056 | int ret; |
| 5057 | struct hdd_config *config = hdd_ctx->config; |
| 5058 | |
| 5059 | if (!config->wlanLoggingEnable) |
| 5060 | return 0; |
| 5061 | |
Srinivas Girigowda | 8187e79 | 2017-03-03 11:50:59 -0800 | [diff] [blame] | 5062 | ret = wlan_logging_sock_activate_svc(config->wlanLoggingToConsole, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5063 | config->wlanLoggingNumBuf); |
| 5064 | if (ret) |
| 5065 | hdd_err("wlan_logging_sock_activate_svc failed: %d", ret); |
| 5066 | return ret; |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 5067 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5068 | |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 5069 | /** |
| 5070 | * wlan_hdd_logging_sock_deactivate_svc() - Deactivate logging |
| 5071 | * @hdd_ctx: HDD context |
| 5072 | * |
| 5073 | * Deactivates the logging service |
| 5074 | * |
| 5075 | * Return: 0 on deactivating the logging service |
| 5076 | */ |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5077 | static int hdd_logging_sock_deactivate_svc(hdd_context_t *hdd_ctx) |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 5078 | { |
| 5079 | if (hdd_ctx && hdd_ctx->config->wlanLoggingEnable) |
| 5080 | return wlan_logging_sock_deactivate_svc(); |
| 5081 | |
| 5082 | return 0; |
| 5083 | } |
| 5084 | #else |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5085 | static inline int hdd_logging_sock_activate_svc(hdd_context_t *hdd_ctx) |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 5086 | { |
| 5087 | return 0; |
| 5088 | } |
| 5089 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5090 | static inline int hdd_logging_sock_deactivate_svc(hdd_context_t *hdd_ctx) |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 5091 | { |
| 5092 | return 0; |
| 5093 | } |
| 5094 | #endif |
| 5095 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5096 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5097 | * hdd_register_notifiers - Register netdev notifiers. |
| 5098 | * @hdd_ctx: HDD context |
| 5099 | * |
| 5100 | * Register netdev notifiers like IPv4 and IPv6. |
| 5101 | * |
| 5102 | * Return: 0 on success and errno on failure |
| 5103 | */ |
| 5104 | static int hdd_register_notifiers(hdd_context_t *hdd_ctx) |
| 5105 | { |
| 5106 | int ret; |
| 5107 | |
| 5108 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 5109 | if (ret) { |
| 5110 | hdd_err("register_netdevice_notifier failed: %d", ret); |
| 5111 | goto out; |
| 5112 | } |
| 5113 | |
| 5114 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 5115 | if (ret) |
| 5116 | goto unregister_notifier; |
| 5117 | |
| 5118 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 5119 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 5120 | if (ret) { |
| 5121 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 5122 | goto unregister_ip6_notifier; |
| 5123 | } |
| 5124 | |
| 5125 | return 0; |
| 5126 | |
| 5127 | unregister_ip6_notifier: |
| 5128 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 5129 | unregister_notifier: |
| 5130 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 5131 | out: |
| 5132 | return ret; |
| 5133 | |
| 5134 | } |
| 5135 | |
| 5136 | /** |
| 5137 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 5138 | * @hdd_ctx: HDD context |
| 5139 | * |
| 5140 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 5141 | * |
| 5142 | * Return: None. |
| 5143 | */ |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 5144 | void hdd_unregister_notifiers(hdd_context_t *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5145 | { |
| 5146 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 5147 | |
| 5148 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 5149 | |
| 5150 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 5151 | } |
| 5152 | |
| 5153 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5154 | * hdd_exit_netlink_services - Exit netlink services |
| 5155 | * @hdd_ctx: HDD context |
| 5156 | * |
| 5157 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 5158 | * nl service. |
| 5159 | * |
| 5160 | * Return: None. |
| 5161 | */ |
| 5162 | static void hdd_exit_netlink_services(hdd_context_t *hdd_ctx) |
| 5163 | { |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5164 | hdd_close_cesium_nl_sock(); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 5165 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5166 | ptt_sock_deactivate_svc(); |
| 5167 | |
| 5168 | nl_srv_exit(); |
| 5169 | } |
| 5170 | |
| 5171 | /** |
| 5172 | * hdd_init_netlink_services- Init netlink services |
| 5173 | * @hdd_ctx: HDD context |
| 5174 | * |
| 5175 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 5176 | * nl service. |
| 5177 | * |
| 5178 | * Return: 0 on success and errno on failure. |
| 5179 | */ |
| 5180 | static int hdd_init_netlink_services(hdd_context_t *hdd_ctx) |
| 5181 | { |
| 5182 | int ret; |
| 5183 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 5184 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5185 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5186 | hdd_err("nl_srv_init failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5187 | goto out; |
| 5188 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 5189 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5190 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 5191 | ret = hdd_activate_wifi_pos(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5192 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5193 | hdd_err("hdd_activate_wifi_pos failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5194 | goto err_nl_srv; |
| 5195 | } |
| 5196 | |
| 5197 | ret = ptt_sock_activate_svc(); |
| 5198 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5199 | hdd_err("ptt_sock_activate_svc failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5200 | goto err_nl_srv; |
| 5201 | } |
| 5202 | |
| 5203 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 5204 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5205 | hdd_err("hdd_open_cesium_nl_sock failed ret: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5206 | |
| 5207 | ret = cnss_diag_activate_service(); |
| 5208 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5209 | hdd_err("cnss_diag_activate_service failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5210 | goto err_close_cesium; |
| 5211 | } |
| 5212 | |
| 5213 | return 0; |
| 5214 | |
| 5215 | err_close_cesium: |
| 5216 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5217 | ptt_sock_deactivate_svc(); |
| 5218 | err_nl_srv: |
| 5219 | nl_srv_exit(); |
| 5220 | out: |
| 5221 | return ret; |
| 5222 | } |
| 5223 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5224 | /** |
| 5225 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 5226 | * @hdd_ctx: HDD context. |
| 5227 | * |
| 5228 | * Destroy RX wakelock. |
| 5229 | * |
| 5230 | * Return: None. |
| 5231 | */ |
| 5232 | static void hdd_rx_wake_lock_destroy(hdd_context_t *hdd_ctx) |
| 5233 | { |
| 5234 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 5235 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5236 | |
| 5237 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5238 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 5239 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5240 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5241 | * Create RX wakelock. |
| 5242 | * |
| 5243 | * Return: None. |
| 5244 | */ |
| 5245 | static void hdd_rx_wake_lock_create(hdd_context_t *hdd_ctx) |
| 5246 | { |
| 5247 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 5248 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5249 | |
| 5250 | /** |
| 5251 | * hdd_roc_context_init() - Init ROC context |
| 5252 | * @hdd_ctx: HDD context. |
| 5253 | * |
| 5254 | * Initialize ROC context. |
| 5255 | * |
| 5256 | * Return: 0 on success and errno on failure. |
| 5257 | */ |
| 5258 | static int hdd_roc_context_init(hdd_context_t *hdd_ctx) |
| 5259 | { |
| 5260 | qdf_spinlock_create(&hdd_ctx->hdd_roc_req_q_lock); |
| 5261 | qdf_list_create(&hdd_ctx->hdd_roc_req_q, MAX_ROC_REQ_QUEUE_ENTRY); |
| 5262 | |
| 5263 | INIT_DELAYED_WORK(&hdd_ctx->roc_req_work, wlan_hdd_roc_request_dequeue); |
| 5264 | |
| 5265 | return 0; |
| 5266 | } |
| 5267 | |
| 5268 | /** |
| 5269 | * hdd_roc_context_destroy() - Destroy ROC context |
| 5270 | * @hdd_ctx: HDD context. |
| 5271 | * |
| 5272 | * Destroy roc list and flush the pending roc work. |
| 5273 | * |
| 5274 | * Return: None. |
| 5275 | */ |
| 5276 | static void hdd_roc_context_destroy(hdd_context_t *hdd_ctx) |
| 5277 | { |
| 5278 | flush_delayed_work(&hdd_ctx->roc_req_work); |
| 5279 | qdf_list_destroy(&hdd_ctx->hdd_roc_req_q); |
Houston Hoffman | 2eac7c4 | 2016-12-12 12:22:52 -0800 | [diff] [blame] | 5280 | qdf_spinlock_destroy(&hdd_ctx->hdd_roc_req_q_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5281 | } |
| 5282 | |
| 5283 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5284 | * hdd_context_deinit() - Deinitialize HDD context |
| 5285 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5286 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5287 | * Deinitialize HDD context along with all the feature specific contexts but |
| 5288 | * do not free hdd context itself. Caller of this API is supposed to free |
| 5289 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5290 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5291 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5292 | */ |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5293 | static int hdd_context_deinit(hdd_context_t *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5294 | { |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5295 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5296 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5297 | hdd_roc_context_destroy(hdd_ctx); |
| 5298 | |
| 5299 | hdd_sap_context_destroy(hdd_ctx); |
| 5300 | |
| 5301 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 5302 | |
| 5303 | hdd_tdls_context_destroy(hdd_ctx); |
| 5304 | |
| 5305 | hdd_scan_context_destroy(hdd_ctx); |
| 5306 | |
| 5307 | qdf_list_destroy(&hdd_ctx->hddAdapters); |
| 5308 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5309 | return 0; |
| 5310 | } |
| 5311 | |
| 5312 | /** |
| 5313 | * hdd_context_destroy() - Destroy HDD context |
| 5314 | * @hdd_ctx: HDD context to be destroyed. |
| 5315 | * |
| 5316 | * Free config and HDD context as well as destroy all the resources. |
| 5317 | * |
| 5318 | * Return: None |
| 5319 | */ |
| 5320 | static void hdd_context_destroy(hdd_context_t *hdd_ctx) |
| 5321 | { |
| 5322 | if (QDF_GLOBAL_FTM_MODE != hdd_get_conparam()) |
| 5323 | hdd_logging_sock_deactivate_svc(hdd_ctx); |
| 5324 | |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 5325 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 5326 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5327 | hdd_context_deinit(hdd_ctx); |
| 5328 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5329 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5330 | hdd_ctx->config = NULL; |
| 5331 | |
| 5332 | wiphy_free(hdd_ctx->wiphy); |
| 5333 | } |
| 5334 | |
| 5335 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5336 | * hdd_wlan_exit() - HDD WLAN exit function |
| 5337 | * @hdd_ctx: Pointer to the HDD Context |
| 5338 | * |
| 5339 | * This is the driver exit point (invoked during rmmod) |
| 5340 | * |
| 5341 | * Return: None |
| 5342 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 5343 | static void hdd_wlan_exit(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5344 | { |
| 5345 | v_CONTEXT_t p_cds_context = hdd_ctx->pcds_context; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5346 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5347 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5348 | int driver_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5349 | |
| 5350 | ENTER(); |
| 5351 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5352 | if (QDF_TIMER_STATE_RUNNING == |
| 5353 | qdf_mc_timer_get_current_state(&hdd_ctx->iface_change_timer)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5354 | hdd_debug("Stop interface change timer"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5355 | qdf_mc_timer_stop(&hdd_ctx->iface_change_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5356 | } |
| 5357 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5358 | if (!QDF_IS_STATUS_SUCCESS |
| 5359 | (qdf_mc_timer_destroy(&hdd_ctx->iface_change_timer))) |
| 5360 | hdd_err("Cannot delete interface change timer"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5361 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5362 | |
| 5363 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5364 | |
Nitesh Shah | 61c10d9 | 2016-10-19 19:29:15 +0530 | [diff] [blame] | 5365 | qdf_mc_timer_destroy(&hdd_ctx->tdls_source_timer); |
| 5366 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 5367 | hdd_bus_bandwidth_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5368 | |
| 5369 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 5370 | if (QDF_TIMER_STATE_RUNNING == |
| 5371 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 5372 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5373 | } |
| 5374 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5375 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 5376 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5377 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5378 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 5379 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 5380 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 5381 | hdd_ctx->last_acs_channel_list = NULL; |
| 5382 | hdd_ctx->num_of_channels = 0; |
| 5383 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5384 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5385 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5386 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 5387 | driver_status = hdd_ctx->driver_status; |
| 5388 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 5389 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5390 | /* |
| 5391 | * Powersave Offload Case |
| 5392 | * Disable Idle Power Save Mode |
| 5393 | */ |
| 5394 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 5395 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5396 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 5397 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 5398 | /* |
| 5399 | * Cancel any outstanding scan requests. We are about to close |
| 5400 | * all of our adapters, but an adapter structure is what SME |
| 5401 | * passes back to our callback function. Hence if there |
| 5402 | * are any outstanding scan requests then there is a |
| 5403 | * race condition between when the adapter is closed and |
| 5404 | * when the callback is invoked. We try to resolve that |
| 5405 | * race condition here by canceling any outstanding scans |
| 5406 | * before we close the adapters. |
| 5407 | * Note that the scans may be cancelled in an asynchronous |
| 5408 | * manner, so ideally there needs to be some kind of |
| 5409 | * synchronization. Rather than introduce a new |
| 5410 | * synchronization here, we will utilize the fact that we are |
| 5411 | * about to Request Full Power, and since that is synchronized, |
| 5412 | * the expectation is that by the time Request Full Power has |
| 5413 | * completed, all scans will be cancelled |
| 5414 | */ |
Sandeep Puligilla | 8de3c1c | 2017-04-13 17:56:18 -0700 | [diff] [blame] | 5415 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5416 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5417 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5418 | hdd_stop_all_adapters(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5419 | } |
| 5420 | |
| 5421 | /* |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 5422 | * Close the scheduler before calling cds_close to make sure |
| 5423 | * no thread is scheduled after the each module close is |
| 5424 | * is called i.e after all the data structures are freed. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5425 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5426 | qdf_status = cds_sched_close(p_cds_context); |
| 5427 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5428 | hdd_err("Failed to close CDS Scheduler"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 5429 | QDF_ASSERT(QDF_IS_STATUS_SUCCESS(qdf_status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5430 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5431 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 5432 | hdd_wlan_stop_modules(hdd_ctx, false); |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 5433 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 5434 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
| 5435 | qdf_spinlock_destroy(&hdd_ctx->sta_update_info_lock); |
| 5436 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
| 5437 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5438 | /* |
| 5439 | * Close CDS |
| 5440 | * This frees pMac(HAL) context. There should not be any call |
| 5441 | * that requires pMac access after this. |
| 5442 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5443 | |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 5444 | hdd_green_ap_deinit(hdd_ctx); |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 5445 | hdd_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5446 | |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 5447 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 5448 | hdd_close_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5449 | |
| 5450 | hdd_ipa_cleanup(hdd_ctx); |
| 5451 | |
| 5452 | /* Free up RoC request queue and flush workqueue */ |
| 5453 | cds_flush_work(&hdd_ctx->roc_req_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5454 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 5455 | wlansap_global_deinit(); |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 5456 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 5457 | /* |
| 5458 | * If there is re_init failure wiphy would have already de-registered |
| 5459 | * check the wiphy status before un-registering again |
| 5460 | */ |
Ashish Kumar Dhanotiya | e16feb7 | 2017-03-31 19:39:37 +0530 | [diff] [blame] | 5461 | if (wiphy && wiphy->registered) { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 5462 | wiphy_unregister(wiphy); |
| 5463 | wlan_hdd_cfg80211_deinit(wiphy); |
| 5464 | hdd_lpass_notify_stop(hdd_ctx); |
| 5465 | } |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 5466 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5467 | hdd_exit_netlink_services(hdd_ctx); |
| 5468 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 5469 | |
| 5470 | driver_status = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 5471 | if (driver_status) |
| 5472 | hdd_err("Pdev delete failed"); |
| 5473 | |
| 5474 | driver_status = hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 5475 | if (driver_status) |
| 5476 | hdd_err("Psoc delete failed"); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5477 | hdd_context_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5478 | } |
| 5479 | |
| 5480 | void __hdd_wlan_exit(void) |
| 5481 | { |
| 5482 | hdd_context_t *hdd_ctx; |
| 5483 | |
| 5484 | ENTER(); |
| 5485 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5486 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5487 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5488 | hdd_err("Invalid HDD Context"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5489 | EXIT(); |
| 5490 | return; |
| 5491 | } |
| 5492 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 5493 | /* Check IPA HW Pipe shutdown */ |
| 5494 | hdd_ipa_uc_force_pipe_shutdown(hdd_ctx); |
| 5495 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 5496 | memdump_deinit(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 5497 | hdd_driver_memdump_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 5498 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5499 | /* Do all the cleanup before deregistering the driver */ |
| 5500 | hdd_wlan_exit(hdd_ctx); |
Mohit Khanna | ebf8a86 | 2016-04-28 17:53:59 -0700 | [diff] [blame] | 5501 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5502 | EXIT(); |
| 5503 | } |
| 5504 | |
| 5505 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 5506 | /** |
| 5507 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
| 5508 | * @data: pointer to hdd_context_t |
| 5509 | * |
| 5510 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 5511 | * Then new ACS request will do a fresh scan without reusing the cached |
| 5512 | * scan information. |
| 5513 | * |
| 5514 | * Return: void |
| 5515 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 5516 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5517 | { |
| 5518 | hdd_context_t *hdd_ctx = (hdd_context_t *) data; |
| 5519 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5520 | hdd_debug("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5521 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 5522 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 5523 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 5524 | hdd_ctx->last_acs_channel_list = NULL; |
| 5525 | hdd_ctx->num_of_channels = 0; |
| 5526 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5527 | |
| 5528 | if (!hdd_ctx->hHal) |
| 5529 | return; |
| 5530 | sme_scan_flush_result(hdd_ctx->hHal); |
| 5531 | } |
| 5532 | #endif |
| 5533 | |
| 5534 | #ifdef QCA_HT_2040_COEX |
| 5535 | /** |
| 5536 | * hdd_wlan_set_ht2040_mode() - notify FW with HT20/HT40 mode |
| 5537 | * @adapter: pointer to adapter |
| 5538 | * @staId: station id |
| 5539 | * @macAddrSTA: station MAC address |
| 5540 | * @channel_type: channel type |
| 5541 | * |
| 5542 | * This function notifies FW with HT20/HT40 mode |
| 5543 | * |
| 5544 | * Return: 0 if successful, error number otherwise |
| 5545 | */ |
| 5546 | int hdd_wlan_set_ht2040_mode(hdd_adapter_t *adapter, uint16_t staId, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5547 | struct qdf_mac_addr macAddrSTA, int channel_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5548 | { |
| 5549 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5550 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5551 | hdd_context_t *hdd_ctx = NULL; |
| 5552 | |
| 5553 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 5554 | |
| 5555 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 5556 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5557 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 5558 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5559 | if (!hdd_ctx->hHal) |
| 5560 | return -EINVAL; |
| 5561 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5562 | qdf_status = sme_notify_ht2040_mode(hdd_ctx->hHal, staId, macAddrSTA, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5563 | adapter->sessionId, channel_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5564 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5565 | hdd_err("Fail to send notification with ht2040 mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5566 | return -EINVAL; |
| 5567 | } |
| 5568 | |
| 5569 | return 0; |
| 5570 | } |
| 5571 | #endif |
| 5572 | |
| 5573 | /** |
| 5574 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 5575 | * @state: state |
| 5576 | * |
| 5577 | * This function notifies FW with modem power status |
| 5578 | * |
| 5579 | * Return: 0 if successful, error number otherwise |
| 5580 | */ |
| 5581 | int hdd_wlan_notify_modem_power_state(int state) |
| 5582 | { |
| 5583 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5584 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5585 | hdd_context_t *hdd_ctx; |
| 5586 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5587 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5588 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 5589 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5590 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 5591 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5592 | if (!hdd_ctx->hHal) |
| 5593 | return -EINVAL; |
| 5594 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5595 | qdf_status = sme_notify_modem_power_state(hdd_ctx->hHal, state); |
| 5596 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5597 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5598 | state); |
| 5599 | return -EINVAL; |
| 5600 | } |
| 5601 | return 0; |
| 5602 | } |
| 5603 | |
| 5604 | /** |
| 5605 | * |
| 5606 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 5607 | * @adapter - Pointer to the HDD |
| 5608 | * |
| 5609 | * Return: None |
| 5610 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5611 | QDF_STATUS hdd_post_cds_enable_config(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5612 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5613 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5614 | |
| 5615 | /* |
| 5616 | * Send ready indication to the HDD. This will kick off the MAC |
| 5617 | * into a 'running' state and should kick off an initial scan. |
| 5618 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5619 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->hHal); |
| 5620 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5621 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 5622 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5623 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5624 | } |
| 5625 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5626 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5627 | } |
| 5628 | |
| 5629 | /* wake lock APIs for HDD */ |
| 5630 | void hdd_prevent_suspend(uint32_t reason) |
| 5631 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5632 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5633 | } |
| 5634 | |
| 5635 | void hdd_allow_suspend(uint32_t reason) |
| 5636 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5637 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5638 | } |
| 5639 | |
| 5640 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 5641 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 5642 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 5643 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5644 | } |
| 5645 | |
| 5646 | /** |
| 5647 | * hdd_exchange_version_and_caps() - exchange version and capability with target |
| 5648 | * @hdd_ctx: Pointer to HDD context |
| 5649 | * |
| 5650 | * This is the HDD function to exchange version and capability information |
| 5651 | * between Host and Target |
| 5652 | * |
| 5653 | * This function gets reported version of FW. |
| 5654 | * It also finds the version of target headers used to compile the host; |
| 5655 | * It compares the above two and prints a warning if they are different; |
| 5656 | * It gets the SW and HW version string; |
| 5657 | * Finally, it exchanges capabilities between host and target i.e. host |
| 5658 | * and target exchange a msg indicating the features they support through a |
| 5659 | * bitmap |
| 5660 | * |
| 5661 | * Return: None |
| 5662 | */ |
| 5663 | void hdd_exchange_version_and_caps(hdd_context_t *hdd_ctx) |
| 5664 | { |
| 5665 | |
| 5666 | tSirVersionType versionCompiled; |
| 5667 | tSirVersionType versionReported; |
| 5668 | tSirVersionString versionString; |
| 5669 | uint8_t fwFeatCapsMsgSupported = 0; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5670 | QDF_STATUS vstatus; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5671 | |
| 5672 | memset(&versionCompiled, 0, sizeof(versionCompiled)); |
| 5673 | memset(&versionReported, 0, sizeof(versionReported)); |
| 5674 | |
| 5675 | /* retrieve and display WCNSS version information */ |
| 5676 | do { |
| 5677 | |
| 5678 | vstatus = sme_get_wcnss_wlan_compiled_version(hdd_ctx->hHal, |
| 5679 | &versionCompiled); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5680 | if (!QDF_IS_STATUS_SUCCESS(vstatus)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5681 | hdd_err("unable to retrieve WCNSS WLAN compiled version"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5682 | break; |
| 5683 | } |
| 5684 | |
| 5685 | vstatus = sme_get_wcnss_wlan_reported_version(hdd_ctx->hHal, |
| 5686 | &versionReported); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5687 | if (!QDF_IS_STATUS_SUCCESS(vstatus)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5688 | hdd_err("unable to retrieve WCNSS WLAN reported version"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5689 | break; |
| 5690 | } |
| 5691 | |
| 5692 | if ((versionCompiled.major != versionReported.major) || |
| 5693 | (versionCompiled.minor != versionReported.minor) || |
| 5694 | (versionCompiled.version != versionReported.version) || |
| 5695 | (versionCompiled.revision != versionReported.revision)) { |
| 5696 | pr_err("%s: WCNSS WLAN Version %u.%u.%u.%u, " |
| 5697 | "Host expected %u.%u.%u.%u\n", |
| 5698 | WLAN_MODULE_NAME, |
| 5699 | (int)versionReported.major, |
| 5700 | (int)versionReported.minor, |
| 5701 | (int)versionReported.version, |
| 5702 | (int)versionReported.revision, |
| 5703 | (int)versionCompiled.major, |
| 5704 | (int)versionCompiled.minor, |
| 5705 | (int)versionCompiled.version, |
| 5706 | (int)versionCompiled.revision); |
| 5707 | } else { |
| 5708 | pr_info("%s: WCNSS WLAN version %u.%u.%u.%u\n", |
| 5709 | WLAN_MODULE_NAME, |
| 5710 | (int)versionReported.major, |
| 5711 | (int)versionReported.minor, |
| 5712 | (int)versionReported.version, |
| 5713 | (int)versionReported.revision); |
| 5714 | } |
| 5715 | |
| 5716 | vstatus = sme_get_wcnss_software_version(hdd_ctx->hHal, |
| 5717 | versionString, |
| 5718 | sizeof(versionString)); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5719 | if (!QDF_IS_STATUS_SUCCESS(vstatus)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5720 | hdd_err("unable to retrieve WCNSS software version string"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5721 | break; |
| 5722 | } |
| 5723 | |
| 5724 | pr_info("%s: WCNSS software version %s\n", |
| 5725 | WLAN_MODULE_NAME, versionString); |
| 5726 | |
| 5727 | vstatus = sme_get_wcnss_hardware_version(hdd_ctx->hHal, |
| 5728 | versionString, |
| 5729 | sizeof(versionString)); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5730 | if (!QDF_IS_STATUS_SUCCESS(vstatus)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5731 | hdd_err("unable to retrieve WCNSS hardware version string"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5732 | break; |
| 5733 | } |
| 5734 | |
| 5735 | pr_info("%s: WCNSS hardware version %s\n", |
| 5736 | WLAN_MODULE_NAME, versionString); |
| 5737 | |
| 5738 | /* |
| 5739 | * 1.Check if FW version is greater than 0.1.1.0. Only then |
| 5740 | * send host-FW capability exchange message |
| 5741 | * 2.Host-FW capability exchange message is only present on |
| 5742 | * target 1.1 so send the message only if it the target is 1.1 |
| 5743 | * minor numbers for different target branches: |
| 5744 | * 0 -> (1.0)Mainline Build |
| 5745 | * 1 -> (1.1)Mainline Build |
| 5746 | * 2->(1.04) Stability Build |
| 5747 | */ |
| 5748 | if (((versionReported.major > 0) || (versionReported.minor > 1) |
| 5749 | || ((versionReported.minor >= 1) |
| 5750 | && (versionReported.version >= 1))) |
| 5751 | && ((versionReported.major == 1) |
| 5752 | && (versionReported.minor >= 1))) |
| 5753 | fwFeatCapsMsgSupported = 1; |
| 5754 | |
| 5755 | if (fwFeatCapsMsgSupported) { |
| 5756 | /* |
| 5757 | * Indicate if IBSS heartbeat monitoring needs to be |
| 5758 | * offloaded |
| 5759 | */ |
| 5760 | if (!hdd_ctx->config->enableIbssHeartBeatOffload) { |
| 5761 | sme_disable_feature_capablity |
| 5762 | (IBSS_HEARTBEAT_OFFLOAD); |
| 5763 | } |
| 5764 | |
| 5765 | sme_feature_caps_exchange(hdd_ctx->hHal); |
| 5766 | } |
| 5767 | |
| 5768 | } while (0); |
| 5769 | |
| 5770 | } |
| 5771 | |
| 5772 | /* Initialize channel list in sme based on the country code */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5773 | QDF_STATUS hdd_set_sme_chan_list(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5774 | { |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 5775 | |
| 5776 | if (hdd_ctx->reg_offload) |
| 5777 | return sme_init_chan_list(hdd_ctx->hHal, |
| 5778 | hdd_ctx->reg.alpha2, |
| 5779 | 0); |
| 5780 | else |
| 5781 | return sme_init_chan_list(hdd_ctx->hHal, |
| 5782 | hdd_ctx->reg.alpha2, |
| 5783 | hdd_ctx->reg.cc_src); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5784 | } |
| 5785 | |
| 5786 | /** |
| 5787 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 5788 | * @hdd_ctx: Pointer to the hdd context |
| 5789 | * |
| 5790 | * HDD function to know if hardware supports 5GHz |
| 5791 | * |
| 5792 | * Return: true if hardware supports 5GHz |
| 5793 | */ |
| 5794 | bool hdd_is_5g_supported(hdd_context_t *hdd_ctx) |
| 5795 | { |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 5796 | if (!hdd_ctx || !hdd_ctx->config) |
| 5797 | return true; |
| 5798 | |
| 5799 | if (hdd_ctx->config->nBandCapability != eCSR_BAND_24) |
| 5800 | return true; |
| 5801 | else |
| 5802 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5803 | } |
| 5804 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 5805 | static int hdd_wiphy_init(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5806 | { |
| 5807 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 5808 | int ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5809 | |
| 5810 | wiphy = hdd_ctx->wiphy; |
| 5811 | |
| 5812 | /* |
| 5813 | * The channel information in |
| 5814 | * wiphy needs to be initialized before wiphy registration |
| 5815 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 5816 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 5817 | if (ret_val) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5818 | hdd_err("regulatory init failed"); |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 5819 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5820 | } |
| 5821 | |
| 5822 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 5823 | wiphy->wowlan = &wowlan_support_reg_init; |
| 5824 | #else |
| 5825 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 5826 | WIPHY_WOWLAN_MAGIC_PKT | |
| 5827 | WIPHY_WOWLAN_DISCONNECT | |
| 5828 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 5829 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 5830 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 5831 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 5832 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 5833 | |
| 5834 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 5835 | WOW_MAX_FILTERS_PER_LIST); |
| 5836 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 5837 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 5838 | #endif |
| 5839 | |
| 5840 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 5841 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 5842 | if (0 > ret_val) { |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 5843 | hdd_err("wiphy registration failed"); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 5844 | return ret_val; |
| 5845 | } |
| 5846 | |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 5847 | if (!hdd_ctx->reg_offload) |
| 5848 | hdd_program_country_code(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5849 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 5850 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5851 | } |
| 5852 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 5853 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5854 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 5855 | * @hdd_ctx - handle to hdd context |
| 5856 | * @tx_packets - transmit packet count |
| 5857 | * @rx_packets - receive packet count |
| 5858 | * |
| 5859 | * The function controls the bus bandwidth and dynamic control of |
| 5860 | * tcp delayed ack configuration |
| 5861 | * |
| 5862 | * Returns: None |
| 5863 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5864 | #ifdef MSM_PLATFORM |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 5865 | static void hdd_pld_request_bus_bandwidth(hdd_context_t *hdd_ctx, |
| 5866 | const uint64_t tx_packets, |
| 5867 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5868 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5869 | uint64_t total = tx_packets + rx_packets; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5870 | uint64_t temp_rx = 0; |
| 5871 | uint64_t temp_tx = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5872 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 5873 | static enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5874 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 5875 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 5876 | uint16_t index = 0; |
| 5877 | bool vote_level_change = false; |
| 5878 | bool rx_level_change = false; |
| 5879 | bool tx_level_change = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5880 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5881 | if (total > hdd_ctx->config->busBandwidthHighThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5882 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5883 | else if (total > hdd_ctx->config->busBandwidthMediumThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5884 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 5885 | else if (total > hdd_ctx->config->busBandwidthLowThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5886 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 5887 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5888 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5889 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5890 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 5891 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 5892 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5893 | hdd_ctx->cur_vote_level = next_vote_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 5894 | vote_level_change = true; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5895 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 5896 | if (next_vote_level == PLD_BUS_WIDTH_LOW) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 5897 | if (hdd_ctx->hbw_requested) { |
| 5898 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 5899 | hdd_ctx->hbw_requested = false; |
| 5900 | } |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 5901 | if (cds_sched_handle_throughput_req(false)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5902 | hdd_warn("low bandwidth set rx affinity fail"); |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 5903 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 5904 | if (!hdd_ctx->hbw_requested) { |
| 5905 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 5906 | hdd_ctx->hbw_requested = true; |
| 5907 | } |
| 5908 | |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 5909 | if (cds_sched_handle_throughput_req(true)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5910 | hdd_warn("high bandwidth set rx affinity fail"); |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 5911 | } |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 5912 | hdd_napi_apply_throughput_policy(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5913 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5914 | |
| 5915 | /* fine-tuning parameters for RX Flows */ |
| 5916 | temp_rx = (rx_packets + hdd_ctx->prev_rx) / 2; |
| 5917 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5918 | hdd_ctx->prev_rx = rx_packets; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 5919 | |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 5920 | if (temp_rx > hdd_ctx->config->tcpDelackThresholdHigh) { |
| 5921 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 5922 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 5923 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 5924 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 5925 | } else { |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 5926 | hdd_ctx->rx_high_ind_cnt = 0; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 5927 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 5928 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5929 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5930 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 5931 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5932 | next_rx_level, temp_rx); |
| 5933 | hdd_ctx->cur_rx_level = next_rx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 5934 | rx_level_change = true; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 5935 | /* Send throughput indication only if it is enabled. |
| 5936 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 5937 | * to default delayed ack. Note that this will disable the |
| 5938 | * dynamic delayed ack mechanism across the system |
| 5939 | */ |
| 5940 | if (hdd_ctx->config->enable_tcp_delack) |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 5941 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 5942 | WLAN_SVC_WLAN_TP_IND, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5943 | &next_rx_level, |
| 5944 | sizeof(next_rx_level)); |
| 5945 | } |
| 5946 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5947 | /* fine-tuning parameters for TX Flows */ |
| 5948 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 5949 | hdd_ctx->prev_tx = tx_packets; |
| 5950 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 5951 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 5952 | else |
| 5953 | next_tx_level = WLAN_SVC_TP_LOW; |
| 5954 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5955 | if (hdd_ctx->cur_tx_level != next_tx_level) { |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5956 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 5957 | next_tx_level, temp_tx); |
| 5958 | hdd_ctx->cur_tx_level = next_tx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 5959 | tx_level_change = true; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 5960 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 5961 | WLAN_SVC_WLAN_TP_TX_IND, |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5962 | &next_tx_level, |
| 5963 | sizeof(next_tx_level)); |
| 5964 | } |
| 5965 | |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 5966 | index = hdd_ctx->hdd_txrx_hist_idx; |
| 5967 | |
| 5968 | if (vote_level_change || tx_level_change || rx_level_change) { |
| 5969 | hdd_ctx->hdd_txrx_hist[index].next_tx_level = next_tx_level; |
| 5970 | hdd_ctx->hdd_txrx_hist[index].next_rx_level = next_rx_level; |
| 5971 | hdd_ctx->hdd_txrx_hist[index].next_vote_level = next_vote_level; |
| 5972 | hdd_ctx->hdd_txrx_hist[index].interval_rx = rx_packets; |
| 5973 | hdd_ctx->hdd_txrx_hist[index].interval_tx = tx_packets; |
| 5974 | hdd_ctx->hdd_txrx_hist[index].qtime = qdf_get_log_timestamp(); |
| 5975 | hdd_ctx->hdd_txrx_hist_idx++; |
| 5976 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
| 5977 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5978 | } |
| 5979 | |
| 5980 | #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] | 5981 | static void hdd_bus_bw_work_handler(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5982 | { |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 5983 | hdd_context_t *hdd_ctx = container_of(work, hdd_context_t, |
| 5984 | bus_bw_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5985 | hdd_adapter_t *adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 5986 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 5987 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 5988 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5989 | uint64_t total_tx = 0, total_rx = 0; |
| 5990 | hdd_adapter_list_node_t *adapterNode = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5991 | QDF_STATUS status = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 5992 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5993 | bool connected = false; |
| 5994 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 5995 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 5996 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 5997 | return; |
| 5998 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5999 | for (status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6000 | NULL != adapterNode && QDF_STATUS_SUCCESS == status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6001 | status = |
| 6002 | hdd_get_next_adapter(hdd_ctx, adapterNode, &adapterNode)) { |
| 6003 | |
| 6004 | if (adapterNode->pAdapter == NULL) |
| 6005 | continue; |
| 6006 | adapter = adapterNode->pAdapter; |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 6007 | /* |
| 6008 | * Validate magic so we don't end up accessing |
| 6009 | * an invalid adapter. |
| 6010 | */ |
| 6011 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 6012 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6013 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6014 | if ((adapter->device_mode == QDF_STA_MODE || |
| 6015 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6016 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.connState |
| 6017 | != eConnectionState_Associated) { |
| 6018 | |
| 6019 | continue; |
| 6020 | } |
| 6021 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6022 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 6023 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6024 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->bApActive == false) { |
| 6025 | |
| 6026 | continue; |
| 6027 | } |
| 6028 | |
| 6029 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 6030 | adapter->prev_tx_packets); |
| 6031 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 6032 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6033 | |
| 6034 | if (adapter->device_mode == QDF_SAP_MODE || |
| 6035 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 6036 | adapter->device_mode == QDF_IBSS_MODE) { |
| 6037 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 6038 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 6039 | cds_get_context(QDF_MODULE_ID_SOC), |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6040 | adapter->sessionId, |
| 6041 | &fwd_tx_packets, &fwd_rx_packets); |
| 6042 | if (ret == A_OK) { |
| 6043 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 6044 | fwd_tx_packets, |
| 6045 | adapter->prev_fwd_tx_packets); |
| 6046 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 6047 | fwd_tx_packets, |
| 6048 | adapter->prev_fwd_rx_packets); |
| 6049 | } |
| 6050 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6051 | |
| 6052 | total_rx += adapter->stats.rx_packets; |
| 6053 | total_tx += adapter->stats.tx_packets; |
| 6054 | |
| 6055 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 6056 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 6057 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6058 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 6059 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6060 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 6061 | connected = true; |
| 6062 | } |
| 6063 | |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6064 | /* add intra bss forwarded tx and rx packets */ |
| 6065 | tx_packets += fwd_tx_packets_diff; |
| 6066 | rx_packets += fwd_rx_packets_diff; |
| 6067 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6068 | hdd_ipa_uc_stat_query(hdd_ctx, &ipa_tx_packets, &ipa_rx_packets); |
| 6069 | tx_packets += (uint64_t)ipa_tx_packets; |
| 6070 | rx_packets += (uint64_t)ipa_rx_packets; |
| 6071 | |
| 6072 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6073 | hdd_err("bus bandwidth timer running in disconnected state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6074 | return; |
| 6075 | } |
| 6076 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6077 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6078 | |
| 6079 | hdd_ipa_set_perf_level(hdd_ctx, tx_packets, rx_packets); |
| 6080 | hdd_ipa_uc_stat_request(adapter, 2); |
| 6081 | |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 6082 | /* ensure periodic timer should still be running before restarting it */ |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6083 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 6084 | if (hdd_ctx->bus_bw_timer_running) |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 6085 | qdf_timer_mod(&hdd_ctx->bus_bw_timer, |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6086 | hdd_ctx->config->busBandwidthComputeInterval); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6087 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6088 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6089 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6090 | /** |
| 6091 | * __hdd_bus_bw_cbk() - Bus bandwidth data structure callback. |
| 6092 | * @arg: Argument of timer function |
| 6093 | * |
| 6094 | * Schedule a workqueue in this function where all the processing is done. |
| 6095 | * |
| 6096 | * Return: None. |
| 6097 | */ |
| 6098 | static void __hdd_bus_bw_cbk(void *arg) |
| 6099 | { |
| 6100 | hdd_context_t *hdd_ctx = (hdd_context_t *) arg; |
| 6101 | |
| 6102 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 6103 | return; |
| 6104 | |
| 6105 | schedule_work(&hdd_ctx->bus_bw_work); |
| 6106 | } |
| 6107 | |
| 6108 | /** |
| 6109 | * hdd_bus_bw_cbk() - Wrapper for bus bw callback for SSR protection. |
| 6110 | * @arg: Argument of timer function |
| 6111 | * |
| 6112 | * Return: None. |
| 6113 | */ |
| 6114 | static void hdd_bus_bw_cbk(void *arg) |
| 6115 | { |
| 6116 | cds_ssr_protect(__func__); |
| 6117 | __hdd_bus_bw_cbk(arg); |
| 6118 | cds_ssr_unprotect(__func__); |
| 6119 | } |
| 6120 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6121 | int hdd_bus_bandwidth_init(hdd_context_t *hdd_ctx) |
| 6122 | { |
| 6123 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6124 | INIT_WORK(&hdd_ctx->bus_bw_work, |
| 6125 | hdd_bus_bw_work_handler); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6126 | hdd_ctx->bus_bw_timer_running = false; |
| 6127 | qdf_spinlock_create(&hdd_ctx->bus_bw_timer_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6128 | qdf_timer_init(NULL, |
| 6129 | &hdd_ctx->bus_bw_timer, |
| 6130 | hdd_bus_bw_cbk, (void *)hdd_ctx, |
| 6131 | QDF_TIMER_TYPE_SW); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6132 | |
| 6133 | return 0; |
| 6134 | } |
| 6135 | |
| 6136 | void hdd_bus_bandwidth_destroy(hdd_context_t *hdd_ctx) |
| 6137 | { |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6138 | if (hdd_ctx->bus_bw_timer_running) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6139 | hdd_reset_tcp_delack(hdd_ctx); |
| 6140 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6141 | hdd_debug("wait for bus bw work to flush"); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6142 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 6143 | qdf_timer_free(&hdd_ctx->bus_bw_timer); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6144 | hdd_ctx->bus_bw_timer_running = false; |
| 6145 | qdf_spinlock_destroy(&hdd_ctx->bus_bw_timer_lock); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6146 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6147 | #endif |
| 6148 | |
| 6149 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6150 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 6151 | * @hdd_ctx: hdd context |
| 6152 | * |
| 6153 | * Return: 0 for success or error code |
| 6154 | */ |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 6155 | static int wlan_hdd_init_tx_rx_histogram(hdd_context_t *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6156 | { |
| 6157 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 6158 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
| 6159 | if (hdd_ctx->hdd_txrx_hist == NULL) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6160 | hdd_err("Failed malloc for hdd_txrx_hist"); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6161 | return -ENOMEM; |
| 6162 | } |
| 6163 | return 0; |
| 6164 | } |
| 6165 | |
| 6166 | /** |
| 6167 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 6168 | * @hdd_ctx: hdd context |
| 6169 | * |
| 6170 | * Return: none |
| 6171 | */ |
| 6172 | void wlan_hdd_deinit_tx_rx_histogram(hdd_context_t *hdd_ctx) |
| 6173 | { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6174 | if (!hdd_ctx || hdd_ctx->hdd_txrx_hist == NULL) |
| 6175 | return; |
| 6176 | |
| 6177 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 6178 | hdd_ctx->hdd_txrx_hist = NULL; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6179 | } |
| 6180 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6181 | static uint8_t *convert_level_to_string(uint32_t level) |
| 6182 | { |
| 6183 | switch (level) { |
| 6184 | /* initialize the wlan sub system */ |
| 6185 | case WLAN_SVC_TP_NONE: |
| 6186 | return "NONE"; |
| 6187 | case WLAN_SVC_TP_LOW: |
| 6188 | return "LOW"; |
| 6189 | case WLAN_SVC_TP_MEDIUM: |
| 6190 | return "MED"; |
| 6191 | case WLAN_SVC_TP_HIGH: |
| 6192 | return "HIGH"; |
| 6193 | default: |
| 6194 | return "INVAL"; |
| 6195 | } |
| 6196 | } |
| 6197 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6198 | |
| 6199 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6200 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 6201 | * @hdd_ctx: hdd context |
| 6202 | * |
| 6203 | * Return: none |
| 6204 | */ |
| 6205 | void wlan_hdd_display_tx_rx_histogram(hdd_context_t *hdd_ctx) |
| 6206 | { |
| 6207 | int i; |
| 6208 | |
| 6209 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6210 | hdd_debug("BW compute Interval: %dms", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6211 | hdd_ctx->config->busBandwidthComputeInterval); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6212 | 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] | 6213 | hdd_ctx->config->busBandwidthHighThreshold, |
| 6214 | hdd_ctx->config->busBandwidthMediumThreshold, |
| 6215 | hdd_ctx->config->busBandwidthLowThreshold); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6216 | hdd_debug("Enable TCP DEL ACK: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6217 | hdd_ctx->config->enable_tcp_delack); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6218 | hdd_debug("TCP DEL High TH: %d TCP DEL Low TH: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6219 | hdd_ctx->config->tcpDelackThresholdHigh, |
| 6220 | hdd_ctx->config->tcpDelackThresholdLow); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6221 | 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] | 6222 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6223 | #endif |
| 6224 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6225 | hdd_debug("Total entries: %d Current index: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6226 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
| 6227 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6228 | 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] | 6229 | |
| 6230 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6231 | /* using hdd_log to avoid printing function name */ |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6232 | if (hdd_ctx->hdd_txrx_hist[i].qtime > 0) |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6233 | hdd_log(QDF_TRACE_LEVEL_ERROR, |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6234 | "[%3d][%15llu]: %6llu, %6llu, %s, %s, %s", |
| 6235 | i, hdd_ctx->hdd_txrx_hist[i].qtime, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6236 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6237 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
| 6238 | convert_level_to_string( |
| 6239 | hdd_ctx->hdd_txrx_hist[i]. |
| 6240 | next_vote_level), |
| 6241 | convert_level_to_string( |
| 6242 | hdd_ctx->hdd_txrx_hist[i]. |
| 6243 | next_rx_level), |
| 6244 | convert_level_to_string( |
| 6245 | hdd_ctx->hdd_txrx_hist[i]. |
| 6246 | next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6247 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6248 | } |
| 6249 | |
| 6250 | /** |
| 6251 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 6252 | * @hdd_ctx: hdd context |
| 6253 | * |
| 6254 | * Return: none |
| 6255 | */ |
| 6256 | void wlan_hdd_clear_tx_rx_histogram(hdd_context_t *hdd_ctx) |
| 6257 | { |
| 6258 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6259 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 6260 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6261 | } |
| 6262 | |
| 6263 | /** |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6264 | * wlan_hdd_display_netif_queue_history() - display netif queue history |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6265 | * @pHddCtx: hdd context |
| 6266 | * |
| 6267 | * Return: none |
| 6268 | */ |
| 6269 | void wlan_hdd_display_netif_queue_history(hdd_context_t *hdd_ctx) |
| 6270 | { |
| 6271 | |
| 6272 | hdd_adapter_t *adapter = NULL; |
| 6273 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6274 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6275 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6276 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6277 | |
| 6278 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6279 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6280 | adapter = adapter_node->pAdapter; |
| 6281 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6282 | hdd_debug("Netif queue operation statistics:"); |
| 6283 | hdd_debug("Session_id %d device mode %d", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6284 | adapter->sessionId, adapter->device_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6285 | hdd_debug("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6286 | curr_time = qdf_system_ticks(); |
| 6287 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6288 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6289 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6290 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6291 | unpause = adapter->total_unpause_time; |
| 6292 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6293 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6294 | pause = adapter->total_pause_time; |
| 6295 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6296 | hdd_debug("Total: %ums Pause: %ums Unpause: %ums", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6297 | qdf_system_ticks_to_msecs(total), |
| 6298 | qdf_system_ticks_to_msecs(pause), |
| 6299 | qdf_system_ticks_to_msecs(unpause)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6300 | hdd_debug("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6301 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6302 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 6303 | qdf_time_t pause_delta = 0; |
| 6304 | |
| 6305 | if (adapter->pause_map & (1 << i)) |
| 6306 | pause_delta = delta; |
| 6307 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6308 | /* using hdd_log to avoid printing function name */ |
| 6309 | hdd_log(QDF_TRACE_LEVEL_ERROR, |
| 6310 | "%s: %d: %d: %ums", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6311 | hdd_reason_type_to_string(i), |
| 6312 | adapter->queue_oper_stats[i].pause_count, |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6313 | adapter->queue_oper_stats[i].unpause_count, |
| 6314 | qdf_system_ticks_to_msecs( |
| 6315 | adapter->queue_oper_stats[i].total_pause_time + |
| 6316 | pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6317 | } |
| 6318 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6319 | hdd_debug("Netif queue operation history:"); |
| 6320 | hdd_debug("Total entries: %d current index %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6321 | WLAN_HDD_MAX_HISTORY_ENTRY, adapter->history_index); |
| 6322 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6323 | hdd_debug("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6324 | |
| 6325 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6326 | /* using hdd_log to avoid printing function name */ |
| 6327 | if (adapter->queue_oper_history[i].time == 0) |
| 6328 | continue; |
| 6329 | hdd_log(QDF_TRACE_LEVEL_ERROR, |
| 6330 | "%d: %u: %s: %s: %x", |
Anurag Chouhan | 50220ce | 2016-02-18 20:11:33 +0530 | [diff] [blame] | 6331 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6332 | adapter->queue_oper_history[i].time), |
| 6333 | hdd_action_type_to_string( |
| 6334 | adapter->queue_oper_history[i].netif_action), |
| 6335 | hdd_reason_type_to_string( |
| 6336 | adapter->queue_oper_history[i].netif_reason), |
| 6337 | adapter->queue_oper_history[i].pause_map); |
| 6338 | } |
| 6339 | |
| 6340 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 6341 | adapter_node = next; |
| 6342 | } |
| 6343 | |
| 6344 | |
| 6345 | } |
| 6346 | |
| 6347 | /** |
| 6348 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 6349 | * @hdd_ctx: hdd context |
| 6350 | * |
| 6351 | * Return: none |
| 6352 | */ |
| 6353 | void wlan_hdd_clear_netif_queue_history(hdd_context_t *hdd_ctx) |
| 6354 | { |
| 6355 | hdd_adapter_t *adapter = NULL; |
| 6356 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6357 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6358 | |
| 6359 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6360 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6361 | adapter = adapter_node->pAdapter; |
| 6362 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6363 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6364 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6365 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6366 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6367 | adapter->history_index = 0; |
| 6368 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 6369 | adapter->total_pause_time = 0; |
| 6370 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6371 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 6372 | adapter_node = next; |
| 6373 | } |
| 6374 | } |
| 6375 | |
| 6376 | /** |
| 6377 | * hdd_11d_scan_done() - callback for 11d scan completion of flushing results |
| 6378 | * @halHandle: Hal handle |
| 6379 | * @pContext: Pointer to the context |
| 6380 | * @sessionId: Session ID |
| 6381 | * @scanId: Scan ID |
| 6382 | * @status: Status |
| 6383 | * |
| 6384 | * This is the callback to be executed when 11d scan is completed to flush out |
| 6385 | * the scan results |
| 6386 | * |
| 6387 | * 11d scan is done during driver load and is a passive scan on all |
| 6388 | * channels supported by the device, 11d scans may find some APs on |
| 6389 | * frequencies which are forbidden to be used in the regulatory domain |
| 6390 | * the device is operating in. If these APs are notified to the supplicant |
| 6391 | * it may try to connect to these APs, thus flush out all the scan results |
| 6392 | * which are present in SME after 11d scan is done. |
| 6393 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6394 | * Return: QDF_STATUS_SUCCESS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6395 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6396 | static QDF_STATUS hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6397 | uint8_t sessionId, uint32_t scanId, |
| 6398 | eCsrScanStatus status) |
| 6399 | { |
| 6400 | ENTER(); |
| 6401 | |
| 6402 | sme_scan_flush_result(halHandle); |
| 6403 | |
| 6404 | EXIT(); |
| 6405 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6406 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6407 | } |
| 6408 | |
| 6409 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 6410 | /** |
| 6411 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 6412 | * @hdd_ctx: hdd global context |
| 6413 | * |
| 6414 | * Return: none |
| 6415 | */ |
| 6416 | static void hdd_init_offloaded_packets_ctx(hdd_context_t *hdd_ctx) |
| 6417 | { |
| 6418 | uint8_t i; |
| 6419 | |
| 6420 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 6421 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 6422 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 6423 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 6424 | } |
| 6425 | } |
| 6426 | #else |
| 6427 | static void hdd_init_offloaded_packets_ctx(hdd_context_t *hdd_ctx) |
| 6428 | { |
| 6429 | } |
| 6430 | #endif |
| 6431 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 6432 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 6433 | /** |
| 6434 | * wlan_hdd_set_wow_pulse() - call SME to send wmi cmd of wow pulse |
| 6435 | * @phddctx: hdd_context_t structure pointer |
| 6436 | * @enable: enable or disable this behaviour |
| 6437 | * |
| 6438 | * Return: int |
| 6439 | */ |
| 6440 | static int wlan_hdd_set_wow_pulse(hdd_context_t *phddctx, bool enable) |
| 6441 | { |
| 6442 | struct hdd_config *pcfg_ini = phddctx->config; |
| 6443 | struct wow_pulse_mode wow_pulse_set_info; |
| 6444 | QDF_STATUS status; |
| 6445 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6446 | hdd_debug("wow pulse enable flag is %d", enable); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 6447 | |
| 6448 | if (false == phddctx->config->wow_pulse_support) |
| 6449 | return 0; |
| 6450 | |
| 6451 | /* prepare the request to send to SME */ |
| 6452 | if (enable == true) { |
| 6453 | wow_pulse_set_info.wow_pulse_enable = true; |
| 6454 | wow_pulse_set_info.wow_pulse_pin = |
| 6455 | pcfg_ini->wow_pulse_pin; |
| 6456 | wow_pulse_set_info.wow_pulse_interval_low = |
| 6457 | pcfg_ini->wow_pulse_interval_low; |
| 6458 | wow_pulse_set_info.wow_pulse_interval_high = |
| 6459 | pcfg_ini->wow_pulse_interval_high; |
| 6460 | } else { |
| 6461 | wow_pulse_set_info.wow_pulse_enable = false; |
| 6462 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 6463 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 6464 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 6465 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6466 | hdd_debug("enable %d pin %d low %d high %d", |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 6467 | wow_pulse_set_info.wow_pulse_enable, |
| 6468 | wow_pulse_set_info.wow_pulse_pin, |
| 6469 | wow_pulse_set_info.wow_pulse_interval_low, |
| 6470 | wow_pulse_set_info.wow_pulse_interval_high); |
| 6471 | |
| 6472 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 6473 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6474 | hdd_debug("sme_set_wow_pulse failure!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 6475 | return -EIO; |
| 6476 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6477 | hdd_debug("sme_set_wow_pulse success!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 6478 | return 0; |
| 6479 | } |
| 6480 | #else |
| 6481 | static inline int wlan_hdd_set_wow_pulse(hdd_context_t *phddctx, bool enable) |
| 6482 | { |
| 6483 | return 0; |
| 6484 | } |
| 6485 | #endif |
| 6486 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6487 | #ifdef WLAN_FEATURE_FASTPATH |
| 6488 | /** |
| 6489 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 6490 | * @hdd_cfg: hdd config |
| 6491 | * @context: lower layer context |
| 6492 | * |
| 6493 | * Return: none |
| 6494 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6495 | void hdd_enable_fastpath(struct hdd_config *hdd_cfg, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6496 | void *context) |
| 6497 | { |
| 6498 | if (hdd_cfg->fastpath_enable) |
| 6499 | hif_enable_fastpath(context); |
| 6500 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6501 | #endif |
| 6502 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6503 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6504 | /** |
| 6505 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 6506 | * @context: hdd context pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6507 | * @level: thermal level |
| 6508 | * |
| 6509 | * Change IPA data path to SW path when the thermal throttle level greater |
| 6510 | * than 0, and restore the original data path when throttle level is 0 |
| 6511 | * |
| 6512 | * Return: none |
| 6513 | */ |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 6514 | 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] | 6515 | { |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 6516 | hdd_context_t *hdd_ctx = context; |
| 6517 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6518 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 6519 | if (level > THROTTLE_LEVEL_0) |
| 6520 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, true); |
| 6521 | else |
| 6522 | /* restore original concurrency mode */ |
| 6523 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, hdd_ctx->mcc_mode); |
| 6524 | } |
| 6525 | |
| 6526 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6527 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 6528 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 6529 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6530 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6531 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 6532 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 6533 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6534 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6535 | * Return: Channel number to restart SAP in case of success. In case of any |
| 6536 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6537 | */ |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6538 | static uint8_t hdd_get_safe_channel_from_pcl_and_acs_range( |
| 6539 | hdd_adapter_t *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6540 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6541 | struct sir_pcl_list pcl; |
| 6542 | QDF_STATUS status; |
| 6543 | uint32_t i, j; |
| 6544 | tHalHandle *hal_handle; |
| 6545 | hdd_context_t *hdd_ctx; |
| 6546 | bool found = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6547 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6548 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6549 | if (!hdd_ctx) { |
| 6550 | hdd_err("invalid HDD context"); |
| 6551 | return INVALID_CHANNEL_ID; |
| 6552 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6553 | |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 6554 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 6555 | if (!hal_handle) { |
| 6556 | hdd_err("invalid HAL handle"); |
| 6557 | return INVALID_CHANNEL_ID; |
| 6558 | } |
| 6559 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 6560 | status = policy_mgr_get_pcl_for_existing_conn(hdd_ctx->hdd_psoc, |
| 6561 | PM_SAP_MODE, pcl.pcl_list, &pcl.pcl_len, |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6562 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list)); |
| 6563 | if (QDF_IS_STATUS_ERROR(status)) { |
| 6564 | hdd_err("Get PCL failed"); |
| 6565 | return INVALID_CHANNEL_ID; |
| 6566 | } |
| 6567 | |
| 6568 | if (!pcl.pcl_len) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6569 | hdd_err("pcl length is zero. this is not expected"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6570 | return INVALID_CHANNEL_ID; |
| 6571 | } |
| 6572 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6573 | hdd_debug("start:%d end:%d", |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6574 | adapter->sessionCtx.ap.sapConfig.acs_cfg.start_ch, |
| 6575 | adapter->sessionCtx.ap.sapConfig.acs_cfg.end_ch); |
| 6576 | |
| 6577 | /* PCL already takes unsafe channel into account */ |
| 6578 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6579 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6580 | if ((pcl.pcl_list[i] >= |
| 6581 | adapter->sessionCtx.ap.sapConfig.acs_cfg.start_ch) && |
| 6582 | (pcl.pcl_list[i] <= |
| 6583 | adapter->sessionCtx.ap.sapConfig.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6584 | hdd_debug("found PCL safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6585 | return pcl.pcl_list[i]; |
| 6586 | } |
| 6587 | } |
| 6588 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6589 | hdd_debug("no safe channel from PCL found in ACS range"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6590 | |
| 6591 | /* Try for safe channel from all valid channel */ |
| 6592 | pcl.pcl_len = MAX_NUM_CHAN; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 6593 | status = sme_get_cfg_valid_channels(pcl.pcl_list, |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6594 | &pcl.pcl_len); |
| 6595 | if (QDF_IS_STATUS_ERROR(status)) { |
| 6596 | hdd_err("error in getting valid channel list"); |
| 6597 | return INVALID_CHANNEL_ID; |
| 6598 | } |
| 6599 | |
| 6600 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6601 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6602 | found = false; |
| 6603 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 6604 | if (pcl.pcl_list[i] == |
| 6605 | hdd_ctx->unsafe_channel_list[j]) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6606 | hdd_debug("unsafe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6607 | found = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6608 | break; |
| 6609 | } |
| 6610 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6611 | |
| 6612 | if (found) |
| 6613 | continue; |
| 6614 | |
| 6615 | if ((pcl.pcl_list[i] >= |
| 6616 | adapter->sessionCtx.ap.sapConfig.acs_cfg.start_ch) && |
| 6617 | (pcl.pcl_list[i] <= |
| 6618 | adapter->sessionCtx.ap.sapConfig.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6619 | hdd_debug("found safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6620 | return pcl.pcl_list[i]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6621 | } |
| 6622 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6623 | |
| 6624 | return INVALID_CHANNEL_ID; |
| 6625 | } |
| 6626 | |
| 6627 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 6628 | * hdd_switch_sap_channel() - Move SAP to the given channel |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6629 | * @adapter: AP adapter |
| 6630 | * @channel: Channel |
| 6631 | * |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 6632 | * Moves the SAP interface by invoking the function which |
| 6633 | * executes the callback to perform channel switch using (E)CSA. |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6634 | * |
| 6635 | * Return: None |
| 6636 | */ |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 6637 | void hdd_switch_sap_channel(hdd_adapter_t *adapter, uint8_t channel) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6638 | { |
| 6639 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 6640 | tHalHandle *hal_handle; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 6641 | hdd_context_t *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6642 | |
| 6643 | if (!adapter) { |
| 6644 | hdd_err("invalid adapter"); |
| 6645 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6646 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6647 | |
| 6648 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 6649 | |
| 6650 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 6651 | if (!hal_handle) { |
| 6652 | hdd_err("invalid HAL handle"); |
| 6653 | return; |
| 6654 | } |
| 6655 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 6656 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6657 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6658 | hdd_ap_ctx->sapConfig.channel = channel; |
| 6659 | hdd_ap_ctx->sapConfig.ch_params.ch_width = |
| 6660 | hdd_ap_ctx->sapConfig.ch_width_orig; |
| 6661 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6662 | hdd_debug("chan:%d width:%d", |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6663 | channel, hdd_ap_ctx->sapConfig.ch_width_orig); |
| 6664 | |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 6665 | cds_set_channel_params(hdd_ap_ctx->sapConfig.channel, |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6666 | hdd_ap_ctx->sapConfig.sec_ch, |
| 6667 | &hdd_ap_ctx->sapConfig.ch_params); |
| 6668 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 6669 | policy_mgr_change_sap_channel_with_csa(hdd_ctx->hdd_psoc, |
| 6670 | adapter->sessionId, channel, |
| 6671 | hdd_ap_ctx->sapConfig.ch_width_orig); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6672 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 6673 | |
| 6674 | int hdd_update_acs_timer_reason(hdd_adapter_t *adapter, uint8_t reason) |
| 6675 | { |
| 6676 | struct hdd_external_acs_timer_context *timer_context; |
| 6677 | |
| 6678 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 6679 | |
| 6680 | if (QDF_TIMER_STATE_RUNNING == |
| 6681 | qdf_mc_timer_get_current_state(&adapter->sessionCtx. |
| 6682 | ap.vendor_acs_timer)) { |
| 6683 | qdf_mc_timer_stop(&adapter->sessionCtx.ap.vendor_acs_timer); |
| 6684 | } |
| 6685 | timer_context = (struct hdd_external_acs_timer_context *) |
| 6686 | adapter->sessionCtx.ap.vendor_acs_timer.user_data; |
| 6687 | timer_context->reason = reason; |
| 6688 | qdf_mc_timer_start(&adapter->sessionCtx.ap.vendor_acs_timer, |
| 6689 | WLAN_VENDOR_ACS_WAIT_TIME); |
| 6690 | /* Update config to application */ |
| 6691 | hdd_cfg80211_update_acs_config(adapter, reason); |
| 6692 | hdd_notice("Updated ACS config to nl with reason %d", reason); |
| 6693 | |
| 6694 | return 0; |
| 6695 | } |
| 6696 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6697 | /** |
| 6698 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 6699 | * @hdd_ctx: hdd context pointer |
| 6700 | * |
| 6701 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 6702 | * and if ACS is enabled, driver will ask userspace to restart the |
| 6703 | * sap. User space on LTE coex indication restart driver. |
| 6704 | * |
| 6705 | * Return - none |
| 6706 | */ |
| 6707 | void hdd_unsafe_channel_restart_sap(hdd_context_t *hdd_ctxt) |
| 6708 | { |
| 6709 | QDF_STATUS status; |
| 6710 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 6711 | hdd_adapter_t *adapter_temp; |
| 6712 | uint32_t i; |
| 6713 | bool found = false; |
| 6714 | uint8_t restart_chan; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6715 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6716 | status = hdd_get_front_adapter(hdd_ctxt, &adapter_node); |
| 6717 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 6718 | adapter_temp = adapter_node->pAdapter; |
| 6719 | |
| 6720 | if (!adapter_temp) { |
| 6721 | hdd_err("adapter is NULL, moving to next one"); |
| 6722 | goto next_adapater; |
| 6723 | } |
| 6724 | |
| 6725 | if (!((adapter_temp->device_mode == QDF_SAP_MODE) && |
| 6726 | (adapter_temp->sessionCtx.ap.sapConfig.acs_cfg.acs_mode))) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6727 | hdd_debug("skip device mode:%d acs:%d", |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6728 | adapter_temp->device_mode, |
| 6729 | adapter_temp->sessionCtx.ap.sapConfig. |
| 6730 | acs_cfg.acs_mode); |
| 6731 | goto next_adapater; |
| 6732 | } |
| 6733 | |
| 6734 | found = false; |
| 6735 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 6736 | if (adapter_temp->sessionCtx.ap.operatingChannel == |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6737 | hdd_ctxt->unsafe_channel_list[i]) { |
| 6738 | found = true; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6739 | hdd_debug("operating ch:%d is unsafe", |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6740 | adapter_temp->sessionCtx.ap.operatingChannel); |
| 6741 | break; |
| 6742 | } |
| 6743 | } |
| 6744 | |
| 6745 | if (!found) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6746 | hdd_debug("ch:%d is safe. no need to change channel", |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6747 | adapter_temp->sessionCtx.ap.operatingChannel); |
| 6748 | goto next_adapater; |
| 6749 | } |
| 6750 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 6751 | if (hdd_ctxt->config->vendor_acs_support && |
| 6752 | hdd_ctxt->config->acs_support_for_dfs_ltecoex) { |
| 6753 | hdd_update_acs_timer_reason(adapter_temp, |
| 6754 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
| 6755 | goto next_adapater; |
| 6756 | } else |
| 6757 | restart_chan = |
| 6758 | hdd_get_safe_channel_from_pcl_and_acs_range( |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6759 | adapter_temp); |
| 6760 | if (!restart_chan) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6761 | hdd_err("fail to restart SAP"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6762 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 6763 | /* |
| 6764 | * SAP restart due to unsafe channel. While |
| 6765 | * restarting the SAP, make sure to clear |
| 6766 | * acs_channel, channel to reset to |
| 6767 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 6768 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 6769 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 6770 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
| 6771 | adapter_temp->sessionCtx.ap.sapConfig.channel = |
| 6772 | AUTO_CHANNEL_SELECT; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6773 | hdd_debug("sending coex indication"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6774 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 6775 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 6776 | hdd_switch_sap_channel(adapter_temp, restart_chan); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6777 | } |
| 6778 | |
| 6779 | next_adapater: |
| 6780 | status = hdd_get_next_adapter(hdd_ctxt, adapter_node, &next); |
| 6781 | adapter_node = next; |
| 6782 | } |
| 6783 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6784 | /** |
| 6785 | * hdd_ch_avoid_cb() - Avoid notified channels from FW handler |
| 6786 | * @adapter: HDD adapter pointer |
| 6787 | * @indParam: Channel avoid notification parameter |
| 6788 | * |
| 6789 | * Avoid channel notification from FW handler. |
| 6790 | * FW will send un-safe channel list to avoid over wrapping. |
| 6791 | * hostapd should not use notified channel |
| 6792 | * |
| 6793 | * Return: None |
| 6794 | */ |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6795 | void hdd_ch_avoid_cb(void *hdd_context, void *indi_param) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6796 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6797 | hdd_context_t *hdd_ctxt; |
| 6798 | tSirChAvoidIndType *ch_avoid_indi; |
| 6799 | uint8_t range_loop; |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6800 | enum channel_enum channel_loop, start_channel_idx = INVALID_CHANNEL, |
| 6801 | end_channel_idx = INVALID_CHANNEL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6802 | uint16_t start_channel; |
| 6803 | uint16_t end_channel; |
| 6804 | v_CONTEXT_t cds_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6805 | tHddAvoidFreqList hdd_avoid_freq_list; |
| 6806 | uint32_t i; |
| 6807 | |
| 6808 | /* Basic sanity */ |
| 6809 | if (!hdd_context || !indi_param) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6810 | hdd_err("Invalid arguments"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6811 | return; |
| 6812 | } |
| 6813 | |
| 6814 | hdd_ctxt = (hdd_context_t *) hdd_context; |
| 6815 | ch_avoid_indi = (tSirChAvoidIndType *) indi_param; |
| 6816 | cds_context = hdd_ctxt->pcds_context; |
| 6817 | |
| 6818 | /* Make unsafe channel list */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6819 | hdd_debug("band count %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6820 | ch_avoid_indi->avoid_range_count); |
| 6821 | |
| 6822 | /* generate vendor specific event */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6823 | qdf_mem_zero((void *)&hdd_avoid_freq_list, sizeof(tHddAvoidFreqList)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6824 | for (i = 0; i < ch_avoid_indi->avoid_range_count; i++) { |
| 6825 | hdd_avoid_freq_list.avoidFreqRange[i].startFreq = |
| 6826 | ch_avoid_indi->avoid_freq_range[i].start_freq; |
| 6827 | hdd_avoid_freq_list.avoidFreqRange[i].endFreq = |
| 6828 | ch_avoid_indi->avoid_freq_range[i].end_freq; |
| 6829 | } |
| 6830 | hdd_avoid_freq_list.avoidFreqRangeCount = |
| 6831 | ch_avoid_indi->avoid_range_count; |
| 6832 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6833 | /* clear existing unsafe channel cache */ |
| 6834 | hdd_ctxt->unsafe_channel_count = 0; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6835 | qdf_mem_zero(hdd_ctxt->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6836 | sizeof(hdd_ctxt->unsafe_channel_list)); |
| 6837 | |
| 6838 | for (range_loop = 0; range_loop < ch_avoid_indi->avoid_range_count; |
| 6839 | range_loop++) { |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6840 | if (hdd_ctxt->unsafe_channel_count >= NUM_CHANNELS) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6841 | hdd_warn("LTE Coex unsafe channel list full"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6842 | break; |
| 6843 | } |
| 6844 | |
| 6845 | start_channel = ieee80211_frequency_to_channel( |
| 6846 | ch_avoid_indi->avoid_freq_range[range_loop].start_freq); |
| 6847 | end_channel = ieee80211_frequency_to_channel( |
| 6848 | ch_avoid_indi->avoid_freq_range[range_loop].end_freq); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6849 | hdd_debug("start %d : %d, end %d : %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6850 | ch_avoid_indi->avoid_freq_range[range_loop].start_freq, |
| 6851 | start_channel, |
| 6852 | ch_avoid_indi->avoid_freq_range[range_loop].end_freq, |
| 6853 | end_channel); |
| 6854 | |
| 6855 | /* do not process frequency bands that are not mapped to |
| 6856 | * predefined channels |
| 6857 | */ |
| 6858 | if (start_channel == 0 || end_channel == 0) |
| 6859 | continue; |
| 6860 | |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6861 | for (channel_loop = CHAN_ENUM_1; channel_loop <= |
| 6862 | CHAN_ENUM_184; channel_loop++) { |
Amar Singhal | 7a1726a | 2015-10-14 16:28:11 -0700 | [diff] [blame] | 6863 | if (CDS_CHANNEL_FREQ(channel_loop) >= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6864 | ch_avoid_indi->avoid_freq_range[ |
| 6865 | range_loop].start_freq) { |
| 6866 | start_channel_idx = channel_loop; |
| 6867 | break; |
| 6868 | } |
| 6869 | } |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6870 | for (channel_loop = CHAN_ENUM_1; channel_loop <= |
| 6871 | CHAN_ENUM_184; channel_loop++) { |
Amar Singhal | 7a1726a | 2015-10-14 16:28:11 -0700 | [diff] [blame] | 6872 | if (CDS_CHANNEL_FREQ(channel_loop) >= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6873 | ch_avoid_indi->avoid_freq_range[ |
| 6874 | range_loop].end_freq) { |
| 6875 | end_channel_idx = channel_loop; |
Amar Singhal | 7a1726a | 2015-10-14 16:28:11 -0700 | [diff] [blame] | 6876 | if (CDS_CHANNEL_FREQ(channel_loop) > |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6877 | ch_avoid_indi->avoid_freq_range[ |
| 6878 | range_loop].end_freq) |
| 6879 | end_channel_idx--; |
| 6880 | break; |
| 6881 | } |
| 6882 | } |
| 6883 | |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6884 | if (start_channel_idx == INVALID_CHANNEL || |
| 6885 | end_channel_idx == INVALID_CHANNEL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6886 | continue; |
| 6887 | |
| 6888 | for (channel_loop = start_channel_idx; channel_loop <= |
| 6889 | end_channel_idx; channel_loop++) { |
| 6890 | hdd_ctxt->unsafe_channel_list[ |
Amar Singhal | 7a1726a | 2015-10-14 16:28:11 -0700 | [diff] [blame] | 6891 | hdd_ctxt->unsafe_channel_count++] = |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 6892 | CDS_CHANNEL_NUM(channel_loop); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6893 | if (hdd_ctxt->unsafe_channel_count >= |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6894 | NUM_CHANNELS) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6895 | hdd_warn("LTECoex unsafe ch list full"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6896 | break; |
| 6897 | } |
| 6898 | } |
| 6899 | } |
| 6900 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6901 | hdd_debug("number of unsafe channels is %d ", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6902 | hdd_ctxt->unsafe_channel_count); |
| 6903 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6904 | if (pld_set_wlan_unsafe_channel(hdd_ctxt->parent_dev, |
| 6905 | hdd_ctxt->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6906 | hdd_ctxt->unsafe_channel_count)) { |
| 6907 | hdd_err("Failed to set unsafe channel"); |
| 6908 | |
| 6909 | /* clear existing unsafe channel cache */ |
| 6910 | hdd_ctxt->unsafe_channel_count = 0; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6911 | qdf_mem_zero(hdd_ctxt->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6912 | sizeof(hdd_ctxt->unsafe_channel_list)); |
| 6913 | |
| 6914 | return; |
| 6915 | } |
| 6916 | |
| 6917 | for (channel_loop = 0; |
| 6918 | channel_loop < hdd_ctxt->unsafe_channel_count; channel_loop++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6919 | hdd_debug("channel %d is not safe ", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6920 | hdd_ctxt->unsafe_channel_list[channel_loop]); |
| 6921 | } |
| 6922 | |
Kondabattini, Ganesh | cf7b60f | 2016-08-10 16:31:55 +0530 | [diff] [blame] | 6923 | /* |
| 6924 | * first update the unsafe channel list to the platform driver and |
| 6925 | * send the avoid freq event to the application |
| 6926 | */ |
| 6927 | wlan_hdd_send_avoid_freq_event(hdd_ctxt, &hdd_avoid_freq_list); |
| 6928 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6929 | if (!hdd_ctxt->unsafe_channel_count) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6930 | hdd_debug("no unsafe channels - not restarting SAP"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6931 | return; |
| 6932 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6933 | hdd_unsafe_channel_restart_sap(hdd_ctxt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6934 | } |
| 6935 | |
| 6936 | /** |
| 6937 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 6938 | * @hdd_ctx: HDD global context |
| 6939 | * |
| 6940 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6941 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6942 | * down to the lower layers. Then subscribe to subsequent channel |
| 6943 | * avoidance events. |
| 6944 | * |
| 6945 | * Return: None |
| 6946 | */ |
| 6947 | static void hdd_init_channel_avoidance(hdd_context_t *hdd_ctx) |
| 6948 | { |
| 6949 | uint16_t unsafe_channel_count; |
| 6950 | int index; |
| 6951 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6952 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 6953 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6954 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6955 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6956 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6957 | hdd_debug("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6958 | hdd_ctx->unsafe_channel_count); |
| 6959 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6960 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6961 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6962 | |
| 6963 | for (index = 0; index < unsafe_channel_count; index++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6964 | hdd_debug("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6965 | hdd_ctx->unsafe_channel_list[index]); |
| 6966 | |
| 6967 | } |
| 6968 | |
| 6969 | /* Plug in avoid channel notification callback */ |
| 6970 | sme_add_ch_avoid_callback(hdd_ctx->hHal, hdd_ch_avoid_cb); |
| 6971 | } |
| 6972 | #else |
| 6973 | static void hdd_init_channel_avoidance(hdd_context_t *hdd_ctx) |
| 6974 | { |
| 6975 | } |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 6976 | 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] | 6977 | { |
| 6978 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6979 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6980 | |
| 6981 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 6982 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 6983 | * user space |
| 6984 | * @frame_ind: Management frame data to be informed. |
| 6985 | * |
| 6986 | * This function is used to indicate management frame to |
| 6987 | * user space |
| 6988 | * |
| 6989 | * Return: None |
| 6990 | * |
| 6991 | */ |
| 6992 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 6993 | { |
| 6994 | hdd_context_t *hdd_ctx = NULL; |
| 6995 | hdd_adapter_t *adapter = NULL; |
| 6996 | void *cds_context = NULL; |
| 6997 | int i; |
| 6998 | |
| 6999 | /* Get the global VOSS context.*/ |
| 7000 | cds_context = cds_get_global_context(); |
| 7001 | if (!cds_context) { |
| 7002 | hdd_err("Global CDS context is Null"); |
| 7003 | return; |
| 7004 | } |
| 7005 | /* Get the HDD context.*/ |
| 7006 | hdd_ctx = (hdd_context_t *)cds_get_context(QDF_MODULE_ID_HDD); |
| 7007 | |
| 7008 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 7009 | return; |
| 7010 | |
| 7011 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
| 7012 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 7013 | adapter = |
| 7014 | hdd_get_adapter_by_sme_session_id(hdd_ctx, i); |
| 7015 | if (adapter) |
| 7016 | break; |
| 7017 | } |
| 7018 | } else { |
| 7019 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 7020 | frame_ind->sessionId); |
| 7021 | } |
| 7022 | |
| 7023 | if ((NULL != adapter) && |
| 7024 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 7025 | __hdd_indicate_mgmt_frame(adapter, |
| 7026 | frame_ind->frame_len, |
| 7027 | frame_ind->frameBuf, |
| 7028 | frame_ind->frameType, |
| 7029 | frame_ind->rxChan, |
| 7030 | frame_ind->rxRssi); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7031 | } |
| 7032 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7033 | static void hdd_lte_coex_restart_sap(hdd_adapter_t *adapter, |
| 7034 | hdd_context_t *hdd_ctx) |
| 7035 | { |
| 7036 | uint8_t restart_chan = 0; |
| 7037 | |
| 7038 | restart_chan = |
| 7039 | hdd_get_safe_channel_from_pcl_and_acs_range(adapter); |
| 7040 | if (!restart_chan) { |
| 7041 | hdd_alert("fail to restart SAP"); |
| 7042 | } else { |
| 7043 | /* SAP restart due to unsafe channel. While restarting |
| 7044 | * the SAP, make sure to clear acs_channel, channel to |
| 7045 | * reset to 0. Otherwise these settings will override |
| 7046 | * the ACS while restart. |
| 7047 | */ |
| 7048 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
| 7049 | adapter->sessionCtx.ap.sapConfig.channel = |
| 7050 | AUTO_CHANNEL_SELECT; |
| 7051 | hdd_info("sending coex indication"); |
| 7052 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7053 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 7054 | hdd_switch_sap_channel(adapter, restart_chan); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7055 | } |
| 7056 | } |
| 7057 | |
| 7058 | void hdd_acs_response_timeout_handler(void *context) |
| 7059 | { |
| 7060 | struct hdd_external_acs_timer_context *timer_context = |
| 7061 | (struct hdd_external_acs_timer_context *)context; |
| 7062 | hdd_adapter_t *adapter; |
| 7063 | hdd_context_t *hdd_ctx; |
| 7064 | uint8_t reason; |
| 7065 | |
| 7066 | ENTER(); |
| 7067 | if (!timer_context) { |
| 7068 | hdd_err("invlaid timer context"); |
| 7069 | return; |
| 7070 | } |
| 7071 | adapter = timer_context->adapter; |
| 7072 | reason = timer_context->reason; |
| 7073 | |
| 7074 | |
| 7075 | if ((!adapter) || |
| 7076 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 7077 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 7078 | return; |
| 7079 | } |
| 7080 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7081 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7082 | return; |
| 7083 | |
| 7084 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 7085 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 7086 | else |
| 7087 | return; |
| 7088 | |
| 7089 | hdd_err("ACS timeout happened for %s reason %d", |
| 7090 | adapter->dev->name, reason); |
| 7091 | switch (reason) { |
| 7092 | /* SAP init case */ |
| 7093 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 7094 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 7095 | false); |
| 7096 | wlan_hdd_cfg80211_start_acs(adapter); |
| 7097 | break; |
| 7098 | /* DFS detected on current channel */ |
| 7099 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 7100 | wlan_sap_update_next_channel( |
| 7101 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
| 7102 | sme_update_new_channel_event(WLAN_HDD_GET_HAL_CTX(adapter), |
| 7103 | adapter->sessionId); |
| 7104 | break; |
| 7105 | /* LTE coex event on current channel */ |
| 7106 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 7107 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 7108 | break; |
| 7109 | default: |
| 7110 | hdd_info("invalid reason for timer invoke"); |
| 7111 | |
| 7112 | } |
| 7113 | } |
| 7114 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7115 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7116 | * wlan_hdd_disable_all_dual_mac_features() - Disable dual mac features |
| 7117 | * @hdd_ctx: HDD context |
| 7118 | * |
| 7119 | * Disables all the dual mac features like DBS, Agile DFS etc. |
| 7120 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7121 | * Return: QDF_STATUS_SUCCESS on success |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7122 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7123 | static QDF_STATUS wlan_hdd_disable_all_dual_mac_features(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7124 | { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7125 | struct policy_mgr_dual_mac_config cfg = {0}; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7126 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7127 | |
| 7128 | if (!hdd_ctx) { |
| 7129 | hdd_err("HDD context is NULL"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7130 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7131 | } |
| 7132 | |
| 7133 | cfg.scan_config = 0; |
| 7134 | cfg.fw_mode_config = 0; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7135 | 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] | 7136 | |
| 7137 | hdd_debug("Disabling all dual mac features..."); |
| 7138 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7139 | status = sme_soc_set_dual_mac_config(cfg); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7140 | if (status != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7141 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 7142 | return status; |
| 7143 | } |
| 7144 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7145 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7146 | } |
| 7147 | |
| 7148 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7149 | * hdd_override_ini_config - Override INI config |
| 7150 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7151 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7152 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7153 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7154 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7155 | */ |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7156 | static void hdd_override_ini_config(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7157 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7158 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7159 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
| 7160 | hdd_ctx->config->enableDFSChnlScan = enable_dfs_chan_scan; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7161 | hdd_debug("Module enable_dfs_chan_scan set to %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7162 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7163 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7164 | if (0 == enable_11d || 1 == enable_11d) { |
| 7165 | hdd_ctx->config->Is11dSupportEnabled = enable_11d; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7166 | hdd_debug("Module enable_11d set to %d", enable_11d); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7167 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 7168 | |
| 7169 | if (!hdd_ipa_is_present(hdd_ctx)) |
| 7170 | hdd_ctx->config->IpaConfig = 0; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7171 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7172 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7173 | /** |
| 7174 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 7175 | * @hdd_ctx - HDD context |
| 7176 | * |
| 7177 | * Set trace level for each module based on INI config. |
| 7178 | * |
| 7179 | * Return: None |
| 7180 | */ |
| 7181 | static void hdd_set_trace_level_for_each(hdd_context_t *hdd_ctx) |
| 7182 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7183 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMI, |
| 7184 | hdd_ctx->config->qdf_trace_enable_wdi); |
| 7185 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD, |
| 7186 | hdd_ctx->config->qdf_trace_enable_hdd); |
| 7187 | hdd_qdf_trace_enable(QDF_MODULE_ID_SME, |
| 7188 | hdd_ctx->config->qdf_trace_enable_sme); |
| 7189 | hdd_qdf_trace_enable(QDF_MODULE_ID_PE, |
| 7190 | hdd_ctx->config->qdf_trace_enable_pe); |
| 7191 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMA, |
| 7192 | hdd_ctx->config->qdf_trace_enable_wma); |
| 7193 | hdd_qdf_trace_enable(QDF_MODULE_ID_SYS, |
| 7194 | hdd_ctx->config->qdf_trace_enable_sys); |
| 7195 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF, |
| 7196 | hdd_ctx->config->qdf_trace_enable_qdf); |
| 7197 | hdd_qdf_trace_enable(QDF_MODULE_ID_SAP, |
| 7198 | hdd_ctx->config->qdf_trace_enable_sap); |
| 7199 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SOFTAP, |
| 7200 | hdd_ctx->config->qdf_trace_enable_hdd_sap); |
| 7201 | hdd_qdf_trace_enable(QDF_MODULE_ID_BMI, |
| 7202 | hdd_ctx->config->qdf_trace_enable_bmi); |
| 7203 | hdd_qdf_trace_enable(QDF_MODULE_ID_CFG, |
| 7204 | hdd_ctx->config->qdf_trace_enable_cfg); |
| 7205 | hdd_qdf_trace_enable(QDF_MODULE_ID_EPPING, |
| 7206 | hdd_ctx->config->qdf_trace_enable_epping); |
| 7207 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF_DEVICE, |
| 7208 | hdd_ctx->config->qdf_trace_enable_qdf_devices); |
| 7209 | hdd_qdf_trace_enable(QDF_MODULE_ID_TXRX, |
Bhargav Shah | 480a90f | 2015-06-24 15:10:14 +0530 | [diff] [blame] | 7210 | hdd_ctx->config->cfd_trace_enable_txrx); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7211 | hdd_qdf_trace_enable(QDF_MODULE_ID_HTC, |
| 7212 | hdd_ctx->config->qdf_trace_enable_htc); |
| 7213 | hdd_qdf_trace_enable(QDF_MODULE_ID_HIF, |
| 7214 | hdd_ctx->config->qdf_trace_enable_hif); |
| 7215 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SAP_DATA, |
| 7216 | hdd_ctx->config->qdf_trace_enable_hdd_sap_data); |
| 7217 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_DATA, |
| 7218 | hdd_ctx->config->qdf_trace_enable_hdd_data); |
Naveen Rawat | 7df3186 | 2017-03-01 17:09:30 -0800 | [diff] [blame] | 7219 | hdd_qdf_trace_enable(QDF_MODULE_ID_WIFIPOS, |
| 7220 | hdd_ctx->config->qdf_trace_enable_wifi_pos); |
Naveen Rawat | f2b0dbd | 2017-03-27 10:00:15 -0700 | [diff] [blame] | 7221 | hdd_qdf_trace_enable(QDF_MODULE_ID_NAN, |
| 7222 | hdd_ctx->config->qdf_trace_enable_nan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7223 | hdd_cfg_print(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7224 | } |
| 7225 | |
| 7226 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7227 | * hdd_context_init() - Initialize HDD context |
| 7228 | * @hdd_ctx: HDD context. |
| 7229 | * |
| 7230 | * Initialize HDD context along with all the feature specific contexts. |
| 7231 | * |
| 7232 | * return: 0 on success and errno on failure. |
| 7233 | */ |
| 7234 | static int hdd_context_init(hdd_context_t *hdd_ctx) |
| 7235 | { |
| 7236 | int ret; |
| 7237 | |
| 7238 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 7239 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 7240 | |
| 7241 | hdd_init_ll_stats_ctx(); |
| 7242 | |
| 7243 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 7244 | init_completion(&hdd_ctx->ready_to_suspend); |
| 7245 | |
| 7246 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7247 | qdf_spinlock_create(&hdd_ctx->sta_update_info_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7248 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7249 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7250 | qdf_list_create(&hdd_ctx->hddAdapters, MAX_NUMBER_OF_ADAPTERS); |
| 7251 | |
| 7252 | init_completion(&hdd_ctx->set_antenna_mode_cmpl); |
| 7253 | |
| 7254 | ret = hdd_scan_context_init(hdd_ctx); |
| 7255 | if (ret) |
| 7256 | goto list_destroy; |
| 7257 | |
Nitesh Shah | d1266d7 | 2017-01-25 22:07:07 +0530 | [diff] [blame] | 7258 | hdd_tdls_context_init(hdd_ctx, false); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7259 | |
| 7260 | hdd_rx_wake_lock_create(hdd_ctx); |
| 7261 | |
| 7262 | ret = hdd_sap_context_init(hdd_ctx); |
| 7263 | if (ret) |
| 7264 | goto scan_destroy; |
| 7265 | |
| 7266 | ret = hdd_roc_context_init(hdd_ctx); |
| 7267 | if (ret) |
| 7268 | goto sap_destroy; |
| 7269 | |
| 7270 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 7271 | |
| 7272 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 7273 | |
| 7274 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 7275 | hdd_ctx->config); |
| 7276 | if (ret) |
| 7277 | goto roc_destroy; |
| 7278 | |
| 7279 | return 0; |
| 7280 | |
| 7281 | roc_destroy: |
| 7282 | hdd_roc_context_destroy(hdd_ctx); |
| 7283 | |
| 7284 | sap_destroy: |
| 7285 | hdd_sap_context_destroy(hdd_ctx); |
| 7286 | |
| 7287 | scan_destroy: |
| 7288 | hdd_scan_context_destroy(hdd_ctx); |
| 7289 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 7290 | hdd_tdls_context_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7291 | list_destroy: |
| 7292 | qdf_list_destroy(&hdd_ctx->hddAdapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 7293 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7294 | return ret; |
| 7295 | } |
| 7296 | |
| 7297 | /** |
| 7298 | * hdd_context_create() - Allocate and inialize HDD context. |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7299 | * @dev: Device Pointer to the underlying device |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7300 | * |
| 7301 | * Allocate and initialize HDD context. HDD context is allocated as part of |
| 7302 | * wiphy allocation and then context is initialized. |
| 7303 | * |
| 7304 | * Return: HDD context on success and ERR_PTR on failure |
| 7305 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 7306 | static hdd_context_t *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7307 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7308 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7309 | int ret = 0; |
| 7310 | hdd_context_t *hdd_ctx; |
| 7311 | v_CONTEXT_t p_cds_context; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 7312 | int qdf_print_idx = -1; |
| 7313 | |
| 7314 | struct category_info cinfo[MAX_SUPPORTED_CATEGORY] = { |
| 7315 | [QDF_MODULE_ID_TLSHIM] = {QDF_TRACE_LEVEL_ALL}, |
| 7316 | [QDF_MODULE_ID_WMI] = {QDF_TRACE_LEVEL_ALL}, |
| 7317 | [QDF_MODULE_ID_HTT] = {QDF_TRACE_LEVEL_ALL}, |
| 7318 | [QDF_MODULE_ID_HDD] = {QDF_TRACE_LEVEL_ALL}, |
| 7319 | [QDF_MODULE_ID_SME] = {QDF_TRACE_LEVEL_ALL}, |
| 7320 | [QDF_MODULE_ID_PE] = {QDF_TRACE_LEVEL_ALL}, |
| 7321 | [QDF_MODULE_ID_WMA] = {QDF_TRACE_LEVEL_ALL}, |
| 7322 | [QDF_MODULE_ID_SYS] = {QDF_TRACE_LEVEL_ALL}, |
| 7323 | [QDF_MODULE_ID_QDF] = {QDF_TRACE_LEVEL_ALL}, |
| 7324 | [QDF_MODULE_ID_SAP] = {QDF_TRACE_LEVEL_ALL}, |
| 7325 | [QDF_MODULE_ID_HDD_SOFTAP] = {QDF_TRACE_LEVEL_ALL}, |
| 7326 | [QDF_MODULE_ID_HDD_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 7327 | [QDF_MODULE_ID_HDD_SAP_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 7328 | [QDF_MODULE_ID_HIF] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 7329 | [QDF_MODULE_ID_HTC] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 7330 | [QDF_MODULE_ID_TXRX] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 7331 | [QDF_MODULE_ID_QDF_DEVICE] = {QDF_TRACE_LEVEL_ALL}, |
| 7332 | [QDF_MODULE_ID_CFG] = {QDF_TRACE_LEVEL_ALL}, |
| 7333 | [QDF_MODULE_ID_BMI] = {QDF_TRACE_LEVEL_ALL}, |
| 7334 | [QDF_MODULE_ID_EPPING] = {QDF_TRACE_LEVEL_ALL}, |
Ashish Kumar Dhanotiya | f928edf | 2017-02-06 14:43:24 +0530 | [diff] [blame] | 7335 | [QDF_MODULE_ID_QVIT] = {QDF_TRACE_LEVEL_ALL}, |
| 7336 | [QDF_MODULE_ID_DP] = {QDF_TRACE_LEVEL_ALL}, |
| 7337 | [QDF_MODULE_ID_SOC] = {QDF_TRACE_LEVEL_ALL}, |
| 7338 | [QDF_MODULE_ID_OS_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 7339 | [QDF_MODULE_ID_TARGET_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 7340 | [QDF_MODULE_ID_SCHEDULER] = {QDF_TRACE_LEVEL_ALL}, |
Mukul Sharma | 4d7d6b0 | 2017-02-13 20:45:22 +0530 | [diff] [blame] | 7341 | [QDF_MODULE_ID_MGMT_TXRX] = {QDF_TRACE_LEVEL_ALL}, |
Abhishek Singh | 9679dbf | 2017-02-15 11:35:41 +0530 | [diff] [blame] | 7342 | [QDF_MODULE_ID_PMO] = {QDF_TRACE_LEVEL_ALL}, |
Tushnim Bhattacharyya | 6796d8d | 2017-03-17 11:06:03 -0700 | [diff] [blame] | 7343 | [QDF_MODULE_ID_SCAN] = {QDF_TRACE_LEVEL_ALL}, |
| 7344 | [QDF_MODULE_ID_POLICY_MGR] = {QDF_TRACE_LEVEL_ALL}, |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 7345 | [QDF_MODULE_ID_P2P] = {QDF_TRACE_LEVEL_ALL}, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 7346 | }; |
| 7347 | |
| 7348 | status = qdf_print_setup(); |
| 7349 | if (status != QDF_STATUS_SUCCESS) { |
| 7350 | pr_err("QDF print control object setup failed\n"); |
| 7351 | ret = -EINVAL; |
| 7352 | goto err_out; |
| 7353 | } |
| 7354 | /* Register the module here with QDF */ |
| 7355 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, |
| 7356 | "MCL_WLAN"); |
| 7357 | |
| 7358 | /* if qdf_print_idx is negative */ |
| 7359 | if (qdf_print_idx < 0) { |
| 7360 | pr_err("QDF print control can not be registered %d\n", |
| 7361 | qdf_print_idx); |
| 7362 | ret = -EINVAL; |
| 7363 | goto err_out; |
| 7364 | } |
| 7365 | |
| 7366 | /* Store the qdf_pidx information into qdf module */ |
| 7367 | qdf_set_pidx(qdf_print_idx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7368 | |
| 7369 | ENTER(); |
| 7370 | |
| 7371 | p_cds_context = cds_get_global_context(); |
| 7372 | if (p_cds_context == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7373 | hdd_err("Failed to get CDS global context"); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7374 | ret = -EINVAL; |
| 7375 | goto err_out; |
| 7376 | } |
| 7377 | |
| 7378 | hdd_ctx = hdd_cfg80211_wiphy_alloc(sizeof(hdd_context_t)); |
| 7379 | |
| 7380 | if (hdd_ctx == NULL) { |
| 7381 | ret = -ENOMEM; |
| 7382 | goto err_out; |
| 7383 | } |
| 7384 | |
| 7385 | hdd_ctx->pcds_context = p_cds_context; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7386 | hdd_ctx->parent_dev = dev; |
Sreelakshmi Konamki | b53c629 | 2017-03-01 13:13:23 +0530 | [diff] [blame] | 7387 | hdd_ctx->last_scan_reject_session_id = 0xFF; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7388 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7389 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7390 | if (hdd_ctx->config == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7391 | hdd_err("Failed to alloc memory for HDD config!"); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7392 | ret = -ENOMEM; |
| 7393 | goto err_free_hdd_context; |
| 7394 | } |
| 7395 | |
| 7396 | /* Read and parse the qcom_cfg.ini file */ |
| 7397 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7398 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7399 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7400 | WLAN_INI_FILE); |
| 7401 | ret = -EINVAL; |
| 7402 | goto err_free_config; |
| 7403 | } |
| 7404 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7405 | hdd_debug("Setting configuredMcastBcastFilter: %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7406 | hdd_ctx->config->mcastBcastFilterSetting); |
| 7407 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 7408 | if (hdd_ctx->config->fhostNSOffload) |
| 7409 | hdd_ctx->ns_offload_enable = true; |
| 7410 | |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 7411 | cds_set_fatal_event(hdd_ctx->config->enable_fatal_event); |
| 7412 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7413 | hdd_override_ini_config(hdd_ctx); |
| 7414 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7415 | ((cds_context_type *) (p_cds_context))->pHDDContext = (void *)hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7416 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7417 | ret = hdd_context_init(hdd_ctx); |
| 7418 | |
| 7419 | if (ret) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7420 | goto err_free_config; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7421 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7422 | |
Yuanyuan Liu | 7a97b8f | 2017-01-27 10:42:52 -0800 | [diff] [blame] | 7423 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 7424 | hdd_ctx->config->enable_fw_log); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7425 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7426 | |
| 7427 | /* Uses to enabled logging after SSR */ |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 7428 | hdd_ctx->fw_log_settings.enable = hdd_ctx->config->enable_fw_log; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7429 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7430 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7431 | goto skip_multicast_logging; |
| 7432 | |
| 7433 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 7434 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 7435 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 7436 | if (ret) |
| 7437 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7438 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7439 | ret = hdd_logging_sock_activate_svc(hdd_ctx); |
| 7440 | if (ret) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7441 | goto err_free_histogram; |
| 7442 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7443 | skip_multicast_logging: |
| 7444 | hdd_set_trace_level_for_each(hdd_ctx); |
| 7445 | |
| 7446 | return hdd_ctx; |
| 7447 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7448 | err_free_histogram: |
| 7449 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 7450 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 7451 | err_deinit_hdd_context: |
| 7452 | hdd_context_deinit(hdd_ctx); |
| 7453 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7454 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7455 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7456 | |
| 7457 | err_free_hdd_context: |
| 7458 | wiphy_free(hdd_ctx->wiphy); |
| 7459 | |
| 7460 | err_out: |
| 7461 | return ERR_PTR(ret); |
| 7462 | } |
| 7463 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7464 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 7465 | /** |
| 7466 | * hdd_open_p2p_interface - Open P2P interface |
| 7467 | * @hdd_ctx: HDD context |
| 7468 | * @rtnl_held: True if RTNL lock held |
| 7469 | * |
| 7470 | * Open P2P interface during probe. This function called to open the P2P |
| 7471 | * interface at probe along with STA interface. |
| 7472 | * |
| 7473 | * Return: 0 on success and errno on failure |
| 7474 | */ |
| 7475 | static int hdd_open_p2p_interface(hdd_context_t *hdd_ctx, bool rtnl_held) |
| 7476 | { |
| 7477 | hdd_adapter_t *adapter; |
| 7478 | uint8_t *p2p_dev_addr; |
| 7479 | |
| 7480 | if (hdd_ctx->config->isP2pDeviceAddrAdministrated && |
| 7481 | !(hdd_ctx->config->intfMacAddr[0].bytes[0] & 0x02)) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7482 | qdf_mem_copy(hdd_ctx->p2pDeviceAddress.bytes, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7483 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 7484 | sizeof(tSirMacAddr)); |
| 7485 | |
| 7486 | /* |
| 7487 | * Generate the P2P Device Address. This consists of |
| 7488 | * the device's primary MAC address with the locally |
| 7489 | * administered bit set. |
| 7490 | */ |
| 7491 | hdd_ctx->p2pDeviceAddress.bytes[0] |= 0x02; |
| 7492 | } else { |
| 7493 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx); |
| 7494 | if (p2p_dev_addr == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7495 | hdd_err("Failed to allocate mac_address for p2p_device"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7496 | return -ENOSPC; |
| 7497 | } |
| 7498 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7499 | qdf_mem_copy(&hdd_ctx->p2pDeviceAddress.bytes[0], p2p_dev_addr, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7500 | QDF_MAC_ADDR_SIZE); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7501 | } |
| 7502 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7503 | adapter = hdd_open_adapter(hdd_ctx, QDF_P2P_DEVICE_MODE, "p2p%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7504 | &hdd_ctx->p2pDeviceAddress.bytes[0], |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 7505 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7506 | |
| 7507 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7508 | hdd_err("Failed to do hdd_open_adapter for P2P Device Interface"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7509 | return -ENOSPC; |
| 7510 | } |
| 7511 | |
| 7512 | return 0; |
| 7513 | } |
| 7514 | #else |
Manishekar Chandrasekaran | c81ba24 | 2016-07-18 17:44:44 +0530 | [diff] [blame] | 7515 | static inline int hdd_open_p2p_interface(hdd_context_t *hdd_ctx, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7516 | bool rtnl_held) |
| 7517 | { |
| 7518 | return 0; |
| 7519 | } |
| 7520 | #endif |
| 7521 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7522 | static int hdd_open_ocb_interface(hdd_context_t *hdd_ctx, bool rtnl_held) |
| 7523 | { |
| 7524 | hdd_adapter_t *adapter; |
| 7525 | int ret = 0; |
| 7526 | |
| 7527 | adapter = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, "wlanocb%d", |
| 7528 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 7529 | NET_NAME_UNKNOWN, rtnl_held); |
| 7530 | if (adapter == NULL) { |
| 7531 | hdd_err("Failed to open 802.11p interface"); |
| 7532 | ret = -ENOSPC; |
| 7533 | } |
| 7534 | |
| 7535 | return ret; |
| 7536 | } |
| 7537 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7538 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 7539 | * hdd_start_station_adapter()- Start the Station Adapter |
| 7540 | * @adapter: HDD adapter |
| 7541 | * |
| 7542 | * This function initializes the adapter for the station mode. |
| 7543 | * |
| 7544 | * Return: 0 on success or errno on failure. |
| 7545 | */ |
| 7546 | int hdd_start_station_adapter(hdd_adapter_t *adapter) |
| 7547 | { |
| 7548 | QDF_STATUS status; |
| 7549 | |
| 7550 | ENTER_DEV(adapter->dev); |
| 7551 | |
| 7552 | status = hdd_init_station_mode(adapter); |
| 7553 | |
| 7554 | if (QDF_STATUS_SUCCESS != status) { |
| 7555 | hdd_err("Error Initializing station mode: %d", status); |
| 7556 | return qdf_status_to_os_return(status); |
| 7557 | } |
| 7558 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7559 | hdd_register_tx_flow_control(adapter, |
| 7560 | hdd_tx_resume_timer_expired_handler, |
| 7561 | hdd_tx_resume_cb); |
| 7562 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 7563 | EXIT(); |
| 7564 | return 0; |
| 7565 | } |
| 7566 | |
| 7567 | /** |
| 7568 | * hdd_start_ap_adapter()- Start AP Adapter |
| 7569 | * @adapter: HDD adapter |
| 7570 | * |
| 7571 | * This function initializes the adapter for the AP mode. |
| 7572 | * |
| 7573 | * Return: 0 on success errno on failure. |
| 7574 | */ |
| 7575 | int hdd_start_ap_adapter(hdd_adapter_t *adapter) |
| 7576 | { |
| 7577 | QDF_STATUS status; |
| 7578 | |
| 7579 | ENTER(); |
| 7580 | |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 7581 | status = hdd_init_ap_mode(adapter, false); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 7582 | |
| 7583 | if (QDF_STATUS_SUCCESS != status) { |
| 7584 | hdd_err("Error Initializing the AP mode: %d", status); |
| 7585 | return qdf_status_to_os_return(status); |
| 7586 | } |
| 7587 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7588 | hdd_register_tx_flow_control(adapter, |
| 7589 | hdd_softap_tx_resume_timer_expired_handler, |
| 7590 | hdd_softap_tx_resume_cb); |
| 7591 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 7592 | EXIT(); |
| 7593 | return 0; |
| 7594 | } |
| 7595 | |
| 7596 | /** |
| 7597 | * hdd_start_ftm_adapter()- Start FTM adapter |
| 7598 | * @adapter: HDD adapter |
| 7599 | * |
| 7600 | * This function initializes the adapter for the FTM mode. |
| 7601 | * |
| 7602 | * Return: 0 on success or errno on failure. |
| 7603 | */ |
| 7604 | int hdd_start_ftm_adapter(hdd_adapter_t *adapter) |
| 7605 | { |
| 7606 | QDF_STATUS qdf_status; |
| 7607 | |
| 7608 | ENTER_DEV(adapter->dev); |
| 7609 | |
| 7610 | qdf_status = hdd_init_tx_rx(adapter); |
| 7611 | |
| 7612 | if (QDF_STATUS_SUCCESS != qdf_status) { |
| 7613 | hdd_err("Failed to start FTM adapter: %d", qdf_status); |
| 7614 | return qdf_status_to_os_return(qdf_status); |
| 7615 | } |
| 7616 | |
| 7617 | return 0; |
| 7618 | EXIT(); |
| 7619 | } |
| 7620 | |
| 7621 | /** |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7622 | * hdd_open_interfaces - Open all required interfaces |
| 7623 | * hdd_ctx: HDD context |
| 7624 | * rtnl_held: True if RTNL lock is held |
| 7625 | * |
| 7626 | * Open all the interfaces like STA, P2P and OCB based on the configuration. |
| 7627 | * |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7628 | * Return: 0 if all interfaces were created, otherwise negative errno |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7629 | */ |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7630 | static int hdd_open_interfaces(hdd_context_t *hdd_ctx, bool rtnl_held) |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7631 | { |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7632 | hdd_adapter_t *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7633 | int ret; |
| 7634 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7635 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_STANDALONE) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7636 | /* Create only 802.11p interface */ |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7637 | return hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7638 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7639 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, "wlan%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7640 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 7641 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7642 | |
| 7643 | if (adapter == NULL) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7644 | return -ENOSPC; |
| 7645 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 7646 | /* fast roaming is allowed only on first STA, i.e. wlan adapter */ |
| 7647 | adapter->fast_roaming_allowed = true; |
| 7648 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7649 | ret = hdd_open_p2p_interface(hdd_ctx, rtnl_held); |
| 7650 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7651 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7652 | |
| 7653 | /* Open 802.11p Interface */ |
| 7654 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_CONCURRENT) { |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7655 | ret = hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
| 7656 | if (ret) |
| 7657 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7658 | } |
| 7659 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7660 | return 0; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7661 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7662 | err_close_adapters: |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7663 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7664 | return ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7665 | } |
| 7666 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7667 | /** |
| 7668 | * hdd_update_country_code - Update country code |
| 7669 | * @hdd_ctx: HDD context |
| 7670 | * @adapter: Primary adapter context |
| 7671 | * |
| 7672 | * Update country code based on module parameter country_code at SME and wait |
| 7673 | * for the settings to take effect. |
| 7674 | * |
| 7675 | * Return: 0 on success and errno on failure |
| 7676 | */ |
| 7677 | static int hdd_update_country_code(hdd_context_t *hdd_ctx, |
| 7678 | hdd_adapter_t *adapter) |
| 7679 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7680 | QDF_STATUS status; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7681 | int ret = 0; |
| 7682 | unsigned long rc; |
| 7683 | |
| 7684 | if (country_code == NULL) |
| 7685 | return 0; |
| 7686 | |
| 7687 | INIT_COMPLETION(adapter->change_country_code); |
| 7688 | |
| 7689 | status = sme_change_country_code(hdd_ctx->hHal, |
| 7690 | wlan_hdd_change_country_code_callback, |
| 7691 | country_code, adapter, |
| 7692 | hdd_ctx->pcds_context, eSIR_TRUE, |
| 7693 | eSIR_TRUE); |
| 7694 | |
| 7695 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7696 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7697 | hdd_err("SME Change Country code from module param fail ret=%d", |
| 7698 | ret); |
| 7699 | return -EINVAL; |
| 7700 | } |
| 7701 | |
| 7702 | rc = wait_for_completion_timeout(&adapter->change_country_code, |
| 7703 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 7704 | if (!rc) { |
| 7705 | hdd_err("SME while setting country code timed out"); |
| 7706 | ret = -ETIMEDOUT; |
| 7707 | } |
| 7708 | |
| 7709 | return ret; |
| 7710 | } |
| 7711 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7712 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 7713 | /** |
| 7714 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 7715 | * @cds_cfg: CDS Configuration |
| 7716 | * @hdd_ctx: Pointer to hdd context |
| 7717 | * |
| 7718 | * Return: none |
| 7719 | */ |
| 7720 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 7721 | *cds_cfg, |
| 7722 | hdd_context_t *hdd_ctx) |
| 7723 | { |
| 7724 | cds_cfg->tx_flow_stop_queue_th = |
| 7725 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 7726 | cds_cfg->tx_flow_start_queue_offset = |
| 7727 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 7728 | } |
| 7729 | #else |
| 7730 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 7731 | *cds_cfg, |
| 7732 | hdd_context_t *hdd_ctx) |
| 7733 | { |
| 7734 | } |
| 7735 | #endif |
| 7736 | |
| 7737 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 7738 | /** |
| 7739 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 7740 | * @cds_cfg: CDS Configuration |
| 7741 | * @hdd_ctx: Pointer to hdd context |
| 7742 | * |
| 7743 | * Return: none |
| 7744 | */ |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 7745 | static inline void hdd_ra_populate_cds_config(struct cds_config_info *cds_cfg, |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7746 | hdd_context_t *hdd_ctx) |
| 7747 | { |
| 7748 | cds_cfg->ra_ratelimit_interval = |
| 7749 | hdd_ctx->config->RArateLimitInterval; |
| 7750 | cds_cfg->is_ra_ratelimit_enabled = |
| 7751 | hdd_ctx->config->IsRArateLimitEnabled; |
| 7752 | } |
| 7753 | #else |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 7754 | static inline void hdd_ra_populate_cds_config(struct cds_config_info *cds_cfg, |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7755 | hdd_context_t *hdd_ctx) |
| 7756 | { |
| 7757 | } |
| 7758 | #endif |
| 7759 | |
| 7760 | /** |
| 7761 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 7762 | * @hdd_ctx: HDD Context |
| 7763 | * |
| 7764 | * Return: 0 for Success, errno on failure |
| 7765 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 7766 | static int hdd_update_cds_config(hdd_context_t *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7767 | { |
| 7768 | struct cds_config_info *cds_cfg; |
| 7769 | |
| 7770 | cds_cfg = (struct cds_config_info *)qdf_mem_malloc(sizeof(*cds_cfg)); |
| 7771 | if (!cds_cfg) { |
| 7772 | hdd_err("failed to allocate cds config"); |
| 7773 | return -ENOMEM; |
| 7774 | } |
| 7775 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7776 | cds_cfg->driver_type = DRIVER_TYPE_PRODUCTION; |
Kiran Kumar Lokere | 7006e0a | 2017-03-07 19:28:36 -0800 | [diff] [blame] | 7777 | if (!hdd_ctx->config->nMaxPsPoll || |
| 7778 | !hdd_ctx->config->enablePowersaveOffload) { |
| 7779 | cds_cfg->powersave_offload_enabled = |
| 7780 | hdd_ctx->config->enablePowersaveOffload; |
| 7781 | } else { |
| 7782 | if ((hdd_ctx->config->enablePowersaveOffload == |
| 7783 | PS_QPOWER_NODEEPSLEEP) || |
| 7784 | (hdd_ctx->config->enablePowersaveOffload == |
| 7785 | PS_LEGACY_NODEEPSLEEP)) |
| 7786 | cds_cfg->powersave_offload_enabled = |
| 7787 | PS_LEGACY_NODEEPSLEEP; |
| 7788 | else |
| 7789 | cds_cfg->powersave_offload_enabled = |
| 7790 | PS_LEGACY_DEEPSLEEP; |
| 7791 | hdd_info("Qpower disabled in cds config, %d", |
| 7792 | cds_cfg->powersave_offload_enabled); |
| 7793 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7794 | cds_cfg->sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 7795 | cds_cfg->sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 7796 | cds_cfg->sta_maxlimod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 7797 | cds_cfg->wow_enable = hdd_ctx->config->wowEnable; |
| 7798 | cds_cfg->max_wow_filters = hdd_ctx->config->maxWoWFilters; |
| 7799 | |
| 7800 | /* Here ol_ini_info is used to store ini status of arp offload |
| 7801 | * ns offload and others. Currently 1st bit is used for arp |
| 7802 | * off load and 2nd bit for ns offload currently, rest bits are unused |
| 7803 | */ |
| 7804 | if (hdd_ctx->config->fhostArpOffload) |
| 7805 | cds_cfg->ol_ini_info = cds_cfg->ol_ini_info | 0x1; |
| 7806 | if (hdd_ctx->config->fhostNSOffload) |
| 7807 | cds_cfg->ol_ini_info = cds_cfg->ol_ini_info | 0x2; |
| 7808 | |
| 7809 | /* |
| 7810 | * Copy the DFS Phyerr Filtering Offload status. |
| 7811 | * This parameter reflects the value of the |
| 7812 | * dfs_phyerr_filter_offload flag as set in the ini. |
| 7813 | */ |
| 7814 | cds_cfg->dfs_phyerr_filter_offload = |
| 7815 | hdd_ctx->config->fDfsPhyerrFilterOffload; |
| 7816 | if (hdd_ctx->config->ssdp) |
| 7817 | cds_cfg->ssdp = hdd_ctx->config->ssdp; |
| 7818 | |
| 7819 | cds_cfg->enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 7820 | cds_cfg->ap_maxoffload_peers = hdd_ctx->config->apMaxOffloadPeers; |
| 7821 | |
| 7822 | cds_cfg->ap_maxoffload_reorderbuffs = |
| 7823 | hdd_ctx->config->apMaxOffloadReorderBuffs; |
| 7824 | |
| 7825 | cds_cfg->ap_disable_intrabss_fwd = |
| 7826 | hdd_ctx->config->apDisableIntraBssFwd; |
| 7827 | |
| 7828 | cds_cfg->dfs_pri_multiplier = |
| 7829 | hdd_ctx->config->dfsRadarPriMultiplier; |
| 7830 | cds_cfg->reorder_offload = |
| 7831 | hdd_ctx->config->reorderOffloadSupport; |
| 7832 | |
| 7833 | /* IPA micro controller data path offload resource config item */ |
| 7834 | cds_cfg->uc_offload_enabled = hdd_ipa_uc_is_enabled(hdd_ctx); |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 7835 | if (!is_power_of_2(hdd_ctx->config->IpaUcTxBufCount)) { |
| 7836 | /* IpaUcTxBufCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7837 | hdd_debug("Round down IpaUcTxBufCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 7838 | hdd_ctx->config->IpaUcTxBufCount); |
| 7839 | hdd_ctx->config->IpaUcTxBufCount = |
| 7840 | rounddown_pow_of_two( |
| 7841 | hdd_ctx->config->IpaUcTxBufCount); |
| 7842 | if (!hdd_ctx->config->IpaUcTxBufCount) { |
| 7843 | hdd_err("Failed to round down IpaUcTxBufCount"); |
| 7844 | return -EINVAL; |
| 7845 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7846 | hdd_debug("IpaUcTxBufCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 7847 | hdd_ctx->config->IpaUcTxBufCount); |
| 7848 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7849 | cds_cfg->uc_txbuf_count = hdd_ctx->config->IpaUcTxBufCount; |
| 7850 | cds_cfg->uc_txbuf_size = hdd_ctx->config->IpaUcTxBufSize; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 7851 | if (!is_power_of_2(hdd_ctx->config->IpaUcRxIndRingCount)) { |
| 7852 | /* IpaUcRxIndRingCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7853 | hdd_debug("Round down IpaUcRxIndRingCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 7854 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 7855 | hdd_ctx->config->IpaUcRxIndRingCount = |
| 7856 | rounddown_pow_of_two( |
| 7857 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 7858 | if (!hdd_ctx->config->IpaUcRxIndRingCount) { |
| 7859 | hdd_err("Failed to round down IpaUcRxIndRingCount"); |
| 7860 | return -EINVAL; |
| 7861 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7862 | hdd_debug("IpaUcRxIndRingCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 7863 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 7864 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7865 | cds_cfg->uc_rxind_ringcount = |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 7866 | hdd_ctx->config->IpaUcRxIndRingCount; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7867 | cds_cfg->uc_tx_partition_base = |
| 7868 | hdd_ctx->config->IpaUcTxPartitionBase; |
| 7869 | cds_cfg->max_scan = hdd_ctx->config->max_scan_count; |
| 7870 | |
| 7871 | cds_cfg->ip_tcp_udp_checksum_offload = |
| 7872 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 7873 | cds_cfg->enable_rxthread = hdd_ctx->enableRxThread; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7874 | cds_cfg->ce_classify_enabled = |
| 7875 | hdd_ctx->config->ce_classify_enabled; |
Dustin Brown | d3fc9ee | 2016-09-14 13:57:27 -0700 | [diff] [blame] | 7876 | cds_cfg->bpf_packet_filter_enable = |
| 7877 | hdd_ctx->config->bpf_packet_filter_enable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7878 | cds_cfg->tx_chain_mask_cck = hdd_ctx->config->tx_chain_mask_cck; |
| 7879 | cds_cfg->self_gen_frm_pwr = hdd_ctx->config->self_gen_frm_pwr; |
| 7880 | cds_cfg->max_station = hdd_ctx->config->maxNumberOfPeers; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 7881 | cds_cfg->sub_20_channel_width = WLAN_SUB_20_CH_WIDTH_NONE; |
Manjunathappa Prakash | fff753c | 2016-09-01 19:34:56 -0700 | [diff] [blame] | 7882 | cds_cfg->flow_steering_enabled = hdd_ctx->config->flow_steering_enable; |
Naveen Rawat | 91df30a | 2016-10-12 21:26:18 -0700 | [diff] [blame] | 7883 | cds_cfg->self_recovery_enabled = hdd_ctx->config->enableSelfRecovery; |
Sandeep Puligilla | afa5289 | 2016-10-26 19:03:16 -0700 | [diff] [blame] | 7884 | cds_cfg->fw_timeout_crash = hdd_ctx->config->fw_timeout_crash; |
Dustin Brown | 13995f0 | 2017-01-12 15:38:42 -0800 | [diff] [blame] | 7885 | cds_cfg->active_bpf_mode = hdd_ctx->config->active_bpf_mode; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7886 | |
| 7887 | hdd_ra_populate_cds_config(cds_cfg, hdd_ctx); |
| 7888 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
| 7889 | hdd_nan_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 7890 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7891 | cds_init_ini_config(cds_cfg); |
| 7892 | return 0; |
| 7893 | } |
| 7894 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7895 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 7896 | * hdd_update_user_config() - API to update user configuration |
| 7897 | * parameters to obj mgr which are used by multiple components |
| 7898 | * @hdd_ctx: HDD Context |
| 7899 | * |
| 7900 | * Return: 0 for Success, errno on failure |
| 7901 | */ |
| 7902 | static int hdd_update_user_config(hdd_context_t *hdd_ctx) |
| 7903 | { |
| 7904 | struct wlan_objmgr_psoc_user_config *user_config; |
| 7905 | |
| 7906 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
| 7907 | if (user_config == NULL) { |
| 7908 | hdd_alert("Failed to alloc memory for user_config!"); |
| 7909 | return -ENOMEM; |
| 7910 | } |
| 7911 | |
| 7912 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
| 7913 | user_config->dual_mac_feature_disable = |
| 7914 | hdd_ctx->config->dual_mac_feature_disable; |
| 7915 | user_config->indoor_channel_support = |
| 7916 | hdd_ctx->config->indoor_channel_support; |
| 7917 | user_config->is_11d_support_enabled = |
| 7918 | hdd_ctx->config->Is11dSupportEnabled; |
| 7919 | user_config->is_11h_support_enabled = |
| 7920 | hdd_ctx->config->Is11hSupportEnabled; |
| 7921 | user_config->optimize_chan_avoid_event = |
| 7922 | hdd_ctx->config->goptimize_chan_avoid_event; |
| 7923 | user_config->skip_dfs_chnl_in_p2p_search = |
| 7924 | hdd_ctx->config->skipDfsChnlInP2pSearch; |
Naveen Rawat | 222b2e9 | 2017-03-16 09:52:21 -0700 | [diff] [blame] | 7925 | user_config->band_capability = hdd_ctx->config->nBandCapability; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 7926 | wlan_objmgr_psoc_set_user_config(hdd_ctx->hdd_psoc, user_config); |
| 7927 | |
| 7928 | qdf_mem_free(user_config); |
| 7929 | return 0; |
| 7930 | } |
| 7931 | |
| 7932 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7933 | * hdd_init_thermal_info - Initialize thermal level |
| 7934 | * @hdd_ctx: HDD context |
| 7935 | * |
| 7936 | * Initialize thermal level at SME layer and set the thermal level callback |
| 7937 | * which would be called when a configured thermal threshold is hit. |
| 7938 | * |
| 7939 | * Return: 0 on success and errno on failure |
| 7940 | */ |
| 7941 | static int hdd_init_thermal_info(hdd_context_t *hdd_ctx) |
| 7942 | { |
| 7943 | tSmeThermalParams thermal_param; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7944 | QDF_STATUS status; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7945 | |
| 7946 | thermal_param.smeThermalMgmtEnabled = |
| 7947 | hdd_ctx->config->thermalMitigationEnable; |
| 7948 | thermal_param.smeThrottlePeriod = hdd_ctx->config->throttlePeriod; |
| 7949 | |
Poddar, Siddarth | 8390502 | 2016-04-16 17:56:08 -0700 | [diff] [blame] | 7950 | thermal_param.sme_throttle_duty_cycle_tbl[0] = |
| 7951 | hdd_ctx->config->throttle_dutycycle_level0; |
| 7952 | thermal_param.sme_throttle_duty_cycle_tbl[1] = |
| 7953 | hdd_ctx->config->throttle_dutycycle_level1; |
| 7954 | thermal_param.sme_throttle_duty_cycle_tbl[2] = |
| 7955 | hdd_ctx->config->throttle_dutycycle_level2; |
| 7956 | thermal_param.sme_throttle_duty_cycle_tbl[3] = |
| 7957 | hdd_ctx->config->throttle_dutycycle_level3; |
| 7958 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7959 | thermal_param.smeThermalLevels[0].smeMinTempThreshold = |
| 7960 | hdd_ctx->config->thermalTempMinLevel0; |
| 7961 | thermal_param.smeThermalLevels[0].smeMaxTempThreshold = |
| 7962 | hdd_ctx->config->thermalTempMaxLevel0; |
| 7963 | thermal_param.smeThermalLevels[1].smeMinTempThreshold = |
| 7964 | hdd_ctx->config->thermalTempMinLevel1; |
| 7965 | thermal_param.smeThermalLevels[1].smeMaxTempThreshold = |
| 7966 | hdd_ctx->config->thermalTempMaxLevel1; |
| 7967 | thermal_param.smeThermalLevels[2].smeMinTempThreshold = |
| 7968 | hdd_ctx->config->thermalTempMinLevel2; |
| 7969 | thermal_param.smeThermalLevels[2].smeMaxTempThreshold = |
| 7970 | hdd_ctx->config->thermalTempMaxLevel2; |
| 7971 | thermal_param.smeThermalLevels[3].smeMinTempThreshold = |
| 7972 | hdd_ctx->config->thermalTempMinLevel3; |
| 7973 | thermal_param.smeThermalLevels[3].smeMaxTempThreshold = |
| 7974 | hdd_ctx->config->thermalTempMaxLevel3; |
| 7975 | |
| 7976 | status = sme_init_thermal_info(hdd_ctx->hHal, thermal_param); |
| 7977 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7978 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 7979 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7980 | |
| 7981 | sme_add_set_thermal_level_callback(hdd_ctx->hHal, |
| 7982 | hdd_set_thermal_level_cb); |
| 7983 | |
| 7984 | return 0; |
| 7985 | |
| 7986 | } |
| 7987 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7988 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 7989 | /** |
| 7990 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 7991 | * |
| 7992 | * Hold RTNL lock |
| 7993 | * |
| 7994 | * Return: True if held and false otherwise |
| 7995 | */ |
| 7996 | static inline bool hdd_hold_rtnl_lock(void) |
| 7997 | { |
| 7998 | rtnl_lock(); |
| 7999 | return true; |
| 8000 | } |
| 8001 | |
| 8002 | /** |
| 8003 | * hdd_release_rtnl_lock - Release RTNL lock |
| 8004 | * |
| 8005 | * Release RTNL lock |
| 8006 | * |
| 8007 | * Return: None |
| 8008 | */ |
| 8009 | static inline void hdd_release_rtnl_lock(void) |
| 8010 | { |
| 8011 | rtnl_unlock(); |
| 8012 | } |
| 8013 | #else |
| 8014 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 8015 | static inline void hdd_release_rtnl_lock(void) { } |
| 8016 | #endif |
| 8017 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8018 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8019 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8020 | /* MAX iwpriv command support */ |
| 8021 | #define PKTLOG_SET_BUFF_SIZE 3 |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8022 | #define PKTLOG_CLEAR_BUFF 4 |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8023 | #define MAX_PKTLOG_SIZE 16 |
| 8024 | |
| 8025 | /** |
| 8026 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 8027 | * @hdd_ctx: hdd context |
| 8028 | * @set_value2: pktlog buffer size value |
| 8029 | * |
| 8030 | * |
| 8031 | * Return: 0 for success or error. |
| 8032 | */ |
| 8033 | static int hdd_pktlog_set_buff_size(hdd_context_t *hdd_ctx, int set_value2) |
| 8034 | { |
| 8035 | struct sir_wifi_start_log start_log = { 0 }; |
| 8036 | QDF_STATUS status; |
| 8037 | |
| 8038 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 8039 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 8040 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 8041 | start_log.user_triggered = 1; |
| 8042 | start_log.size = set_value2; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8043 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8044 | |
| 8045 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 8046 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8047 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 8048 | EXIT(); |
| 8049 | return -EINVAL; |
| 8050 | } |
| 8051 | |
| 8052 | return 0; |
| 8053 | } |
| 8054 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8055 | /** |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8056 | * hdd_pktlog_clear_buff() - clear pktlog buffer |
| 8057 | * @hdd_ctx: hdd context |
| 8058 | * |
| 8059 | * Return: 0 for success or error. |
| 8060 | */ |
| 8061 | static int hdd_pktlog_clear_buff(hdd_context_t *hdd_ctx) |
| 8062 | { |
| 8063 | struct sir_wifi_start_log start_log; |
| 8064 | QDF_STATUS status; |
| 8065 | |
| 8066 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 8067 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 8068 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 8069 | start_log.user_triggered = 1; |
| 8070 | start_log.size = 0; |
| 8071 | start_log.is_pktlog_buff_clear = true; |
| 8072 | |
| 8073 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 8074 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8075 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 8076 | EXIT(); |
| 8077 | return -EINVAL; |
| 8078 | } |
| 8079 | |
| 8080 | return 0; |
| 8081 | } |
| 8082 | |
| 8083 | |
| 8084 | /** |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8085 | * hdd_process_pktlog_command() - process pktlog command |
| 8086 | * @hdd_ctx: hdd context |
| 8087 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8088 | * @set_value2: pktlog buffer size value |
| 8089 | * |
| 8090 | * This function process pktlog command. |
| 8091 | * set_value2 only matters when set_value is 3 (set buff size) |
| 8092 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8093 | * |
| 8094 | * Return: 0 for success or error. |
| 8095 | */ |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8096 | int hdd_process_pktlog_command(hdd_context_t *hdd_ctx, uint32_t set_value, |
| 8097 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8098 | { |
| 8099 | int ret; |
| 8100 | bool enable; |
| 8101 | uint8_t user_triggered = 0; |
| 8102 | |
| 8103 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 8104 | if (0 != ret) |
| 8105 | return ret; |
| 8106 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8107 | hdd_debug("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8108 | |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8109 | if (set_value > PKTLOG_CLEAR_BUFF) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8110 | hdd_err("invalid pktlog value %d", set_value); |
| 8111 | return -EINVAL; |
| 8112 | } |
| 8113 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8114 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 8115 | if (set_value2 <= 0) { |
| 8116 | hdd_err("invalid pktlog size %d", set_value2); |
| 8117 | return -EINVAL; |
| 8118 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
| 8119 | hdd_err("Pktlog buff size is too large. max value is 16MB.\n"); |
| 8120 | return -EINVAL; |
| 8121 | } |
| 8122 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8123 | } else if (set_value == PKTLOG_CLEAR_BUFF) { |
| 8124 | return hdd_pktlog_clear_buff(hdd_ctx); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8125 | } |
| 8126 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8127 | /* |
| 8128 | * set_value = 0 then disable packetlog |
| 8129 | * set_value = 1 enable packetlog forcefully |
| 8130 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 8131 | * enable packetlog with AUTO type. |
| 8132 | */ |
| 8133 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 8134 | true : false; |
| 8135 | |
| 8136 | if (1 == set_value) { |
| 8137 | enable = true; |
| 8138 | user_triggered = 1; |
| 8139 | } |
| 8140 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8141 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8142 | } |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8143 | /** |
| 8144 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 8145 | * @hdd_ctx: HDD context |
| 8146 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8147 | * @user_triggered: triggered through iwpriv |
| 8148 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8149 | * |
| 8150 | * Return: 0 on success; error number otherwise |
| 8151 | */ |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8152 | int hdd_pktlog_enable_disable(hdd_context_t *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8153 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8154 | { |
| 8155 | struct sir_wifi_start_log start_log; |
| 8156 | QDF_STATUS status; |
| 8157 | |
| 8158 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 8159 | start_log.verbose_level = |
| 8160 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8161 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 8162 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8163 | start_log.size = size; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8164 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 8165 | /* |
| 8166 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 8167 | * commands. Host uses this flag to decide whether to send pktlog |
| 8168 | * disable command to fw without sending pktlog enable command |
| 8169 | * previously. For eg, If vendor sends pktlog disable command without |
| 8170 | * sending pktlog enable command, then host discards the packet |
| 8171 | * but for iwpriv command, host will send it to fw. |
| 8172 | */ |
| 8173 | start_log.is_iwpriv_command = 1; |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8174 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 8175 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8176 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 8177 | EXIT(); |
| 8178 | return -EINVAL; |
| 8179 | } |
| 8180 | |
| 8181 | return 0; |
| 8182 | } |
| 8183 | #endif /* REMOVE_PKT_LOG */ |
| 8184 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8185 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 8186 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 8187 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8188 | * @dev: Device Pointer |
| 8189 | * @num: Number of Valid Mac address |
| 8190 | * |
| 8191 | * Return: Pointer to MAC address buffer |
| 8192 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 8193 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 8194 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8195 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 8196 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8197 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8198 | |
| 8199 | /** |
| 8200 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 8201 | * @hdd_ctx: HDD Context |
| 8202 | * @num: Number of random mac addresses needed |
| 8203 | * |
| 8204 | * Generate random addresses using bit manipulation on the base mac address |
| 8205 | * |
| 8206 | * Return: None |
| 8207 | */ |
| 8208 | static void hdd_populate_random_mac_addr(hdd_context_t *hdd_ctx, uint32_t num) |
| 8209 | { |
| 8210 | uint32_t start_idx = QDF_MAX_CONCURRENCY_PERSONA - num; |
| 8211 | uint32_t iter; |
| 8212 | struct hdd_config *ini = hdd_ctx->config; |
| 8213 | uint8_t *buf = NULL; |
| 8214 | uint8_t macaddr_b3, tmp_br3; |
| 8215 | uint8_t *src = ini->intfMacAddr[0].bytes; |
| 8216 | |
| 8217 | for (iter = start_idx; iter < QDF_MAX_CONCURRENCY_PERSONA; ++iter) { |
| 8218 | buf = ini->intfMacAddr[iter].bytes; |
| 8219 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 8220 | macaddr_b3 = buf[3]; |
| 8221 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + iter) & |
| 8222 | INTF_MACADDR_MASK; |
| 8223 | macaddr_b3 += tmp_br3; |
| 8224 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 8225 | buf[0] |= 0x02; |
| 8226 | buf[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8227 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8228 | } |
| 8229 | } |
| 8230 | |
| 8231 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 8232 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8233 | * @hdd_ctx: HDD Context |
| 8234 | * |
| 8235 | * API to get mac addresses from platform driver and update the driver |
| 8236 | * structures and configure FW with the base mac address. |
| 8237 | * Return: int |
| 8238 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 8239 | static int hdd_platform_wlan_mac(hdd_context_t *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8240 | { |
| 8241 | uint32_t no_of_mac_addr, iter; |
| 8242 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 8243 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 8244 | uint8_t *addr, *buf; |
| 8245 | struct device *dev = hdd_ctx->parent_dev; |
| 8246 | struct hdd_config *ini = hdd_ctx->config; |
| 8247 | tSirMacAddr mac_addr; |
| 8248 | QDF_STATUS status; |
| 8249 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 8250 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8251 | |
| 8252 | if (no_of_mac_addr == 0 || !addr) { |
| 8253 | hdd_warn("Platform Driver Doesn't have wlan mac addresses"); |
| 8254 | return -EINVAL; |
| 8255 | } |
| 8256 | |
| 8257 | if (no_of_mac_addr > max_mac_addr) |
| 8258 | no_of_mac_addr = max_mac_addr; |
| 8259 | |
| 8260 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 8261 | |
| 8262 | for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { |
| 8263 | buf = ini->intfMacAddr[iter].bytes; |
| 8264 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8265 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8266 | } |
| 8267 | |
| 8268 | status = sme_set_custom_mac_addr(mac_addr); |
| 8269 | |
| 8270 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8271 | return -EAGAIN; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 8272 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8273 | if (no_of_mac_addr < max_mac_addr) |
| 8274 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 8275 | no_of_mac_addr); |
| 8276 | return 0; |
| 8277 | } |
| 8278 | |
| 8279 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 8280 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 8281 | * @hdd_ctx: HDD Context |
| 8282 | * |
| 8283 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 8284 | * will generate its own MAC and update it to FW. |
| 8285 | * |
| 8286 | * Return: 0 for success |
| 8287 | * Non-zero error code for failure |
| 8288 | */ |
| 8289 | static int hdd_update_mac_addr_to_fw(hdd_context_t *hdd_ctx) |
| 8290 | { |
| 8291 | tSirMacAddr customMacAddr; |
| 8292 | QDF_STATUS status; |
| 8293 | |
| 8294 | qdf_mem_copy(&customMacAddr, |
| 8295 | &hdd_ctx->config->intfMacAddr[0].bytes[0], |
| 8296 | sizeof(tSirMacAddr)); |
| 8297 | status = sme_set_custom_mac_addr(customMacAddr); |
| 8298 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8299 | return -EAGAIN; |
| 8300 | return 0; |
| 8301 | } |
| 8302 | |
| 8303 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8304 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 8305 | * @hdd_ctx: HDD Context |
| 8306 | * |
| 8307 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 8308 | * is provisioned with mac addresses, driver uses it, else it will use |
| 8309 | * wlan_mac.bin to update HW MAC addresses. |
| 8310 | * |
| 8311 | * Return: None |
| 8312 | */ |
| 8313 | static void hdd_initialize_mac_address(hdd_context_t *hdd_ctx) |
| 8314 | { |
| 8315 | QDF_STATUS status; |
| 8316 | int ret; |
| 8317 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 8318 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8319 | if (ret == 0) |
| 8320 | return; |
| 8321 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8322 | hdd_warn("Can't update mac config via platform driver ret: %d", ret); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8323 | |
| 8324 | status = hdd_update_mac_config(hdd_ctx); |
| 8325 | |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 8326 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 8327 | return; |
| 8328 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8329 | hdd_warn("Can't update mac config via wlan_mac.bin, using MAC from ini file or auto-gen"); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 8330 | |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 8331 | if (hdd_ctx->update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 8332 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 8333 | if (ret != 0) { |
| 8334 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
| 8335 | QDF_ASSERT(ret); |
| 8336 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 8337 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8338 | } |
| 8339 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8340 | /** |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 8341 | * hdd_tsf_init() - Initialize the TSF synchronization interface |
| 8342 | * @hdd_ctx: HDD global context |
| 8343 | * |
| 8344 | * When TSF synchronization via GPIO is supported by the driver and |
| 8345 | * has been enabled in the configuration file, this function plumbs |
| 8346 | * the GPIO value down to firmware via SME. |
| 8347 | * |
| 8348 | * Return: None |
| 8349 | */ |
| 8350 | #ifdef WLAN_FEATURE_TSF |
| 8351 | static void hdd_tsf_init(hdd_context_t *hdd_ctx) |
| 8352 | { |
| 8353 | QDF_STATUS status; |
| 8354 | |
| 8355 | if (hdd_ctx->config->tsf_gpio_pin == TSF_GPIO_PIN_INVALID) |
| 8356 | return; |
| 8357 | |
| 8358 | status = sme_set_tsf_gpio(hdd_ctx->hHal, |
| 8359 | hdd_ctx->config->tsf_gpio_pin); |
| 8360 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8361 | hdd_err("Set tsf GPIO failed, status: %d", status); |
| 8362 | } |
| 8363 | #else |
| 8364 | static void hdd_tsf_init(hdd_context_t *hdd_ctx) |
| 8365 | { |
| 8366 | } |
| 8367 | #endif |
| 8368 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 8369 | static int hdd_set_smart_chainmask_enabled(hdd_context_t *hdd_ctx) |
| 8370 | { |
| 8371 | int vdev_id = 0; |
| 8372 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
| 8373 | int value = hdd_ctx->config->smart_chainmask_enabled; |
| 8374 | int vpdev = PDEV_CMD; |
| 8375 | int ret; |
| 8376 | |
| 8377 | ret = wma_cli_set_command(vdev_id, param_id, value, vpdev); |
| 8378 | if (ret) |
| 8379 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 8380 | |
| 8381 | return ret; |
| 8382 | } |
| 8383 | |
| 8384 | static int hdd_set_alternative_chainmask_enabled(hdd_context_t *hdd_ctx) |
| 8385 | { |
| 8386 | int vdev_id = 0; |
| 8387 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
| 8388 | int value = hdd_ctx->config->alternative_chainmask_enabled; |
| 8389 | int vpdev = PDEV_CMD; |
| 8390 | int ret; |
| 8391 | |
| 8392 | ret = wma_cli_set_command(vdev_id, param_id, value, vpdev); |
| 8393 | if (ret) |
| 8394 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 8395 | ret); |
| 8396 | |
| 8397 | return ret; |
| 8398 | } |
| 8399 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 8400 | static int hdd_set_ani_enabled(hdd_context_t *hdd_ctx) |
| 8401 | { |
| 8402 | int vdev_id = 0; |
| 8403 | int param_id = WMI_PDEV_PARAM_ANI_ENABLE; |
| 8404 | int value = hdd_ctx->config->ani_enabled; |
| 8405 | int vpdev = PDEV_CMD; |
| 8406 | int ret; |
| 8407 | |
| 8408 | ret = wma_cli_set_command(vdev_id, param_id, value, vpdev); |
| 8409 | if (ret) |
| 8410 | hdd_err("WMI_PDEV_PARAM_ANI_ENABLE failed %d", ret); |
| 8411 | |
| 8412 | return ret; |
| 8413 | } |
| 8414 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 8415 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8416 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 8417 | * @hdd_ctx: HDD context |
| 8418 | * |
| 8419 | * Pre configurations to be done at lower layer before calling cds enable. |
| 8420 | * |
| 8421 | * Return: 0 on success and errno on failure. |
| 8422 | */ |
| 8423 | static int hdd_pre_enable_configure(hdd_context_t *hdd_ctx) |
| 8424 | { |
| 8425 | int ret; |
| 8426 | QDF_STATUS status; |
| 8427 | tSirRetStatus hal_status; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 8428 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8429 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 8430 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8431 | /* |
| 8432 | * Set 802.11p config |
| 8433 | * TODO-OCB: This has been temporarily added here to ensure this |
| 8434 | * parameter is set in CSR when we init the channel list. This should |
| 8435 | * be removed once the 5.9 GHz channels are added to the regulatory |
| 8436 | * domain. |
| 8437 | */ |
| 8438 | hdd_set_dot11p_config(hdd_ctx); |
| 8439 | |
| 8440 | /* |
| 8441 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 8442 | * The cfg download must occur before we update the SME config |
| 8443 | * since the SME config operation must access the cfg database |
| 8444 | */ |
| 8445 | status = hdd_set_sme_config(hdd_ctx); |
| 8446 | |
| 8447 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8448 | hdd_err("Failed hdd_set_sme_config: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8449 | ret = qdf_status_to_os_return(status); |
| 8450 | goto out; |
| 8451 | } |
| 8452 | |
Tushnim Bhattacharyya | ba8ee93 | 2017-03-23 09:27:40 -0700 | [diff] [blame] | 8453 | status = hdd_set_policy_mgr_user_cfg(hdd_ctx); |
| 8454 | if (QDF_STATUS_SUCCESS != status) { |
| 8455 | hdd_alert("Failed hdd_set_policy_mgr_user_cfg: %d", status); |
| 8456 | ret = qdf_status_to_os_return(status); |
| 8457 | goto out; |
| 8458 | } |
| 8459 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8460 | ret = wma_cli_set_command(0, WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS, |
| 8461 | hdd_ctx->config->tx_chain_mask_1ss, |
| 8462 | PDEV_CMD); |
| 8463 | if (0 != ret) { |
| 8464 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 8465 | goto out; |
| 8466 | } |
| 8467 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 8468 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 8469 | if (ret) |
| 8470 | goto out; |
| 8471 | |
| 8472 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 8473 | if (ret) |
| 8474 | goto out; |
| 8475 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 8476 | ret = hdd_set_ani_enabled(hdd_ctx); |
| 8477 | if (ret) |
| 8478 | goto out; |
| 8479 | |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 8480 | ret = wma_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
| 8481 | hdd_ctx->config->arp_ac_category, |
| 8482 | PDEV_CMD); |
| 8483 | if (0 != ret) { |
| 8484 | hdd_err("WMI_PDEV_PARAM_ARP_AC_OVERRIDE ac: %d ret: %d", |
| 8485 | hdd_ctx->config->arp_ac_category, ret); |
| 8486 | goto out; |
| 8487 | } |
| 8488 | |
| 8489 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8490 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 8491 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8492 | hdd_err("Failed to init channel list: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8493 | ret = qdf_status_to_os_return(status); |
| 8494 | goto out; |
| 8495 | } |
| 8496 | |
| 8497 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 8498 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8499 | hdd_err("config update failed"); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8500 | ret = -EINVAL; |
| 8501 | goto out; |
| 8502 | } |
| 8503 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8504 | /* |
| 8505 | * Set the MAC Address Currently this is used by HAL to add self sta. |
| 8506 | * Remove this once self sta is added as part of session open. |
| 8507 | */ |
| 8508 | hal_status = cfg_set_str(hdd_ctx->hHal, WNI_CFG_STA_ID, |
| 8509 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 8510 | sizeof(hdd_ctx->config->intfMacAddr[0])); |
| 8511 | |
| 8512 | if (!IS_SIR_STATUS_SUCCESS(hal_status)) { |
| 8513 | hdd_err("Failed to set MAC Address. HALStatus is %08d [x%08x]", |
| 8514 | hal_status, hal_status); |
| 8515 | ret = -EINVAL; |
| 8516 | goto out; |
| 8517 | } |
| 8518 | |
| 8519 | hdd_init_channel_avoidance(hdd_ctx); |
| 8520 | |
| 8521 | out: |
| 8522 | return ret; |
| 8523 | } |
| 8524 | |
| 8525 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 8526 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
| 8527 | * @context_ptr - hdd context pointer |
| 8528 | * @event_ptr - event structure pointer |
| 8529 | * |
| 8530 | * This is the p2p listen offload stop event handler, it sends vendor |
| 8531 | * event back to supplicant to notify the stop reason. |
| 8532 | * |
| 8533 | * Return: None |
| 8534 | */ |
| 8535 | static void wlan_hdd_p2p_lo_event_callback(void *context_ptr, |
| 8536 | void *event_ptr) |
| 8537 | { |
| 8538 | hdd_context_t *hdd_ctx = (hdd_context_t *)context_ptr; |
| 8539 | struct sir_p2p_lo_event *evt = event_ptr; |
| 8540 | struct sk_buff *vendor_event; |
| 8541 | |
| 8542 | ENTER(); |
| 8543 | |
| 8544 | if (hdd_ctx == NULL) { |
| 8545 | hdd_err("Invalid HDD context pointer"); |
| 8546 | return; |
| 8547 | } |
| 8548 | |
| 8549 | vendor_event = |
| 8550 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
| 8551 | NULL, sizeof(uint32_t) + NLMSG_HDRLEN, |
| 8552 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 8553 | GFP_KERNEL); |
| 8554 | |
| 8555 | if (!vendor_event) { |
| 8556 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 8557 | return; |
| 8558 | } |
| 8559 | |
| 8560 | if (nla_put_u32(vendor_event, |
| 8561 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 8562 | evt->reason_code)) { |
| 8563 | hdd_err("nla put failed"); |
| 8564 | kfree_skb(vendor_event); |
| 8565 | return; |
| 8566 | } |
| 8567 | |
| 8568 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 8569 | } |
| 8570 | |
| 8571 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 8572 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 8573 | * @hdd_ctx: HDD context |
| 8574 | * |
| 8575 | * This function sends the adaptive dwell time config configuration to the |
| 8576 | * firmware via WMA |
| 8577 | * |
| 8578 | * Return: 0 - success, < 0 - failure |
| 8579 | */ |
| 8580 | static int hdd_adaptive_dwelltime_init(hdd_context_t *hdd_ctx) |
| 8581 | { |
| 8582 | QDF_STATUS status; |
| 8583 | struct adaptive_dwelltime_params dwelltime_params; |
| 8584 | |
| 8585 | dwelltime_params.is_enabled = |
| 8586 | hdd_ctx->config->adaptive_dwell_mode_enabled; |
| 8587 | dwelltime_params.dwelltime_mode = |
| 8588 | hdd_ctx->config->global_adapt_dwelltime_mode; |
| 8589 | dwelltime_params.lpf_weight = |
| 8590 | hdd_ctx->config->adapt_dwell_lpf_weight; |
| 8591 | dwelltime_params.passive_mon_intval = |
| 8592 | hdd_ctx->config->adapt_dwell_passive_mon_intval; |
| 8593 | dwelltime_params.wifi_act_threshold = |
| 8594 | hdd_ctx->config->adapt_dwell_wifi_act_threshold; |
| 8595 | |
| 8596 | status = sme_set_adaptive_dwelltime_config(hdd_ctx->hHal, |
| 8597 | &dwelltime_params); |
| 8598 | |
| 8599 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 8600 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8601 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 8602 | return -EAGAIN; |
| 8603 | } |
| 8604 | return 0; |
| 8605 | } |
| 8606 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 8607 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 8608 | /** |
| 8609 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 8610 | * @hdd_ctx: HDD context |
| 8611 | * |
| 8612 | * Set auto shutdown callback to get indications from firmware to indicate |
| 8613 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 8614 | * |
| 8615 | * Return: 0 on success and errno on failure. |
| 8616 | */ |
| 8617 | static int hdd_set_auto_shutdown_cb(hdd_context_t *hdd_ctx) |
| 8618 | { |
| 8619 | QDF_STATUS status; |
| 8620 | |
| 8621 | if (!hdd_ctx->config->WlanAutoShutdown) |
| 8622 | return 0; |
| 8623 | |
| 8624 | status = sme_set_auto_shutdown_cb(hdd_ctx->hHal, |
| 8625 | wlan_hdd_auto_shutdown_cb); |
| 8626 | if (status != QDF_STATUS_SUCCESS) |
| 8627 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 8628 | status); |
| 8629 | |
| 8630 | return qdf_status_to_os_return(status); |
| 8631 | } |
| 8632 | #else |
| 8633 | static int hdd_set_auto_shutdown_cb(hdd_context_t *hdd_ctx) |
| 8634 | { |
| 8635 | return 0; |
| 8636 | } |
| 8637 | #endif |
| 8638 | |
| 8639 | /** |
| 8640 | * hdd_features_init() - Init features |
| 8641 | * @hdd_ctx: HDD context |
| 8642 | * @adapter: Primary adapter context |
| 8643 | * |
| 8644 | * Initialize features and their feature context after WLAN firmware is up. |
| 8645 | * |
| 8646 | * Return: 0 on success and errno on failure. |
| 8647 | */ |
| 8648 | static int hdd_features_init(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter) |
| 8649 | { |
| 8650 | tSirTxPowerLimit hddtxlimit; |
| 8651 | QDF_STATUS status; |
| 8652 | int ret; |
| 8653 | |
| 8654 | ENTER(); |
| 8655 | |
| 8656 | ret = hdd_update_country_code(hdd_ctx, adapter); |
| 8657 | if (ret) { |
| 8658 | hdd_err("Failed to update country code: %d", ret); |
| 8659 | goto out; |
| 8660 | } |
| 8661 | |
| 8662 | /* FW capabilities received, Set the Dot11 mode */ |
| 8663 | sme_setdef_dot11mode(hdd_ctx->hHal); |
Kiran Kumar Lokere | 1aa9c9a | 2016-10-05 18:50:59 -0700 | [diff] [blame] | 8664 | sme_set_prefer_80MHz_over_160MHz(hdd_ctx->hHal, |
| 8665 | hdd_ctx->config->sta_prefer_80MHz_over_160MHz); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 8666 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 8667 | |
| 8668 | if (hdd_ctx->config->fIsImpsEnabled) |
| 8669 | hdd_set_idle_ps_config(hdd_ctx, true); |
| 8670 | else |
| 8671 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 8672 | |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 8673 | if (hdd_ctx->config->enable_go_cts2self_for_sta) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 8674 | sme_set_cts2self_for_p2p_go(hdd_ctx->hHal); |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 8675 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 8676 | if (hdd_lro_init(hdd_ctx)) |
| 8677 | hdd_err("Unable to initialize LRO in fw"); |
| 8678 | |
| 8679 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 8680 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 8681 | |
| 8682 | ret = hdd_init_thermal_info(hdd_ctx); |
| 8683 | if (ret) { |
| 8684 | hdd_err("Error while initializing thermal information"); |
| 8685 | goto deregister_frames; |
| 8686 | } |
| 8687 | |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 8688 | if (cds_is_packet_log_enabled()) |
| 8689 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
| 8690 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 8691 | hddtxlimit.txPower2g = hdd_ctx->config->TxPower2g; |
| 8692 | hddtxlimit.txPower5g = hdd_ctx->config->TxPower5g; |
| 8693 | status = sme_txpower_limit(hdd_ctx->hHal, &hddtxlimit); |
| 8694 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8695 | hdd_err("Error setting txlimit in sme: %d", status); |
| 8696 | |
| 8697 | hdd_tsf_init(hdd_ctx); |
| 8698 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 8699 | ret = hdd_register_cb(hdd_ctx); |
| 8700 | if (ret) { |
| 8701 | hdd_err("Failed to register HDD callbacks!"); |
| 8702 | goto deregister_frames; |
| 8703 | } |
| 8704 | |
| 8705 | if (hdd_ctx->config->dual_mac_feature_disable) { |
| 8706 | status = wlan_hdd_disable_all_dual_mac_features(hdd_ctx); |
| 8707 | if (status != QDF_STATUS_SUCCESS) { |
| 8708 | hdd_err("Failed to disable dual mac features"); |
| 8709 | goto deregister_cb; |
| 8710 | } |
| 8711 | } |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 8712 | if (hdd_ctx->config->goptimize_chan_avoid_event) { |
| 8713 | status = sme_enable_disable_chanavoidind_event( |
| 8714 | hdd_ctx->hHal, 0); |
| 8715 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8716 | hdd_err("Failed to disable Chan Avoidance Indication"); |
| 8717 | goto deregister_cb; |
| 8718 | } |
| 8719 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 8720 | |
| 8721 | /* register P2P Listen Offload event callback */ |
| 8722 | if (wma_is_p2p_lo_capable()) |
| 8723 | sme_register_p2p_lo_event(hdd_ctx->hHal, hdd_ctx, |
| 8724 | wlan_hdd_p2p_lo_event_callback); |
| 8725 | |
| 8726 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 8727 | |
| 8728 | if (ret) |
| 8729 | goto deregister_cb; |
| 8730 | |
| 8731 | EXIT(); |
| 8732 | return 0; |
| 8733 | |
| 8734 | deregister_cb: |
| 8735 | hdd_deregister_cb(hdd_ctx); |
| 8736 | deregister_frames: |
| 8737 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 8738 | out: |
| 8739 | return -EINVAL; |
| 8740 | |
| 8741 | } |
| 8742 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 8743 | #ifdef NAPIER_SCAN |
| 8744 | /** |
| 8745 | * |
| 8746 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 8747 | * @adapter - Pointer to the HDD |
| 8748 | * |
| 8749 | * Return: None |
| 8750 | */ |
| 8751 | static inline QDF_STATUS hdd_register_bcn_cb(hdd_context_t *hdd_ctx) |
| 8752 | { |
| 8753 | QDF_STATUS status; |
| 8754 | |
| 8755 | status = ucfg_scan_register_bcn_cb(hdd_ctx->hdd_psoc, |
| 8756 | wlan_cfg80211_inform_bss_frame, |
| 8757 | SCAN_CB_TYPE_INFORM_BCN); |
| 8758 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8759 | hdd_err("failed with status code %08d [x%08x]", |
| 8760 | status, status); |
| 8761 | return status; |
| 8762 | } |
| 8763 | |
| 8764 | return QDF_STATUS_SUCCESS; |
| 8765 | } |
| 8766 | #else |
| 8767 | static inline QDF_STATUS hdd_register_bcn_cb(hdd_context_t *hdd_ctx) |
| 8768 | { |
| 8769 | return QDF_STATUS_SUCCESS; |
| 8770 | } |
| 8771 | |
| 8772 | #endif |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 8773 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 8774 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8775 | * hdd_configure_cds() - Configure cds modules |
| 8776 | * @hdd_ctx: HDD context |
| 8777 | * @adapter: Primary adapter context |
| 8778 | * |
| 8779 | * Enable Cds modules after WLAN firmware is up. |
| 8780 | * |
| 8781 | * Return: 0 on success and errno on failure. |
| 8782 | */ |
| 8783 | int hdd_configure_cds(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter) |
| 8784 | { |
| 8785 | int ret; |
| 8786 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8787 | |
| 8788 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 8789 | if (ret) { |
| 8790 | hdd_err("Failed to pre-configure cds"); |
| 8791 | goto out; |
| 8792 | } |
| 8793 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 8794 | /* Always get latest IPA resources allocated from cds_open and configure |
| 8795 | * IPA module before configuring them to FW. Sequence required as crash |
| 8796 | * observed otherwise. |
| 8797 | */ |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame^] | 8798 | if (hdd_ipa_uc_ol_init(hdd_ctx)) { |
| 8799 | hdd_err("Failed to setup pipes"); |
| 8800 | goto out; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 8801 | } |
| 8802 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8803 | /* |
| 8804 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 8805 | * else |
| 8806 | */ |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 8807 | status = cds_enable(hdd_ctx->hdd_psoc, hdd_ctx->pcds_context); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8808 | |
| 8809 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8810 | hdd_err("cds_enable failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8811 | goto out; |
| 8812 | } |
| 8813 | |
| 8814 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 8815 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8816 | hdd_err("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 8817 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8818 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 8819 | status = hdd_register_bcn_cb(hdd_ctx); |
| 8820 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8821 | hdd_alert("hdd_post_cds_enable_config failed"); |
| 8822 | goto cds_disable; |
| 8823 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8824 | |
| 8825 | ret = hdd_features_init(hdd_ctx, adapter); |
| 8826 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 8827 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8828 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8829 | |
| 8830 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 8831 | |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 8832 | cds_disable: |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 8833 | cds_disable(hdd_ctx->hdd_psoc, hdd_ctx->pcds_context); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 8834 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8835 | out: |
| 8836 | return -EINVAL; |
| 8837 | } |
| 8838 | |
| 8839 | /** |
| 8840 | * hdd_deconfigure_cds() -De-Configure cds |
| 8841 | * @hdd_ctx: HDD context |
| 8842 | * |
| 8843 | * Deconfigure Cds modules before WLAN firmware is down. |
| 8844 | * |
| 8845 | * Return: 0 on success and errno on failure. |
| 8846 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 8847 | static int hdd_deconfigure_cds(hdd_context_t *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8848 | { |
| 8849 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 8850 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8851 | |
| 8852 | ENTER(); |
| 8853 | /* De-register the SME callbacks */ |
| 8854 | hdd_deregister_cb(hdd_ctx); |
| 8855 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 8856 | qdf_status = cds_disable(hdd_ctx->hdd_psoc, hdd_ctx->pcds_context); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8857 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 8858 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 8859 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 8860 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8861 | } |
| 8862 | |
| 8863 | EXIT(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 8864 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8865 | } |
| 8866 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 8867 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 8868 | static void hdd_deregister_policy_manager_callback( |
| 8869 | struct wlan_objmgr_psoc *psoc) |
| 8870 | { |
| 8871 | if (QDF_STATUS_SUCCESS != |
| 8872 | policy_mgr_deregister_hdd_cb(psoc)) { |
| 8873 | hdd_err("HDD callback deregister with policy manager failed"); |
| 8874 | } |
| 8875 | } |
| 8876 | #else |
| 8877 | static void hdd_deregister_policy_manager_callback( |
| 8878 | struct wlan_objmgr_psoc *psoc) |
| 8879 | { |
| 8880 | } |
| 8881 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8882 | |
| 8883 | /** |
| 8884 | * hdd_wlan_stop_modules - Single driver state machine for stoping modules |
| 8885 | * @hdd_ctx: HDD context |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 8886 | * @ftm_mode: ftm mode |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8887 | * |
| 8888 | * This function maintains the driver state machine it will be invoked from |
| 8889 | * exit, shutdown and con_mode change handler. Depending on the driver state |
| 8890 | * shall perform the stopping/closing of the modules. |
| 8891 | * |
| 8892 | * Return: 0 for success; non-zero for failure |
| 8893 | */ |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 8894 | int hdd_wlan_stop_modules(hdd_context_t *hdd_ctx, bool ftm_mode) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8895 | { |
| 8896 | void *hif_ctx; |
| 8897 | qdf_device_t qdf_ctx; |
| 8898 | QDF_STATUS qdf_status; |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8899 | int ret = 0; |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 8900 | bool is_idle_stop = !cds_is_driver_unloading() && |
| 8901 | !cds_is_driver_recovering(); |
| 8902 | int active_threads; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8903 | |
| 8904 | ENTER(); |
| 8905 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 8906 | hdd_deregister_policy_manager_callback(hdd_ctx->hdd_psoc); |
| 8907 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8908 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 8909 | if (!qdf_ctx) { |
| 8910 | hdd_err("QDF device context NULL"); |
| 8911 | return -EINVAL; |
| 8912 | } |
| 8913 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8914 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 8915 | hdd_ctx->stop_modules_in_progress = true; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8916 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 8917 | active_threads = cds_return_external_threads_count(); |
| 8918 | if (active_threads > 0 || hdd_ctx->isWiphySuspended) { |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 8919 | hdd_warn("External threads %d wiphy suspend %d", |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 8920 | active_threads, hdd_ctx->isWiphySuspended); |
| 8921 | |
| 8922 | cds_print_external_threads(); |
| 8923 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 8924 | if (is_idle_stop && !ftm_mode) { |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 8925 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 8926 | qdf_mc_timer_start(&hdd_ctx->iface_change_timer, |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 8927 | hdd_ctx->config->iface_change_wait_time); |
| 8928 | hdd_ctx->stop_modules_in_progress = false; |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 8929 | return 0; |
| 8930 | } |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 8931 | } |
| 8932 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8933 | hdd_info("Present Driver Status: %d", hdd_ctx->driver_status); |
| 8934 | |
| 8935 | switch (hdd_ctx->driver_status) { |
| 8936 | case DRIVER_MODULES_UNINITIALIZED: |
| 8937 | hdd_info("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8938 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8939 | case DRIVER_MODULES_CLOSED: |
| 8940 | hdd_info("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8941 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8942 | case DRIVER_MODULES_ENABLED: |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 8943 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8944 | if (hdd_deconfigure_cds(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8945 | hdd_err("Failed to de-configure CDS"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8946 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8947 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8948 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8949 | hdd_debug("successfully Disabled the CDS modules!"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8950 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
| 8951 | break; |
| 8952 | case DRIVER_MODULES_OPENED: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8953 | hdd_debug("Closing CDS modules!"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8954 | break; |
| 8955 | default: |
| 8956 | hdd_err("Trying to stop wlan in a wrong state: %d", |
| 8957 | hdd_ctx->driver_status); |
| 8958 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8959 | ret = -EINVAL; |
| 8960 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8961 | } |
| 8962 | |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 8963 | qdf_status = cds_post_disable(hdd_ctx->pcds_context); |
| 8964 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 8965 | hdd_err("Failed to process post CDS disable Modules! :%d", |
| 8966 | qdf_status); |
| 8967 | ret = -EINVAL; |
| 8968 | QDF_ASSERT(0); |
| 8969 | } |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 8970 | qdf_status = cds_close(hdd_ctx->hdd_psoc, hdd_ctx->pcds_context); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8971 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8972 | hdd_warn("Failed to stop CDS: %d", qdf_status); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 8973 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8974 | QDF_ASSERT(0); |
| 8975 | } |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 8976 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8977 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 8978 | if (!hif_ctx) { |
| 8979 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8980 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8981 | } |
| 8982 | |
| 8983 | hdd_hif_close(hif_ctx); |
| 8984 | |
| 8985 | ol_cds_free(); |
| 8986 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 8987 | if (is_idle_stop) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8988 | ret = pld_power_off(qdf_ctx->dev); |
| 8989 | if (ret) |
| 8990 | hdd_err("CNSS power down failed put device into Low power mode:%d", |
| 8991 | ret); |
| 8992 | } |
| 8993 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Sandeep Puligilla | 1cf6ebe | 2017-04-04 14:40:27 -0700 | [diff] [blame] | 8994 | /* |
| 8995 | * Reset total mac phy during module stop such that during |
| 8996 | * next module start same psoc is used to populate new service |
| 8997 | * ready data |
| 8998 | */ |
| 8999 | hdd_ctx->hdd_psoc->total_mac_phy = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9000 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9001 | done: |
| 9002 | hdd_ctx->stop_modules_in_progress = false; |
| 9003 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9004 | EXIT(); |
| 9005 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9006 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9007 | |
| 9008 | } |
| 9009 | |
| 9010 | /** |
| 9011 | * hdd_iface_change_callback() - Function invoked when stop modules expires |
| 9012 | * @priv: pointer to hdd context |
| 9013 | * |
| 9014 | * This function is invoked when the timer waiting for the interface change |
| 9015 | * expires, it shall cut-down the power to wlan and stop all the modules. |
| 9016 | * |
| 9017 | * Return: void |
| 9018 | */ |
| 9019 | static void hdd_iface_change_callback(void *priv) |
| 9020 | { |
| 9021 | hdd_context_t *hdd_ctx = (hdd_context_t *) priv; |
| 9022 | int ret; |
| 9023 | int status = wlan_hdd_validate_context(hdd_ctx); |
| 9024 | |
| 9025 | if (status) |
| 9026 | return; |
| 9027 | |
| 9028 | ENTER(); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9029 | hdd_debug("Interface change timer expired close the modules!"); |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 9030 | ret = hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9031 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9032 | hdd_err("Failed to stop modules"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9033 | EXIT(); |
| 9034 | } |
| 9035 | |
| 9036 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 9037 | * hdd_state_info_dump() - prints state information of hdd layer |
| 9038 | * @buf: buffer pointer |
| 9039 | * @size: size of buffer to be filled |
| 9040 | * |
| 9041 | * This function is used to dump state information of hdd layer |
| 9042 | * |
| 9043 | * Return: None |
| 9044 | */ |
| 9045 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 9046 | { |
| 9047 | hdd_context_t *hdd_ctx; |
| 9048 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 9049 | QDF_STATUS status; |
| 9050 | hdd_station_ctx_t *hdd_sta_ctx; |
| 9051 | hdd_adapter_t *adapter; |
| 9052 | uint16_t len = 0; |
| 9053 | char *buf = *buf_ptr; |
| 9054 | |
| 9055 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 9056 | if (!hdd_ctx) { |
| 9057 | hdd_err("Failed to get hdd context "); |
| 9058 | return; |
| 9059 | } |
| 9060 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9061 | hdd_debug("size of buffer: %d", *size); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 9062 | |
| 9063 | len += scnprintf(buf + len, *size - len, |
| 9064 | "\n isWiphySuspended %d", hdd_ctx->isWiphySuspended); |
| 9065 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 9066 | "\n is_scheduler_suspended %d", |
| 9067 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 9068 | |
| 9069 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 9070 | |
| 9071 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 9072 | adapter = adapter_node->pAdapter; |
| 9073 | if (adapter->dev) |
| 9074 | len += scnprintf(buf + len, *size - len, |
| 9075 | "\n device name: %s", adapter->dev->name); |
| 9076 | len += scnprintf(buf + len, *size - len, |
| 9077 | "\n device_mode: %d", adapter->device_mode); |
| 9078 | switch (adapter->device_mode) { |
| 9079 | case QDF_STA_MODE: |
| 9080 | case QDF_P2P_CLIENT_MODE: |
| 9081 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 9082 | len += scnprintf(buf + len, *size - len, |
| 9083 | "\n connState: %d", |
| 9084 | hdd_sta_ctx->conn_info.connState); |
| 9085 | break; |
| 9086 | |
| 9087 | default: |
| 9088 | break; |
| 9089 | } |
| 9090 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 9091 | adapter_node = next; |
| 9092 | } |
| 9093 | |
| 9094 | *size -= len; |
| 9095 | *buf_ptr += len; |
| 9096 | } |
| 9097 | |
| 9098 | /** |
| 9099 | * hdd_register_debug_callback() - registration function for hdd layer |
| 9100 | * to print hdd state information |
| 9101 | * |
| 9102 | * Return: None |
| 9103 | */ |
| 9104 | static void hdd_register_debug_callback(void) |
| 9105 | { |
| 9106 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 9107 | } |
| 9108 | |
| 9109 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9110 | * hdd_wlan_startup() - HDD init function |
| 9111 | * @dev: Pointer to the underlying device |
| 9112 | * |
| 9113 | * This is the driver startup code executed once a WLAN device has been detected |
| 9114 | * |
| 9115 | * Return: 0 for success, < 0 for failure |
| 9116 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9117 | int hdd_wlan_startup(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9118 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9119 | QDF_STATUS status; |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9120 | hdd_context_t *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9121 | int ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9122 | bool rtnl_held; |
Manjeet Singh | e7ecb7c | 2016-09-03 12:34:53 +0530 | [diff] [blame] | 9123 | int set_value; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9124 | |
| 9125 | ENTER(); |
| 9126 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9127 | hdd_ctx = hdd_context_create(dev); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9128 | |
| 9129 | if (IS_ERR(hdd_ctx)) |
| 9130 | return PTR_ERR(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9131 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 9132 | ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, |
| 9133 | DEFAULT_PSOC_ID); |
| 9134 | if (ret) { |
| 9135 | hdd_err("Psoc creation fails!"); |
| 9136 | QDF_BUG(0); |
| 9137 | goto err_hdd_free_context; |
| 9138 | } |
| 9139 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9140 | qdf_mc_timer_init(&hdd_ctx->iface_change_timer, QDF_TIMER_TYPE_SW, |
| 9141 | hdd_iface_change_callback, (void *)hdd_ctx); |
| 9142 | |
| 9143 | mutex_init(&hdd_ctx->iface_change_lock); |
| 9144 | |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 9145 | ret = hdd_init_netlink_services(hdd_ctx); |
| 9146 | if (ret) |
| 9147 | goto err_hdd_free_context; |
| 9148 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 9149 | hdd_request_manager_init(); |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 9150 | hdd_green_ap_init(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9151 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9152 | ret = hdd_wlan_start_modules(hdd_ctx, NULL, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9153 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9154 | hdd_err("Failed to start modules: %d", ret); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 9155 | goto err_exit_nl_srv; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9156 | } |
| 9157 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 9158 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9159 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 9160 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9161 | hdd_debug("Failed to set wow pulse"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 9162 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9163 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9164 | |
| 9165 | if (NULL == hdd_ctx->hHal) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9166 | hdd_err("HAL context is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9167 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9168 | } |
| 9169 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9170 | ret = hdd_wiphy_init(hdd_ctx); |
| 9171 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9172 | hdd_err("Failed to initialize wiphy: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9173 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9174 | } |
| 9175 | |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 9176 | if (hdd_ctx->config->enable_dp_trace) |
| 9177 | qdf_dp_trace_init(); |
| 9178 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9179 | if (hdd_ipa_init(hdd_ctx) == QDF_STATUS_E_FAILURE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9180 | goto err_wiphy_unregister; |
| 9181 | |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 9182 | wlan_hdd_init_chan_info(hdd_ctx); |
| 9183 | |
Yuanyuan Liu | c98370e | 2016-10-13 11:22:13 -0700 | [diff] [blame] | 9184 | hdd_initialize_mac_address(hdd_ctx); |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 9185 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9186 | rtnl_held = hdd_hold_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9187 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9188 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 9189 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9190 | hdd_err("Failed to open interfaces: %d", ret); |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 9191 | goto err_release_rtnl_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9192 | } |
| 9193 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9194 | hdd_release_rtnl_lock(); |
| 9195 | rtnl_held = false; |
| 9196 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 9197 | wlan_hdd_update_11n_mode(hdd_ctx->config); |
| 9198 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9199 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 9200 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9201 | QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9202 | hdd_skip_acs_scan_timer_handler, |
| 9203 | (void *)hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9204 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 9205 | hdd_err("Failed to init ACS Skip timer"); |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 9206 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9207 | #endif |
| 9208 | |
Nitesh Shah | 61c10d9 | 2016-10-19 19:29:15 +0530 | [diff] [blame] | 9209 | qdf_mc_timer_init(&hdd_ctx->tdls_source_timer, |
| 9210 | QDF_TIMER_TYPE_SW, |
| 9211 | wlan_hdd_change_tdls_mode, |
| 9212 | hdd_ctx); |
| 9213 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 9214 | hdd_bus_bandwidth_init(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9215 | |
Jeff Johnson | 9afc501 | 2016-09-23 13:56:27 -0700 | [diff] [blame] | 9216 | hdd_lpass_notify_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9217 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 9218 | if (hdd_ctx->rps) |
| 9219 | hdd_set_rps_cpu_mask(hdd_ctx); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9220 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 9221 | ret = hdd_register_notifiers(hdd_ctx); |
| 9222 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9223 | goto err_close_adapters; |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 9224 | |
| 9225 | status = wlansap_global_init(); |
| 9226 | if (QDF_IS_STATUS_ERROR(status)) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9227 | goto err_close_adapters; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 9228 | |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 9229 | hdd_runtime_suspend_context_init(hdd_ctx); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9230 | memdump_init(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 9231 | hdd_driver_memdump_init(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9232 | |
bings | 612b9c4 | 2016-11-07 10:52:03 +0800 | [diff] [blame] | 9233 | if (hdd_enable_egap(hdd_ctx)) |
Srinivas Girigowda | c06543c | 2017-03-09 15:10:03 -0800 | [diff] [blame] | 9234 | hdd_debug("enhance green ap is not enabled"); |
bings | 612b9c4 | 2016-11-07 10:52:03 +0800 | [diff] [blame] | 9235 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9236 | if (hdd_ctx->config->fIsImpsEnabled) |
| 9237 | hdd_set_idle_ps_config(hdd_ctx, true); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 9238 | |
Manjeet Singh | e7ecb7c | 2016-09-03 12:34:53 +0530 | [diff] [blame] | 9239 | if (hdd_ctx->config->sifs_burst_duration) { |
| 9240 | set_value = (SIFS_BURST_DUR_MULTIPLIER) * |
| 9241 | hdd_ctx->config->sifs_burst_duration; |
| 9242 | |
| 9243 | if ((set_value > 0) && (set_value <= SIFS_BURST_DUR_MAX)) |
| 9244 | wma_cli_set_command(0, (int)WMI_PDEV_PARAM_BURST_DUR, |
| 9245 | set_value, PDEV_CMD); |
| 9246 | } |
| 9247 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9248 | qdf_mc_timer_start(&hdd_ctx->iface_change_timer, |
| 9249 | hdd_ctx->config->iface_change_wait_time * 5000); |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 9250 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 9251 | hdd_start_complete(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9252 | goto success; |
| 9253 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9254 | err_close_adapters: |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 9255 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9256 | |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 9257 | err_release_rtnl_lock: |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9258 | if (rtnl_held) |
| 9259 | hdd_release_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9260 | |
Anurag Chouhan | ce6a405 | 2016-09-14 18:20:42 +0530 | [diff] [blame] | 9261 | hdd_ipa_cleanup(hdd_ctx); |
Yun Park | 6a46ad8 | 2016-01-04 16:48:19 -0800 | [diff] [blame] | 9262 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9263 | err_wiphy_unregister: |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9264 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9265 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9266 | err_stop_modules: |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 9267 | hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9268 | |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 9269 | err_exit_nl_srv: |
Arunk Khandavalli | fbc1ef0 | 2017-03-14 21:25:05 +0530 | [diff] [blame] | 9270 | if (DRIVER_MODULES_CLOSED == hdd_ctx->driver_status) { |
| 9271 | status = cds_sched_close(hdd_ctx->pcds_context); |
| 9272 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9273 | hdd_err("Failed to close CDS Scheduler"); |
| 9274 | QDF_ASSERT(QDF_IS_STATUS_SUCCESS(status)); |
| 9275 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9276 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9277 | |
Houston Hoffman | 47a4a05 | 2016-11-14 23:22:44 -0800 | [diff] [blame] | 9278 | hdd_green_ap_deinit(hdd_ctx); |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 9279 | hdd_request_manager_deinit(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 9280 | hdd_exit_netlink_services(hdd_ctx); |
| 9281 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9282 | cds_deinit_ini_config(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9283 | err_hdd_free_context: |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 9284 | hdd_start_complete(ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9285 | qdf_mc_timer_destroy(&hdd_ctx->iface_change_timer); |
| 9286 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9287 | hdd_context_destroy(hdd_ctx); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 9288 | QDF_BUG(1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9289 | return -EIO; |
| 9290 | |
| 9291 | success: |
| 9292 | EXIT(); |
| 9293 | return 0; |
| 9294 | } |
| 9295 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9296 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9297 | * hdd_wlan_update_target_info() - update target type info |
| 9298 | * @hdd_ctx: HDD context |
| 9299 | * @context: hif context |
| 9300 | * |
| 9301 | * Update target info received from firmware in hdd context |
| 9302 | * Return:None |
| 9303 | */ |
| 9304 | |
| 9305 | void hdd_wlan_update_target_info(hdd_context_t *hdd_ctx, void *context) |
| 9306 | { |
| 9307 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 9308 | |
| 9309 | if (!tgt_info) { |
| 9310 | hdd_err("Target info is Null"); |
| 9311 | return; |
| 9312 | } |
| 9313 | |
| 9314 | hdd_ctx->target_type = tgt_info->target_type; |
| 9315 | } |
| 9316 | |
| 9317 | /** |
| 9318 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 9319 | * @hdd_ctx: HDD context |
| 9320 | * |
| 9321 | * Register the HDD callbacks to CDS/SME. |
| 9322 | * |
| 9323 | * Return: 0 for success or Error code for failure |
| 9324 | */ |
| 9325 | int hdd_register_cb(hdd_context_t *hdd_ctx) |
| 9326 | { |
| 9327 | QDF_STATUS status; |
| 9328 | int ret = 0; |
| 9329 | |
| 9330 | ENTER(); |
| 9331 | |
| 9332 | sme_register11d_scan_done_callback(hdd_ctx->hHal, hdd_11d_scan_done); |
| 9333 | |
| 9334 | sme_register_oem_data_rsp_callback(hdd_ctx->hHal, |
| 9335 | hdd_send_oem_data_rsp_msg); |
| 9336 | |
| 9337 | status = sme_fw_mem_dump_register_cb(hdd_ctx->hHal, |
| 9338 | wlan_hdd_cfg80211_fw_mem_dump_cb); |
| 9339 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9340 | hdd_err("Failed to register memdump callback"); |
| 9341 | ret = -EINVAL; |
| 9342 | return ret; |
| 9343 | } |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 9344 | sme_register_mgmt_frame_ind_callback(hdd_ctx->hHal, |
| 9345 | hdd_indicate_mgmt_frame); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 9346 | sme_set_tsfcb(hdd_ctx->hHal, hdd_get_tsf_cb, hdd_ctx); |
| 9347 | sme_nan_register_callback(hdd_ctx->hHal, |
| 9348 | wlan_hdd_cfg80211_nan_callback); |
| 9349 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 9350 | wlan_hdd_cfg80211_stats_ext_callback); |
| 9351 | |
| 9352 | sme_ext_scan_register_callback(hdd_ctx->hHal, |
| 9353 | wlan_hdd_cfg80211_extscan_callback); |
| 9354 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 9355 | sme_set_rssi_threshold_breached_cb(hdd_ctx->hHal, |
| 9356 | hdd_rssi_threshold_breached); |
| 9357 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 9358 | sme_set_link_layer_stats_ind_cb(hdd_ctx->hHal, |
| 9359 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 9360 | |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 9361 | sme_rso_cmd_status_cb(hdd_ctx->hHal, wlan_hdd_rso_cmd_status_cb); |
| 9362 | |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 9363 | status = sme_set_lost_link_info_cb(hdd_ctx->hHal, |
| 9364 | hdd_lost_link_info_cb); |
| 9365 | /* print error and not block the startup process */ |
| 9366 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9367 | hdd_err("set lost link info callback failed"); |
| 9368 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 9369 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 9370 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 9371 | sme_register_set_connection_info_cb(hdd_ctx->hHal, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 9372 | hdd_set_connection_in_progress, |
| 9373 | hdd_is_connection_in_progress); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 9374 | EXIT(); |
| 9375 | |
| 9376 | return ret; |
| 9377 | } |
| 9378 | |
| 9379 | /** |
| 9380 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 9381 | * @hdd_ctx: HDD context |
| 9382 | * |
| 9383 | * De-Register the HDD callbacks to CDS/SME. |
| 9384 | * |
| 9385 | * Return: void |
| 9386 | */ |
| 9387 | void hdd_deregister_cb(hdd_context_t *hdd_ctx) |
| 9388 | { |
| 9389 | QDF_STATUS status; |
| 9390 | |
| 9391 | ENTER(); |
| 9392 | |
| 9393 | status = sme_deregister_for_dcc_stats_event(hdd_ctx->hHal); |
| 9394 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9395 | hdd_err("De-register of dcc stats callback failed: %d", |
| 9396 | status); |
| 9397 | |
| 9398 | sme_reset_link_layer_stats_ind_cb(hdd_ctx->hHal); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 9399 | sme_reset_rssi_threshold_breached_cb(hdd_ctx->hHal); |
| 9400 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 9401 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 9402 | wlan_hdd_cfg80211_stats_ext_callback); |
| 9403 | |
| 9404 | sme_nan_deregister_callback(hdd_ctx->hHal); |
| 9405 | status = sme_reset_tsfcb(hdd_ctx->hHal); |
| 9406 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9407 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 9408 | status); |
| 9409 | status = sme_fw_mem_dump_unregister_cb(hdd_ctx->hHal); |
| 9410 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9411 | hdd_err("Failed to de-register the fw mem dump callback: %d", |
| 9412 | status); |
| 9413 | |
| 9414 | sme_deregister_oem_data_rsp_callback(hdd_ctx->hHal); |
| 9415 | sme_deregister11d_scan_done_callback(hdd_ctx->hHal); |
| 9416 | |
| 9417 | EXIT(); |
| 9418 | } |
| 9419 | |
| 9420 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9421 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
| 9422 | * @adapter: Pointer to the HDD |
| 9423 | * @enable: bool value |
| 9424 | * |
| 9425 | * This to take counter measure to handle deauth req from HDD |
| 9426 | * |
| 9427 | * Return: None |
| 9428 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9429 | QDF_STATUS hdd_softap_sta_deauth(hdd_adapter_t *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9430 | struct tagCsrDelStaParams *pDelStaParams) |
| 9431 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9432 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9433 | |
| 9434 | ENTER(); |
| 9435 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9436 | hdd_debug("hdd_softap_sta_deauth:(%p, false)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9437 | (WLAN_HDD_GET_CTX(adapter))->pcds_context); |
| 9438 | |
| 9439 | /* Ignore request to deauth bcmc station */ |
| 9440 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9441 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9442 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9443 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9444 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 9445 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9446 | |
| 9447 | EXIT(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9448 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9449 | } |
| 9450 | |
| 9451 | /** |
| 9452 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
| 9453 | * @adapter: Pointer to the HDD |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 9454 | * @p_del_sta_params: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9455 | * |
| 9456 | * This to take counter measure to handle deauth req from HDD |
| 9457 | * |
| 9458 | * Return: None |
| 9459 | */ |
| 9460 | void hdd_softap_sta_disassoc(hdd_adapter_t *adapter, |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 9461 | struct tagCsrDelStaParams *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9462 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9463 | ENTER(); |
| 9464 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9465 | hdd_debug("hdd_softap_sta_disassoc:(%p, false)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9466 | (WLAN_HDD_GET_CTX(adapter))->pcds_context); |
| 9467 | |
| 9468 | /* Ignore request to disassoc bcmc station */ |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 9469 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9470 | return; |
| 9471 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9472 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 9473 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9474 | } |
| 9475 | |
| 9476 | void hdd_softap_tkip_mic_fail_counter_measure(hdd_adapter_t *adapter, |
| 9477 | bool enable) |
| 9478 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9479 | ENTER(); |
| 9480 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9481 | hdd_debug("hdd_softap_tkip_mic_fail_counter_measure:(%p, false)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9482 | (WLAN_HDD_GET_CTX(adapter))->pcds_context); |
| 9483 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9484 | wlansap_set_counter_measure(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 9485 | (bool) enable); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9486 | } |
| 9487 | |
| 9488 | /** |
| 9489 | * hdd_issta_p2p_clientconnected() - check if sta or p2p client is connected |
| 9490 | * @hdd_ctx: HDD Context |
| 9491 | * |
| 9492 | * API to find if there is any STA or P2P-Client is connected |
| 9493 | * |
| 9494 | * Return: true if connected; false otherwise |
| 9495 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9496 | QDF_STATUS hdd_issta_p2p_clientconnected(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9497 | { |
| 9498 | return sme_is_sta_p2p_client_connected(hdd_ctx->hHal); |
| 9499 | } |
| 9500 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9501 | /** |
| 9502 | * wlan_hdd_disable_roaming() - disable roaming on all STAs except the input one |
| 9503 | * @adapter: HDD adapter pointer |
| 9504 | * |
| 9505 | * This function loop through each adapter and disable roaming on each STA |
| 9506 | * device mode except the input adapter. |
| 9507 | * |
| 9508 | * Note: On the input adapter roaming is not enabled yet hence no need to |
| 9509 | * disable. |
| 9510 | * |
| 9511 | * Return: None |
| 9512 | */ |
| 9513 | void wlan_hdd_disable_roaming(hdd_adapter_t *adapter) |
| 9514 | { |
| 9515 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 9516 | hdd_adapter_t *adapterIdx = NULL; |
| 9517 | hdd_adapter_list_node_t *adapterNode = NULL; |
| 9518 | hdd_adapter_list_node_t *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9519 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9520 | |
| 9521 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 9522 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 9523 | QDF_STA_MODE == adapter->device_mode && |
| 9524 | policy_mgr_is_sta_active_connection_exists( |
| 9525 | hdd_ctx->hdd_psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9526 | hdd_debug("Connect received on STA sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9527 | adapter->sessionId); |
| 9528 | /* |
| 9529 | * Loop through adapter and disable roaming for each STA device |
| 9530 | * mode except the input adapter. |
| 9531 | */ |
| 9532 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 9533 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9534 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9535 | adapterIdx = adapterNode->pAdapter; |
| 9536 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9537 | if (QDF_STA_MODE == adapterIdx->device_mode |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9538 | && adapter->sessionId != adapterIdx->sessionId) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9539 | hdd_debug("Disable Roaming on sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9540 | adapterIdx->sessionId); |
| 9541 | sme_stop_roaming(WLAN_HDD_GET_HAL_CTX |
| 9542 | (adapterIdx), |
| 9543 | adapterIdx->sessionId, 0); |
| 9544 | } |
| 9545 | |
| 9546 | status = hdd_get_next_adapter(hdd_ctx, |
| 9547 | adapterNode, |
| 9548 | &pNext); |
| 9549 | adapterNode = pNext; |
| 9550 | } |
| 9551 | } |
| 9552 | } |
| 9553 | |
| 9554 | /** |
| 9555 | * wlan_hdd_enable_roaming() - enable roaming on all STAs except the input one |
| 9556 | * @adapter: HDD adapter pointer |
| 9557 | * |
| 9558 | * This function loop through each adapter and enable roaming on each STA |
| 9559 | * device mode except the input adapter. |
| 9560 | * Note: On the input adapter no need to enable roaming because link got |
| 9561 | * disconnected on this. |
| 9562 | * |
| 9563 | * Return: None |
| 9564 | */ |
| 9565 | void wlan_hdd_enable_roaming(hdd_adapter_t *adapter) |
| 9566 | { |
| 9567 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 9568 | hdd_adapter_t *adapterIdx = NULL; |
| 9569 | hdd_adapter_list_node_t *adapterNode = NULL; |
| 9570 | hdd_adapter_list_node_t *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9571 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9572 | |
| 9573 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 9574 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 9575 | QDF_STA_MODE == adapter->device_mode && |
| 9576 | policy_mgr_is_sta_active_connection_exists( |
| 9577 | hdd_ctx->hdd_psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9578 | hdd_debug("Disconnect received on STA sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9579 | adapter->sessionId); |
| 9580 | /* |
| 9581 | * Loop through adapter and enable roaming for each STA device |
| 9582 | * mode except the input adapter. |
| 9583 | */ |
| 9584 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 9585 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9586 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9587 | adapterIdx = adapterNode->pAdapter; |
| 9588 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9589 | if (QDF_STA_MODE == adapterIdx->device_mode |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9590 | && adapter->sessionId != adapterIdx->sessionId) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9591 | hdd_debug("Enabling Roaming on sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9592 | adapterIdx->sessionId); |
| 9593 | sme_start_roaming(WLAN_HDD_GET_HAL_CTX |
| 9594 | (adapterIdx), |
| 9595 | adapterIdx->sessionId, |
| 9596 | REASON_CONNECT); |
| 9597 | } |
| 9598 | |
| 9599 | status = hdd_get_next_adapter(hdd_ctx, |
| 9600 | adapterNode, |
| 9601 | &pNext); |
| 9602 | adapterNode = pNext; |
| 9603 | } |
| 9604 | } |
| 9605 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9606 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 9607 | /** |
| 9608 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 9609 | * @skb: sk buffer pointer |
| 9610 | * |
| 9611 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 9612 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 9613 | * |
| 9614 | * Return: None |
| 9615 | */ |
| 9616 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 9617 | { |
| 9618 | #ifdef CNSS_GENL |
| 9619 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 9620 | #else |
| 9621 | nl_srv_bcast(skb); |
| 9622 | #endif |
| 9623 | } |
| 9624 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 9625 | 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] | 9626 | { |
| 9627 | struct sk_buff *skb; |
| 9628 | struct nlmsghdr *nlh; |
| 9629 | tAniMsgHdr *ani_hdr; |
| 9630 | void *nl_data = NULL; |
| 9631 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 9632 | struct radio_index_tlv *radio_info; |
| 9633 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9634 | |
| 9635 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 9636 | flags = GFP_ATOMIC; |
| 9637 | |
| 9638 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 9639 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9640 | if (skb == NULL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9641 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9642 | |
| 9643 | nlh = (struct nlmsghdr *)skb->data; |
| 9644 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 9645 | nlh->nlmsg_flags = 0; |
| 9646 | nlh->nlmsg_seq = 0; |
| 9647 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 9648 | |
| 9649 | ani_hdr = NLMSG_DATA(nlh); |
| 9650 | ani_hdr->type = type; |
| 9651 | |
| 9652 | switch (type) { |
| 9653 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 9654 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9655 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9656 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 9657 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9658 | ani_hdr->length = 0; |
| 9659 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9660 | break; |
| 9661 | case WLAN_SVC_WLAN_STATUS_IND: |
| 9662 | case WLAN_SVC_WLAN_VERSION_IND: |
| 9663 | case WLAN_SVC_DFS_CAC_START_IND: |
| 9664 | case WLAN_SVC_DFS_CAC_END_IND: |
| 9665 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 9666 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 9667 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 9668 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 9669 | case WLAN_SVC_RPS_ENABLE_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9670 | ani_hdr->length = len; |
| 9671 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 9672 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 9673 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9674 | break; |
| 9675 | |
| 9676 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 9677 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9678 | type); |
| 9679 | kfree_skb(skb); |
| 9680 | return; |
| 9681 | } |
| 9682 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 9683 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 9684 | * Add radio index at the end of the svc event in TLV format |
| 9685 | * to maintain the backward compatibility with userspace |
| 9686 | * applications. |
| 9687 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 9688 | |
| 9689 | tlv_len = 0; |
| 9690 | |
| 9691 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 9692 | < WLAN_NL_MAX_PAYLOAD) { |
| 9693 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 9694 | sizeof(*ani_hdr) + len); |
| 9695 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 9696 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 9697 | radio_info->radio = radio; |
| 9698 | tlv_len = sizeof(*radio_info); |
Srinivas Girigowda | c06543c | 2017-03-09 15:10:03 -0800 | [diff] [blame] | 9699 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG, |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 9700 | "Added radio index tlv - radio index %d", |
| 9701 | radio_info->radio); |
| 9702 | } |
| 9703 | |
| 9704 | nlh->nlmsg_len += tlv_len; |
| 9705 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 9706 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 9707 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9708 | } |
| 9709 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9710 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 9711 | void wlan_hdd_auto_shutdown_cb(void) |
| 9712 | { |
Mahesh Kumar Kalikot Veetil | d214d55 | 2016-09-14 15:15:49 -0700 | [diff] [blame] | 9713 | hdd_context_t *hdd_ctx = cds_get_global_context(); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 9714 | |
| 9715 | if (!hdd_ctx) |
| 9716 | return; |
| 9717 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9718 | hdd_debug("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 9719 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 9720 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9721 | } |
| 9722 | |
| 9723 | void wlan_hdd_auto_shutdown_enable(hdd_context_t *hdd_ctx, bool enable) |
| 9724 | { |
| 9725 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9726 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9727 | hdd_adapter_t *adapter; |
| 9728 | bool ap_connected = false, sta_connected = false; |
| 9729 | tHalHandle hal_handle; |
| 9730 | |
| 9731 | hal_handle = hdd_ctx->hHal; |
| 9732 | if (hal_handle == NULL) |
| 9733 | return; |
| 9734 | |
| 9735 | if (hdd_ctx->config->WlanAutoShutdown == 0) |
| 9736 | return; |
| 9737 | |
| 9738 | if (enable == false) { |
| 9739 | if (sme_set_auto_shutdown_timer(hal_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9740 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9741 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9742 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 9743 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 9744 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9745 | return; |
| 9746 | } |
| 9747 | |
| 9748 | /* To enable shutdown timer check conncurrency */ |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 9749 | if (policy_mgr_concurrent_open_sessions_running( |
| 9750 | hdd_ctx->hdd_psoc)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9751 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 9752 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9753 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9754 | adapter = adapterNode->pAdapter; |
| 9755 | if (adapter |
| 9756 | && adapter->device_mode == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9757 | QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9758 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 9759 | conn_info.connState == |
| 9760 | eConnectionState_Associated) { |
| 9761 | sta_connected = true; |
| 9762 | break; |
| 9763 | } |
| 9764 | } |
| 9765 | if (adapter |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9766 | && adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9767 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
| 9768 | bApActive == true) { |
| 9769 | ap_connected = true; |
| 9770 | break; |
| 9771 | } |
| 9772 | } |
| 9773 | status = hdd_get_next_adapter(hdd_ctx, |
| 9774 | adapterNode, |
| 9775 | &pNext); |
| 9776 | adapterNode = pNext; |
| 9777 | } |
| 9778 | } |
| 9779 | |
| 9780 | if (ap_connected == true || sta_connected == true) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9781 | hdd_debug("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9782 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9783 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 9784 | |
| 9785 | if (sme_set_auto_shutdown_timer(hal_handle, |
| 9786 | hdd_ctx->config->WlanAutoShutdown) |
| 9787 | != QDF_STATUS_SUCCESS) |
| 9788 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 9789 | else |
| 9790 | hdd_notice("Auto Shutdown timer for %d seconds enabled", |
| 9791 | hdd_ctx->config->WlanAutoShutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9792 | } |
| 9793 | #endif |
| 9794 | |
| 9795 | hdd_adapter_t *hdd_get_con_sap_adapter(hdd_adapter_t *this_sap_adapter, |
| 9796 | bool check_start_bss) |
| 9797 | { |
| 9798 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
| 9799 | hdd_adapter_t *adapter, *con_sap_adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9800 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9801 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 9802 | |
| 9803 | con_sap_adapter = NULL; |
| 9804 | |
| 9805 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9806 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9807 | adapter = adapterNode->pAdapter; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9808 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 9809 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9810 | adapter != this_sap_adapter) { |
| 9811 | if (check_start_bss) { |
| 9812 | if (test_bit(SOFTAP_BSS_STARTED, |
| 9813 | &adapter->event_flags)) { |
| 9814 | con_sap_adapter = adapter; |
| 9815 | break; |
| 9816 | } |
| 9817 | } else { |
| 9818 | con_sap_adapter = adapter; |
| 9819 | break; |
| 9820 | } |
| 9821 | } |
| 9822 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 9823 | adapterNode = pNext; |
| 9824 | } |
| 9825 | |
| 9826 | return con_sap_adapter; |
| 9827 | } |
| 9828 | |
| 9829 | #ifdef MSM_PLATFORM |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 9830 | static inline bool hdd_adapter_is_sta(hdd_adapter_t *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9831 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 9832 | return adapter->device_mode == QDF_STA_MODE || |
| 9833 | adapter->device_mode == QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9834 | } |
| 9835 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 9836 | static inline bool hdd_adapter_is_ap(hdd_adapter_t *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9837 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 9838 | return adapter->device_mode == QDF_SAP_MODE || |
| 9839 | adapter->device_mode == QDF_P2P_GO_MODE; |
| 9840 | } |
| 9841 | |
| 9842 | static bool hdd_any_adapter_is_assoc(hdd_context_t *hdd_ctx) |
| 9843 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9844 | QDF_STATUS status; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 9845 | hdd_adapter_list_node_t *node; |
| 9846 | |
| 9847 | status = hdd_get_front_adapter(hdd_ctx, &node); |
| 9848 | while (QDF_IS_STATUS_SUCCESS(status) && node) { |
| 9849 | hdd_adapter_t *adapter = node->pAdapter; |
| 9850 | |
| 9851 | if (adapter && |
| 9852 | hdd_adapter_is_sta(adapter) && |
| 9853 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 9854 | conn_info.connState == eConnectionState_Associated) { |
| 9855 | return true; |
| 9856 | } |
| 9857 | |
| 9858 | if (adapter && |
| 9859 | hdd_adapter_is_ap(adapter) && |
| 9860 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->bApActive) { |
| 9861 | return true; |
| 9862 | } |
| 9863 | |
| 9864 | status = hdd_get_next_adapter(hdd_ctx, node, &node); |
| 9865 | } |
| 9866 | |
| 9867 | return false; |
| 9868 | } |
| 9869 | |
| 9870 | static bool hdd_bus_bw_compute_timer_is_running(hdd_context_t *hdd_ctx) |
| 9871 | { |
| 9872 | bool is_running; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9873 | |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 9874 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 9875 | is_running = hdd_ctx->bus_bw_timer_running; |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 9876 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9877 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 9878 | return is_running; |
| 9879 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9880 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 9881 | static void __hdd_bus_bw_compute_timer_start(hdd_context_t *hdd_ctx) |
| 9882 | { |
| 9883 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 9884 | hdd_ctx->bus_bw_timer_running = true; |
| 9885 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
| 9886 | hdd_ctx->config->busBandwidthComputeInterval); |
| 9887 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 9888 | } |
| 9889 | |
| 9890 | void hdd_bus_bw_compute_timer_start(hdd_context_t *hdd_ctx) |
| 9891 | { |
| 9892 | ENTER(); |
| 9893 | |
| 9894 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 9895 | hdd_debug("Bandwidth compute timer already started"); |
| 9896 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9897 | } |
| 9898 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 9899 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 9900 | |
| 9901 | EXIT(); |
| 9902 | } |
| 9903 | |
| 9904 | void hdd_bus_bw_compute_timer_try_start(hdd_context_t *hdd_ctx) |
| 9905 | { |
| 9906 | ENTER(); |
| 9907 | |
| 9908 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 9909 | hdd_debug("Bandwidth compute timer already started"); |
| 9910 | return; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 9911 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 9912 | |
| 9913 | if (hdd_any_adapter_is_assoc(hdd_ctx)) |
| 9914 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 9915 | |
| 9916 | EXIT(); |
| 9917 | } |
| 9918 | |
| 9919 | static void __hdd_bus_bw_compute_timer_stop(hdd_context_t *hdd_ctx) |
| 9920 | { |
| 9921 | hdd_ipa_set_perf_level(hdd_ctx, 0, 0); |
| 9922 | |
| 9923 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 9924 | qdf_timer_stop(&hdd_ctx->bus_bw_timer); |
| 9925 | hdd_ctx->bus_bw_timer_running = false; |
| 9926 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 9927 | |
| 9928 | hdd_reset_tcp_delack(hdd_ctx); |
| 9929 | } |
| 9930 | |
| 9931 | void hdd_bus_bw_compute_timer_stop(hdd_context_t *hdd_ctx) |
| 9932 | { |
| 9933 | ENTER(); |
| 9934 | |
| 9935 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 9936 | hdd_debug("Bandwidth compute timer already stopped"); |
| 9937 | return; |
| 9938 | } |
| 9939 | |
| 9940 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 9941 | |
| 9942 | EXIT(); |
| 9943 | } |
| 9944 | |
| 9945 | void hdd_bus_bw_compute_timer_try_stop(hdd_context_t *hdd_ctx) |
| 9946 | { |
| 9947 | ENTER(); |
| 9948 | |
| 9949 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 9950 | hdd_debug("Bandwidth compute timer already stopped"); |
| 9951 | return; |
| 9952 | } |
| 9953 | |
| 9954 | if (!hdd_any_adapter_is_assoc(hdd_ctx)) |
| 9955 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 9956 | |
| 9957 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9958 | } |
| 9959 | #endif |
| 9960 | |
| 9961 | /** |
| 9962 | * wlan_hdd_check_custom_con_channel_rules() - This function checks the sap's |
| 9963 | * and sta's operating channel. |
| 9964 | * @sta_adapter: Describe the first argument to foobar. |
| 9965 | * @ap_adapter: Describe the second argument to foobar. |
| 9966 | * @roam_profile: Roam profile of AP to which STA wants to connect. |
| 9967 | * @concurrent_chnl_same: If both SAP and STA channels are same then |
| 9968 | * set this flag to true else false. |
| 9969 | * |
| 9970 | * This function checks the sap's operating channel and sta's operating channel. |
| 9971 | * if both are same then it will return false else it will restart the sap in |
| 9972 | * sta's channel and return true. |
| 9973 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9974 | * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9975 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9976 | QDF_STATUS wlan_hdd_check_custom_con_channel_rules(hdd_adapter_t *sta_adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9977 | hdd_adapter_t *ap_adapter, |
| 9978 | tCsrRoamProfile *roam_profile, |
| 9979 | tScanResultHandle *scan_cache, |
| 9980 | bool *concurrent_chnl_same) |
| 9981 | { |
| 9982 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 9983 | uint8_t channel_id; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9984 | QDF_STATUS status; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9985 | enum tQDF_ADAPTER_MODE device_mode = ap_adapter->device_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9986 | *concurrent_chnl_same = true; |
| 9987 | |
| 9988 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 9989 | status = |
Archana Ramachandran | 2eb7a61 | 2017-03-23 22:58:42 -0700 | [diff] [blame] | 9990 | sme_get_ap_channel_from_scan_cache(roam_profile, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9991 | scan_cache, |
| 9992 | &channel_id); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9993 | if (QDF_STATUS_SUCCESS == status) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9994 | if ((QDF_SAP_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9995 | (channel_id < SIR_11A_CHANNEL_BEGIN)) { |
| 9996 | if (hdd_ap_ctx->operatingChannel != channel_id) { |
| 9997 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9998 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9999 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 10000 | } else if ((QDF_P2P_GO_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10001 | (channel_id >= SIR_11A_CHANNEL_BEGIN)) { |
| 10002 | if (hdd_ap_ctx->operatingChannel != channel_id) { |
| 10003 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10004 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10005 | } |
| 10006 | } |
| 10007 | } else { |
| 10008 | /* |
| 10009 | * Lets handle worst case scenario here, Scan cache lookup is |
| 10010 | * failed so we have to stop the SAP to avoid any channel |
| 10011 | * discrepancy between SAP's channel and STA's channel. |
| 10012 | * Return the status as failure so caller function could know |
| 10013 | * that scan look up is failed. |
| 10014 | */ |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10015 | hdd_err("Finding AP from scan cache failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10016 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10017 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10018 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10019 | } |
| 10020 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10021 | /** |
| 10022 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 10023 | * @ap_adapter: SAP adapter |
| 10024 | * |
| 10025 | * This function will process the stopping of sap adapter. |
| 10026 | * |
| 10027 | * Return: None |
| 10028 | */ |
| 10029 | void wlan_hdd_stop_sap(hdd_adapter_t *ap_adapter) |
| 10030 | { |
| 10031 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 10032 | hdd_hostapd_state_t *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 10033 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10034 | hdd_context_t *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10035 | |
| 10036 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10037 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10038 | return; |
| 10039 | } |
| 10040 | |
| 10041 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 10042 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 10043 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10044 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 10045 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10046 | mutex_lock(&hdd_ctx->sap_lock); |
| 10047 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 10048 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10049 | hdd_cleanup_actionframe(hdd_ctx, ap_adapter); |
| 10050 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10051 | hdd_debug("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 10052 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10053 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10054 | sapContext)) { |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 10055 | qdf_status = qdf_wait_single_event(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 10056 | qdf_stop_bss_event, |
| 10057 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 10058 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10059 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10060 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10061 | return; |
| 10062 | } |
| 10063 | } |
| 10064 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10065 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 10066 | ap_adapter->device_mode, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10067 | ap_adapter->sessionId); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10068 | hdd_debug("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10069 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10070 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10071 | } |
| 10072 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10073 | } |
| 10074 | |
| 10075 | /** |
| 10076 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 10077 | * @ap_adapter: SAP adapter |
| 10078 | * |
| 10079 | * This function will process the starting of sap adapter. |
| 10080 | * |
| 10081 | * Return: None |
| 10082 | */ |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 10083 | void wlan_hdd_start_sap(hdd_adapter_t *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10084 | { |
| 10085 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 10086 | hdd_hostapd_state_t *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 10087 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10088 | hdd_context_t *hdd_ctx; |
| 10089 | tsap_Config_t *sap_config; |
| 10090 | |
| 10091 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10092 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10093 | return; |
| 10094 | } |
| 10095 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 10096 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 10097 | hdd_err("SoftAp role has not been enabled"); |
| 10098 | return; |
| 10099 | } |
| 10100 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10101 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 10102 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 10103 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 10104 | sap_config = &ap_adapter->sessionCtx.ap.sapConfig; |
| 10105 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10106 | mutex_lock(&hdd_ctx->sap_lock); |
| 10107 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 10108 | goto end; |
| 10109 | |
| 10110 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10111 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10112 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
| 10113 | goto end; |
| 10114 | } |
| 10115 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 10116 | qdf_event_reset(&hostapd_state->qdf_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10117 | if (wlansap_start_bss(hdd_ap_ctx->sapContext, hdd_hostapd_sap_event_cb, |
| 10118 | &hdd_ap_ctx->sapConfig, |
| 10119 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10120 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10121 | goto end; |
| 10122 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10123 | hdd_debug("Waiting for SAP to start"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 10124 | qdf_status = qdf_wait_single_event(&hostapd_state->qdf_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 10125 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 10126 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10127 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10128 | goto end; |
| 10129 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10130 | hdd_info("SAP Start Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10131 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Krunal Soni | b37bb35 | 2016-12-20 14:12:21 -0800 | [diff] [blame] | 10132 | if (hostapd_state->bssState == BSS_START) |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10133 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 10134 | ap_adapter->device_mode, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10135 | ap_adapter->sessionId); |
| 10136 | hostapd_state->bCommit = true; |
| 10137 | |
| 10138 | end: |
| 10139 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10140 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10141 | |
| 10142 | /** |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 10143 | * wlan_hdd_soc_set_antenna_mode_cb() - Callback for set dual |
| 10144 | * mac scan config |
| 10145 | * @status: Status of set antenna mode |
| 10146 | * |
| 10147 | * Callback on setting the dual mac configuration |
| 10148 | * |
| 10149 | * Return: None |
| 10150 | */ |
| 10151 | void wlan_hdd_soc_set_antenna_mode_cb( |
| 10152 | enum set_antenna_mode_status status) |
| 10153 | { |
| 10154 | hdd_context_t *hdd_ctx; |
| 10155 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10156 | hdd_debug("Status: %d", status); |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 10157 | |
| 10158 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10159 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 10160 | return; |
| 10161 | |
| 10162 | /* Signal the completion of set dual mac config */ |
| 10163 | complete(&hdd_ctx->set_antenna_mode_cmpl); |
| 10164 | } |
| 10165 | |
| 10166 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10167 | * hdd_get_fw_version() - Get FW version |
| 10168 | * @hdd_ctx: pointer to HDD context. |
| 10169 | * @major_spid: FW version - major spid. |
| 10170 | * @minor_spid: FW version - minor spid |
| 10171 | * @ssid: FW version - ssid |
| 10172 | * @crmid: FW version - crmid |
| 10173 | * |
| 10174 | * This function is called to get the firmware build version stored |
| 10175 | * as part of the HDD context |
| 10176 | * |
| 10177 | * Return: None |
| 10178 | */ |
| 10179 | void hdd_get_fw_version(hdd_context_t *hdd_ctx, |
| 10180 | uint32_t *major_spid, uint32_t *minor_spid, |
| 10181 | uint32_t *siid, uint32_t *crmid) |
| 10182 | { |
| 10183 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 10184 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 10185 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 10186 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 10187 | } |
| 10188 | |
| 10189 | #ifdef QCA_CONFIG_SMP |
| 10190 | /** |
| 10191 | * wlan_hdd_get_cpu() - get cpu_index |
| 10192 | * |
| 10193 | * Return: cpu_index |
| 10194 | */ |
| 10195 | int wlan_hdd_get_cpu(void) |
| 10196 | { |
| 10197 | int cpu_index = get_cpu(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 10198 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10199 | put_cpu(); |
| 10200 | return cpu_index; |
| 10201 | } |
| 10202 | #endif |
| 10203 | |
| 10204 | /** |
| 10205 | * hdd_get_fwpath() - get framework path |
| 10206 | * |
| 10207 | * This function is used to get the string written by |
| 10208 | * userspace to start the wlan driver |
| 10209 | * |
| 10210 | * Return: string |
| 10211 | */ |
| 10212 | const char *hdd_get_fwpath(void) |
| 10213 | { |
| 10214 | return fwpath.string; |
| 10215 | } |
| 10216 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10217 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10218 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10219 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10220 | * This function initilizes CDS global context with the help of cds_init. This |
| 10221 | * has to be the first function called after probe to get a valid global |
| 10222 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10223 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10224 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10225 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10226 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10227 | { |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10228 | v_CONTEXT_t p_cds_context = NULL; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10229 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10230 | |
Houston Hoffman | 9e06e54 | 2016-12-12 12:06:26 -0800 | [diff] [blame] | 10231 | p_cds_context = cds_init(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10232 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 10233 | wlan_logging_sock_init_svc(); |
| 10234 | #endif |
| 10235 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10236 | if (p_cds_context == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10237 | hdd_err("Failed to allocate CDS context"); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10238 | ret = -ENOMEM; |
| 10239 | goto err_out; |
| 10240 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10241 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10242 | hdd_trace_init(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10243 | hdd_register_debug_callback(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10244 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10245 | err_out: |
| 10246 | return ret; |
| 10247 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10248 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10249 | /** |
| 10250 | * hdd_deinit() - Deinitialize Driver |
| 10251 | * |
| 10252 | * This function frees CDS global context with the help of cds_deinit. This |
| 10253 | * has to be the last function call in remove callback to free the global |
| 10254 | * context. |
| 10255 | */ |
| 10256 | void hdd_deinit(void) |
| 10257 | { |
| 10258 | cds_deinit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10259 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10260 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 10261 | wlan_logging_sock_deinit_svc(); |
| 10262 | #endif |
| 10263 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10264 | |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 10265 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 10266 | #define HDD_WLAN_START_WAIT_TIME ((CDS_WMA_TIMEOUT + 5000) * 100) |
| 10267 | #else |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10268 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 10269 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10270 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 10271 | static int wlan_hdd_state_ctrl_param_open(struct inode *inode, |
| 10272 | struct file *file) |
| 10273 | { |
| 10274 | return 0; |
| 10275 | } |
| 10276 | |
| 10277 | static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, |
| 10278 | const char __user *user_buf, |
| 10279 | size_t count, |
| 10280 | loff_t *f_pos) |
| 10281 | { |
| 10282 | char buf; |
| 10283 | static const char wlan_off_str[] = "OFF"; |
| 10284 | static const char wlan_on_str[] = "ON"; |
| 10285 | int ret; |
| 10286 | unsigned long rc; |
| 10287 | |
| 10288 | if (copy_from_user(&buf, user_buf, 3)) { |
| 10289 | pr_err("Failed to read buffer\n"); |
| 10290 | return -EINVAL; |
| 10291 | } |
| 10292 | |
| 10293 | if (strncmp(&buf, wlan_off_str, strlen(wlan_off_str)) == 0) { |
| 10294 | pr_debug("Wifi turning off from UI\n"); |
| 10295 | goto exit; |
| 10296 | } |
| 10297 | |
| 10298 | if (strncmp(&buf, wlan_on_str, strlen(wlan_on_str)) != 0) { |
| 10299 | pr_err("Invalid value received from framework"); |
| 10300 | goto exit; |
| 10301 | } |
| 10302 | |
| 10303 | if (!cds_is_driver_loaded()) { |
| 10304 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 10305 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 10306 | if (!rc) { |
| 10307 | hdd_alert("Timed-out waiting in wlan_hdd_state_ctrl_param_write"); |
| 10308 | ret = -EINVAL; |
| 10309 | hdd_start_complete(ret); |
| 10310 | return ret; |
| 10311 | } |
| 10312 | |
| 10313 | hdd_start_complete(0); |
| 10314 | } |
| 10315 | |
| 10316 | exit: |
| 10317 | return count; |
| 10318 | } |
| 10319 | |
| 10320 | |
| 10321 | const struct file_operations wlan_hdd_state_fops = { |
| 10322 | .owner = THIS_MODULE, |
| 10323 | .open = wlan_hdd_state_ctrl_param_open, |
| 10324 | .write = wlan_hdd_state_ctrl_param_write, |
| 10325 | }; |
| 10326 | |
| 10327 | static int wlan_hdd_state_ctrl_param_create(void) |
| 10328 | { |
| 10329 | unsigned int wlan_hdd_state_major = 0; |
| 10330 | int ret; |
| 10331 | struct device *dev; |
| 10332 | |
| 10333 | device = MKDEV(wlan_hdd_state_major, 0); |
| 10334 | |
| 10335 | ret = alloc_chrdev_region(&device, 0, dev_num, "qcwlanstate"); |
| 10336 | if (ret) { |
| 10337 | pr_err("Failed to register qcwlanstate"); |
| 10338 | goto dev_alloc_err; |
| 10339 | } |
| 10340 | wlan_hdd_state_major = MAJOR(device); |
| 10341 | |
| 10342 | class = class_create(THIS_MODULE, WLAN_MODULE_NAME); |
| 10343 | if (IS_ERR(class)) { |
| 10344 | pr_err("wlan_hdd_state class_create error"); |
| 10345 | goto class_err; |
| 10346 | } |
| 10347 | |
| 10348 | dev = device_create(class, NULL, device, NULL, WLAN_MODULE_NAME); |
| 10349 | if (IS_ERR(dev)) { |
| 10350 | pr_err("wlan_hdd_statedevice_create error"); |
| 10351 | goto err_class_destroy; |
| 10352 | } |
| 10353 | |
| 10354 | cdev_init(&wlan_hdd_state_cdev, &wlan_hdd_state_fops); |
| 10355 | ret = cdev_add(&wlan_hdd_state_cdev, device, dev_num); |
| 10356 | if (ret) { |
| 10357 | pr_err("Failed to add cdev error"); |
| 10358 | goto cdev_add_err; |
| 10359 | } |
| 10360 | |
| 10361 | pr_info("wlan_hdd_state %s major(%d) initialized", |
| 10362 | WLAN_MODULE_NAME, wlan_hdd_state_major); |
| 10363 | |
| 10364 | return 0; |
| 10365 | |
| 10366 | cdev_add_err: |
| 10367 | device_destroy(class, device); |
| 10368 | err_class_destroy: |
| 10369 | class_destroy(class); |
| 10370 | class_err: |
| 10371 | unregister_chrdev_region(device, dev_num); |
| 10372 | dev_alloc_err: |
| 10373 | return -ENODEV; |
| 10374 | } |
| 10375 | |
| 10376 | static void wlan_hdd_state_ctrl_param_destroy(void) |
| 10377 | { |
| 10378 | cdev_del(&wlan_hdd_state_cdev); |
| 10379 | device_destroy(class, device); |
| 10380 | class_destroy(class); |
| 10381 | unregister_chrdev_region(device, dev_num); |
| 10382 | |
| 10383 | pr_info("Device node unregistered"); |
| 10384 | } |
| 10385 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10386 | /** |
| 10387 | * __hdd_module_init - Module init helper |
| 10388 | * |
| 10389 | * Module init helper function used by both module and static driver. |
| 10390 | * |
| 10391 | * Return: 0 for success, errno on failure |
| 10392 | */ |
| 10393 | static int __hdd_module_init(void) |
| 10394 | { |
| 10395 | int ret = 0; |
Arun Khandavalli | 13cb5da | 2017-01-19 15:43:52 +0530 | [diff] [blame] | 10396 | unsigned long rc; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10397 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10398 | pr_err("%s: Loading driver v%s\n", WLAN_MODULE_NAME, |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10399 | QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10400 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 10401 | ret = wlan_hdd_state_ctrl_param_create(); |
| 10402 | if (ret) { |
| 10403 | pr_err("wlan_hdd_state_create:%x\n", ret); |
| 10404 | goto err_dev_state; |
| 10405 | } |
| 10406 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 10407 | pld_init(); |
| 10408 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 10409 | ret = hdd_init(); |
| 10410 | if (ret) { |
| 10411 | pr_err("hdd_init failed %x\n", ret); |
| 10412 | goto err_hdd_init; |
| 10413 | } |
| 10414 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 10415 | dispatcher_init(); |
| 10416 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 10417 | qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10418 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10419 | hdd_set_conparam((uint32_t) con_mode); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10420 | |
Arun Khandavalli | 13cb5da | 2017-01-19 15:43:52 +0530 | [diff] [blame] | 10421 | init_completion(&wlan_start_comp); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10422 | ret = wlan_hdd_register_driver(); |
| 10423 | if (ret) { |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 10424 | pr_err("%s: driver load failure, err %d\n", WLAN_MODULE_NAME, |
| 10425 | ret); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10426 | goto out; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10427 | } |
| 10428 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 10429 | /* |
| 10430 | * This wait is temporarily introduced till |
| 10431 | * boardconfig changes for dev node are merged |
| 10432 | */ |
Arun Khandavalli | 13cb5da | 2017-01-19 15:43:52 +0530 | [diff] [blame] | 10433 | rc = wait_for_completion_timeout(&wlan_start_comp, |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 10434 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
Arun Khandavalli | 13cb5da | 2017-01-19 15:43:52 +0530 | [diff] [blame] | 10435 | if (!rc) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10436 | hdd_err("Timed-out waiting for wlan_hdd_register_driver"); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 10437 | ret = -ETIMEDOUT; |
| 10438 | wlan_hdd_unregister_driver(); |
Arun Khandavalli | 13cb5da | 2017-01-19 15:43:52 +0530 | [diff] [blame] | 10439 | goto out; |
| 10440 | } |
| 10441 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 10442 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10443 | |
| 10444 | return 0; |
| 10445 | out: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 10446 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 10447 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 10448 | hdd_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 10449 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 10450 | err_hdd_init: |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 10451 | pld_deinit(); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 10452 | wlan_hdd_state_ctrl_param_destroy(); |
| 10453 | err_dev_state: |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10454 | return ret; |
| 10455 | } |
| 10456 | |
| 10457 | /** |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 10458 | * hdd_wait_for_recovery_completion() - Wait for cds recovery completion |
| 10459 | * |
| 10460 | * Block the unloading of the driver until the cds recovery is completed |
| 10461 | * |
| 10462 | * Return: None |
| 10463 | */ |
| 10464 | static void hdd_wait_for_recovery_completion(void) |
| 10465 | { |
| 10466 | int retry = 0; |
| 10467 | |
| 10468 | /* Wait for recovery to complete */ |
| 10469 | while (cds_is_driver_recovering()) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10470 | hdd_err("Recovery in progress; wait here!!!"); |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 10471 | msleep(1000); |
| 10472 | if (retry++ == HDD_MOD_EXIT_SSR_MAX_RETRIES) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10473 | hdd_err("SSR never completed, error"); |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 10474 | QDF_BUG(0); |
| 10475 | } |
| 10476 | } |
| 10477 | } |
| 10478 | |
| 10479 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10480 | * __hdd_module_exit - Module exit helper |
| 10481 | * |
| 10482 | * Module exit helper function used by both module and static driver. |
| 10483 | */ |
| 10484 | static void __hdd_module_exit(void) |
| 10485 | { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 10486 | int qdf_print_idx = -1; |
| 10487 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10488 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 10489 | QWLAN_VERSIONSTR); |
| 10490 | |
bings | 6028ee8 | 2017-03-29 07:51:40 +0800 | [diff] [blame] | 10491 | cds_set_unload_in_progress(true); |
| 10492 | |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 10493 | hdd_wait_for_recovery_completion(); |
| 10494 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10495 | wlan_hdd_unregister_driver(); |
| 10496 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 10497 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10498 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 10499 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 10500 | hdd_deinit(); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 10501 | pld_deinit(); |
| 10502 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 10503 | qdf_print_idx = qdf_get_pidx(); |
| 10504 | qdf_print_ctrl_cleanup(qdf_print_idx); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 10505 | wlan_hdd_state_ctrl_param_destroy(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10506 | } |
| 10507 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10508 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10509 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10510 | * wlan_boot_cb() - Wlan boot callback |
| 10511 | * @kobj: object whose directory we're creating the link in. |
| 10512 | * @attr: attribute the user is interacting with |
| 10513 | * @buff: the buffer containing the user data |
| 10514 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10515 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10516 | * This callback is invoked when the fs is ready to start the |
| 10517 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10518 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10519 | * 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] | 10520 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10521 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 10522 | struct kobj_attribute *attr, |
| 10523 | const char *buf, |
| 10524 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10525 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10526 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10527 | if (wlan_loader->loaded_state) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 10528 | pr_err("%s: wlan driver already initialized\n", __func__); |
| 10529 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10530 | } |
| 10531 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10532 | if (__hdd_module_init()) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 10533 | pr_err("%s: wlan driver initialization failed\n", __func__); |
| 10534 | return -EIO; |
| 10535 | } |
| 10536 | |
| 10537 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10538 | |
| 10539 | return count; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10540 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10541 | |
| 10542 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 10543 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 10544 | * |
| 10545 | * Return: None |
| 10546 | * |
| 10547 | */ |
| 10548 | static void hdd_sysfs_cleanup(void) |
| 10549 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 10550 | /* remove from group */ |
| 10551 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 10552 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 10553 | wlan_loader->attr_group); |
| 10554 | |
| 10555 | /* unlink the object from parent */ |
| 10556 | kobject_del(wlan_loader->boot_wlan_obj); |
| 10557 | |
| 10558 | /* free the object */ |
| 10559 | kobject_put(wlan_loader->boot_wlan_obj); |
| 10560 | |
| 10561 | kfree(wlan_loader->attr_group); |
| 10562 | kfree(wlan_loader); |
| 10563 | |
| 10564 | wlan_loader = NULL; |
| 10565 | } |
| 10566 | |
| 10567 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10568 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 10569 | * ready |
| 10570 | * |
| 10571 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 10572 | * when the filesystem is ready. |
| 10573 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 10574 | * QDF API cannot be used here since this function is called even before |
| 10575 | * initializing WLAN driver. |
| 10576 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 10577 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10578 | */ |
| 10579 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10580 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 10581 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10582 | |
| 10583 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 10584 | if (!wlan_loader) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 10585 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10586 | |
| 10587 | wlan_loader->boot_wlan_obj = NULL; |
| 10588 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 10589 | GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 10590 | if (!wlan_loader->attr_group) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10591 | goto error_return; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10592 | |
| 10593 | wlan_loader->loaded_state = 0; |
| 10594 | wlan_loader->attr_group->attrs = attrs; |
| 10595 | |
| 10596 | wlan_loader->boot_wlan_obj = kobject_create_and_add("boot_wlan", |
| 10597 | kernel_kobj); |
| 10598 | if (!wlan_loader->boot_wlan_obj) { |
| 10599 | pr_err("%s: sysfs create and add failed\n", __func__); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10600 | goto error_return; |
| 10601 | } |
| 10602 | |
| 10603 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 10604 | wlan_loader->attr_group); |
| 10605 | if (ret) { |
| 10606 | pr_err("%s: sysfs create group failed %d\n", __func__, ret); |
| 10607 | goto error_return; |
| 10608 | } |
| 10609 | |
| 10610 | return 0; |
| 10611 | |
| 10612 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 10613 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10614 | |
| 10615 | return ret; |
| 10616 | } |
| 10617 | |
| 10618 | /** |
| 10619 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 10620 | * |
| 10621 | * Return: 0 on success or errno on failure |
| 10622 | */ |
| 10623 | static int wlan_deinit_sysfs(void) |
| 10624 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10625 | if (!wlan_loader) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10626 | hdd_err("wlan loader context is Null!"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10627 | return -EINVAL; |
| 10628 | } |
| 10629 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 10630 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10631 | return 0; |
| 10632 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10633 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 10634 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10635 | |
| 10636 | #ifdef MODULE |
| 10637 | /** |
| 10638 | * __hdd_module_init - Module init helper |
| 10639 | * |
| 10640 | * Module init helper function used by both module and static driver. |
| 10641 | * |
| 10642 | * Return: 0 for success, errno on failure |
| 10643 | */ |
| 10644 | static int hdd_module_init(void) |
| 10645 | { |
| 10646 | int ret = 0; |
| 10647 | |
| 10648 | pr_err("%s: Loading driver v%s\n", WLAN_MODULE_NAME, |
| 10649 | QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
| 10650 | |
| 10651 | if (__hdd_module_init()) { |
| 10652 | pr_err("%s: Failed to register handler\n", __func__); |
| 10653 | ret = -EINVAL; |
| 10654 | } |
| 10655 | |
| 10656 | return ret; |
| 10657 | } |
| 10658 | #else |
| 10659 | static int __init hdd_module_init(void) |
| 10660 | { |
| 10661 | int ret = -EINVAL; |
| 10662 | |
| 10663 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 10664 | if (ret) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10665 | pr_err("Failed to create sysfs entry for loading wlan"); |
| 10666 | |
| 10667 | return ret; |
| 10668 | } |
| 10669 | #endif |
| 10670 | |
| 10671 | |
| 10672 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10673 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10674 | * hdd_module_exit() - Exit function |
| 10675 | * |
| 10676 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 10677 | * |
| 10678 | * Return: None |
| 10679 | */ |
| 10680 | static void __exit hdd_module_exit(void) |
| 10681 | { |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10682 | __hdd_module_exit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10683 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10684 | #else |
| 10685 | static void __exit hdd_module_exit(void) |
| 10686 | { |
| 10687 | __hdd_module_exit(); |
| 10688 | wlan_deinit_sysfs(); |
| 10689 | } |
| 10690 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10691 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10692 | static int fwpath_changed_handler(const char *kmessage, struct kernel_param *kp) |
| 10693 | { |
| 10694 | return param_set_copystring(kmessage, kp); |
| 10695 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10696 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10697 | /** |
| 10698 | * is_con_mode_valid() check con mode is valid or not |
| 10699 | * @mode: global con mode |
| 10700 | * |
| 10701 | * Return: TRUE on success FALSE on failure |
| 10702 | */ |
| 10703 | static bool is_con_mode_valid(enum tQDF_GLOBAL_CON_MODE mode) |
| 10704 | { |
| 10705 | switch (mode) { |
| 10706 | case QDF_GLOBAL_MONITOR_MODE: |
| 10707 | case QDF_GLOBAL_FTM_MODE: |
| 10708 | case QDF_GLOBAL_EPPING_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10709 | case QDF_GLOBAL_MISSION_MODE: |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10710 | return true; |
| 10711 | default: |
| 10712 | return false; |
| 10713 | } |
| 10714 | } |
| 10715 | |
| 10716 | /** |
| 10717 | * hdd_get_adpter_mode() - returns adapter mode based on global con mode |
| 10718 | * @mode: global con mode |
| 10719 | * |
| 10720 | * Return: adapter mode |
| 10721 | */ |
| 10722 | static enum tQDF_ADAPTER_MODE hdd_get_adpter_mode( |
| 10723 | enum tQDF_GLOBAL_CON_MODE mode) |
| 10724 | { |
| 10725 | |
| 10726 | switch (mode) { |
| 10727 | case QDF_GLOBAL_MISSION_MODE: |
| 10728 | return QDF_STA_MODE; |
| 10729 | case QDF_GLOBAL_MONITOR_MODE: |
| 10730 | return QDF_MONITOR_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10731 | case QDF_GLOBAL_EPPING_MODE: |
| 10732 | return QDF_EPPING_MODE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10733 | case QDF_GLOBAL_FTM_MODE: |
| 10734 | return QDF_FTM_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10735 | case QDF_GLOBAL_QVIT_MODE: |
| 10736 | return QDF_QVIT_MODE; |
| 10737 | default: |
| 10738 | return QDF_MAX_NO_OF_MODE; |
| 10739 | } |
| 10740 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10741 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10742 | static void hdd_cleanup_present_mode(hdd_context_t *hdd_ctx, |
| 10743 | enum tQDF_GLOBAL_CON_MODE curr_mode) |
| 10744 | { |
Ashish Kumar Dhanotiya | 0024313 | 2017-01-24 16:37:34 +0530 | [diff] [blame] | 10745 | int driver_status; |
| 10746 | |
| 10747 | driver_status = hdd_ctx->driver_status; |
| 10748 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10749 | switch (curr_mode) { |
| 10750 | case QDF_GLOBAL_MISSION_MODE: |
| 10751 | case QDF_GLOBAL_MONITOR_MODE: |
| 10752 | case QDF_GLOBAL_FTM_MODE: |
Ashish Kumar Dhanotiya | 0024313 | 2017-01-24 16:37:34 +0530 | [diff] [blame] | 10753 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 10754 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
| 10755 | hdd_stop_all_adapters(hdd_ctx); |
| 10756 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10757 | hdd_deinit_all_adapters(hdd_ctx, false); |
| 10758 | hdd_close_all_adapters(hdd_ctx, false); |
| 10759 | break; |
| 10760 | case QDF_GLOBAL_EPPING_MODE: |
| 10761 | epping_disable(); |
| 10762 | epping_close(); |
| 10763 | break; |
| 10764 | default: |
| 10765 | return; |
| 10766 | } |
| 10767 | } |
| 10768 | |
| 10769 | static int hdd_register_req_mode(hdd_context_t *hdd_ctx, |
| 10770 | enum tQDF_GLOBAL_CON_MODE mode) |
| 10771 | { |
| 10772 | hdd_adapter_t *adapter; |
| 10773 | int ret = 0; |
| 10774 | bool rtnl_held; |
| 10775 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 10776 | QDF_STATUS status; |
| 10777 | |
| 10778 | if (!qdf_dev) { |
| 10779 | hdd_err("qdf device context is Null return!"); |
| 10780 | return -EINVAL; |
| 10781 | } |
| 10782 | |
| 10783 | rtnl_held = hdd_hold_rtnl_lock(); |
| 10784 | switch (mode) { |
| 10785 | case QDF_GLOBAL_MISSION_MODE: |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10786 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 10787 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10788 | hdd_err("Failed to open interfaces: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10789 | break; |
| 10790 | case QDF_GLOBAL_FTM_MODE: |
| 10791 | adapter = hdd_open_adapter(hdd_ctx, QDF_FTM_MODE, "wlan%d", |
| 10792 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 10793 | NET_NAME_UNKNOWN, rtnl_held); |
| 10794 | if (adapter == NULL) |
| 10795 | ret = -EINVAL; |
| 10796 | break; |
| 10797 | case QDF_GLOBAL_MONITOR_MODE: |
| 10798 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
| 10799 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 10800 | NET_NAME_UNKNOWN, rtnl_held); |
| 10801 | if (adapter == NULL) |
| 10802 | ret = -EINVAL; |
| 10803 | break; |
| 10804 | case QDF_GLOBAL_EPPING_MODE: |
| 10805 | status = epping_open(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 10806 | if (status != QDF_STATUS_SUCCESS) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10807 | hdd_err("Failed to open in eeping mode: %d", status); |
| 10808 | ret = -EINVAL; |
| 10809 | break; |
| 10810 | } |
| 10811 | ret = epping_enable(qdf_dev->dev); |
| 10812 | if (ret) { |
| 10813 | hdd_err("Failed to enable in epping mode : %d", ret); |
| 10814 | epping_close(); |
| 10815 | } |
| 10816 | break; |
| 10817 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10818 | hdd_err("Mode not supported"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10819 | ret = -ENOTSUPP; |
| 10820 | break; |
| 10821 | } |
| 10822 | hdd_release_rtnl_lock(); |
| 10823 | rtnl_held = false; |
| 10824 | return ret; |
| 10825 | } |
| 10826 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10827 | /** |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 10828 | * __con_mode_handler() - Handles module param con_mode change |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10829 | * @kmessage: con mode name on which driver to be bring up |
| 10830 | * @kp: The associated kernel parameter |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 10831 | * @hdd_ctx: Pointer to the global HDD context |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10832 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10833 | * This function is invoked when user updates con mode using sys entry, |
| 10834 | * to initialize and bring-up driver in that specific mode. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10835 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10836 | * Return - 0 on success and failure code on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10837 | */ |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10838 | static int __con_mode_handler(const char *kmessage, struct kernel_param *kp, |
| 10839 | hdd_context_t *hdd_ctx) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10840 | { |
| 10841 | int ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10842 | hdd_adapter_t *adapter; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10843 | enum tQDF_GLOBAL_CON_MODE curr_mode; |
| 10844 | enum tQDF_ADAPTER_MODE adapter_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10845 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 10846 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 10847 | if (ret) |
| 10848 | return ret; |
| 10849 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10850 | cds_set_load_in_progress(true); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10851 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10852 | hdd_debug("con_mode handler: %s", kmessage); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10853 | ret = param_set_int(kmessage, kp); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10854 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10855 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10856 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10857 | if (!(is_con_mode_valid(con_mode))) { |
| 10858 | hdd_err("invlaid con_mode %d", con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10859 | ret = -EINVAL; |
| 10860 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10861 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10862 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10863 | curr_mode = hdd_get_conparam(); |
| 10864 | if (curr_mode == con_mode) { |
| 10865 | hdd_err("curr mode: %d is same as user triggered mode %d", |
| 10866 | curr_mode, con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10867 | ret = 0; |
| 10868 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10869 | } |
| 10870 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10871 | /* Cleanup present mode before switching to new mode */ |
| 10872 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 10873 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10874 | ret = hdd_wlan_stop_modules(hdd_ctx, true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10875 | if (ret) { |
| 10876 | hdd_err("Stop wlan modules failed"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10877 | goto reset_flags; |
| 10878 | } |
| 10879 | |
| 10880 | hdd_set_conparam(con_mode); |
| 10881 | |
| 10882 | /* Register for new con_mode & then kick_start modules again */ |
| 10883 | ret = hdd_register_req_mode(hdd_ctx, con_mode); |
| 10884 | if (ret) { |
| 10885 | hdd_err("Failed to register for new mode"); |
| 10886 | goto reset_flags; |
| 10887 | } |
| 10888 | |
| 10889 | adapter_mode = hdd_get_adpter_mode(con_mode); |
| 10890 | if (adapter_mode == QDF_MAX_NO_OF_MODE) { |
| 10891 | hdd_err("invalid adapter"); |
| 10892 | ret = -EINVAL; |
| 10893 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10894 | } |
| 10895 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10896 | adapter = hdd_get_adapter(hdd_ctx, adapter_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10897 | if (!adapter) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10898 | hdd_err("Failed to get adapter:%d", adapter_mode); |
| 10899 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10900 | } |
| 10901 | |
| 10902 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 10903 | if (ret) { |
| 10904 | hdd_err("Start wlan modules failed: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10905 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10906 | } |
| 10907 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10908 | if (con_mode == QDF_GLOBAL_MONITOR_MODE || |
| 10909 | con_mode == QDF_GLOBAL_FTM_MODE) { |
| 10910 | if (hdd_start_adapter(adapter)) { |
| 10911 | hdd_err("Failed to start %s adapter", kmessage); |
| 10912 | ret = -EINVAL; |
| 10913 | goto reset_flags; |
| 10914 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10915 | } |
| 10916 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10917 | hdd_info("Mode successfully changed to %s", kmessage); |
| 10918 | ret = 0; |
| 10919 | |
| 10920 | reset_flags: |
| 10921 | cds_set_load_in_progress(false); |
| 10922 | return ret; |
| 10923 | } |
| 10924 | |
| 10925 | |
| 10926 | static int con_mode_handler(const char *kmessage, struct kernel_param *kp) |
| 10927 | { |
| 10928 | int ret; |
| 10929 | hdd_context_t *hdd_ctx; |
| 10930 | |
| 10931 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10932 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 10933 | if (ret) |
| 10934 | return ret; |
| 10935 | |
| 10936 | cds_ssr_protect(__func__); |
| 10937 | ret = __con_mode_handler(kmessage, kp, hdd_ctx); |
| 10938 | cds_ssr_unprotect(__func__); |
| 10939 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10940 | return ret; |
| 10941 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10942 | |
| 10943 | /** |
| 10944 | * hdd_get_conparam() - driver exit point |
| 10945 | * |
| 10946 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 10947 | * |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10948 | * Return: enum tQDF_GLOBAL_CON_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10949 | */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10950 | enum tQDF_GLOBAL_CON_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10951 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10952 | return (enum tQDF_GLOBAL_CON_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10953 | } |
| 10954 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 10955 | void hdd_set_conparam(uint32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10956 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 10957 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10958 | } |
| 10959 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 10960 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10961 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 10962 | * @hdd_ctx: HDD context |
| 10963 | * |
| 10964 | * Cleans up the pre cac interface, if it exists |
| 10965 | * |
| 10966 | * Return: None |
| 10967 | */ |
| 10968 | void hdd_clean_up_pre_cac_interface(hdd_context_t *hdd_ctx) |
| 10969 | { |
| 10970 | uint8_t session_id; |
| 10971 | QDF_STATUS status; |
| 10972 | struct hdd_adapter_s *precac_adapter; |
| 10973 | |
| 10974 | status = wlan_sap_get_pre_cac_vdev_id(hdd_ctx->hHal, &session_id); |
| 10975 | if (QDF_IS_STATUS_ERROR(status)) { |
| 10976 | hdd_err("failed to get pre cac vdev id"); |
| 10977 | return; |
| 10978 | } |
| 10979 | |
| 10980 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, session_id); |
| 10981 | if (!precac_adapter) { |
| 10982 | hdd_err("invalid pre cac adapater"); |
| 10983 | return; |
| 10984 | } |
| 10985 | |
| 10986 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 10987 | wlan_hdd_sap_pre_cac_failure, |
| 10988 | (void *)precac_adapter); |
| 10989 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 10990 | |
| 10991 | } |
| 10992 | |
| 10993 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 10994 | * hdd_update_ol_config - API to update ol configuration parameters |
| 10995 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 10996 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 10997 | * Return: void |
| 10998 | */ |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 10999 | static void hdd_update_ol_config(hdd_context_t *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 11000 | { |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11001 | struct ol_config_info cfg; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 11002 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 11003 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11004 | if (!ol_ctx) |
| 11005 | return; |
| 11006 | |
| 11007 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
| 11008 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 11009 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 11010 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 11011 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11012 | |
| 11013 | ol_init_ini_config(ol_ctx, &cfg); |
| 11014 | } |
| 11015 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 11016 | #ifdef FEATURE_RUNTIME_PM |
| 11017 | /** |
| 11018 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 11019 | * @hdd_ctx: hdd context |
| 11020 | * @cfg: pointer to the configuration memory being populated |
| 11021 | * |
| 11022 | * Return: void |
| 11023 | */ |
| 11024 | static void hdd_populate_runtime_cfg(hdd_context_t *hdd_ctx, |
| 11025 | struct hif_config_info *cfg) |
| 11026 | { |
| 11027 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
| 11028 | cfg->runtime_pm_delay = hdd_ctx->config->runtime_pm_delay; |
| 11029 | } |
| 11030 | #else |
| 11031 | static void hdd_populate_runtime_cfg(hdd_context_t *hdd_ctx, |
| 11032 | struct hif_config_info *cfg) |
| 11033 | { |
| 11034 | } |
| 11035 | #endif |
| 11036 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11037 | /** |
| 11038 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 11039 | * @hdd_ctx: HDD Context |
| 11040 | * |
| 11041 | * Return: void |
| 11042 | */ |
| 11043 | static void hdd_update_hif_config(hdd_context_t *hdd_ctx) |
| 11044 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 11045 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11046 | struct hif_config_info cfg; |
| 11047 | |
| 11048 | if (!scn) |
| 11049 | return; |
| 11050 | |
| 11051 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 11052 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11053 | hif_init_ini_config(scn, &cfg); |
| 11054 | } |
| 11055 | |
| 11056 | /** |
| 11057 | * hdd_update_config() - Initialize driver per module ini parameters |
| 11058 | * @hdd_ctx: HDD Context |
| 11059 | * |
| 11060 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 11061 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11062 | */ |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 11063 | int hdd_update_config(hdd_context_t *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11064 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 11065 | int ret; |
| 11066 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11067 | hdd_update_ol_config(hdd_ctx); |
| 11068 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 11069 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 11070 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 11071 | else |
| 11072 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 11073 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 11074 | |
| 11075 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 11076 | } |
| 11077 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 11078 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 11079 | /** |
| 11080 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 11081 | * @psoc_cfg: pmo psoc Configuration |
| 11082 | * @hdd_ctx: Pointer to hdd context |
| 11083 | * |
| 11084 | * Return: none |
| 11085 | */ |
| 11086 | static inline void hdd_ra_populate_pmo_config( |
| 11087 | struct pmo_psoc_cfg *psoc_cfg, |
| 11088 | hdd_context_t *hdd_ctx) |
| 11089 | { |
| 11090 | psoc_cfg->ra_ratelimit_interval = |
| 11091 | hdd_ctx->config->RArateLimitInterval; |
| 11092 | psoc_cfg->ra_ratelimit_enable = |
| 11093 | hdd_ctx->config->IsRArateLimitEnabled; |
| 11094 | } |
| 11095 | #else |
| 11096 | static inline void hdd_ra_populate_pmo_config( |
| 11097 | struct cds_config_info *cds_cfg, |
| 11098 | hdd_context_t *hdd_ctx) |
| 11099 | { |
| 11100 | } |
| 11101 | #endif |
| 11102 | /** |
| 11103 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 11104 | * @hdd_ctx: HDD context |
| 11105 | * |
| 11106 | * Return: void |
| 11107 | */ |
| 11108 | static int hdd_update_pmo_config(hdd_context_t *hdd_ctx) |
| 11109 | { |
| 11110 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 11111 | struct pmo_psoc_cfg psoc_cfg; |
| 11112 | QDF_STATUS status; |
| 11113 | |
| 11114 | /* |
| 11115 | * Value of hdd_ctx->wowEnable can be, |
| 11116 | * 0 - Disable both magic pattern match and pattern byte match. |
| 11117 | * 1 - Enable magic pattern match on all interfaces. |
| 11118 | * 2 - Enable pattern byte match on all interfaces. |
| 11119 | * 3 - Enable both magic patter and pattern byte match on |
| 11120 | * all interfaces. |
| 11121 | */ |
| 11122 | psoc_cfg.magic_ptrn_enable = |
| 11123 | (hdd_ctx->config->wowEnable & 0x01) ? true : false; |
| 11124 | psoc_cfg.ptrn_match_enable_all_vdev = |
| 11125 | (hdd_ctx->config->wowEnable & 0x02) ? true : false; |
| 11126 | psoc_cfg.bpf_enable = |
| 11127 | hdd_ctx->config->bpf_packet_filter_enable; |
| 11128 | psoc_cfg.arp_offload_enable = hdd_ctx->config->fhostArpOffload; |
Ravi Kumar Bokka | 794fd71 | 2017-03-21 20:52:46 +0530 | [diff] [blame] | 11129 | psoc_cfg.hw_bcast_filter = hdd_ctx->config->hw_broadcast_filter; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 11130 | psoc_cfg.ns_offload_enable_static = hdd_ctx->config->fhostNSOffload; |
| 11131 | if (hdd_ctx->config->fhostNSOffload) |
| 11132 | psoc_cfg.ns_offload_enable_dynamic = true; |
| 11133 | psoc_cfg.ssdp = hdd_ctx->config->ssdp; |
| 11134 | psoc_cfg.enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 11135 | psoc_cfg.active_mode_offload = |
| 11136 | hdd_ctx->config->active_mode_offload; |
| 11137 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
| 11138 | psoc_cfg.max_wow_filters = hdd_ctx->config->maxWoWFilters; |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 11139 | psoc_cfg.sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 11140 | psoc_cfg.sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 11141 | psoc_cfg.sta_max_li_mod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 11142 | psoc_cfg.power_save_mode = |
| 11143 | hdd_ctx->config->enablePowersaveOffload; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 11144 | |
| 11145 | hdd_ra_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 11146 | hdd_nan_populate_pmo_config(&psoc_cfg, hdd_ctx); |
| 11147 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 11148 | status = pmo_ucfg_update_psoc_config(psoc, &psoc_cfg); |
| 11149 | if (status != QDF_STATUS_SUCCESS) { |
| 11150 | hdd_err("failed pmo psoc configuration"); |
| 11151 | return -EINVAL; |
| 11152 | } |
| 11153 | |
| 11154 | return 0; |
| 11155 | } |
| 11156 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 11157 | #ifdef NAPIER_SCAN |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 11158 | |
| 11159 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 11160 | static inline void hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
| 11161 | struct hdd_config *cfg) |
| 11162 | { |
| 11163 | pno_cfg->channel_prediction = cfg->pno_channel_prediction; |
| 11164 | pno_cfg->top_k_num_of_channels = cfg->top_k_num_of_channels; |
| 11165 | pno_cfg->stationary_thresh = cfg->stationary_thresh; |
| 11166 | pno_cfg->adaptive_dwell_mode = cfg->adaptive_dwell_mode_enabled; |
| 11167 | pno_cfg->channel_prediction_full_scan = |
| 11168 | cfg->channel_prediction_full_scan; |
| 11169 | } |
| 11170 | #else |
| 11171 | static inline void |
| 11172 | hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
| 11173 | struct hdd_config *cfg) |
| 11174 | { |
| 11175 | return; |
| 11176 | } |
| 11177 | #endif |
| 11178 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 11179 | /** |
| 11180 | * hdd_update_scan_config - API to update scan configuration parameters |
| 11181 | * @hdd_ctx: HDD context |
| 11182 | * |
| 11183 | * Return: 0 if success else err |
| 11184 | */ |
| 11185 | static int hdd_update_scan_config(hdd_context_t *hdd_ctx) |
| 11186 | { |
| 11187 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 11188 | struct scan_user_cfg scan_cfg; |
| 11189 | struct hdd_config *cfg = hdd_ctx->config; |
| 11190 | QDF_STATUS status; |
| 11191 | |
| 11192 | scan_cfg.active_dwell = cfg->nActiveMaxChnTime; |
| 11193 | scan_cfg.passive_dwell = cfg->nPassiveMaxChnTime; |
| 11194 | scan_cfg.conc_active_dwell = cfg->nActiveMaxChnTimeConc; |
| 11195 | scan_cfg.conc_passive_dwell = cfg->nPassiveMaxChnTimeConc; |
| 11196 | scan_cfg.conc_max_rest_time = cfg->nRestTimeConc; |
| 11197 | scan_cfg.conc_min_rest_time = cfg->min_rest_time_conc; |
| 11198 | scan_cfg.conc_idle_time = cfg->idle_time_conc; |
| 11199 | scan_cfg.scan_cache_aging_time = cfg->scanAgingTimeout; |
| 11200 | scan_cfg.scan_dwell_time_mode = cfg->scan_adaptive_dwell_mode; |
Kapil Gupta | fa9a8c6 | 2017-04-10 15:25:40 +0530 | [diff] [blame] | 11201 | scan_cfg.is_snr_monitoring_enabled = cfg->fEnableSNRMonitoring; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 11202 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 11203 | hdd_update_pno_config(&scan_cfg.pno_cfg, cfg); |
| 11204 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 11205 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 11206 | if (status != QDF_STATUS_SUCCESS) { |
| 11207 | hdd_err("failed pmo psoc configuration"); |
| 11208 | return -EINVAL; |
| 11209 | } |
| 11210 | |
| 11211 | return 0; |
| 11212 | } |
| 11213 | #else |
| 11214 | static int hdd_update_scan_config(hdd_context_t *hdd_ctx) |
| 11215 | { |
| 11216 | return 0; |
| 11217 | } |
| 11218 | #endif |
| 11219 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 11220 | int hdd_update_components_config(hdd_context_t *hdd_ctx) |
| 11221 | { |
| 11222 | int ret; |
| 11223 | |
| 11224 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 11225 | if (ret) |
| 11226 | return ret; |
| 11227 | ret = hdd_update_scan_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 11228 | |
| 11229 | return ret; |
| 11230 | } |
| 11231 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 11232 | /** |
| 11233 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 11234 | * @mode : cfg80211 DFS mode |
| 11235 | * |
| 11236 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 11237 | */ |
| 11238 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 11239 | { |
| 11240 | switch (mode) { |
| 11241 | case DFS_MODE_ENABLE: |
| 11242 | return ACS_DFS_MODE_ENABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 11243 | case DFS_MODE_DISABLE: |
| 11244 | return ACS_DFS_MODE_DISABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 11245 | case DFS_MODE_DEPRIORITIZE: |
| 11246 | return ACS_DFS_MODE_DEPRIORITIZE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 11247 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11248 | hdd_debug("ACS dfs mode is NONE"); |
| 11249 | return ACS_DFS_MODE_NONE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 11250 | } |
| 11251 | } |
| 11252 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 11253 | /** |
| 11254 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 11255 | * @hddctx: pointer to hdd context |
| 11256 | * @set_value: enable/disable |
| 11257 | * |
| 11258 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 11259 | * Host(even though it is duplicate). When Host send vendor command |
| 11260 | * disable,FW doesn't perform any action. Whenever any change in |
| 11261 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 11262 | * |
| 11263 | * return - 0 on success, appropriate error values on failure. |
| 11264 | */ |
| 11265 | int hdd_enable_disable_ca_event(hdd_context_t *hddctx, uint8_t set_value) |
| 11266 | { |
| 11267 | QDF_STATUS status; |
| 11268 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11269 | if (0 != wlan_hdd_validate_context(hddctx)) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 11270 | return -EAGAIN; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 11271 | |
| 11272 | if (!hddctx->config->goptimize_chan_avoid_event) { |
| 11273 | hdd_warn("goptimize_chan_avoid_event ini param disabled"); |
| 11274 | return -EINVAL; |
| 11275 | } |
| 11276 | |
| 11277 | status = sme_enable_disable_chanavoidind_event(hddctx->hHal, set_value); |
| 11278 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 11279 | hdd_err("Failed to send chan avoid command to SME"); |
| 11280 | return -EINVAL; |
| 11281 | } |
| 11282 | return 0; |
| 11283 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 11284 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 11285 | /** |
| 11286 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 11287 | * @value: value to set |
| 11288 | * |
| 11289 | * This function will set the passed value to roaming in progress flag. |
| 11290 | * |
| 11291 | * Return: None |
| 11292 | */ |
| 11293 | void hdd_set_roaming_in_progress(bool value) |
| 11294 | { |
| 11295 | hdd_context_t *hdd_ctx; |
| 11296 | |
| 11297 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11298 | if (!hdd_ctx) { |
| 11299 | hdd_err("HDD context is NULL"); |
| 11300 | return; |
| 11301 | } |
| 11302 | |
| 11303 | hdd_ctx->roaming_in_progress = value; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11304 | hdd_debug("Roaming in Progress set to %d", value); |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 11305 | } |
| 11306 | |
| 11307 | /** |
| 11308 | * hdd_is_roaming_in_progress() - check if roaming is in progress |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 11309 | * @adapter - HDD adapter |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 11310 | * |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 11311 | * 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] | 11312 | */ |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 11313 | bool hdd_is_roaming_in_progress(hdd_adapter_t *adapter) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 11314 | { |
| 11315 | hdd_context_t *hdd_ctx; |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 11316 | bool ret_status = false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 11317 | |
| 11318 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11319 | if (!hdd_ctx) { |
| 11320 | hdd_err("HDD context is NULL"); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 11321 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 11322 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11323 | hdd_debug("dev mode = %d, roaming_in_progress = %d", |
| 11324 | adapter->device_mode, hdd_ctx->roaming_in_progress); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 11325 | ret_status = ((adapter->device_mode == QDF_STA_MODE) && |
| 11326 | hdd_ctx->roaming_in_progress); |
| 11327 | |
| 11328 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 11329 | } |
| 11330 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 11331 | /** |
| 11332 | * hdd_is_connection_in_progress() - check if connection is in |
| 11333 | * progress |
| 11334 | * @session_id: session id |
| 11335 | * @reason: scan reject reason |
| 11336 | * |
| 11337 | * Go through each adapter and check if Connection is in progress |
| 11338 | * |
| 11339 | * Return: true if connection is in progress else false |
| 11340 | */ |
| 11341 | bool hdd_is_connection_in_progress(uint8_t *session_id, |
| 11342 | enum scan_reject_states *reason) |
| 11343 | { |
| 11344 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 11345 | hdd_station_ctx_t *hdd_sta_ctx = NULL; |
| 11346 | hdd_adapter_t *adapter = NULL; |
| 11347 | QDF_STATUS status = 0; |
| 11348 | uint8_t sta_id = 0; |
| 11349 | uint8_t *sta_mac = NULL; |
| 11350 | hdd_context_t *hdd_ctx; |
| 11351 | |
| 11352 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11353 | if (!hdd_ctx) { |
| 11354 | hdd_err("HDD context is NULL"); |
| 11355 | return false; |
| 11356 | } |
| 11357 | |
| 11358 | if (true == hdd_ctx->btCoexModeSet) { |
| 11359 | hdd_info("BTCoex Mode operation in progress"); |
| 11360 | return true; |
| 11361 | } |
| 11362 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 11363 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 11364 | adapter = adapter_node->pAdapter; |
| 11365 | if (!adapter) |
| 11366 | goto end; |
| 11367 | |
| 11368 | hdd_info("Adapter with device mode %s(%d) exists", |
| 11369 | hdd_device_mode_to_string(adapter->device_mode), |
| 11370 | adapter->device_mode); |
| 11371 | if (((QDF_STA_MODE == adapter->device_mode) |
| 11372 | || (QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 11373 | || (QDF_P2P_DEVICE_MODE == adapter->device_mode)) |
| 11374 | && (eConnectionState_Connecting == |
| 11375 | (WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> |
| 11376 | conn_info.connState)) { |
| 11377 | hdd_err("%p(%d) Connection is in progress", |
| 11378 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
| 11379 | adapter->sessionId); |
| 11380 | if (session_id && reason) { |
| 11381 | *session_id = adapter->sessionId; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11382 | *reason = CONNECTION_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 11383 | } |
| 11384 | return true; |
| 11385 | } |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 11386 | /* |
| 11387 | * sme_neighbor_middle_of_roaming is for LFR2 |
| 11388 | * hdd_is_roaming_in_progress is for LFR3 |
| 11389 | */ |
| 11390 | if (((QDF_STA_MODE == adapter->device_mode) && |
| 11391 | sme_neighbor_middle_of_roaming( |
| 11392 | WLAN_HDD_GET_HAL_CTX(adapter), |
| 11393 | adapter->sessionId)) || |
| 11394 | hdd_is_roaming_in_progress(adapter)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 11395 | hdd_err("%p(%d) Reassociation in progress", |
| 11396 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
| 11397 | adapter->sessionId); |
| 11398 | if (session_id && reason) { |
| 11399 | *session_id = adapter->sessionId; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11400 | *reason = REASSOC_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 11401 | } |
| 11402 | return true; |
| 11403 | } |
| 11404 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 11405 | (QDF_P2P_CLIENT_MODE == adapter->device_mode) || |
| 11406 | (QDF_P2P_DEVICE_MODE == adapter->device_mode)) { |
| 11407 | hdd_sta_ctx = |
| 11408 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 11409 | if ((eConnectionState_Associated == |
| 11410 | hdd_sta_ctx->conn_info.connState) |
| 11411 | && (false == |
| 11412 | hdd_sta_ctx->conn_info.uIsAuthenticated)) { |
| 11413 | sta_mac = (uint8_t *) |
| 11414 | &(adapter->macAddressCurrent.bytes[0]); |
| 11415 | hdd_err("client " MAC_ADDRESS_STR |
| 11416 | " is in middle of WPS/EAPOL exchange.", |
| 11417 | MAC_ADDR_ARRAY(sta_mac)); |
| 11418 | if (session_id && reason) { |
| 11419 | *session_id = adapter->sessionId; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11420 | *reason = EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 11421 | } |
| 11422 | return true; |
| 11423 | } |
| 11424 | } else if ((QDF_SAP_MODE == adapter->device_mode) || |
| 11425 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
| 11426 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; |
| 11427 | sta_id++) { |
| 11428 | if (!((adapter->aStaInfo[sta_id].isUsed) |
| 11429 | && (OL_TXRX_PEER_STATE_CONN == |
| 11430 | adapter->aStaInfo[sta_id].tlSTAState))) |
| 11431 | continue; |
| 11432 | |
| 11433 | sta_mac = (uint8_t *) |
| 11434 | &(adapter->aStaInfo[sta_id]. |
| 11435 | macAddrSTA.bytes[0]); |
| 11436 | hdd_err("client " MAC_ADDRESS_STR |
| 11437 | " of SAP/GO is in middle of WPS/EAPOL exchange", |
| 11438 | MAC_ADDR_ARRAY(sta_mac)); |
| 11439 | if (session_id && reason) { |
| 11440 | *session_id = adapter->sessionId; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11441 | *reason = SAP_EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 11442 | } |
| 11443 | return true; |
| 11444 | } |
| 11445 | if (hdd_ctx->connection_in_progress) { |
| 11446 | hdd_err("AP/GO: connection is in progress"); |
| 11447 | return true; |
| 11448 | } |
| 11449 | } |
| 11450 | end: |
| 11451 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 11452 | adapter_node = next; |
| 11453 | } |
| 11454 | return false; |
| 11455 | } |
| 11456 | |
| 11457 | /** |
| 11458 | * hdd_restart_sap() - to restart SAP in driver internally |
| 11459 | * @ap_adapter: Pointer to SAP hdd_adapter_t structure |
| 11460 | * |
| 11461 | * Return: None |
| 11462 | */ |
| 11463 | void hdd_restart_sap(hdd_adapter_t *ap_adapter) |
| 11464 | { |
| 11465 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 11466 | hdd_hostapd_state_t *hostapd_state; |
| 11467 | QDF_STATUS qdf_status; |
| 11468 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 11469 | tsap_Config_t *sap_config; |
| 11470 | void *sap_ctx; |
| 11471 | |
| 11472 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11473 | sap_config = &hdd_ap_ctx->sapConfig; |
| 11474 | sap_ctx = hdd_ap_ctx->sapContext; |
| 11475 | |
| 11476 | mutex_lock(&hdd_ctx->sap_lock); |
| 11477 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
| 11478 | wlan_hdd_del_station(ap_adapter); |
| 11479 | hdd_cleanup_actionframe(hdd_ctx, ap_adapter); |
| 11480 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 11481 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
| 11482 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(sap_ctx)) { |
| 11483 | qdf_status = |
| 11484 | qdf_wait_single_event(&hostapd_state-> |
| 11485 | qdf_stop_bss_event, |
| 11486 | SME_CMD_TIMEOUT_VALUE); |
| 11487 | |
| 11488 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11489 | cds_err("SAP Stop Failed"); |
| 11490 | goto end; |
| 11491 | } |
| 11492 | } |
| 11493 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11494 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 11495 | ap_adapter->device_mode, ap_adapter->sessionId); |
| 11496 | cds_err("SAP Stop Success"); |
| 11497 | |
| 11498 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
| 11499 | cds_err("SAP Not able to set AP IEs"); |
| 11500 | wlansap_reset_sap_config_add_ie(sap_config, |
| 11501 | eUPDATE_IE_ALL); |
| 11502 | goto end; |
| 11503 | } |
| 11504 | |
| 11505 | qdf_event_reset(&hostapd_state->qdf_event); |
| 11506 | if (wlansap_start_bss(sap_ctx, hdd_hostapd_sap_event_cb, |
| 11507 | sap_config, |
| 11508 | ap_adapter->dev) != QDF_STATUS_SUCCESS) { |
| 11509 | cds_err("SAP Start Bss fail"); |
| 11510 | wlansap_reset_sap_config_add_ie(sap_config, |
| 11511 | eUPDATE_IE_ALL); |
| 11512 | goto end; |
| 11513 | } |
| 11514 | |
| 11515 | cds_info("Waiting for SAP to start"); |
| 11516 | qdf_status = |
| 11517 | qdf_wait_single_event(&hostapd_state->qdf_event, |
| 11518 | SME_CMD_TIMEOUT_VALUE); |
| 11519 | wlansap_reset_sap_config_add_ie(sap_config, |
| 11520 | eUPDATE_IE_ALL); |
| 11521 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11522 | cds_err("SAP Start failed"); |
| 11523 | goto end; |
| 11524 | } |
| 11525 | cds_err("SAP Start Success"); |
| 11526 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
| 11527 | if (hostapd_state->bssState == BSS_START) |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11528 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 11529 | ap_adapter->device_mode, |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 11530 | ap_adapter->sessionId); |
| 11531 | hostapd_state->bCommit = true; |
| 11532 | } |
| 11533 | end: |
| 11534 | mutex_unlock(&hdd_ctx->sap_lock); |
| 11535 | return; |
| 11536 | } |
| 11537 | |
| 11538 | /** |
| 11539 | * hdd_check_and_restart_sap_with_non_dfs_acs() - Restart SAP |
| 11540 | * with non dfs acs |
| 11541 | * |
| 11542 | * Restarts SAP in non-DFS ACS mode when STA-AP mode DFS is not supported |
| 11543 | * |
| 11544 | * Return: None |
| 11545 | */ |
| 11546 | void hdd_check_and_restart_sap_with_non_dfs_acs(void) |
| 11547 | { |
| 11548 | hdd_adapter_t *ap_adapter; |
| 11549 | hdd_context_t *hdd_ctx; |
| 11550 | cds_context_type *cds_ctx; |
| 11551 | |
| 11552 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11553 | if (!hdd_ctx) { |
| 11554 | cds_err("HDD context is NULL"); |
| 11555 | return; |
| 11556 | } |
| 11557 | |
| 11558 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 11559 | if (!cds_ctx) { |
| 11560 | cds_err("Invalid CDS Context"); |
| 11561 | return; |
| 11562 | } |
| 11563 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11564 | if (policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc) |
| 11565 | != (QDF_STA_MASK | QDF_SAP_MASK)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 11566 | cds_info("Concurrency mode is not SAP"); |
| 11567 | return; |
| 11568 | } |
| 11569 | |
| 11570 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 11571 | if (ap_adapter != NULL && |
| 11572 | test_bit(SOFTAP_BSS_STARTED, |
| 11573 | &ap_adapter->event_flags) |
| 11574 | && CDS_IS_DFS_CH(ap_adapter->sessionCtx.ap. |
| 11575 | operatingChannel)) { |
| 11576 | |
| 11577 | cds_warn("STA-AP Mode DFS not supported. Restart SAP with Non DFS ACS"); |
| 11578 | ap_adapter->sessionCtx.ap.sapConfig.channel = |
| 11579 | AUTO_CHANNEL_SELECT; |
| 11580 | ap_adapter->sessionCtx.ap.sapConfig. |
| 11581 | acs_cfg.acs_mode = true; |
| 11582 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11583 | hdd_restart_sap(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 11584 | } |
| 11585 | } |
| 11586 | |
| 11587 | /** |
| 11588 | * hdd_set_connection_in_progress() - to set the connection in |
| 11589 | * progress flag |
| 11590 | * @value: value to set |
| 11591 | * |
| 11592 | * This function will set the passed value to connection in progress flag. |
| 11593 | * If value is previously being set to true then no need to set it again. |
| 11594 | * |
| 11595 | * Return: true if value is being set correctly and false otherwise. |
| 11596 | */ |
| 11597 | bool hdd_set_connection_in_progress(bool value) |
| 11598 | { |
| 11599 | bool status = true; |
| 11600 | hdd_context_t *hdd_ctx; |
| 11601 | |
| 11602 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11603 | if (!hdd_ctx) { |
| 11604 | cds_err("HDD context is NULL"); |
| 11605 | return false; |
| 11606 | } |
| 11607 | |
| 11608 | qdf_spin_lock(&hdd_ctx->connection_status_lock); |
| 11609 | /* |
| 11610 | * if the value is set to true previously and if someone is |
| 11611 | * trying to make it true again then it could be some race |
| 11612 | * condition being triggered. Avoid this situation by returning |
| 11613 | * false |
| 11614 | */ |
| 11615 | if (hdd_ctx->connection_in_progress && value) |
| 11616 | status = false; |
| 11617 | else |
| 11618 | hdd_ctx->connection_in_progress = value; |
| 11619 | qdf_spin_unlock(&hdd_ctx->connection_status_lock); |
| 11620 | return status; |
| 11621 | } |
| 11622 | |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 11623 | int wlan_hdd_send_p2p_quota(hdd_adapter_t *adapter, int set_value) |
| 11624 | { |
| 11625 | if (!adapter) { |
| 11626 | hdd_err("Invalid adapter"); |
| 11627 | return -EINVAL; |
| 11628 | } |
| 11629 | hdd_info("Send MCC P2P QUOTA to WMA: %d", set_value); |
| 11630 | wma_cli_set_command(adapter->sessionId, |
| 11631 | WMA_VDEV_MCC_SET_TIME_QUOTA, |
| 11632 | set_value, VDEV_CMD); |
| 11633 | return 0; |
| 11634 | |
| 11635 | } |
| 11636 | |
| 11637 | int wlan_hdd_send_mcc_latency(hdd_adapter_t *adapter, int set_value) |
| 11638 | { |
| 11639 | if (!adapter) { |
| 11640 | hdd_err("Invalid adapter"); |
| 11641 | return -EINVAL; |
| 11642 | } |
| 11643 | |
| 11644 | hdd_info("Send MCC latency WMA: %d", set_value); |
| 11645 | wma_cli_set_command(adapter->sessionId, |
| 11646 | WMA_VDEV_MCC_SET_TIME_LATENCY, |
| 11647 | set_value, VDEV_CMD); |
| 11648 | return 0; |
| 11649 | } |
| 11650 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 11651 | hdd_adapter_t *wlan_hdd_get_adapter_from_vdev(struct wlan_objmgr_psoc |
| 11652 | *psoc, uint8_t vdev_id) |
| 11653 | { |
| 11654 | hdd_adapter_t *adapter = NULL; |
| 11655 | hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11656 | |
| 11657 | /* |
| 11658 | * Currently PSOC is not being used. But this logic will |
| 11659 | * change once we have the converged implementation of |
| 11660 | * HDD context per PSOC in place. This would break if |
| 11661 | * multiple vdev objects reuse the vdev id. |
| 11662 | */ |
| 11663 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 11664 | if (!adapter) |
| 11665 | hdd_err("Get adapter by vdev id failed"); |
| 11666 | |
| 11667 | return adapter; |
| 11668 | } |
| 11669 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11670 | /* Register the module init/exit functions */ |
| 11671 | module_init(hdd_module_init); |
| 11672 | module_exit(hdd_module_exit); |
| 11673 | |
| 11674 | MODULE_LICENSE("Dual BSD/GPL"); |
| 11675 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 11676 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 11677 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11678 | module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode, |
| 11679 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11680 | |
| 11681 | module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath, |
| 11682 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 11683 | |
| 11684 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 11685 | |
| 11686 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 11687 | |
| 11688 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |