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" |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame^] | 96 | #include "wlan_hdd_he.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 97 | |
| 98 | #include <wlan_hdd_ipa.h> |
| 99 | #include "hif.h" |
| 100 | #include "wma.h" |
| 101 | #include "cds_concurrency.h" |
Manikandan Mohan | dcc21ba | 2016-03-15 14:31:56 -0700 | [diff] [blame] | 102 | #include "wlan_hdd_tsf.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 103 | #include "wlan_hdd_green_ap.h" |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 104 | #include "bmi.h" |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 105 | #include <wlan_hdd_regulatory.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 106 | #include "wlan_hdd_lpass.h" |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 107 | #include "nan_api.h" |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 108 | #include <wlan_hdd_napi.h> |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 109 | #include "wlan_hdd_disa.h" |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 110 | #include <dispatcher_init_deinit.h> |
Rajeev Kumar | 699debf | 2017-01-06 14:17:00 -0800 | [diff] [blame] | 111 | #include "wlan_hdd_object_manager.h" |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 112 | #include "cds_utils.h" |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 113 | #include <cdp_txrx_handle.h> |
Sandeep Puligilla | fdd201e | 2017-02-02 18:43:46 -0800 | [diff] [blame] | 114 | #include <qca_vendor.h> |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 115 | #include "wlan_pmo_ucfg_api.h" |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 116 | #include "sir_api.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 117 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 118 | #ifdef CNSS_GENL |
| 119 | #include <net/cnss_nl.h> |
| 120 | #endif |
| 121 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 122 | #ifdef MODULE |
| 123 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 124 | #else |
| 125 | #define WLAN_MODULE_NAME "wlan" |
| 126 | #endif |
| 127 | |
| 128 | #ifdef TIMER_MANAGER |
| 129 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 130 | #else |
| 131 | #define TIMER_MANAGER_STR "" |
| 132 | #endif |
| 133 | |
| 134 | #ifdef MEMORY_DEBUG |
| 135 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 136 | #else |
| 137 | #define MEMORY_DEBUG_STR "" |
| 138 | #endif |
| 139 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 140 | #ifndef MODULE |
| 141 | static struct gwlan_loader *wlan_loader; |
| 142 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 143 | struct kobj_attribute *attr, |
| 144 | const char *buf, size_t count); |
| 145 | struct gwlan_loader { |
| 146 | bool loaded_state; |
| 147 | struct kobject *boot_wlan_obj; |
| 148 | struct attribute_group *attr_group; |
| 149 | }; |
| 150 | |
| 151 | static struct kobj_attribute wlan_boot_attribute = |
| 152 | __ATTR(boot_wlan, 0220, NULL, wlan_boot_cb); |
| 153 | |
| 154 | static struct attribute *attrs[] = { |
| 155 | &wlan_boot_attribute.attr, |
| 156 | NULL, |
| 157 | }; |
| 158 | |
| 159 | #define MODULE_INITIALIZED 1 |
| 160 | #endif |
| 161 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 162 | /* the Android framework expects this param even though we don't use it */ |
| 163 | #define BUF_LEN 20 |
| 164 | static char fwpath_buffer[BUF_LEN]; |
| 165 | static struct kparam_string fwpath = { |
| 166 | .string = fwpath_buffer, |
| 167 | .maxlen = BUF_LEN, |
| 168 | }; |
| 169 | |
| 170 | static char *country_code; |
| 171 | static int enable_11d = -1; |
| 172 | static int enable_dfs_chan_scan = -1; |
| 173 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 174 | /* |
| 175 | * spinlock for synchronizing asynchronous request/response |
| 176 | * (full description of use in wlan_hdd_main.h) |
| 177 | */ |
| 178 | DEFINE_SPINLOCK(hdd_context_lock); |
| 179 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 180 | #define WLAN_NLINK_CESIUM 30 |
| 181 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 182 | static qdf_wake_lock_t wlan_wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 183 | |
| 184 | #define WOW_MAX_FILTER_LISTS 1 |
| 185 | #define WOW_MAX_FILTERS_PER_LIST 4 |
| 186 | #define WOW_MIN_PATTERN_SIZE 6 |
| 187 | #define WOW_MAX_PATTERN_SIZE 64 |
| 188 | |
| 189 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 190 | static const struct wiphy_wowlan_support wowlan_support_reg_init = { |
| 191 | .flags = WIPHY_WOWLAN_ANY | |
| 192 | WIPHY_WOWLAN_MAGIC_PKT | |
| 193 | WIPHY_WOWLAN_DISCONNECT | |
| 194 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 195 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 196 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 197 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 198 | WIPHY_WOWLAN_RFKILL_RELEASE, |
| 199 | .n_patterns = WOW_MAX_FILTER_LISTS * WOW_MAX_FILTERS_PER_LIST, |
| 200 | .pattern_min_len = WOW_MIN_PATTERN_SIZE, |
| 201 | .pattern_max_len = WOW_MAX_PATTERN_SIZE, |
| 202 | }; |
| 203 | #endif |
| 204 | |
| 205 | /* internal function declaration */ |
| 206 | |
| 207 | struct sock *cesium_nl_srv_sock; |
Arun Khandavalli | 13cb5da | 2017-01-19 15:43:52 +0530 | [diff] [blame] | 208 | struct completion wlan_start_comp; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 209 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 210 | void wlan_hdd_auto_shutdown_cb(void); |
| 211 | #endif |
| 212 | |
| 213 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 214 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
| 215 | * @hdd_ctx: pointer to hdd_context_t |
| 216 | * |
| 217 | * Return: none |
| 218 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 219 | static void hdd_set_rps_cpu_mask(hdd_context_t *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 220 | { |
| 221 | hdd_adapter_t *adapter; |
| 222 | hdd_adapter_list_node_t *adapter_node, *next; |
| 223 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 224 | |
| 225 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 226 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 227 | adapter = adapter_node->pAdapter; |
| 228 | if (NULL != adapter) |
| 229 | hdd_send_rps_ind(adapter); |
| 230 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 231 | adapter_node = next; |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 236 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 237 | * @vdev_id: vdev_id |
| 238 | * @action: action type |
| 239 | * @reason: reason type |
| 240 | * |
| 241 | * Return: none |
| 242 | */ |
| 243 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 244 | enum netif_action_type action, enum netif_reason_type reason) |
| 245 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 246 | hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 247 | hdd_adapter_t *adapter; |
| 248 | |
| 249 | if (!hdd_ctx) { |
| 250 | hdd_err("hdd ctx is NULL"); |
| 251 | return; |
| 252 | } |
| 253 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 254 | |
| 255 | wlan_hdd_netif_queue_control(adapter, action, reason); |
| 256 | return; |
| 257 | } |
| 258 | |
| 259 | /* |
| 260 | * Store WLAN driver version info in a global variable such that crash debugger |
| 261 | * can extract it from driver debug symbol and crashdump for post processing |
| 262 | */ |
| 263 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR; |
| 264 | |
| 265 | /** |
| 266 | * hdd_device_mode_to_string() - return string conversion of device mode |
| 267 | * @device_mode: device mode |
| 268 | * |
| 269 | * This utility function helps log string conversion of device mode. |
| 270 | * |
| 271 | * Return: string conversion of device mode, if match found; |
| 272 | * "Unknown" otherwise. |
| 273 | */ |
| 274 | const char *hdd_device_mode_to_string(uint8_t device_mode) |
| 275 | { |
| 276 | switch (device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 277 | CASE_RETURN_STRING(QDF_STA_MODE); |
| 278 | CASE_RETURN_STRING(QDF_SAP_MODE); |
| 279 | CASE_RETURN_STRING(QDF_P2P_CLIENT_MODE); |
| 280 | CASE_RETURN_STRING(QDF_P2P_GO_MODE); |
| 281 | CASE_RETURN_STRING(QDF_FTM_MODE); |
| 282 | CASE_RETURN_STRING(QDF_IBSS_MODE); |
| 283 | CASE_RETURN_STRING(QDF_P2P_DEVICE_MODE); |
| 284 | CASE_RETURN_STRING(QDF_OCB_MODE); |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 285 | CASE_RETURN_STRING(QDF_NDI_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 286 | default: |
| 287 | return "Unknown"; |
| 288 | } |
| 289 | } |
| 290 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 291 | /** |
| 292 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 293 | * @adapter: HDD adapter |
| 294 | * @chan_number: Channel number |
| 295 | * @chan_bw: Bandwidth |
| 296 | * |
| 297 | * Checks if the given bandwidth is valid for the given channel number. |
| 298 | * |
| 299 | * Return: 0 for success, non-zero for failure |
| 300 | */ |
| 301 | int hdd_validate_channel_and_bandwidth(hdd_adapter_t *adapter, |
| 302 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 303 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 304 | { |
| 305 | uint8_t chan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 306 | uint32_t len = WNI_CFG_VALID_CHANNEL_LIST_LEN, i; |
| 307 | bool found = false; |
| 308 | tHalHandle hal; |
| 309 | |
| 310 | hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 311 | if (!hal) { |
| 312 | hdd_err("Invalid HAL context"); |
| 313 | return -EINVAL; |
| 314 | } |
| 315 | |
| 316 | if (0 != sme_cfg_get_str(hal, WNI_CFG_VALID_CHANNEL_LIST, chan, &len)) { |
| 317 | hdd_err("No valid channel list"); |
| 318 | return -EOPNOTSUPP; |
| 319 | } |
| 320 | |
| 321 | for (i = 0; i < len; i++) { |
| 322 | if (chan[i] == chan_number) { |
| 323 | found = true; |
| 324 | break; |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | if (found == false) { |
| 329 | hdd_err("Channel not in driver's valid channel list"); |
| 330 | return -EOPNOTSUPP; |
| 331 | } |
| 332 | |
| 333 | if ((!CDS_IS_CHANNEL_24GHZ(chan_number)) && |
| 334 | (!CDS_IS_CHANNEL_5GHZ(chan_number))) { |
| 335 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 336 | return -EINVAL; |
| 337 | } |
| 338 | |
| 339 | if (CDS_IS_CHANNEL_24GHZ(chan_number)) { |
| 340 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 341 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 342 | return -EINVAL; |
| 343 | } |
| 344 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 345 | (chan_bw != CH_WIDTH_MAX)) { |
| 346 | hdd_err("Only BW20 possible on channel 14"); |
| 347 | return -EINVAL; |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | if (CDS_IS_CHANNEL_5GHZ(chan_number)) { |
| 352 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 353 | (chan_bw != CH_WIDTH_MAX)) { |
| 354 | hdd_err("Only BW20 possible on channel 165"); |
| 355 | return -EINVAL; |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | return 0; |
| 360 | } |
| 361 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 362 | static int __hdd_netdev_notifier_call(struct notifier_block *nb, |
| 363 | unsigned long state, void *data) |
| 364 | { |
| 365 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 366 | struct netdev_notifier_info *dev_notif_info = data; |
| 367 | struct net_device *dev = dev_notif_info->dev; |
| 368 | #else |
| 369 | struct net_device *dev = data; |
| 370 | #endif |
| 371 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 372 | hdd_context_t *hdd_ctx; |
| 373 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 374 | ENTER_DEV(dev); |
| 375 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 376 | /* Make sure that this callback corresponds to our device. */ |
| 377 | if ((strncmp(dev->name, "wlan", 4)) && (strncmp(dev->name, "p2p", 3))) |
| 378 | return NOTIFY_DONE; |
| 379 | |
Samuel Ahn | c9c48ca | 2016-09-19 15:46:36 +0530 | [diff] [blame] | 380 | if ((adapter->magic != WLAN_HDD_ADAPTER_MAGIC) || |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 381 | (adapter->dev != dev)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 382 | hdd_err("device adapter is not matching!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 383 | return NOTIFY_DONE; |
| 384 | } |
| 385 | |
| 386 | if (!dev->ieee80211_ptr) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 387 | hdd_err("ieee80211_ptr is NULL!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 388 | return NOTIFY_DONE; |
| 389 | } |
| 390 | |
| 391 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 392 | if (NULL == hdd_ctx) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 393 | hdd_alert("HDD Context Null Pointer"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 394 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 395 | return NOTIFY_DONE; |
| 396 | } |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 397 | if (cds_is_driver_recovering()) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 398 | return NOTIFY_DONE; |
| 399 | |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 400 | hdd_notice("%s New Net Device State = %lu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 401 | dev->name, state); |
| 402 | |
| 403 | switch (state) { |
| 404 | case NETDEV_REGISTER: |
| 405 | break; |
| 406 | |
| 407 | case NETDEV_UNREGISTER: |
| 408 | break; |
| 409 | |
| 410 | case NETDEV_UP: |
| 411 | sme_ch_avoid_update_req(hdd_ctx->hHal); |
| 412 | break; |
| 413 | |
| 414 | case NETDEV_DOWN: |
| 415 | break; |
| 416 | |
| 417 | case NETDEV_CHANGE: |
| 418 | if (true == adapter->isLinkUpSvcNeeded) |
| 419 | complete(&adapter->linkup_event_var); |
| 420 | break; |
| 421 | |
| 422 | case NETDEV_GOING_DOWN: |
| 423 | if (adapter->scan_info.mScanPending != false) { |
| 424 | unsigned long rc; |
| 425 | INIT_COMPLETION(adapter->scan_info. |
| 426 | abortscan_event_var); |
| 427 | hdd_abort_mac_scan(adapter->pHddCtx, |
| 428 | adapter->sessionId, |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 429 | INVALID_SCAN_ID, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 430 | eCSR_SCAN_ABORT_DEFAULT); |
| 431 | rc = wait_for_completion_timeout( |
| 432 | &adapter->scan_info.abortscan_event_var, |
| 433 | msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN)); |
| 434 | if (!rc) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 435 | hdd_err("Timeout occurred while waiting for abortscan"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 436 | } |
| 437 | } else { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 438 | hdd_notice("Scan is not Pending from user"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 439 | } |
| 440 | break; |
| 441 | |
| 442 | default: |
| 443 | break; |
| 444 | } |
| 445 | |
| 446 | return NOTIFY_DONE; |
| 447 | } |
| 448 | |
| 449 | /** |
| 450 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 451 | * @nb: pointer to notifier block |
| 452 | * @state: state |
| 453 | * @ndev: ndev pointer |
| 454 | * |
| 455 | * Return: 0 on success, error number otherwise. |
| 456 | */ |
| 457 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 458 | unsigned long state, |
| 459 | void *ndev) |
| 460 | { |
| 461 | int ret; |
| 462 | |
| 463 | cds_ssr_protect(__func__); |
| 464 | ret = __hdd_netdev_notifier_call(nb, state, ndev); |
| 465 | cds_ssr_unprotect(__func__); |
| 466 | |
| 467 | return ret; |
| 468 | } |
| 469 | |
| 470 | struct notifier_block hdd_netdev_notifier = { |
| 471 | .notifier_call = hdd_netdev_notifier_call, |
| 472 | }; |
| 473 | |
| 474 | /* variable to hold the insmod parameters */ |
| 475 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 476 | |
| 477 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 478 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 479 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 480 | /** |
| 481 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 482 | * @ch_width: NL channel width |
| 483 | * |
| 484 | * Converts the NL channel width to the driver's internal representation |
| 485 | * |
| 486 | * Return: Converted channel width. In case of non matching NL channel width, |
| 487 | * CH_WIDTH_MAX will be returned. |
| 488 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 489 | 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] | 490 | { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 491 | uint8_t fw_ch_bw; |
| 492 | fw_ch_bw = wma_get_vht_ch_width(); |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 493 | switch (ch_width) { |
| 494 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 495 | case NL80211_CHAN_WIDTH_20: |
| 496 | return CH_WIDTH_20MHZ; |
| 497 | case NL80211_CHAN_WIDTH_40: |
| 498 | return CH_WIDTH_40MHZ; |
| 499 | break; |
| 500 | case NL80211_CHAN_WIDTH_80: |
| 501 | return CH_WIDTH_80MHZ; |
| 502 | case NL80211_CHAN_WIDTH_80P80: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 503 | if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ) |
| 504 | return CH_WIDTH_80P80MHZ; |
| 505 | else if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 506 | return CH_WIDTH_160MHZ; |
| 507 | else |
| 508 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 509 | case NL80211_CHAN_WIDTH_160: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 510 | if (fw_ch_bw >= WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 511 | return CH_WIDTH_160MHZ; |
| 512 | else |
| 513 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 514 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 515 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 516 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 517 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 518 | default: |
| 519 | hdd_err("Invalid channel width %d, setting to default", |
| 520 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 521 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 522 | } |
| 523 | } |
| 524 | |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 525 | /* wlan_hdd_find_opclass() - Find operating class for a channel |
| 526 | * @hal: handler to HAL |
| 527 | * @channel: channel id |
| 528 | * @bw_offset: bandwidth offset |
| 529 | * |
| 530 | * Function invokes sme api to find the operating class |
| 531 | * |
| 532 | * Return: operating class |
| 533 | */ |
| 534 | uint8_t wlan_hdd_find_opclass(tHalHandle hal, uint8_t channel, |
| 535 | uint8_t bw_offset) |
| 536 | { |
| 537 | uint8_t opclass = 0; |
| 538 | |
| 539 | sme_get_opclass(hal, channel, bw_offset, &opclass); |
| 540 | return opclass; |
| 541 | } |
| 542 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 543 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 544 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 545 | * @module_id: Module whose trace level is being configured |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 546 | * @bitmask: Bitmask of log levels to be enabled |
| 547 | * |
| 548 | * Called immediately after the cfg.ini is read in order to configure |
| 549 | * the desired trace levels. |
| 550 | * |
| 551 | * Return: None |
| 552 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 553 | 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] | 554 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 555 | QDF_TRACE_LEVEL level; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 556 | int qdf_print_idx = -1; |
| 557 | int status = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 558 | /* |
| 559 | * if the bitmask is the default value, then a bitmask was not |
| 560 | * specified in cfg.ini, so leave the logging level alone (it |
| 561 | * will remain at the "compiled in" default value) |
| 562 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 563 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) { |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 564 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 565 | } |
| 566 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 567 | qdf_print_idx = qdf_get_pidx(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 568 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 569 | /* a mask was specified. start by disabling all logging */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 570 | status = qdf_print_set_category_verbose(qdf_print_idx, module_id, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 571 | QDF_TRACE_LEVEL_NONE, 0); |
| 572 | |
| 573 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 574 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 575 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 576 | level = QDF_TRACE_LEVEL_FATAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 577 | while (0 != bitmask) { |
| 578 | if (bitmask & 1) { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 579 | status = qdf_print_set_category_verbose(qdf_print_idx, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 580 | module_id, level, 1); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 581 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 582 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 583 | } |
| 584 | level++; |
| 585 | bitmask >>= 1; |
| 586 | } |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 587 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 588 | } |
| 589 | |
| 590 | /** |
| 591 | * wlan_hdd_validate_context() - check the HDD context |
| 592 | * @hdd_ctx: HDD context pointer |
| 593 | * |
| 594 | * Return: 0 if the context is valid. Error code otherwise |
| 595 | */ |
| 596 | int wlan_hdd_validate_context(hdd_context_t *hdd_ctx) |
| 597 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 598 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 599 | hdd_err("%pS HDD context is Null", (void *)_RET_IP_); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 600 | return -ENODEV; |
| 601 | } |
| 602 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 603 | if (cds_is_driver_recovering()) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 604 | hdd_err("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
| 605 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 606 | return -EAGAIN; |
| 607 | } |
| 608 | |
Rajeev Kumar | fec3dbe | 2016-01-19 15:23:52 -0800 | [diff] [blame] | 609 | if (cds_is_load_or_unload_in_progress()) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 610 | hdd_err("%pS Unloading/Loading in Progress. Ignore!!!: 0x%x", |
| 611 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 612 | return -EAGAIN; |
| 613 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 614 | |
| 615 | if (hdd_ctx->start_modules_in_progress || |
| 616 | hdd_ctx->stop_modules_in_progress) { |
| 617 | hdd_err("%pS Start/Stop Modules in progress. Ignore!!!", |
| 618 | (void *)_RET_IP_); |
| 619 | return -EAGAIN; |
| 620 | } |
| 621 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 622 | return 0; |
| 623 | } |
| 624 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 625 | /** |
| 626 | * hdd_set_ibss_power_save_params() - update IBSS Power Save params to WMA. |
| 627 | * @hdd_adapter_t Hdd adapter. |
| 628 | * |
| 629 | * This function sets the IBSS power save config parameters to WMA |
| 630 | * which will send it to firmware if FW supports IBSS power save |
| 631 | * before vdev start. |
| 632 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 633 | * 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] | 634 | * on failure. |
| 635 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 636 | QDF_STATUS hdd_set_ibss_power_save_params(hdd_adapter_t *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 637 | { |
| 638 | int ret; |
| 639 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 640 | |
| 641 | if (hdd_ctx == NULL) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 642 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 643 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 644 | } |
| 645 | |
| 646 | ret = wma_cli_set_command(adapter->sessionId, |
| 647 | WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE, |
| 648 | hdd_ctx->config->ibssATIMWinSize, |
| 649 | VDEV_CMD); |
| 650 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 651 | hdd_err("WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 652 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 653 | } |
| 654 | |
| 655 | ret = wma_cli_set_command(adapter->sessionId, |
| 656 | WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED, |
| 657 | hdd_ctx->config->isIbssPowerSaveAllowed, |
| 658 | VDEV_CMD); |
| 659 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 660 | hdd_err("WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED failed %d", |
| 661 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 662 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 663 | } |
| 664 | |
| 665 | ret = wma_cli_set_command(adapter->sessionId, |
| 666 | WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED, |
| 667 | hdd_ctx->config-> |
| 668 | isIbssPowerCollapseAllowed, VDEV_CMD); |
| 669 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 670 | hdd_err("WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED failed %d", |
| 671 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 672 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 673 | } |
| 674 | |
| 675 | ret = wma_cli_set_command(adapter->sessionId, |
| 676 | WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX, |
| 677 | hdd_ctx->config->isIbssAwakeOnTxRx, |
| 678 | VDEV_CMD); |
| 679 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 680 | 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] | 681 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 682 | } |
| 683 | |
| 684 | ret = wma_cli_set_command(adapter->sessionId, |
| 685 | WMA_VDEV_IBSS_SET_INACTIVITY_TIME, |
| 686 | hdd_ctx->config->ibssInactivityCount, |
| 687 | VDEV_CMD); |
| 688 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 689 | hdd_err("WMA_VDEV_IBSS_SET_INACTIVITY_TIME failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 690 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 691 | } |
| 692 | |
| 693 | ret = wma_cli_set_command(adapter->sessionId, |
| 694 | WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME, |
| 695 | hdd_ctx->config->ibssTxSpEndInactivityTime, |
| 696 | VDEV_CMD); |
| 697 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 698 | hdd_err("WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME failed %d", |
| 699 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 700 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 701 | } |
| 702 | |
| 703 | ret = wma_cli_set_command(adapter->sessionId, |
| 704 | WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS, |
| 705 | hdd_ctx->config->ibssPsWarmupTime, |
| 706 | VDEV_CMD); |
| 707 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 708 | hdd_err("WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS failed %d", |
| 709 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 710 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 711 | } |
| 712 | |
| 713 | ret = wma_cli_set_command(adapter->sessionId, |
| 714 | WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW, |
| 715 | hdd_ctx->config->ibssPs1RxChainInAtimEnable, |
| 716 | VDEV_CMD); |
| 717 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 718 | hdd_err("WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW failed %d", |
| 719 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 720 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 721 | } |
| 722 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 723 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 724 | } |
| 725 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 726 | #define INTF_MACADDR_MASK 0x7 |
| 727 | |
| 728 | /** |
| 729 | * hdd_update_macaddr() - update mac address |
| 730 | * @config: hdd configuration |
| 731 | * @hw_macaddr: mac address |
| 732 | * |
| 733 | * Mac address for multiple virtual interface is found as following |
| 734 | * i) The mac address of the first interface is just the actual hw mac address. |
| 735 | * ii) MSM 3 or 4 bits of byte5 of the actual mac address are used to |
| 736 | * define the mac address for the remaining interfaces and locally |
| 737 | * admistered bit is set. INTF_MACADDR_MASK is based on the number of |
| 738 | * supported virtual interfaces, right now this is 0x07 (meaning 8 |
| 739 | * interface). |
| 740 | * Byte[3] of second interface will be hw_macaddr[3](bit5..7) + 1, |
| 741 | * for third interface it will be hw_macaddr[3](bit5..7) + 2, etc. |
| 742 | * |
| 743 | * Return: None |
| 744 | */ |
| 745 | void hdd_update_macaddr(struct hdd_config *config, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 746 | struct qdf_mac_addr hw_macaddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 747 | { |
| 748 | int8_t i; |
| 749 | uint8_t macaddr_b3, tmp_br3; |
| 750 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 751 | qdf_mem_copy(config->intfMacAddr[0].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 752 | QDF_MAC_ADDR_SIZE); |
| 753 | for (i = 1; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 754 | qdf_mem_copy(config->intfMacAddr[i].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 755 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 756 | macaddr_b3 = config->intfMacAddr[i].bytes[3]; |
| 757 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 758 | INTF_MACADDR_MASK; |
| 759 | macaddr_b3 += tmp_br3; |
| 760 | |
| 761 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 762 | * mac address range before collision |
| 763 | */ |
| 764 | macaddr_b3 ^= (1 << 7); |
| 765 | |
| 766 | /* Set locally administered bit */ |
| 767 | config->intfMacAddr[i].bytes[0] |= 0x02; |
| 768 | config->intfMacAddr[i].bytes[3] = macaddr_b3; |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 769 | hdd_notice("config->intfMacAddr[%d]: " |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 770 | MAC_ADDRESS_STR, i, |
| 771 | MAC_ADDR_ARRAY(config->intfMacAddr[i].bytes)); |
| 772 | } |
| 773 | } |
| 774 | |
| 775 | static void hdd_update_tgt_services(hdd_context_t *hdd_ctx, |
| 776 | struct wma_tgt_services *cfg) |
| 777 | { |
| 778 | struct hdd_config *config = hdd_ctx->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 779 | |
| 780 | /* Set up UAPSD */ |
| 781 | config->apUapsdEnabled &= cfg->uapsd; |
| 782 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 783 | /* 11AC mode support */ |
| 784 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 785 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 786 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 787 | |
| 788 | /* ARP offload: override user setting if invalid */ |
| 789 | config->fhostArpOffload &= cfg->arp_offload; |
| 790 | |
| 791 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 792 | /* PNO offload */ |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 793 | hdd_info("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 794 | if (cfg->pno_offload) |
| 795 | config->PnoOffload = true; |
| 796 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 797 | #ifdef FEATURE_WLAN_TDLS |
| 798 | config->fEnableTDLSSupport &= cfg->en_tdls; |
Manjeet Singh | fdd2ac7 | 2016-09-02 18:11:43 +0530 | [diff] [blame] | 799 | config->fEnableTDLSOffChannel = config->fEnableTDLSOffChannel && |
| 800 | cfg->en_tdls_offchan; |
| 801 | config->fEnableTDLSBufferSta = config->fEnableTDLSBufferSta && |
| 802 | cfg->en_tdls_uapsd_buf_sta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 803 | if (config->fTDLSUapsdMask && cfg->en_tdls_uapsd_sleep_sta) { |
| 804 | config->fEnableTDLSSleepSta = true; |
| 805 | } else { |
| 806 | config->fEnableTDLSSleepSta = false; |
| 807 | } |
| 808 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 809 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 810 | config->isRoamOffloadEnabled &= cfg->en_roam_offload; |
| 811 | #endif |
Krishna Kumaar Natarajan | 052c6e6 | 2015-09-28 15:32:55 -0700 | [diff] [blame] | 812 | sme_update_tgt_services(hdd_ctx->hHal, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 813 | |
| 814 | } |
| 815 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 816 | /** |
| 817 | * hdd_update_vdev_nss() - sets the vdev nss |
| 818 | * @hdd_ctx: HDD context |
| 819 | * |
| 820 | * Sets the Nss per vdev type based on INI |
| 821 | * |
| 822 | * Return: None |
| 823 | */ |
| 824 | static void hdd_update_vdev_nss(hdd_context_t *hdd_ctx) |
| 825 | { |
| 826 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 827 | uint8_t max_supp_nss = 1; |
| 828 | |
Naveen Rawat | 10b1c15 | 2017-01-18 11:16:06 -0800 | [diff] [blame] | 829 | if (cfg_ini->enable2x2 && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 830 | max_supp_nss = 2; |
| 831 | |
| 832 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
| 833 | cfg_ini->vdev_type_nss_2g, eCSR_BAND_24); |
| 834 | |
| 835 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
| 836 | cfg_ini->vdev_type_nss_5g, eCSR_BAND_5G); |
| 837 | } |
| 838 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 839 | static void hdd_update_tgt_ht_cap(hdd_context_t *hdd_ctx, |
| 840 | struct wma_tgt_ht_cap *cfg) |
| 841 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 842 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 843 | uint32_t value, val32; |
| 844 | uint16_t val16; |
| 845 | struct hdd_config *pconfig = hdd_ctx->config; |
| 846 | tSirMacHTCapabilityInfo *phtCapInfo; |
| 847 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
| 848 | uint8_t enable_tx_stbc; |
| 849 | |
| 850 | /* check and update RX STBC */ |
| 851 | if (pconfig->enableRxSTBC && !cfg->ht_rx_stbc) |
| 852 | pconfig->enableRxSTBC = cfg->ht_rx_stbc; |
| 853 | |
| 854 | /* get the MPDU density */ |
| 855 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, &value); |
| 856 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 857 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 858 | hdd_err("could not get MPDU DENSITY"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 859 | value = 0; |
| 860 | } |
| 861 | |
| 862 | /* |
| 863 | * MPDU density: |
| 864 | * override user's setting if value is larger |
| 865 | * than the one supported by target |
| 866 | */ |
| 867 | if (value > cfg->mpdu_density) { |
| 868 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, |
| 869 | cfg->mpdu_density); |
| 870 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 871 | if (status == QDF_STATUS_E_FAILURE) |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 872 | hdd_alert("could not set MPDU DENSITY to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 873 | } |
| 874 | |
| 875 | /* get the HT capability info */ |
| 876 | 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] | 877 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 878 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 879 | return; |
| 880 | } |
| 881 | val16 = (uint16_t) val32; |
| 882 | phtCapInfo = (tSirMacHTCapabilityInfo *) &val16; |
| 883 | |
| 884 | /* Set the LDPC capability */ |
| 885 | phtCapInfo->advCodingCap = cfg->ht_rx_ldpc; |
| 886 | |
| 887 | if (pconfig->ShortGI20MhzEnable && !cfg->ht_sgi_20) |
| 888 | pconfig->ShortGI20MhzEnable = cfg->ht_sgi_20; |
| 889 | |
| 890 | if (pconfig->ShortGI40MhzEnable && !cfg->ht_sgi_40) |
| 891 | pconfig->ShortGI40MhzEnable = cfg->ht_sgi_40; |
| 892 | |
| 893 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 894 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 895 | |
| 896 | enable_tx_stbc = pconfig->enableTxSTBC; |
| 897 | |
| 898 | if (pconfig->enable2x2 && (cfg->num_rf_chains == 2)) { |
| 899 | pconfig->enable2x2 = 1; |
| 900 | } else { |
| 901 | pconfig->enable2x2 = 0; |
| 902 | enable_tx_stbc = 0; |
| 903 | |
| 904 | /* 1x1 */ |
| 905 | /* Update Rx Highest Long GI data Rate */ |
| 906 | if (sme_cfg_set_int(hdd_ctx->hHal, |
| 907 | WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 908 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 909 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 910 | 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] | 911 | } |
| 912 | |
| 913 | /* Update Tx Highest Long GI data Rate */ |
| 914 | if (sme_cfg_set_int |
| 915 | (hdd_ctx->hHal, |
| 916 | WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 917 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 918 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 919 | hdd_err("VHT_TX_HIGHEST_SUPP_RATE_1_1 to CCM fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 920 | } |
| 921 | } |
| 922 | if (!(cfg->ht_tx_stbc && pconfig->enable2x2)) |
| 923 | enable_tx_stbc = 0; |
| 924 | phtCapInfo->txSTBC = enable_tx_stbc; |
| 925 | |
| 926 | val32 = val16; |
| 927 | 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] | 928 | if (status != QDF_STATUS_SUCCESS) |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 929 | hdd_alert("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 930 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
| 931 | value = SIZE_OF_SUPPORTED_MCS_SET; |
| 932 | 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] | 933 | &value) == QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 934 | hdd_notice("Read MCS rate set"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 935 | |
| 936 | if (pconfig->enable2x2) { |
| 937 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 938 | mcs_set[value] = |
| 939 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 940 | |
| 941 | status = |
| 942 | sme_cfg_set_str(hdd_ctx->hHal, |
| 943 | WNI_CFG_SUPPORTED_MCS_SET, |
| 944 | mcs_set, |
| 945 | SIZE_OF_SUPPORTED_MCS_SET); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 946 | if (status == QDF_STATUS_E_FAILURE) |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 947 | hdd_alert("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 948 | } |
| 949 | } |
| 950 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 951 | } |
| 952 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 953 | static void hdd_update_tgt_vht_cap(hdd_context_t *hdd_ctx, |
| 954 | struct wma_tgt_vht_cap *cfg) |
| 955 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 956 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 957 | uint32_t value = 0; |
| 958 | struct hdd_config *pconfig = hdd_ctx->config; |
| 959 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 960 | struct ieee80211_supported_band *band_5g = |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 961 | wiphy->bands[NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 962 | uint32_t temp = 0; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 963 | uint32_t ch_width = eHT_CHANNEL_WIDTH_80MHZ; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 964 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 965 | if (!band_5g) { |
| 966 | hdd_info("5GHz band disabled, skipping capability population"); |
| 967 | return; |
| 968 | } |
| 969 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 970 | /* Get the current MPDU length */ |
| 971 | status = |
| 972 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 973 | &value); |
| 974 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 975 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 976 | hdd_err("could not get MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 977 | value = 0; |
| 978 | } |
| 979 | |
| 980 | /* |
| 981 | * VHT max MPDU length: |
| 982 | * override if user configured value is too high |
| 983 | * that the target cannot support |
| 984 | */ |
| 985 | if (value > cfg->vht_max_mpdu) { |
| 986 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 987 | WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 988 | cfg->vht_max_mpdu); |
| 989 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 990 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 991 | hdd_alert("could not set VHT MAX MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 992 | } |
| 993 | } |
| 994 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 995 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, &temp); |
| 996 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 997 | |
| 998 | if (pconfig->enable2x2) |
| 999 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1000 | |
| 1001 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, temp) == |
| 1002 | QDF_STATUS_E_FAILURE) { |
| 1003 | hdd_err("Could not pass VHT_BASIC_MCS_SET to CCM"); |
| 1004 | } |
| 1005 | |
| 1006 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, &temp); |
| 1007 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1008 | if (pconfig->enable2x2) |
| 1009 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1010 | |
| 1011 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, temp) == |
| 1012 | QDF_STATUS_E_FAILURE) { |
| 1013 | hdd_err("Could not pass WNI_CFG_VHT_RX_MCS_MAP to CCM"); |
| 1014 | } |
| 1015 | |
| 1016 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, &temp); |
| 1017 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtTxMCS; |
| 1018 | if (pconfig->enable2x2) |
| 1019 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtTxMCS2x2 << 2); |
| 1020 | |
| 1021 | hdd_info("vhtRxMCS2x2 - %x temp - %u enable2x2 %d", |
| 1022 | pconfig->vhtRxMCS2x2, temp, pconfig->enable2x2); |
| 1023 | |
| 1024 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, temp) == |
| 1025 | QDF_STATUS_E_FAILURE) { |
| 1026 | hdd_err("Could not pass WNI_CFG_VHT_TX_MCS_MAP to CCM"); |
| 1027 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1028 | /* Get the current RX LDPC setting */ |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1029 | 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] | 1030 | &value); |
| 1031 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1032 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1033 | hdd_err("could not get VHT LDPC CODING CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1034 | value = 0; |
| 1035 | } |
| 1036 | |
| 1037 | /* Set the LDPC capability */ |
| 1038 | if (value && !cfg->vht_rx_ldpc) { |
| 1039 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1040 | WNI_CFG_VHT_LDPC_CODING_CAP, |
| 1041 | cfg->vht_rx_ldpc); |
| 1042 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1043 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1044 | hdd_alert("could not set VHT LDPC CODING CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1045 | } |
| 1046 | } |
| 1047 | |
| 1048 | /* Get current GI 80 value */ |
| 1049 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1050 | &value); |
| 1051 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1052 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1053 | hdd_err("could not get SHORT GI 80MHZ"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1054 | value = 0; |
| 1055 | } |
| 1056 | |
| 1057 | /* set the Guard interval 80MHz */ |
| 1058 | if (value && !cfg->vht_short_gi_80) { |
| 1059 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1060 | WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1061 | cfg->vht_short_gi_80); |
| 1062 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1063 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1064 | hdd_alert("could not set SHORT GI 80MHZ to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1065 | } |
| 1066 | } |
| 1067 | |
| 1068 | /* Get current GI 160 value */ |
| 1069 | status = sme_cfg_get_int(hdd_ctx->hHal, |
| 1070 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
| 1071 | &value); |
| 1072 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1073 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1074 | hdd_err("could not get SHORT GI 80 & 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1075 | value = 0; |
| 1076 | } |
| 1077 | |
| 1078 | /* Get VHT TX STBC cap */ |
| 1079 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, &value); |
| 1080 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1081 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1082 | hdd_err("could not get VHT TX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1083 | value = 0; |
| 1084 | } |
| 1085 | |
| 1086 | /* VHT TX STBC cap */ |
| 1087 | if (value && !cfg->vht_tx_stbc) { |
| 1088 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, |
| 1089 | cfg->vht_tx_stbc); |
| 1090 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1091 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1092 | hdd_alert("could not set the VHT TX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1093 | } |
| 1094 | } |
| 1095 | |
| 1096 | /* Get VHT RX STBC cap */ |
| 1097 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, &value); |
| 1098 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1099 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1100 | hdd_err("could not get VHT RX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1101 | value = 0; |
| 1102 | } |
| 1103 | |
| 1104 | /* VHT RX STBC cap */ |
| 1105 | if (value && !cfg->vht_rx_stbc) { |
| 1106 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, |
| 1107 | cfg->vht_rx_stbc); |
| 1108 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1109 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1110 | hdd_alert("could not set the VHT RX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1111 | } |
| 1112 | } |
| 1113 | |
| 1114 | /* Get VHT SU Beamformer cap */ |
| 1115 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1116 | &value); |
| 1117 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1118 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1119 | hdd_err("could not get VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1120 | value = 0; |
| 1121 | } |
| 1122 | |
| 1123 | /* set VHT SU Beamformer cap */ |
| 1124 | if (value && !cfg->vht_su_bformer) { |
| 1125 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1126 | WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1127 | cfg->vht_su_bformer); |
| 1128 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1129 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1130 | hdd_alert("could not set VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1131 | } |
| 1132 | } |
| 1133 | |
| 1134 | /* check and update SU BEAMFORMEE capabality */ |
| 1135 | if (pconfig->enableTxBF && !cfg->vht_su_bformee) |
| 1136 | pconfig->enableTxBF = cfg->vht_su_bformee; |
| 1137 | |
| 1138 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1139 | WNI_CFG_VHT_SU_BEAMFORMEE_CAP, |
| 1140 | pconfig->enableTxBF); |
| 1141 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1142 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1143 | hdd_alert("could not set VHT SU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1144 | } |
| 1145 | |
| 1146 | /* Get VHT MU Beamformer cap */ |
| 1147 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1148 | &value); |
| 1149 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1150 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1151 | hdd_err("could not get VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1152 | value = 0; |
| 1153 | } |
| 1154 | |
| 1155 | /* set VHT MU Beamformer cap */ |
| 1156 | if (value && !cfg->vht_mu_bformer) { |
| 1157 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1158 | WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1159 | cfg->vht_mu_bformer); |
| 1160 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1161 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1162 | hdd_alert("could not set the VHT MU BEAMFORMER CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1163 | } |
| 1164 | } |
| 1165 | |
| 1166 | /* Get VHT MU Beamformee cap */ |
| 1167 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1168 | &value); |
| 1169 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1170 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1171 | hdd_err("could not get VHT MU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1172 | value = 0; |
| 1173 | } |
| 1174 | |
| 1175 | /* set VHT MU Beamformee cap */ |
| 1176 | if (value && !cfg->vht_mu_bformee) { |
| 1177 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1178 | WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1179 | cfg->vht_mu_bformee); |
| 1180 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1181 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1182 | hdd_alert("could not set VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1183 | } |
| 1184 | } |
| 1185 | |
| 1186 | /* Get VHT MAX AMPDU Len exp */ |
| 1187 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1188 | &value); |
| 1189 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1190 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1191 | hdd_err("could not get VHT AMPDU LEN"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1192 | value = 0; |
| 1193 | } |
| 1194 | |
| 1195 | /* |
| 1196 | * VHT max AMPDU len exp: |
| 1197 | * override if user configured value is too high |
| 1198 | * that the target cannot support. |
| 1199 | * Even though Rome publish ampdu_len=7, it can |
| 1200 | * only support 4 because of some h/w bug. |
| 1201 | */ |
| 1202 | |
| 1203 | if (value > cfg->vht_max_ampdu_len_exp) { |
| 1204 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1205 | WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1206 | cfg->vht_max_ampdu_len_exp); |
| 1207 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1208 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1209 | hdd_alert("could not set the VHT AMPDU LEN EXP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1210 | } |
| 1211 | } |
| 1212 | |
| 1213 | /* Get VHT TXOP PS CAP */ |
| 1214 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, &value); |
| 1215 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1216 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1217 | hdd_err("could not get VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1218 | value = 0; |
| 1219 | } |
| 1220 | |
| 1221 | /* set VHT TXOP PS cap */ |
| 1222 | if (value && !cfg->vht_txop_ps) { |
| 1223 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, |
| 1224 | cfg->vht_txop_ps); |
| 1225 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1226 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1227 | hdd_alert("could not set the VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1228 | } |
| 1229 | } |
| 1230 | |
| 1231 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1232 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1233 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1234 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1235 | else |
| 1236 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1237 | |
| 1238 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1239 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) { |
| 1240 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1241 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1242 | VHT_CAP_160_AND_80P80_SUPP); |
| 1243 | if (status == QDF_STATUS_E_FAILURE) |
| 1244 | hdd_alert("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1245 | band_5g->vht_cap.cap |= |
| 1246 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1247 | ch_width = eHT_CHANNEL_WIDTH_80P80MHZ; |
| 1248 | } else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) { |
| 1249 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1250 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1251 | VHT_CAP_160_SUPP); |
| 1252 | if (status == QDF_STATUS_E_FAILURE) |
| 1253 | hdd_alert("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1254 | band_5g->vht_cap.cap |= |
| 1255 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1256 | ch_width = eHT_CHANNEL_WIDTH_160MHZ; |
| 1257 | } |
| 1258 | pconfig->vhtChannelWidth = QDF_MIN(pconfig->vhtChannelWidth, |
| 1259 | ch_width); |
| 1260 | /* Get the current supported chan width */ |
| 1261 | status = sme_cfg_get_int(hdd_ctx->hHal, |
| 1262 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1263 | &value); |
| 1264 | if (status != QDF_STATUS_SUCCESS) { |
| 1265 | hdd_err("could not get CH BW"); |
| 1266 | value = 0; |
| 1267 | } |
| 1268 | /* set the Guard interval 80MHz */ |
| 1269 | if (value) { |
| 1270 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1271 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
| 1272 | cfg->vht_short_gi_160); |
| 1273 | |
| 1274 | if (status == QDF_STATUS_E_FAILURE) |
| 1275 | hdd_alert("failed to set SHORT GI 80MHZ"); |
| 1276 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1277 | |
| 1278 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) |
| 1279 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1280 | |
| 1281 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1282 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1283 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1284 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1285 | |
| 1286 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1287 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1288 | |
| 1289 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1290 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1291 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1292 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1293 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1294 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1295 | |
| 1296 | band_5g->vht_cap.cap |= |
| 1297 | (cfg->vht_max_ampdu_len_exp << |
| 1298 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1299 | |
| 1300 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1301 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1302 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1303 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1304 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1305 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1306 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1307 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1308 | |
| 1309 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1310 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1311 | |
| 1312 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1313 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1314 | /** |
| 1315 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1316 | * @hdd_ctx: Pointer to the HDD context |
| 1317 | * |
| 1318 | * Auto-generate mac address using device serial number. |
| 1319 | * Keep the first 3 bytes of OUI as before and replace |
| 1320 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1321 | * |
| 1322 | * Return: 0 for success |
| 1323 | * Non zero failure code for errors |
| 1324 | */ |
| 1325 | static int hdd_generate_macaddr_auto(hdd_context_t *hdd_ctx) |
| 1326 | { |
| 1327 | unsigned int serialno = 0; |
| 1328 | struct qdf_mac_addr mac_addr = { |
| 1329 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1330 | }; |
| 1331 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1332 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1333 | if (serialno == 0) |
| 1334 | return -EINVAL; |
| 1335 | |
| 1336 | serialno &= 0x00ffffff; |
| 1337 | |
| 1338 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1339 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1340 | mac_addr.bytes[5] = serialno & 0xff; |
| 1341 | |
| 1342 | hdd_update_macaddr(hdd_ctx->config, mac_addr); |
| 1343 | return 0; |
| 1344 | } |
| 1345 | |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1346 | /** |
| 1347 | * hdd_update_ra_rate_limit() - Update RA rate limit from target |
| 1348 | * configuration to cfg_ini in HDD |
| 1349 | * @hdd_ctx: Pointer to hdd_ctx |
| 1350 | * @cfg: target configuration |
| 1351 | * |
| 1352 | * Return: None |
| 1353 | */ |
| 1354 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 1355 | static void hdd_update_ra_rate_limit(hdd_context_t *hdd_ctx, |
| 1356 | struct wma_tgt_cfg *cfg) |
| 1357 | { |
| 1358 | hdd_ctx->config->IsRArateLimitEnabled = cfg->is_ra_rate_limit_enabled; |
| 1359 | } |
| 1360 | #else |
| 1361 | static void hdd_update_ra_rate_limit(hdd_context_t *hdd_ctx, |
| 1362 | struct wma_tgt_cfg *cfg) |
| 1363 | { |
| 1364 | } |
| 1365 | #endif |
| 1366 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1367 | void hdd_update_tgt_cfg(void *context, void *param) |
| 1368 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1369 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1370 | hdd_context_t *hdd_ctx = (hdd_context_t *) context; |
| 1371 | struct wma_tgt_cfg *cfg = param; |
| 1372 | uint8_t temp_band_cap; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1373 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1374 | |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1375 | ret = hdd_create_and_store_pdev(hdd_ctx); |
| 1376 | if (ret) { |
| 1377 | hdd_err("pdev creation fails!"); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1378 | QDF_BUG(0); |
| 1379 | } |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1380 | |
| 1381 | if (cds_cfg) { |
| 1382 | if (hdd_ctx->config->enable_sub_20_channel_width != |
| 1383 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
| 1384 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1385 | cds_cfg->sub_20_channel_width = |
| 1386 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1387 | } else { |
| 1388 | cds_cfg->sub_20_channel_width = |
| 1389 | hdd_ctx->config->enable_sub_20_channel_width; |
| 1390 | } |
| 1391 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1392 | |
| 1393 | /* first store the INI band capability */ |
| 1394 | temp_band_cap = hdd_ctx->config->nBandCapability; |
| 1395 | |
| 1396 | hdd_ctx->config->nBandCapability = cfg->band_cap; |
| 1397 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 1398 | /* |
| 1399 | * now overwrite the target band capability with INI |
| 1400 | * setting if INI setting is a subset |
| 1401 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1402 | |
| 1403 | if ((hdd_ctx->config->nBandCapability == eCSR_BAND_ALL) && |
| 1404 | (temp_band_cap != eCSR_BAND_ALL)) |
| 1405 | hdd_ctx->config->nBandCapability = temp_band_cap; |
| 1406 | else if ((hdd_ctx->config->nBandCapability != eCSR_BAND_ALL) && |
| 1407 | (temp_band_cap != eCSR_BAND_ALL) && |
| 1408 | (hdd_ctx->config->nBandCapability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1409 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1410 | } |
| 1411 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 1412 | if (!cds_is_driver_recovering()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1413 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 1414 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 1415 | } |
| 1416 | |
| 1417 | /* This can be extended to other configurations like ht, vht cap... */ |
| 1418 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 1419 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1420 | hdd_update_macaddr(hdd_ctx->config, cfg->hw_macaddr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1421 | hdd_ctx->update_mac_addr_to_fw = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1422 | } else { |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1423 | static struct qdf_mac_addr default_mac_addr = { |
| 1424 | {0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF} |
| 1425 | }; |
| 1426 | if (qdf_is_macaddr_equal(&hdd_ctx->config->intfMacAddr[0], |
| 1427 | &default_mac_addr)) { |
| 1428 | if (hdd_generate_macaddr_auto(hdd_ctx) != 0) |
| 1429 | hdd_err("Fail to auto-generate MAC, using MAC from ini file " |
| 1430 | MAC_ADDRESS_STR, |
| 1431 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1432 | intfMacAddr[0].bytes)); |
| 1433 | } else { |
| 1434 | hdd_err("Invalid MAC passed from target, using MAC from ini file " |
| 1435 | MAC_ADDRESS_STR, |
| 1436 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1437 | intfMacAddr[0].bytes)); |
| 1438 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1439 | hdd_ctx->update_mac_addr_to_fw = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1440 | } |
| 1441 | |
| 1442 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 1443 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1444 | |
| 1445 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 1446 | |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 1447 | hdd_lpass_target_config(hdd_ctx, cfg); |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 1448 | hdd_green_ap_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1449 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1450 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 1451 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 1452 | |
| 1453 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 1454 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1455 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame^] | 1456 | if (cfg->services.en_11ax) { |
| 1457 | hdd_info("11AX: 11ax is enabled - update HDD config"); |
| 1458 | hdd_update_tgt_he_cap(hdd_ctx, cfg); |
| 1459 | } |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1460 | |
| 1461 | hdd_update_vdev_nss(hdd_ctx); |
| 1462 | |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1463 | hdd_ctx->config->fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 1464 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1465 | hdd_info("fine_time_meas_cap: 0x%x", |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1466 | hdd_ctx->config->fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1467 | |
| 1468 | hdd_ctx->current_antenna_mode = |
| 1469 | (hdd_ctx->config->enable2x2 == 0x01) ? |
| 1470 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 1471 | hdd_info("Init current antenna mode: %d", |
| 1472 | hdd_ctx->current_antenna_mode); |
| 1473 | |
Rajeev Kumar | dd3bc60 | 2016-08-16 14:21:05 -0700 | [diff] [blame] | 1474 | hdd_info("Target BPF %d Host BPF %d", |
| 1475 | cfg->bpf_enabled, hdd_ctx->config->bpf_packet_filter_enable); |
| 1476 | hdd_ctx->bpf_enabled = (cfg->bpf_enabled && |
| 1477 | hdd_ctx->config->bpf_packet_filter_enable); |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1478 | hdd_update_ra_rate_limit(hdd_ctx, cfg); |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1479 | |
Arun Khandavalli | d454d42 | 2016-08-17 12:47:05 +0530 | [diff] [blame] | 1480 | /* |
| 1481 | * If BPF is enabled, maxWowFilters set to WMA_STA_WOW_DEFAULT_PTRN_MAX |
| 1482 | * because we need atleast WMA_STA_WOW_DEFAULT_PTRN_MAX free slots to |
| 1483 | * configure the STA mode wow pattern. |
| 1484 | */ |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1485 | if (hdd_ctx->bpf_enabled) |
Arun Khandavalli | d454d42 | 2016-08-17 12:47:05 +0530 | [diff] [blame] | 1486 | hdd_ctx->config->maxWoWFilters = WMA_STA_WOW_DEFAULT_PTRN_MAX; |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1487 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 1488 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 1489 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 1490 | /* Configure NAN datapath features */ |
| 1491 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1492 | } |
| 1493 | |
| 1494 | /** |
| 1495 | * hdd_dfs_indicate_radar() - handle radar detection on current SAP channel |
| 1496 | * @context: HDD context pointer |
| 1497 | * @param: HDD radar indication pointer |
| 1498 | * |
Sandeep Puligilla | a8d4eec | 2016-06-30 15:13:11 -0700 | [diff] [blame] | 1499 | * This function is invoked in atomic context when a radar |
| 1500 | * is found on the SAP current operating channel and Data Tx |
| 1501 | * from netif has to be stopped to honor the DFS regulations. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1502 | * Actions: Stop the netif Tx queues,Indicate Radar present |
| 1503 | * in HDD context for future usage. |
| 1504 | * |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1505 | * Return: true to allow radar indication to host else false |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1506 | */ |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1507 | bool hdd_dfs_indicate_radar(void *context, void *param) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1508 | { |
| 1509 | hdd_context_t *hdd_ctx = (hdd_context_t *) context; |
| 1510 | struct wma_dfs_radar_ind *hdd_radar_event = |
| 1511 | (struct wma_dfs_radar_ind *)param; |
| 1512 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 1513 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1514 | QDF_STATUS status; |
Manishekar Chandrasekaran | 11ecd55 | 2016-08-31 12:44:05 +0530 | [diff] [blame] | 1515 | hdd_ap_ctx_t *ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1516 | |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1517 | if (!hdd_ctx || !hdd_radar_event || |
| 1518 | hdd_ctx->config->disableDFSChSwitch) |
| 1519 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1520 | |
| 1521 | if (true == hdd_radar_event->dfs_radar_status) { |
Arif Hussain | 2a7c1f3 | 2016-07-18 14:24:36 -0700 | [diff] [blame] | 1522 | if (qdf_atomic_inc_return(&hdd_ctx->dfs_radar_found) > 1) { |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1523 | /* |
| 1524 | * Application already triggered channel switch |
| 1525 | * on current channel, so return here. |
| 1526 | */ |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1527 | return false; |
| 1528 | } |
| 1529 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1530 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1531 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1532 | adapter = adapterNode->pAdapter; |
Manishekar Chandrasekaran | 11ecd55 | 2016-08-31 12:44:05 +0530 | [diff] [blame] | 1533 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 1534 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 1535 | QDF_P2P_GO_MODE == adapter->device_mode) && |
| 1536 | (CHANNEL_STATE_DFS == |
| 1537 | cds_get_channel_state(ap_ctx->operatingChannel))) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1538 | WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
| 1539 | dfs_cac_block_tx = true; |
Manishekar Chandrasekaran | 11ecd55 | 2016-08-31 12:44:05 +0530 | [diff] [blame] | 1540 | hdd_info("tx blocked for session:%d", |
| 1541 | adapter->sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1542 | } |
| 1543 | |
| 1544 | status = hdd_get_next_adapter(hdd_ctx, |
| 1545 | adapterNode, |
| 1546 | &pNext); |
| 1547 | adapterNode = pNext; |
| 1548 | } |
| 1549 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1550 | |
| 1551 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1552 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1553 | |
| 1554 | /** |
| 1555 | * hdd_is_valid_mac_address() - validate MAC address |
| 1556 | * @pMacAddr: Pointer to the input MAC address |
| 1557 | * |
| 1558 | * This function validates whether the given MAC address is valid or not |
| 1559 | * Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 1560 | * where X is the hexa decimal digit character and separated by ':' |
| 1561 | * This algorithm works even if MAC address is not separated by ':' |
| 1562 | * |
| 1563 | * This code checks given input string mac contains exactly 12 hexadecimal |
| 1564 | * digits and a separator colon : appears in the input string only after |
| 1565 | * an even number of hex digits. |
| 1566 | * |
| 1567 | * Return: 1 for valid and 0 for invalid |
| 1568 | */ |
| 1569 | bool hdd_is_valid_mac_address(const uint8_t *pMacAddr) |
| 1570 | { |
| 1571 | int xdigit = 0; |
| 1572 | int separator = 0; |
| 1573 | while (*pMacAddr) { |
| 1574 | if (isxdigit(*pMacAddr)) { |
| 1575 | xdigit++; |
| 1576 | } else if (':' == *pMacAddr) { |
| 1577 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 1578 | break; |
| 1579 | |
| 1580 | ++separator; |
| 1581 | } else { |
| 1582 | /* Invalid MAC found */ |
| 1583 | return 0; |
| 1584 | } |
| 1585 | ++pMacAddr; |
| 1586 | } |
| 1587 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 1588 | } |
| 1589 | |
| 1590 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 1591 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 1592 | * @dev: Handle to struct net_device to be updated. |
| 1593 | * |
| 1594 | * Return: None |
| 1595 | */ |
| 1596 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 1597 | { |
| 1598 | dev->header_ops = NULL; |
| 1599 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 1600 | dev->hard_header_len = ETH_HLEN; |
| 1601 | dev->mtu = ETH_DATA_LEN; |
| 1602 | dev->addr_len = ETH_ALEN; |
| 1603 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 1604 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 1605 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 1606 | |
| 1607 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 1608 | } |
| 1609 | |
| 1610 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1611 | * __hdd__mon_open() - HDD Open function |
| 1612 | * @dev: Pointer to net_device structure |
| 1613 | * |
| 1614 | * This is called in response to ifconfig up |
| 1615 | * |
| 1616 | * Return: 0 for success; non-zero for failure |
| 1617 | */ |
| 1618 | static int __hdd_mon_open(struct net_device *dev) |
| 1619 | { |
| 1620 | int ret; |
| 1621 | |
| 1622 | ENTER_DEV(dev); |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 1623 | hdd_mon_mode_ether_setup(dev); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1624 | ret = hdd_set_mon_rx_cb(dev); |
| 1625 | return ret; |
| 1626 | } |
| 1627 | |
| 1628 | /** |
| 1629 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 1630 | * @dev: Pointer to net_device structure |
| 1631 | * |
| 1632 | * This is called in response to ifconfig up |
| 1633 | * |
| 1634 | * Return: 0 for success; non-zero for failure |
| 1635 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 1636 | static int hdd_mon_open(struct net_device *dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1637 | { |
| 1638 | int ret; |
| 1639 | |
| 1640 | cds_ssr_protect(__func__); |
| 1641 | ret = __hdd_mon_open(dev); |
| 1642 | cds_ssr_unprotect(__func__); |
| 1643 | |
| 1644 | return ret; |
| 1645 | } |
| 1646 | |
| 1647 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1648 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 1649 | * @adapter: pointer to HDD adapter |
| 1650 | * |
| 1651 | * This function is called to start the device specific adapter for |
| 1652 | * the mode passed in the adapter's device_mode. |
| 1653 | * |
| 1654 | * Return: 0 for success; non-zero for failure |
| 1655 | */ |
| 1656 | int hdd_start_adapter(hdd_adapter_t *adapter) |
| 1657 | { |
| 1658 | |
| 1659 | int ret; |
| 1660 | enum tQDF_ADAPTER_MODE device_mode = adapter->device_mode; |
| 1661 | |
| 1662 | ENTER_DEV(adapter->dev); |
| 1663 | hdd_info("Start_adapter for mode : %d", adapter->device_mode); |
| 1664 | |
| 1665 | switch (device_mode) { |
| 1666 | case QDF_P2P_CLIENT_MODE: |
| 1667 | case QDF_P2P_DEVICE_MODE: |
| 1668 | case QDF_OCB_MODE: |
| 1669 | case QDF_STA_MODE: |
| 1670 | case QDF_MONITOR_MODE: |
| 1671 | ret = hdd_start_station_adapter(adapter); |
| 1672 | if (ret) |
| 1673 | goto err_start_adapter; |
| 1674 | break; |
| 1675 | case QDF_P2P_GO_MODE: |
| 1676 | case QDF_SAP_MODE: |
| 1677 | ret = hdd_start_ap_adapter(adapter); |
| 1678 | if (ret) |
| 1679 | goto err_start_adapter; |
| 1680 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 1681 | case QDF_IBSS_MODE: |
| 1682 | /* |
| 1683 | * For IBSS interface is initialized as part of |
| 1684 | * hdd_init_station_mode() |
| 1685 | */ |
| 1686 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1687 | case QDF_FTM_MODE: |
| 1688 | ret = hdd_start_ftm_adapter(adapter); |
| 1689 | if (ret) |
| 1690 | goto err_start_adapter; |
| 1691 | break; |
| 1692 | default: |
| 1693 | hdd_err("Invalid session type %d", device_mode); |
| 1694 | QDF_ASSERT(0); |
| 1695 | goto err_start_adapter; |
| 1696 | } |
| 1697 | if (hdd_set_fw_params(adapter)) |
| 1698 | hdd_err("Failed to set the FW params for the adapter!"); |
| 1699 | |
| 1700 | /* |
| 1701 | * Action frame registered in one adapter which will |
| 1702 | * applicable to all interfaces |
| 1703 | */ |
| 1704 | wlan_hdd_cfg80211_register_frames(adapter); |
| 1705 | EXIT(); |
| 1706 | return 0; |
| 1707 | err_start_adapter: |
| 1708 | return -EINVAL; |
| 1709 | } |
| 1710 | |
| 1711 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 1712 | * hdd_enable_power_management() - API to Enable Power Management |
| 1713 | * |
| 1714 | * API invokes Bus Interface Layer power management functionality |
| 1715 | * |
| 1716 | * Return: None |
| 1717 | */ |
| 1718 | static void hdd_enable_power_management(void) |
| 1719 | { |
| 1720 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 1721 | |
| 1722 | if (!hif_ctx) { |
| 1723 | hdd_err("Bus Interface Context is Invalid"); |
| 1724 | return; |
| 1725 | } |
| 1726 | |
| 1727 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 1728 | } |
| 1729 | |
| 1730 | /** |
| 1731 | * hdd_disable_power_management() - API to disable Power Management |
| 1732 | * |
| 1733 | * API disable Bus Interface Layer Power management functionality |
| 1734 | * |
| 1735 | * Return: None |
| 1736 | */ |
| 1737 | static void hdd_disable_power_management(void) |
| 1738 | { |
| 1739 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 1740 | |
| 1741 | if (!hif_ctx) { |
| 1742 | hdd_err("Bus Interface Context is Invalid"); |
| 1743 | return; |
| 1744 | } |
| 1745 | |
| 1746 | hif_disable_power_management(hif_ctx); |
| 1747 | } |
| 1748 | |
| 1749 | /** |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 1750 | * hdd_update_hw_sw_info() - API to update the HW/SW information |
| 1751 | * |
| 1752 | * API to update the HW and SW information in the driver |
| 1753 | * |
| 1754 | * Return: None |
| 1755 | */ |
| 1756 | static void hdd_update_hw_sw_info(hdd_context_t *hdd_ctx) |
| 1757 | { |
| 1758 | void *hif_sc; |
| 1759 | |
| 1760 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
| 1761 | if (!hif_sc) { |
| 1762 | hdd_err("HIF context is NULL"); |
| 1763 | return; |
| 1764 | } |
| 1765 | |
| 1766 | /* |
| 1767 | * target hw version/revision would only be retrieved after firmware |
| 1768 | * download |
| 1769 | */ |
| 1770 | hif_get_hw_info(hif_sc, &hdd_ctx->target_hw_version, |
| 1771 | &hdd_ctx->target_hw_revision, |
| 1772 | &hdd_ctx->target_hw_name); |
| 1773 | |
| 1774 | /* Get the wlan hw/fw version */ |
| 1775 | hdd_wlan_get_version(hdd_ctx, NULL, NULL); |
| 1776 | |
| 1777 | return; |
| 1778 | } |
| 1779 | |
| 1780 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 1781 | * hdd_update_cds_ac_specs_params() - update cds ac_specs params |
| 1782 | * @hdd_ctx: Pointer to hdd context |
| 1783 | * |
| 1784 | * Return: none |
| 1785 | */ |
| 1786 | static void |
| 1787 | hdd_update_cds_ac_specs_params(hdd_context_t *hdd_ctx) |
| 1788 | { |
| 1789 | uint8_t num_entries = 0; |
| 1790 | uint8_t tx_sched_wrr_param[TX_SCHED_WRR_PARAMS_NUM]; |
| 1791 | uint8_t *tx_sched_wrr_ac; |
| 1792 | int i; |
| 1793 | cds_context_type *cds_ctx; |
| 1794 | |
| 1795 | if (NULL == hdd_ctx) |
| 1796 | return; |
| 1797 | |
| 1798 | if (NULL == hdd_ctx->config) { |
| 1799 | /* Do nothing if hdd_ctx is invalid */ |
| 1800 | hdd_err("%s: Warning: hdd_ctx->cfg_ini is NULL", __func__); |
| 1801 | return; |
| 1802 | } |
| 1803 | |
| 1804 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 1805 | |
| 1806 | if (!cds_ctx) { |
| 1807 | hdd_err("Invalid CDS Context"); |
| 1808 | return; |
| 1809 | } |
| 1810 | |
| 1811 | for (i = 0; i < OL_TX_NUM_WMM_AC; i++) { |
| 1812 | switch (i) { |
| 1813 | case OL_TX_WMM_AC_BE: |
| 1814 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_be; |
| 1815 | break; |
| 1816 | case OL_TX_WMM_AC_BK: |
| 1817 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_bk; |
| 1818 | break; |
| 1819 | case OL_TX_WMM_AC_VI: |
| 1820 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vi; |
| 1821 | break; |
| 1822 | case OL_TX_WMM_AC_VO: |
| 1823 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vo; |
| 1824 | break; |
| 1825 | default: |
| 1826 | tx_sched_wrr_ac = NULL; |
| 1827 | break; |
| 1828 | } |
| 1829 | |
| 1830 | hdd_string_to_u8_array(tx_sched_wrr_ac, |
| 1831 | tx_sched_wrr_param, |
| 1832 | &num_entries, |
| 1833 | sizeof(tx_sched_wrr_param)); |
| 1834 | |
| 1835 | if (num_entries == TX_SCHED_WRR_PARAMS_NUM) { |
| 1836 | cds_ctx->ac_specs[i].wrr_skip_weight = |
| 1837 | tx_sched_wrr_param[0]; |
| 1838 | cds_ctx->ac_specs[i].credit_threshold = |
| 1839 | tx_sched_wrr_param[1]; |
| 1840 | cds_ctx->ac_specs[i].send_limit = |
| 1841 | tx_sched_wrr_param[2]; |
| 1842 | cds_ctx->ac_specs[i].credit_reserve = |
| 1843 | tx_sched_wrr_param[3]; |
| 1844 | cds_ctx->ac_specs[i].discard_weight = |
| 1845 | tx_sched_wrr_param[4]; |
| 1846 | } |
| 1847 | |
| 1848 | num_entries = 0; |
| 1849 | } |
| 1850 | } |
| 1851 | |
| 1852 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1853 | * hdd_wlan_start_modules() - Single driver state machine for starting modules |
| 1854 | * @hdd_ctx: HDD context |
| 1855 | * @adapter: HDD adapter |
| 1856 | * @reinit: flag to indicate from SSR or normal path |
| 1857 | * |
| 1858 | * This function maintains the driver state machine it will be invoked from |
| 1859 | * startup, reinit and change interface. Depending on the driver state shall |
| 1860 | * perform the opening of the modules. |
| 1861 | * |
| 1862 | * Return: 0 for success; non-zero for failure |
| 1863 | */ |
| 1864 | int hdd_wlan_start_modules(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, |
| 1865 | bool reinit) |
| 1866 | { |
| 1867 | int ret; |
| 1868 | qdf_device_t qdf_dev; |
| 1869 | QDF_STATUS status; |
| 1870 | p_cds_contextType p_cds_context; |
| 1871 | bool unint = false; |
| 1872 | void *hif_ctx; |
| 1873 | |
| 1874 | ENTER(); |
| 1875 | |
| 1876 | p_cds_context = cds_get_global_context(); |
| 1877 | if (!p_cds_context) { |
| 1878 | hdd_err("Global Context is NULL"); |
| 1879 | QDF_ASSERT(0); |
| 1880 | return -EINVAL; |
| 1881 | } |
| 1882 | |
| 1883 | hdd_info("start modules called in state! :%d reinit: %d", |
| 1884 | hdd_ctx->driver_status, reinit); |
| 1885 | |
| 1886 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 1887 | if (!qdf_dev) { |
| 1888 | hdd_err("QDF Device Context is Invalid return"); |
| 1889 | return -EINVAL; |
| 1890 | } |
| 1891 | |
| 1892 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 1893 | hdd_ctx->start_modules_in_progress = true; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1894 | |
| 1895 | if (QDF_TIMER_STATE_RUNNING == |
| 1896 | qdf_mc_timer_get_current_state(&hdd_ctx->iface_change_timer)) { |
| 1897 | |
| 1898 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 1899 | hdd_info("Interface change Timer running Stop timer"); |
| 1900 | qdf_mc_timer_stop(&hdd_ctx->iface_change_timer); |
| 1901 | } |
| 1902 | |
| 1903 | switch (hdd_ctx->driver_status) { |
| 1904 | case DRIVER_MODULES_UNINITIALIZED: |
| 1905 | unint = true; |
| 1906 | /* Fall through dont add break here */ |
| 1907 | case DRIVER_MODULES_CLOSED: |
| 1908 | if (!reinit && !unint) { |
| 1909 | ret = pld_power_on(qdf_dev->dev); |
| 1910 | if (ret) { |
| 1911 | hdd_err("Failed to Powerup the device: %d", ret); |
| 1912 | goto release_lock; |
| 1913 | } |
| 1914 | } |
| 1915 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 1916 | qdf_dev->bus_type, |
| 1917 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 1918 | HIF_ENABLE_TYPE_PROBE); |
| 1919 | if (ret) { |
| 1920 | hdd_err("Failed to open hif: %d", ret); |
| 1921 | goto power_down; |
| 1922 | } |
| 1923 | |
| 1924 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 1925 | if (!hif_ctx) { |
| 1926 | hdd_err("hif context is null!!"); |
| 1927 | goto power_down; |
| 1928 | } |
| 1929 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1930 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 1931 | if (status != QDF_STATUS_SUCCESS) { |
| 1932 | hdd_err("No Memory to Create BMI Context :%d", status); |
| 1933 | goto hif_close; |
| 1934 | } |
| 1935 | |
Rajeev Kumar | 138ef91 | 2017-01-13 15:19:48 -0800 | [diff] [blame] | 1936 | ret = hdd_create_and_store_psoc(hdd_ctx, DEFAULT_PSOC_ID); |
| 1937 | if (ret) { |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1938 | hdd_err("Psoc creation fails!"); |
| 1939 | goto ol_cds_free; |
| 1940 | } |
| 1941 | |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 1942 | ret = hdd_update_config(hdd_ctx); |
| 1943 | if (ret) { |
| 1944 | hdd_err("Failed to update configuration :%d", ret); |
| 1945 | goto destroy_psoc_object; |
| 1946 | } |
| 1947 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 1948 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 1949 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1950 | status = cds_open(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1951 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 1952 | hdd_err("Failed to Open CDS: %d", status); |
Selvaraj, Sridhar | a7dc238 | 2017-01-27 18:29:39 +0530 | [diff] [blame] | 1953 | goto destroy_psoc_object; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1954 | } |
| 1955 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 1956 | /* initalize components configurations after psoc open */ |
| 1957 | ret = hdd_update_components_config(hdd_ctx); |
| 1958 | if (ret) { |
| 1959 | hdd_err("Failed to update components configs :%d", |
| 1960 | ret); |
| 1961 | goto close; |
| 1962 | } |
| 1963 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1964 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
| 1965 | |
| 1966 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
| 1967 | |
| 1968 | status = cds_pre_enable(hdd_ctx->pcds_context); |
| 1969 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 1970 | hdd_err("Failed to pre-enable CDS: %d", status); |
| 1971 | goto close; |
| 1972 | } |
| 1973 | |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 1974 | hdd_update_hw_sw_info(hdd_ctx); |
| 1975 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1976 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 1977 | sme_register_ftm_msg_processor(hdd_ctx->hHal, |
| 1978 | hdd_ftm_mc_process_msg); |
| 1979 | break; |
| 1980 | } |
| 1981 | if (unint) { |
| 1982 | hdd_info("In phase-1 initialization don't enable modules"); |
| 1983 | break; |
| 1984 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 1985 | |
| 1986 | if (reinit) { |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 1987 | if (hdd_ipa_uc_ssr_reinit(hdd_ctx)) { |
| 1988 | hdd_err("HDD IPA UC reinit failed"); |
| 1989 | goto close; |
| 1990 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 1991 | } |
| 1992 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1993 | /* Fall through dont add break here */ |
| 1994 | case DRIVER_MODULES_OPENED: |
| 1995 | if (!adapter) { |
| 1996 | hdd_alert("adapter is Null"); |
| 1997 | goto close; |
| 1998 | } |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 1999 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2000 | hdd_err("in ftm mode, no need to configure cds modules"); |
| 2001 | break; |
| 2002 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2003 | if (hdd_configure_cds(hdd_ctx, adapter)) { |
| 2004 | hdd_err("Failed to Enable cds modules"); |
| 2005 | goto close; |
| 2006 | } |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2007 | hdd_enable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2008 | hdd_info("Driver Modules Successfully Enabled"); |
| 2009 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
| 2010 | break; |
| 2011 | case DRIVER_MODULES_ENABLED: |
| 2012 | hdd_info("Driver modules already Enabled"); |
| 2013 | break; |
| 2014 | default: |
| 2015 | hdd_err("WLAN start invoked in wrong state! :%d\n", |
| 2016 | hdd_ctx->driver_status); |
| 2017 | goto release_lock; |
| 2018 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2019 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2020 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 2021 | EXIT(); |
| 2022 | return 0; |
| 2023 | |
| 2024 | close: |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2025 | cds_close(hdd_ctx->hdd_psoc, p_cds_context); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2026 | |
Selvaraj, Sridhar | a7dc238 | 2017-01-27 18:29:39 +0530 | [diff] [blame] | 2027 | destroy_psoc_object: |
| 2028 | hdd_release_and_destroy_psoc(hdd_ctx); |
| 2029 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2030 | ol_cds_free: |
| 2031 | ol_cds_free(); |
| 2032 | |
| 2033 | hif_close: |
| 2034 | hdd_hif_close(p_cds_context->pHIFContext); |
| 2035 | power_down: |
| 2036 | if (!reinit && !unint) |
| 2037 | pld_power_off(qdf_dev->dev); |
| 2038 | release_lock: |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2039 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2040 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2041 | EXIT(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2042 | return -EINVAL; |
| 2043 | } |
| 2044 | |
| 2045 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2046 | * __hdd_open() - HDD Open function |
| 2047 | * @dev: Pointer to net_device structure |
| 2048 | * |
| 2049 | * This is called in response to ifconfig up |
| 2050 | * |
| 2051 | * Return: 0 for success; non-zero for failure |
| 2052 | */ |
| 2053 | static int __hdd_open(struct net_device *dev) |
| 2054 | { |
| 2055 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2056 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2057 | int ret; |
| 2058 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2059 | ENTER_DEV(dev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2060 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2061 | adapter->sessionId, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2062 | |
| 2063 | ret = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2064 | if (ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2065 | return ret; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2066 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2067 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2068 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 2069 | if (ret) { |
| 2070 | hdd_err("Failed to start WLAN modules return"); |
| 2071 | return -ret; |
| 2072 | } |
| 2073 | |
| 2074 | |
| 2075 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2076 | ret = hdd_start_adapter(adapter); |
| 2077 | if (ret) { |
| 2078 | hdd_err("Failed to start adapter :%d", |
| 2079 | adapter->device_mode); |
| 2080 | return ret; |
| 2081 | } |
| 2082 | } |
| 2083 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2084 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2085 | if (hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2086 | hdd_info("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2087 | /* Enable TX queues only when we are connected */ |
| 2088 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2089 | WLAN_START_ALL_NETIF_QUEUE, |
| 2090 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2091 | } |
| 2092 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2093 | /* Enable carrier and transmit queues for NDI */ |
| 2094 | if (WLAN_HDD_IS_NDI(adapter)) { |
| 2095 | hdd_notice("Enabling Tx Queues"); |
| 2096 | wlan_hdd_netif_queue_control(adapter, |
| 2097 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 2098 | WLAN_CONTROL_PATH); |
| 2099 | } |
| 2100 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2101 | return ret; |
| 2102 | } |
| 2103 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2104 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2105 | /** |
| 2106 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 2107 | * @dev: Pointer to net_device structure |
| 2108 | * |
| 2109 | * This is called in response to ifconfig up |
| 2110 | * |
| 2111 | * Return: 0 for success; non-zero for failure |
| 2112 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2113 | static int hdd_open(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2114 | { |
| 2115 | int ret; |
| 2116 | |
| 2117 | cds_ssr_protect(__func__); |
| 2118 | ret = __hdd_open(dev); |
| 2119 | cds_ssr_unprotect(__func__); |
| 2120 | |
| 2121 | return ret; |
| 2122 | } |
| 2123 | |
| 2124 | /** |
| 2125 | * __hdd_stop() - HDD stop function |
| 2126 | * @dev: Pointer to net_device structure |
| 2127 | * |
| 2128 | * This is called in response to ifconfig down |
| 2129 | * |
| 2130 | * Return: 0 for success; non-zero for failure |
| 2131 | */ |
| 2132 | static int __hdd_stop(struct net_device *dev) |
| 2133 | { |
| 2134 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2135 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2136 | int ret; |
| 2137 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2138 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2139 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2140 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2141 | adapter->sessionId, adapter->device_mode)); |
| 2142 | |
| 2143 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 2144 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2145 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2146 | |
| 2147 | /* Nothing to be done if the interface is not opened */ |
| 2148 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2149 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2150 | return -ENODEV; |
| 2151 | } |
| 2152 | |
| 2153 | /* Make sure the interface is marked as closed */ |
| 2154 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2155 | hdd_notice("Disabling OS Tx queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2156 | |
| 2157 | /* |
| 2158 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 2159 | * be called on that interface |
| 2160 | */ |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2161 | hdd_notice("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2162 | wlan_hdd_netif_queue_control(adapter, WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 2163 | WLAN_CONTROL_PATH); |
| 2164 | |
| 2165 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2166 | * NAN data interface is different in some sense. The traffic on NDI is |
| 2167 | * bursty in nature and depends on the need to transfer. The service |
| 2168 | * layer may down the interface after the usage and up again when |
| 2169 | * required. In some sense, the NDI is expected to be available |
| 2170 | * (like SAP) iface until NDI delete request is issued by the service |
| 2171 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 2172 | * interface (NDI). |
| 2173 | */ |
| 2174 | if (WLAN_HDD_IS_NDI(adapter)) |
| 2175 | return 0; |
| 2176 | |
| 2177 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2178 | * The interface is marked as down for outside world (aka kernel) |
| 2179 | * But the driver is pretty much alive inside. The driver needs to |
| 2180 | * tear down the existing connection on the netdev (session) |
| 2181 | * cleanup the data pipes and wait until the control plane is stabilized |
| 2182 | * for this interface. The call also needs to wait until the above |
| 2183 | * mentioned actions are completed before returning to the caller. |
| 2184 | * Notice that the hdd_stop_adapter is requested not to close the session |
| 2185 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 2186 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2187 | hdd_stop_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2188 | |
| 2189 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 2190 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 2191 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2192 | |
| 2193 | /* |
| 2194 | * Find if any iface is up. If any iface is up then can't put device to |
| 2195 | * sleep/power save mode |
| 2196 | */ |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 2197 | if (hdd_check_for_opened_interfaces(hdd_ctx)) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2198 | hdd_info("Closing all modules from the hdd_stop"); |
| 2199 | qdf_mc_timer_start(&hdd_ctx->iface_change_timer, |
| 2200 | hdd_ctx->config->iface_change_wait_time |
| 2201 | * 50000); |
| 2202 | } |
| 2203 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2204 | EXIT(); |
| 2205 | return 0; |
| 2206 | } |
| 2207 | |
| 2208 | /** |
| 2209 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 2210 | * @dev: pointer to net_device structure |
| 2211 | * |
| 2212 | * This is called in response to ifconfig down |
| 2213 | * |
| 2214 | * Return: 0 for success and error number for failure |
| 2215 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2216 | static int hdd_stop(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2217 | { |
| 2218 | int ret; |
| 2219 | |
| 2220 | cds_ssr_protect(__func__); |
| 2221 | ret = __hdd_stop(dev); |
| 2222 | cds_ssr_unprotect(__func__); |
| 2223 | |
| 2224 | return ret; |
| 2225 | } |
| 2226 | |
| 2227 | /** |
| 2228 | * __hdd_uninit() - HDD uninit function |
| 2229 | * @dev: Pointer to net_device structure |
| 2230 | * |
| 2231 | * This is called during the netdev unregister to uninitialize all data |
| 2232 | * associated with the device |
| 2233 | * |
| 2234 | * Return: None |
| 2235 | */ |
| 2236 | static void __hdd_uninit(struct net_device *dev) |
| 2237 | { |
| 2238 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2239 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2240 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2241 | |
| 2242 | do { |
| 2243 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2244 | hdd_alert("Invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2245 | break; |
| 2246 | } |
| 2247 | |
| 2248 | if (NULL == adapter->pHddCtx) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2249 | hdd_alert("NULL hdd_ctx"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2250 | break; |
| 2251 | } |
| 2252 | |
| 2253 | if (dev != adapter->dev) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2254 | hdd_alert("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2255 | /* |
| 2256 | * we haven't validated all cases so let this go for |
| 2257 | * now |
| 2258 | */ |
| 2259 | } |
| 2260 | |
| 2261 | hdd_deinit_adapter(adapter->pHddCtx, adapter, true); |
| 2262 | |
| 2263 | /* after uninit our adapter structure will no longer be valid */ |
| 2264 | adapter->dev = NULL; |
| 2265 | adapter->magic = 0; |
| 2266 | } while (0); |
| 2267 | |
| 2268 | EXIT(); |
| 2269 | } |
| 2270 | |
| 2271 | /** |
| 2272 | * hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 2273 | * @dev: pointer to net_device structure |
| 2274 | * |
| 2275 | * This is called during the netdev unregister to uninitialize all data |
| 2276 | * associated with the device |
| 2277 | * |
| 2278 | * Return: none |
| 2279 | */ |
| 2280 | static void hdd_uninit(struct net_device *dev) |
| 2281 | { |
| 2282 | cds_ssr_protect(__func__); |
| 2283 | __hdd_uninit(dev); |
| 2284 | cds_ssr_unprotect(__func__); |
| 2285 | } |
| 2286 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2287 | static int hdd_open_cesium_nl_sock(void) |
| 2288 | { |
| 2289 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 2290 | struct netlink_kernel_cfg cfg = { |
| 2291 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 2292 | .input = NULL |
| 2293 | }; |
| 2294 | #endif |
| 2295 | int ret = 0; |
| 2296 | |
| 2297 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 2298 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 2299 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 2300 | THIS_MODULE, |
| 2301 | #endif |
| 2302 | &cfg); |
| 2303 | #else |
| 2304 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 2305 | WLAN_NLINK_MCAST_GRP_ID, |
| 2306 | NULL, NULL, THIS_MODULE); |
| 2307 | #endif |
| 2308 | |
| 2309 | if (cesium_nl_srv_sock == NULL) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2310 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2311 | ret = -ECONNREFUSED; |
| 2312 | } |
| 2313 | |
| 2314 | return ret; |
| 2315 | } |
| 2316 | |
| 2317 | static void hdd_close_cesium_nl_sock(void) |
| 2318 | { |
| 2319 | if (NULL != cesium_nl_srv_sock) { |
| 2320 | netlink_kernel_release(cesium_nl_srv_sock); |
| 2321 | cesium_nl_srv_sock = NULL; |
| 2322 | } |
| 2323 | } |
| 2324 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2325 | /** |
| 2326 | * __hdd_set_mac_address() - set the user specified mac address |
| 2327 | * @dev: Pointer to the net device. |
| 2328 | * @addr: Pointer to the sockaddr. |
| 2329 | * |
| 2330 | * This function sets the user specified mac address using |
| 2331 | * the command ifconfig wlanX hw ether <mac adress>. |
| 2332 | * |
| 2333 | * Return: 0 for success, non zero for failure |
| 2334 | */ |
| 2335 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 2336 | { |
| 2337 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2338 | hdd_context_t *hdd_ctx; |
| 2339 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2340 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2341 | int ret; |
| 2342 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2343 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2344 | |
| 2345 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2346 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2347 | if (0 != ret) |
| 2348 | return ret; |
| 2349 | |
| 2350 | memcpy(&adapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN); |
| 2351 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 2352 | |
| 2353 | EXIT(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2354 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2355 | } |
| 2356 | |
| 2357 | /** |
| 2358 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
| 2359 | * function from SSR |
| 2360 | * @dev: pointer to net_device structure |
| 2361 | * @addr: Pointer to the sockaddr |
| 2362 | * |
| 2363 | * This function sets the user specified mac address using |
| 2364 | * the command ifconfig wlanX hw ether <mac adress>. |
| 2365 | * |
| 2366 | * Return: 0 for success. |
| 2367 | */ |
| 2368 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 2369 | { |
| 2370 | int ret; |
| 2371 | |
| 2372 | cds_ssr_protect(__func__); |
| 2373 | ret = __hdd_set_mac_address(dev, addr); |
| 2374 | cds_ssr_unprotect(__func__); |
| 2375 | |
| 2376 | return ret; |
| 2377 | } |
| 2378 | |
| 2379 | uint8_t *wlan_hdd_get_intf_addr(hdd_context_t *hdd_ctx) |
| 2380 | { |
| 2381 | int i; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2382 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2383 | if (0 == ((hdd_ctx->config->intfAddrMask) & (1 << i))) |
| 2384 | break; |
| 2385 | } |
| 2386 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2387 | if (QDF_MAX_CONCURRENCY_PERSONA == i) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2388 | return NULL; |
| 2389 | |
| 2390 | hdd_ctx->config->intfAddrMask |= (1 << i); |
| 2391 | return &hdd_ctx->config->intfMacAddr[i].bytes[0]; |
| 2392 | } |
| 2393 | |
| 2394 | void wlan_hdd_release_intf_addr(hdd_context_t *hdd_ctx, uint8_t *releaseAddr) |
| 2395 | { |
| 2396 | int i; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2397 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2398 | if (!memcmp(releaseAddr, |
| 2399 | &hdd_ctx->config->intfMacAddr[i].bytes[0], |
| 2400 | 6)) { |
| 2401 | hdd_ctx->config->intfAddrMask &= ~(1 << i); |
| 2402 | break; |
| 2403 | } |
| 2404 | } |
| 2405 | return; |
| 2406 | } |
| 2407 | |
| 2408 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 2409 | /** |
| 2410 | * __hdd_set_multicast_list() - set the multicast address list |
| 2411 | * @dev: Pointer to the WLAN device. |
| 2412 | * @skb: Pointer to OS packet (sk_buff). |
| 2413 | * |
| 2414 | * This funciton sets the multicast address list. |
| 2415 | * |
| 2416 | * Return: None |
| 2417 | */ |
| 2418 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 2419 | { |
| 2420 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2421 | int i = 0, status; |
| 2422 | struct netdev_hw_addr *ha; |
| 2423 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2424 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
| 2425 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 2426 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2427 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2428 | ENTER_DEV(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2429 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2430 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 2431 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2432 | status = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 2433 | if (0 != status) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2434 | goto out; |
| 2435 | |
| 2436 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
| 2437 | if (!mc_list_request) { |
| 2438 | hdd_notice("Cannot allocate mc_list_request"); |
| 2439 | goto out; |
| 2440 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2441 | |
| 2442 | if (dev->flags & IFF_ALLMULTI) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2443 | hdd_notice("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2444 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 2445 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2446 | } else { |
| 2447 | mc_count = netdev_mc_count(dev); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2448 | if (mc_count > pmo_ucfg_max_mc_addr_supported(psoc)) { |
Dustin Brown | 6126946 | 2016-09-19 13:25:45 -0700 | [diff] [blame] | 2449 | hdd_notice("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] | 2450 | pmo_ucfg_max_mc_addr_supported(psoc)); |
| 2451 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 2452 | pmo_mc_list_change_notify); |
| 2453 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2454 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2455 | netdev_for_each_mc_addr(ha, dev) { |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 2456 | hdd_notice("ha_addr[%d] "MAC_ADDRESS_STR, |
| 2457 | i, MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2458 | if (i == mc_count) |
| 2459 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2460 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 2461 | 0, ETH_ALEN); |
| 2462 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 2463 | ha->addr, ETH_ALEN); |
| 2464 | hdd_info("mlist[%d] = %pM", i, |
| 2465 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2466 | i++; |
| 2467 | } |
| 2468 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2469 | |
| 2470 | mc_list_request->psoc = psoc; |
| 2471 | mc_list_request->vdev_id = adapter->sessionId; |
| 2472 | mc_list_request->count = mc_count; |
| 2473 | status = hdd_cache_mc_addr_list(mc_list_request); |
| 2474 | if (status == 0) { |
| 2475 | hdd_enable_mc_addr_filtering(adapter, |
| 2476 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2477 | } else { |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2478 | hdd_err("error while caching mc list"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2479 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2480 | out: |
| 2481 | if (mc_list_request) |
| 2482 | qdf_mem_free(mc_list_request); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 2483 | EXIT(); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2484 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2485 | } |
| 2486 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2487 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2488 | /** |
| 2489 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
| 2490 | * @dev: pointer to net_device |
| 2491 | * |
| 2492 | * Return: none |
| 2493 | */ |
| 2494 | static void hdd_set_multicast_list(struct net_device *dev) |
| 2495 | { |
| 2496 | cds_ssr_protect(__func__); |
| 2497 | __hdd_set_multicast_list(dev); |
| 2498 | cds_ssr_unprotect(__func__); |
| 2499 | } |
| 2500 | #endif |
| 2501 | |
| 2502 | /** |
| 2503 | * hdd_select_queue() - used by Linux OS to decide which queue to use first |
| 2504 | * @dev: Pointer to the WLAN device. |
| 2505 | * @skb: Pointer to OS packet (sk_buff). |
| 2506 | * |
| 2507 | * This function is registered with the Linux OS for network |
| 2508 | * core to decide which queue to use first. |
| 2509 | * |
| 2510 | * Return: ac, Queue Index/access category corresponding to UP in IP header |
| 2511 | */ |
| 2512 | static uint16_t hdd_select_queue(struct net_device *dev, struct sk_buff *skb |
| 2513 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) |
| 2514 | , void *accel_priv |
| 2515 | #endif |
| 2516 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 2517 | , select_queue_fallback_t fallback |
| 2518 | #endif |
| 2519 | ) |
| 2520 | { |
| 2521 | return hdd_wmm_select_queue(dev, skb); |
| 2522 | } |
| 2523 | |
| 2524 | static struct net_device_ops wlan_drv_ops = { |
| 2525 | .ndo_open = hdd_open, |
| 2526 | .ndo_stop = hdd_stop, |
| 2527 | .ndo_uninit = hdd_uninit, |
| 2528 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 2529 | .ndo_tx_timeout = hdd_tx_timeout, |
| 2530 | .ndo_get_stats = hdd_get_stats, |
| 2531 | .ndo_do_ioctl = hdd_ioctl, |
| 2532 | .ndo_set_mac_address = hdd_set_mac_address, |
| 2533 | .ndo_select_queue = hdd_select_queue, |
| 2534 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2535 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2536 | #endif |
| 2537 | }; |
| 2538 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2539 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
| 2540 | static struct net_device_ops wlan_mon_drv_ops = { |
| 2541 | .ndo_open = hdd_mon_open, |
| 2542 | .ndo_stop = hdd_stop, |
| 2543 | .ndo_get_stats = hdd_get_stats, |
| 2544 | }; |
| 2545 | |
| 2546 | /** |
| 2547 | * hdd_set_station_ops() - update net_device ops for monitor mode |
| 2548 | * @pWlanDev: Handle to struct net_device to be updated. |
| 2549 | * Return: None |
| 2550 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2551 | void hdd_set_station_ops(struct net_device *pWlanDev) |
| 2552 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2553 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
| 2554 | pWlanDev->netdev_ops = &wlan_mon_drv_ops; |
| 2555 | else |
| 2556 | pWlanDev->netdev_ops = &wlan_drv_ops; |
| 2557 | } |
| 2558 | |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 2559 | #ifdef FEATURE_RUNTIME_PM |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 2560 | /** |
| 2561 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 2562 | * @hdd_ctx: HDD context |
| 2563 | * |
| 2564 | * Return: None |
| 2565 | */ |
| 2566 | static void hdd_runtime_suspend_context_init(hdd_context_t *hdd_ctx) |
| 2567 | { |
| 2568 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 2569 | |
| 2570 | ctx->scan = qdf_runtime_lock_init("scan"); |
Komal Seelam | aa75f26 | 2016-09-29 12:32:13 +0530 | [diff] [blame] | 2571 | ctx->roc = qdf_runtime_lock_init("roc"); |
Komal Seelam | 81cb166 | 2016-09-29 12:39:08 +0530 | [diff] [blame] | 2572 | ctx->dfs = qdf_runtime_lock_init("dfs"); |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 2573 | } |
| 2574 | |
| 2575 | /** |
| 2576 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 2577 | * @hdd_ctx: HDD Context |
| 2578 | * |
| 2579 | * Return: None |
| 2580 | */ |
| 2581 | static void hdd_runtime_suspend_context_deinit(hdd_context_t *hdd_ctx) |
| 2582 | { |
| 2583 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 2584 | |
| 2585 | qdf_runtime_lock_deinit(ctx->scan); |
| 2586 | ctx->scan = NULL; |
Komal Seelam | aa75f26 | 2016-09-29 12:32:13 +0530 | [diff] [blame] | 2587 | qdf_runtime_lock_deinit(ctx->roc); |
| 2588 | ctx->roc = NULL; |
Komal Seelam | 81cb166 | 2016-09-29 12:39:08 +0530 | [diff] [blame] | 2589 | qdf_runtime_lock_deinit(ctx->dfs); |
| 2590 | ctx->dfs = NULL; |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 2591 | } |
| 2592 | |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 2593 | static void hdd_adapter_runtime_suspend_init(hdd_adapter_t *adapter) |
| 2594 | { |
| 2595 | struct hdd_connect_pm_context *ctx = &adapter->connect_rpm_ctx; |
| 2596 | |
| 2597 | ctx->connect = qdf_runtime_lock_init("connect"); |
| 2598 | } |
| 2599 | |
| 2600 | static void hdd_adapter_runtime_suspend_denit(hdd_adapter_t *adapter) |
| 2601 | { |
| 2602 | struct hdd_connect_pm_context *ctx = &adapter->connect_rpm_ctx; |
| 2603 | |
| 2604 | qdf_runtime_lock_deinit(ctx->connect); |
| 2605 | ctx->connect = NULL; |
| 2606 | } |
| 2607 | #else /* FEATURE_RUNTIME_PM */ |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 2608 | static void hdd_runtime_suspend_context_init(hdd_context_t *hdd_ctx) {} |
| 2609 | static void hdd_runtime_suspend_context_deinit(hdd_context_t *hdd_ctx) {} |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 2610 | static inline void hdd_adapter_runtime_suspend_init(hdd_adapter_t *adapter) {} |
| 2611 | static inline void hdd_adapter_runtime_suspend_denit(hdd_adapter_t *adapter) {} |
| 2612 | #endif /* FEATURE_RUNTIME_PM */ |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2613 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 2614 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 2615 | * @hdd_ctx: global hdd context |
| 2616 | * @macAddr: mac address to assign to the interface |
| 2617 | * @name: User-visible name of the interface |
| 2618 | * |
| 2619 | * hdd adapter pointer would point to the netdev->priv space, this function |
| 2620 | * would retrive the pointer, and setup the hdd adapter configuration. |
| 2621 | * |
| 2622 | * Return: the pointer to hdd adapter, otherwise NULL |
| 2623 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2624 | static hdd_adapter_t *hdd_alloc_station_adapter(hdd_context_t *hdd_ctx, |
| 2625 | tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 2626 | unsigned char name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2627 | const char *name) |
| 2628 | { |
| 2629 | struct net_device *pWlanDev = NULL; |
| 2630 | hdd_adapter_t *adapter = NULL; |
| 2631 | /* |
| 2632 | * cfg80211 initialization and registration.... |
| 2633 | */ |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 2634 | pWlanDev = alloc_netdev_mq(sizeof(hdd_adapter_t), name, |
| 2635 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
| 2636 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2637 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2638 | (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam() ? |
| 2639 | hdd_mon_mode_ether_setup : ether_setup), |
| 2640 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2641 | |
| 2642 | if (pWlanDev != NULL) { |
| 2643 | |
| 2644 | /* Save the pointer to the net_device in the HDD adapter */ |
| 2645 | adapter = (hdd_adapter_t *) netdev_priv(pWlanDev); |
| 2646 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2647 | qdf_mem_zero(adapter, sizeof(hdd_adapter_t)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2648 | |
| 2649 | adapter->dev = pWlanDev; |
| 2650 | adapter->pHddCtx = hdd_ctx; |
| 2651 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Arun Khandavalli | 9ad88f0 | 2016-09-01 19:03:37 +0530 | [diff] [blame] | 2652 | adapter->sessionId = HDD_SESSION_ID_INVALID; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2653 | |
| 2654 | init_completion(&adapter->session_open_comp_var); |
| 2655 | init_completion(&adapter->session_close_comp_var); |
| 2656 | init_completion(&adapter->disconnect_comp_var); |
| 2657 | init_completion(&adapter->linkup_event_var); |
| 2658 | init_completion(&adapter->cancel_rem_on_chan_var); |
| 2659 | init_completion(&adapter->rem_on_chan_ready_event); |
| 2660 | init_completion(&adapter->sta_authorized_event); |
| 2661 | init_completion(&adapter->offchannel_tx_event); |
| 2662 | init_completion(&adapter->tx_action_cnf_event); |
| 2663 | #ifdef FEATURE_WLAN_TDLS |
| 2664 | init_completion(&adapter->tdls_add_station_comp); |
| 2665 | init_completion(&adapter->tdls_del_station_comp); |
| 2666 | init_completion(&adapter->tdls_mgmt_comp); |
| 2667 | init_completion(&adapter->tdls_link_establish_req_comp); |
| 2668 | #endif |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2669 | init_completion(&adapter->ibss_peer_info_comp); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2670 | init_completion(&adapter->change_country_code); |
| 2671 | |
| 2672 | |
| 2673 | init_completion(&adapter->scan_info.abortscan_event_var); |
| 2674 | |
| 2675 | adapter->offloads_configured = false; |
| 2676 | adapter->isLinkUpSvcNeeded = false; |
| 2677 | adapter->higherDtimTransition = true; |
| 2678 | /* Init the net_device structure */ |
| 2679 | strlcpy(pWlanDev->name, name, IFNAMSIZ); |
| 2680 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2681 | qdf_mem_copy(pWlanDev->dev_addr, (void *)macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2682 | sizeof(tSirMacAddr)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2683 | qdf_mem_copy(adapter->macAddressCurrent.bytes, macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2684 | sizeof(tSirMacAddr)); |
| 2685 | pWlanDev->watchdog_timeo = HDD_TX_TIMEOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2686 | |
| 2687 | if (hdd_ctx->config->enable_ip_tcp_udp_checksum_offload) |
| 2688 | pWlanDev->features |= |
| 2689 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
| 2690 | pWlanDev->features |= NETIF_F_RXCSUM; |
| 2691 | |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 2692 | hdd_set_tso_flags(hdd_ctx, pWlanDev); |
| 2693 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2694 | hdd_set_station_ops(adapter->dev); |
| 2695 | |
| 2696 | pWlanDev->destructor = free_netdev; |
| 2697 | pWlanDev->ieee80211_ptr = &adapter->wdev; |
Mohit Khanna | ee9e80f | 2015-11-10 11:32:49 -0800 | [diff] [blame] | 2698 | pWlanDev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2699 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
| 2700 | adapter->wdev.netdev = pWlanDev; |
| 2701 | /* set pWlanDev's parent to underlying device */ |
| 2702 | SET_NETDEV_DEV(pWlanDev, hdd_ctx->parent_dev); |
| 2703 | hdd_wmm_init(adapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 2704 | hdd_adapter_runtime_suspend_init(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2705 | spin_lock_init(&adapter->pause_map_lock); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 2706 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2707 | } |
| 2708 | |
| 2709 | return adapter; |
| 2710 | } |
| 2711 | |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2712 | static QDF_STATUS hdd_register_interface(hdd_adapter_t *adapter, |
| 2713 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2714 | { |
| 2715 | struct net_device *pWlanDev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2716 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 2717 | if (rtnl_held) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2718 | if (strnchr(pWlanDev->name, strlen(pWlanDev->name), '%')) { |
| 2719 | if (dev_alloc_name(pWlanDev, pWlanDev->name) < 0) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2720 | hdd_err("Failed:dev_alloc_name"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2721 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2722 | } |
| 2723 | } |
| 2724 | if (register_netdevice(pWlanDev)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2725 | hdd_err("Failed:register_netdev"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2726 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2727 | } |
| 2728 | } else { |
| 2729 | if (register_netdev(pWlanDev)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2730 | hdd_err("Failed:register_netdev"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2731 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2732 | } |
| 2733 | } |
| 2734 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 2735 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2736 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2737 | } |
| 2738 | |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 2739 | QDF_STATUS hdd_sme_close_session_callback(void *pContext) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2740 | { |
| 2741 | hdd_adapter_t *adapter = pContext; |
| 2742 | |
| 2743 | if (NULL == adapter) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2744 | hdd_alert("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2745 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2746 | } |
| 2747 | |
| 2748 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2749 | hdd_alert("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2750 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2751 | } |
| 2752 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 2753 | /* |
| 2754 | * For NAN Data interface, the close session results in the final |
| 2755 | * indication to the userspace |
| 2756 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 2757 | if (adapter->device_mode == QDF_NDI_MODE) |
| 2758 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 2759 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2760 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 2761 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2762 | /* |
| 2763 | * We can be blocked while waiting for scheduled work to be |
| 2764 | * flushed, and the adapter structure can potentially be freed, in |
| 2765 | * which case the magic will have been reset. So make sure the |
| 2766 | * magic is still good, and hence the adapter structure is still |
| 2767 | * valid, before signaling completion |
| 2768 | */ |
| 2769 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
| 2770 | complete(&adapter->session_close_comp_var); |
| 2771 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2772 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2773 | } |
| 2774 | |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 2775 | /** |
| 2776 | * hdd_check_and_init_tdls() - check and init TDLS operation for desired mode |
| 2777 | * @adapter: pointer to device adapter |
| 2778 | * @type: type of interface |
| 2779 | * |
| 2780 | * This routine will check the mode of adapter and if it is required then it |
| 2781 | * will initialize the TDLS operations |
| 2782 | * |
| 2783 | * Return: QDF_STATUS |
| 2784 | */ |
| 2785 | #ifdef FEATURE_WLAN_TDLS |
| 2786 | static QDF_STATUS hdd_check_and_init_tdls(hdd_adapter_t *adapter, uint32_t type) |
| 2787 | { |
| 2788 | if (QDF_IBSS_MODE != type) { |
| 2789 | if (0 != wlan_hdd_tdls_init(adapter)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2790 | hdd_err("wlan_hdd_tdls_init failed"); |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 2791 | return QDF_STATUS_E_FAILURE; |
| 2792 | } |
| 2793 | set_bit(TDLS_INIT_DONE, &adapter->event_flags); |
| 2794 | } |
| 2795 | return QDF_STATUS_SUCCESS; |
| 2796 | } |
| 2797 | #else |
| 2798 | static QDF_STATUS hdd_check_and_init_tdls(hdd_adapter_t *adapter, uint32_t type) |
| 2799 | { |
| 2800 | return QDF_STATUS_SUCCESS; |
| 2801 | } |
| 2802 | #endif |
| 2803 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2804 | QDF_STATUS hdd_init_station_mode(hdd_adapter_t *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2805 | { |
| 2806 | struct net_device *pWlanDev = adapter->dev; |
| 2807 | hdd_station_ctx_t *pHddStaCtx = &adapter->sessionCtx.station; |
| 2808 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2809 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2810 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2811 | uint32_t type, subType; |
| 2812 | unsigned long rc; |
| 2813 | int ret_val; |
| 2814 | |
| 2815 | INIT_COMPLETION(adapter->session_open_comp_var); |
| 2816 | sme_set_curr_device_mode(hdd_ctx->hHal, adapter->device_mode); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 2817 | sme_set_pdev_ht_vht_ies(hdd_ctx->hHal, hdd_ctx->config->enable2x2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2818 | status = cds_get_vdev_types(adapter->device_mode, &type, &subType); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2819 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2820 | hdd_err("failed to get vdev type"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2821 | goto error_sme_open; |
| 2822 | } |
| 2823 | /* Open a SME session for future operation */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2824 | qdf_ret_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2825 | sme_open_session(hdd_ctx->hHal, hdd_sme_roam_callback, adapter, |
| 2826 | (uint8_t *) &adapter->macAddressCurrent, |
| 2827 | &adapter->sessionId, type, subType); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2828 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2829 | hdd_alert("sme_open_session() failed, status code %08d [x%08x]", |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2830 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2831 | status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2832 | goto error_sme_open; |
| 2833 | } |
| 2834 | /* Block on a completion variable. Can't wait forever though. */ |
| 2835 | rc = wait_for_completion_timeout( |
| 2836 | &adapter->session_open_comp_var, |
| 2837 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
| 2838 | if (!rc) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2839 | hdd_alert("Session is not opened within timeout period code %ld", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2840 | rc); |
Sandeep Puligilla | e806599 | 2016-11-14 00:23:43 -0800 | [diff] [blame] | 2841 | adapter->sessionId = HDD_SESSION_ID_INVALID; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2842 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2843 | } |
| 2844 | |
Rajeev Kumar | deabf3e | 2017-01-13 15:55:05 -0800 | [diff] [blame] | 2845 | ret_val = hdd_create_and_store_vdev(hdd_ctx->hdd_pdev, adapter); |
| 2846 | if (ret_val) |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2847 | goto error_vdev_create; |
| 2848 | |
Naveen Rawat | a410c5a | 2016-09-19 14:22:33 -0700 | [diff] [blame] | 2849 | sme_set_vdev_ies_per_band(hdd_ctx->hHal, adapter->sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2850 | /* Register wireless extensions */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2851 | qdf_ret_status = hdd_register_wext(pWlanDev); |
| 2852 | if (QDF_STATUS_SUCCESS != qdf_ret_status) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2853 | hdd_alert("hdd_register_wext() failed, status code %08d [x%08x]", |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2854 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2855 | status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2856 | goto error_register_wext; |
| 2857 | } |
| 2858 | /* Set the Connection State to Not Connected */ |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2859 | hdd_notice("Set HDD connState to eConnectionState_NotConnected"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2860 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 2861 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 2862 | /* set fast roaming capability in sme session */ |
| 2863 | status = sme_config_fast_roaming(hdd_ctx->hHal, adapter->sessionId, |
| 2864 | adapter->fast_roaming_allowed); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2865 | /* Set the default operation channel */ |
| 2866 | pHddStaCtx->conn_info.operationChannel = |
| 2867 | hdd_ctx->config->OperatingChannel; |
| 2868 | |
| 2869 | /* Make the default Auth Type as OPEN */ |
| 2870 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 2871 | |
| 2872 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2873 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2874 | hdd_alert("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2875 | status, status); |
| 2876 | goto error_init_txrx; |
| 2877 | } |
| 2878 | |
| 2879 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 2880 | |
| 2881 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2882 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2883 | hdd_alert("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2884 | status, status); |
| 2885 | goto error_wmm_init; |
| 2886 | } |
| 2887 | |
| 2888 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 2889 | |
| 2890 | ret_val = wma_cli_set_command(adapter->sessionId, |
| 2891 | WMI_PDEV_PARAM_BURST_ENABLE, |
| 2892 | hdd_ctx->config->enableSifsBurst, |
| 2893 | PDEV_CMD); |
| 2894 | |
| 2895 | if (0 != ret_val) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2896 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2897 | ret_val); |
| 2898 | } |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 2899 | status = hdd_check_and_init_tdls(adapter, type); |
| 2900 | if (status != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2901 | goto error_tdls_init; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2902 | |
Himanshu Agarwal | 3d95b90 | 2016-08-24 16:27:03 +0530 | [diff] [blame] | 2903 | status = hdd_lro_enable(hdd_ctx, adapter); |
| 2904 | if (status != QDF_STATUS_SUCCESS) |
| 2905 | goto error_lro_enable; |
| 2906 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2907 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2908 | |
Himanshu Agarwal | 3d95b90 | 2016-08-24 16:27:03 +0530 | [diff] [blame] | 2909 | error_lro_enable: |
| 2910 | wlan_hdd_tdls_exit(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2911 | error_tdls_init: |
| 2912 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 2913 | hdd_wmm_adapter_close(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2914 | error_wmm_init: |
| 2915 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 2916 | hdd_deinit_tx_rx(adapter); |
| 2917 | error_init_txrx: |
| 2918 | hdd_unregister_wext(pWlanDev); |
| 2919 | error_register_wext: |
Rajeev Kumar | 9591d2b | 2017-01-13 16:05:06 -0800 | [diff] [blame] | 2920 | ret_val = hdd_release_and_destroy_vdev(adapter); |
| 2921 | if (ret_val) |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2922 | hdd_err("vdev delete failed"); |
| 2923 | error_vdev_create: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2924 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2925 | INIT_COMPLETION(adapter->session_close_comp_var); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2926 | if (QDF_STATUS_SUCCESS == sme_close_session(hdd_ctx->hHal, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2927 | adapter->sessionId, |
| 2928 | hdd_sme_close_session_callback, |
| 2929 | adapter)) { |
| 2930 | unsigned long rc; |
| 2931 | |
| 2932 | /* |
| 2933 | * Block on a completion variable. |
| 2934 | * Can't wait forever though. |
| 2935 | */ |
| 2936 | rc = wait_for_completion_timeout( |
| 2937 | &adapter->session_close_comp_var, |
| 2938 | msecs_to_jiffies |
| 2939 | (WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
| 2940 | if (rc <= 0) |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2941 | hdd_err("Session is not opened within timeout period code %ld", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2942 | rc); |
| 2943 | } |
| 2944 | } |
| 2945 | error_sme_open: |
| 2946 | return status; |
| 2947 | } |
| 2948 | |
| 2949 | void hdd_cleanup_actionframe(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter) |
| 2950 | { |
| 2951 | hdd_cfg80211_state_t *cfgState; |
| 2952 | |
| 2953 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR(adapter); |
| 2954 | |
| 2955 | if (NULL != cfgState->buf) { |
| 2956 | unsigned long rc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2957 | rc = wait_for_completion_timeout( |
| 2958 | &adapter->tx_action_cnf_event, |
| 2959 | msecs_to_jiffies(ACTION_FRAME_TX_TIMEOUT)); |
| 2960 | if (!rc) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 2961 | hdd_err("HDD Wait for Action Confirmation Failed!!"); |
Masti, Narayanraddi | f8f6e7e | 2015-08-25 10:22:46 +0530 | [diff] [blame] | 2962 | /* |
| 2963 | * Inform tx status as FAILURE to upper layer and free |
| 2964 | * cfgState->buf |
| 2965 | */ |
| 2966 | hdd_send_action_cnf(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2967 | } |
| 2968 | } |
| 2969 | return; |
| 2970 | } |
| 2971 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2972 | /** |
| 2973 | * hdd_station_adapter_deinit() - De-initialize the station adapter |
| 2974 | * @hdd_ctx: global hdd context |
| 2975 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2976 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 2977 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2978 | * |
| 2979 | * This function De-initializes the STA/P2P/OCB adapter. |
| 2980 | * |
| 2981 | * Return: None. |
| 2982 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2983 | static void hdd_station_adapter_deinit(hdd_context_t *hdd_ctx, |
| 2984 | hdd_adapter_t *adapter, |
| 2985 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2986 | { |
| 2987 | ENTER_DEV(adapter->dev); |
| 2988 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 2989 | if (adapter->dev) { |
| 2990 | if (rtnl_held) |
| 2991 | adapter->dev->wireless_handlers = NULL; |
| 2992 | else { |
| 2993 | rtnl_lock(); |
| 2994 | adapter->dev->wireless_handlers = NULL; |
| 2995 | rtnl_unlock(); |
| 2996 | } |
| 2997 | } |
| 2998 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2999 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 3000 | hdd_deinit_tx_rx(adapter); |
| 3001 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3002 | } |
| 3003 | |
| 3004 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 3005 | hdd_wmm_adapter_close(adapter); |
| 3006 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3007 | } |
| 3008 | |
| 3009 | hdd_cleanup_actionframe(hdd_ctx, adapter); |
| 3010 | wlan_hdd_tdls_exit(adapter); |
| 3011 | |
| 3012 | EXIT(); |
| 3013 | } |
| 3014 | |
| 3015 | /** |
| 3016 | * hdd_ap_adapter_deinit() - De-initialize the ap adapter |
| 3017 | * @hdd_ctx: global hdd context |
| 3018 | * @adapter: HDD adapter |
| 3019 | * @rtnl_held: the rtnl lock hold flag |
| 3020 | * This function De-initializes the AP/P2PGo adapter. |
| 3021 | * |
| 3022 | * Return: None. |
| 3023 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3024 | static void hdd_ap_adapter_deinit(hdd_context_t *hdd_ctx, |
| 3025 | hdd_adapter_t *adapter, |
| 3026 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3027 | { |
| 3028 | ENTER_DEV(adapter->dev); |
| 3029 | |
| 3030 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 3031 | hdd_wmm_adapter_close(adapter); |
| 3032 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3033 | } |
Liangwei Dong | 8baf7c8 | 2016-10-11 01:26:59 -0400 | [diff] [blame] | 3034 | wlan_hdd_undo_acs(adapter); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3035 | |
| 3036 | hdd_cleanup_actionframe(hdd_ctx, adapter); |
| 3037 | |
| 3038 | hdd_unregister_hostapd(adapter, rtnl_held); |
| 3039 | |
| 3040 | EXIT(); |
| 3041 | } |
| 3042 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3043 | void hdd_deinit_adapter(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, |
| 3044 | bool rtnl_held) |
| 3045 | { |
| 3046 | ENTER(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3047 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3048 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3049 | case QDF_STA_MODE: |
| 3050 | case QDF_P2P_CLIENT_MODE: |
| 3051 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3052 | { |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 3053 | hdd_station_adapter_deinit(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3054 | break; |
| 3055 | } |
| 3056 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3057 | case QDF_SAP_MODE: |
| 3058 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3059 | { |
| 3060 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3061 | hdd_ap_adapter_deinit(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3062 | break; |
| 3063 | } |
| 3064 | |
| 3065 | default: |
| 3066 | break; |
| 3067 | } |
| 3068 | |
| 3069 | EXIT(); |
| 3070 | } |
| 3071 | |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3072 | static void hdd_cleanup_adapter(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, |
| 3073 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3074 | { |
Rajeev Kumar | 9591d2b | 2017-01-13 16:05:06 -0800 | [diff] [blame] | 3075 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3076 | struct net_device *pWlanDev = NULL; |
| 3077 | |
| 3078 | if (adapter) |
| 3079 | pWlanDev = adapter->dev; |
| 3080 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3081 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3082 | return; |
| 3083 | } |
| 3084 | |
Rajeev Kumar | 9591d2b | 2017-01-13 16:05:06 -0800 | [diff] [blame] | 3085 | ret = hdd_release_and_destroy_vdev(adapter); |
| 3086 | if (ret) |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 3087 | hdd_err("vdev delete failed"); |
| 3088 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 3089 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 3090 | |
| 3091 | if (adapter->scan_info.default_scan_ies) { |
| 3092 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 3093 | adapter->scan_info.default_scan_ies = NULL; |
| 3094 | } |
| 3095 | |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3096 | hdd_adapter_runtime_suspend_denit(adapter); |
| 3097 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3098 | /* |
| 3099 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 3100 | * the driver is almost closed and cannot handle either control |
| 3101 | * messages or data. However, unregister_netdevice() call above will |
| 3102 | * eventually invoke hdd_stop (ndo_close) driver callback, which attempts |
| 3103 | * to close the active connections (basically excites control path) which |
| 3104 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 3105 | * the interface is closed and restricts any operations on that |
| 3106 | */ |
| 3107 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 3108 | |
| 3109 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
| 3110 | if (rtnl_held) { |
| 3111 | unregister_netdevice(pWlanDev); |
| 3112 | } else { |
| 3113 | unregister_netdev(pWlanDev); |
| 3114 | } |
| 3115 | /* |
| 3116 | * Note that the adapter is no longer valid at this point |
| 3117 | * since the memory has been reclaimed |
| 3118 | */ |
| 3119 | } |
| 3120 | } |
| 3121 | |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3122 | static QDF_STATUS hdd_check_for_existing_macaddr(hdd_context_t *hdd_ctx, |
| 3123 | tSirMacAddr macAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3124 | { |
| 3125 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 3126 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3127 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3128 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3129 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3130 | adapter = adapterNode->pAdapter; |
| 3131 | if (adapter |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3132 | && !qdf_mem_cmp(adapter->macAddressCurrent.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3133 | macAddr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3134 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3135 | } |
| 3136 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 3137 | adapterNode = pNext; |
| 3138 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3139 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3140 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3141 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3142 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 3143 | /** |
| 3144 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 3145 | * @hdd_ctx: HDD Context |
| 3146 | * @adapter: HDD Adapter |
| 3147 | * |
| 3148 | * This function set the FW Debug log level based on the INI. |
| 3149 | * |
| 3150 | * Return: None |
| 3151 | */ |
| 3152 | static void hdd_set_fw_log_params(hdd_context_t *hdd_ctx, |
| 3153 | hdd_adapter_t *adapter) |
| 3154 | { |
| 3155 | uint8_t count = 0, numentries = 0, |
| 3156 | moduleloglevel[FW_MODULE_LOG_LEVEL_STRING_LENGTH]; |
| 3157 | uint32_t value = 0; |
| 3158 | int ret; |
| 3159 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3160 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 3161 | (!hdd_ctx->config->enable_fw_log)) { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3162 | hdd_info("enable_fw_log not enabled in INI or in FTM mode return"); |
| 3163 | return; |
| 3164 | } |
| 3165 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3166 | /* Enable FW logs based on INI configuration */ |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3167 | hdd_ctx->fw_log_settings.dl_type = |
| 3168 | hdd_ctx->config->enableFwLogType; |
| 3169 | ret = wma_cli_set_command(adapter->sessionId, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3170 | WMI_DBGLOG_TYPE, |
| 3171 | hdd_ctx->config->enableFwLogType, |
| 3172 | DBG_CMD); |
| 3173 | if (ret != 0) |
| 3174 | hdd_err("Failed to enable FW log type ret %d", |
| 3175 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3176 | |
| 3177 | hdd_ctx->fw_log_settings.dl_loglevel = |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3178 | hdd_ctx->config->enableFwLogLevel; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3179 | ret = wma_cli_set_command(adapter->sessionId, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3180 | WMI_DBGLOG_LOG_LEVEL, |
| 3181 | hdd_ctx->config->enableFwLogLevel, |
| 3182 | DBG_CMD); |
| 3183 | if (ret != 0) |
| 3184 | hdd_err("Failed to enable FW log level ret %d", |
| 3185 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3186 | |
| 3187 | hdd_string_to_u8_array( |
| 3188 | hdd_ctx->config->enableFwModuleLogLevel, |
| 3189 | moduleloglevel, |
| 3190 | &numentries, |
| 3191 | FW_MODULE_LOG_LEVEL_STRING_LENGTH); |
| 3192 | |
| 3193 | while (count < numentries) { |
| 3194 | /* |
| 3195 | * FW module log level input string looks like |
| 3196 | * below: |
| 3197 | * gFwDebugModuleLoglevel=<FW Module ID>, |
| 3198 | * <Log Level>,... |
| 3199 | * For example: |
| 3200 | * gFwDebugModuleLoglevel= |
| 3201 | * 1,0,2,1,3,2,4,3,5,4,6,5,7,6 |
| 3202 | * Above input string means : |
| 3203 | * For FW module ID 1 enable log level 0 |
| 3204 | * For FW module ID 2 enable log level 1 |
| 3205 | * For FW module ID 3 enable log level 2 |
| 3206 | * For FW module ID 4 enable log level 3 |
| 3207 | * For FW module ID 5 enable log level 4 |
| 3208 | * For FW module ID 6 enable log level 5 |
| 3209 | * For FW module ID 7 enable log level 6 |
| 3210 | */ |
| 3211 | |
Nishank Aggarwal | e239d96 | 2017-03-03 12:26:02 +0530 | [diff] [blame] | 3212 | if ((moduleloglevel[count] > WLAN_MODULE_ID_MAX) |
| 3213 | || (moduleloglevel[count + 1] > DBGLOG_LVL_MAX)) { |
| 3214 | hdd_err("Module id %d and dbglog level %d input length is more than max", |
| 3215 | moduleloglevel[count], |
| 3216 | moduleloglevel[count + 1]); |
| 3217 | return; |
| 3218 | } |
| 3219 | |
| 3220 | value = moduleloglevel[count] << 16; |
| 3221 | value |= moduleloglevel[count + 1]; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3222 | ret = wma_cli_set_command(adapter->sessionId, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3223 | WMI_DBGLOG_MOD_LOG_LEVEL, |
| 3224 | value, DBG_CMD); |
| 3225 | if (ret != 0) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3226 | hdd_err("Failed to enable FW module log level %d ret %d", |
| 3227 | value, ret); |
| 3228 | |
| 3229 | count += 2; |
| 3230 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3231 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3232 | } |
| 3233 | #else |
| 3234 | static void hdd_set_fw_log_params(hdd_context_t *hdd_ctx, |
| 3235 | hdd_adapter_t *adapter) |
| 3236 | { |
| 3237 | } |
| 3238 | |
| 3239 | #endif |
| 3240 | |
| 3241 | /** |
| 3242 | * hdd_set_fw_params() - Set parameters to firmware |
| 3243 | * @adapter: HDD adapter |
| 3244 | * |
| 3245 | * This function Sets various parameters to fw once the |
| 3246 | * adapter is started. |
| 3247 | * |
| 3248 | * Return: 0 on success or errno on failure |
| 3249 | */ |
| 3250 | int hdd_set_fw_params(hdd_adapter_t *adapter) |
| 3251 | { |
| 3252 | int ret; |
| 3253 | hdd_context_t *hdd_ctx; |
| 3254 | |
| 3255 | ENTER_DEV(adapter->dev); |
| 3256 | |
| 3257 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3258 | if (!hdd_ctx) |
| 3259 | return -EINVAL; |
| 3260 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3261 | if ((cds_get_conparam() != QDF_GLOBAL_FTM_MODE) && |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3262 | (!hdd_ctx->config->enable2x2)) { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3263 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 3264 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3265 | /* |
| 3266 | * Disable DTIM 1 chain Rx when in 1x1, |
| 3267 | * we are passing two value |
| 3268 | * as param_id << 29 | param_value. |
| 3269 | * Below param_value = 0(disable) |
| 3270 | */ |
| 3271 | ret = wma_cli_set_command(adapter->sessionId, |
| 3272 | WMI_STA_SMPS_PARAM_CMDID, |
| 3273 | HDD_DTIM_1CHAIN_RX_ID << |
| 3274 | HDD_SMPS_PARAM_VALUE_S, |
| 3275 | VDEV_CMD); |
| 3276 | if (ret) { |
| 3277 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 3278 | goto error; |
| 3279 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3280 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3281 | ret = wma_cli_set_command(adapter->sessionId, |
| 3282 | WMI_PDEV_PARAM_TX_CHAIN_MASK, |
| 3283 | hdd_ctx->config->txchainmask1x1, |
| 3284 | PDEV_CMD); |
| 3285 | if (ret) { |
| 3286 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK set failed %d", |
| 3287 | ret); |
| 3288 | goto error; |
| 3289 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3290 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3291 | ret = wma_cli_set_command(adapter->sessionId, |
| 3292 | WMI_PDEV_PARAM_RX_CHAIN_MASK, |
| 3293 | hdd_ctx->config->rxchainmask1x1, |
| 3294 | PDEV_CMD); |
| 3295 | if (ret) { |
| 3296 | hdd_err("WMI_PDEV_PARAM_RX_CHAIN_MASK set failed %d", |
| 3297 | ret); |
| 3298 | goto error; |
| 3299 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3300 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 3301 | #undef HDD_SMPS_PARAM_VALUE_S |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3302 | } else { |
| 3303 | hdd_info("FTM Mode or 2x2 mode - Do not set 1x1 params"); |
| 3304 | } |
| 3305 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3306 | if (QDF_GLOBAL_FTM_MODE != cds_get_conparam()) { |
| 3307 | ret = wma_cli_set_command(adapter->sessionId, |
| 3308 | WMI_PDEV_PARAM_HYST_EN, |
| 3309 | hdd_ctx->config->enableMemDeepSleep, |
| 3310 | PDEV_CMD); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3311 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3312 | if (ret) { |
| 3313 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", |
| 3314 | ret); |
| 3315 | goto error; |
| 3316 | } |
Rajeev Kumar Sirasanagandla | 2dab3ec | 2016-10-18 16:10:15 +0530 | [diff] [blame] | 3317 | |
| 3318 | ret = wma_cli_set_command(adapter->sessionId, |
| 3319 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
| 3320 | hdd_ctx->config->rts_profile, |
| 3321 | VDEV_CMD); |
| 3322 | if (ret) { |
| 3323 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 3324 | goto error; |
| 3325 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3326 | } |
| 3327 | |
| 3328 | hdd_set_fw_log_params(hdd_ctx, adapter); |
| 3329 | |
| 3330 | EXIT(); |
| 3331 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3332 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3333 | error: |
| 3334 | return -EINVAL; |
| 3335 | } |
| 3336 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3337 | /** |
| 3338 | * hdd_open_adapter() - open and setup the hdd adatper |
| 3339 | * @hdd_ctx: global hdd context |
| 3340 | * @session_type: type of the interface to be created |
| 3341 | * @iface_name: User-visible name of the interface |
| 3342 | * @macAddr: MAC address to assign to the interface |
| 3343 | * @name_assign_type: the name of assign type of the netdev |
| 3344 | * @rtnl_held: the rtnl lock hold flag |
| 3345 | * |
| 3346 | * This function open and setup the hdd adpater according to the device |
| 3347 | * type request, assign the name, the mac address assigned, and then prepared |
| 3348 | * the hdd related parameters, queue, lock and ready to start. |
| 3349 | * |
| 3350 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 3351 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3352 | hdd_adapter_t *hdd_open_adapter(hdd_context_t *hdd_ctx, uint8_t session_type, |
| 3353 | const char *iface_name, tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3354 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3355 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3356 | { |
| 3357 | hdd_adapter_t *adapter = NULL; |
| 3358 | hdd_adapter_list_node_t *pHddAdapterNode = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3359 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3360 | hdd_cfg80211_state_t *cfgState; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3361 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3362 | hdd_info("iface(%s) type(%d)", iface_name, session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3363 | |
| 3364 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 3365 | /* |
| 3366 | * Max limit reached on the number of vdevs configured by the |
| 3367 | * host. Return error |
| 3368 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3369 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 3370 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3371 | return NULL; |
| 3372 | } |
| 3373 | |
| 3374 | if (macAddr == NULL) { |
| 3375 | /* Not received valid macAddr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3376 | 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] | 3377 | return NULL; |
| 3378 | } |
| 3379 | status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3380 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3381 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 3382 | " already exists", |
| 3383 | MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3384 | return NULL; |
| 3385 | } |
| 3386 | |
| 3387 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3388 | case QDF_STA_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3389 | /* Reset locally administered bit if the device mode is STA */ |
| 3390 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr); |
| 3391 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3392 | case QDF_P2P_CLIENT_MODE: |
| 3393 | case QDF_P2P_DEVICE_MODE: |
| 3394 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 3395 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3396 | case QDF_MONITOR_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3397 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 3398 | name_assign_type, |
| 3399 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3400 | |
| 3401 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3402 | hdd_err("failed to allocate adapter for session %d", |
| 3403 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3404 | return NULL; |
| 3405 | } |
| 3406 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3407 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3408 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3409 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3410 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3411 | else if (QDF_MONITOR_MODE == session_type) |
| 3412 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3413 | else |
| 3414 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 3415 | |
| 3416 | adapter->device_mode = session_type; |
| 3417 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3418 | if (QDF_NDI_MODE == session_type) { |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 3419 | status = hdd_init_nan_data_mode(adapter); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3420 | if (QDF_STATUS_SUCCESS != status) |
| 3421 | goto err_free_netdev; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3422 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3423 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3424 | /* |
| 3425 | * Workqueue which gets scheduled in IPv4 notification |
| 3426 | * callback |
| 3427 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3428 | INIT_WORK(&adapter->ipv4NotifierWorkQueue, |
| 3429 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3430 | |
| 3431 | #ifdef WLAN_NS_OFFLOAD |
| 3432 | /* |
| 3433 | * Workqueue which gets scheduled in IPv6 |
| 3434 | * notification callback. |
| 3435 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3436 | INIT_WORK(&adapter->ipv6NotifierWorkQueue, |
| 3437 | hdd_ipv6_notifier_work_queue); |
| 3438 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3439 | status = hdd_register_interface(adapter, rtnl_held); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3440 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3441 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 3442 | goto err_free_netdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3443 | } |
| 3444 | |
| 3445 | /* Stop the Interface TX queue. */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3446 | hdd_info("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3447 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3448 | WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 3449 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3450 | break; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3451 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3452 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3453 | case QDF_P2P_GO_MODE: |
| 3454 | case QDF_SAP_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3455 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr, |
| 3456 | name_assign_type, |
| 3457 | (uint8_t *) iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3458 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3459 | hdd_alert("failed to allocate adapter for session %d", |
| 3460 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3461 | return NULL; |
| 3462 | } |
| 3463 | |
| 3464 | adapter->wdev.iftype = |
| 3465 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3466 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3467 | NL80211_IFTYPE_P2P_GO; |
| 3468 | adapter->device_mode = session_type; |
| 3469 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3470 | status = hdd_register_hostapd(adapter, rtnl_held); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3471 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3472 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
| 3473 | goto err_free_netdev; |
| 3474 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3475 | hdd_info("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3476 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3477 | WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 3478 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3479 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3480 | case QDF_FTM_MODE: |
| 3481 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 3482 | name_assign_type, |
| 3483 | "wlan0"); |
| 3484 | if (NULL == adapter) { |
| 3485 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 3486 | return NULL; |
| 3487 | } |
| 3488 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 3489 | adapter->device_mode = session_type; |
| 3490 | status = hdd_register_interface(adapter, rtnl_held); |
| 3491 | if (QDF_STATUS_SUCCESS != status) { |
| 3492 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
| 3493 | goto err_free_netdev; |
| 3494 | } |
| 3495 | /* Stop the Interface TX queue. */ |
| 3496 | hdd_info("Disabling queues"); |
| 3497 | wlan_hdd_netif_queue_control(adapter, |
| 3498 | WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 3499 | WLAN_CONTROL_PATH); |
| 3500 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3501 | default: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3502 | hdd_alert("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3503 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3504 | return NULL; |
| 3505 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3506 | |
| 3507 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR(adapter); |
| 3508 | mutex_init(&cfgState->remain_on_chan_ctx_lock); |
| 3509 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3510 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3511 | /* Add it to the hdd's session list. */ |
| 3512 | pHddAdapterNode = |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3513 | qdf_mem_malloc(sizeof(hdd_adapter_list_node_t)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3514 | if (NULL == pHddAdapterNode) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3515 | status = QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3516 | } else { |
| 3517 | pHddAdapterNode->pAdapter = adapter; |
| 3518 | status = hdd_add_adapter_back(hdd_ctx, pHddAdapterNode); |
| 3519 | } |
| 3520 | } |
| 3521 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3522 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3523 | if (NULL != adapter) { |
| 3524 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 3525 | adapter = NULL; |
| 3526 | } |
| 3527 | if (NULL != pHddAdapterNode) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3528 | qdf_mem_free(pHddAdapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3529 | } |
| 3530 | return NULL; |
| 3531 | } |
| 3532 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3533 | if (QDF_STATUS_SUCCESS == status) { |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 3534 | cds_set_concurrency_mode(session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3535 | |
| 3536 | /* Initialize the WoWL service */ |
| 3537 | if (!hdd_init_wowl(adapter)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3538 | hdd_alert("hdd_init_wowl failed"); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 3539 | goto err_close_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3540 | } |
| 3541 | |
| 3542 | /* Adapter successfully added. Increment the vdev count */ |
| 3543 | hdd_ctx->current_intf_count++; |
| 3544 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3545 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3546 | hdd_ctx->current_intf_count); |
| 3547 | |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 3548 | cds_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3549 | } |
| 3550 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 3551 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
| 3552 | hdd_err("Interface %s wow debug_fs init failed", iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3553 | |
| 3554 | return adapter; |
| 3555 | |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 3556 | err_close_adapter: |
| 3557 | hdd_close_adapter(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3558 | err_free_netdev: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3559 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->macAddressCurrent.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 3560 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3561 | |
| 3562 | return NULL; |
| 3563 | } |
| 3564 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3565 | 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] | 3566 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3567 | { |
| 3568 | hdd_adapter_list_node_t *adapterNode, *pCurrent, *pNext; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3569 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3570 | |
| 3571 | status = hdd_get_front_adapter(hdd_ctx, &pCurrent); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3572 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3573 | hdd_warn("adapter list empty %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3574 | status); |
| 3575 | return status; |
| 3576 | } |
| 3577 | |
| 3578 | while (pCurrent->pAdapter != adapter) { |
| 3579 | status = hdd_get_next_adapter(hdd_ctx, pCurrent, &pNext); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3580 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3581 | break; |
| 3582 | |
| 3583 | pCurrent = pNext; |
| 3584 | } |
| 3585 | adapterNode = pCurrent; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3586 | if (QDF_STATUS_SUCCESS == status) { |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 3587 | hdd_info("wait for bus bw work to flush"); |
| 3588 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 3589 | cds_clear_concurrency_mode(adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3590 | hdd_cleanup_adapter(hdd_ctx, adapterNode->pAdapter, rtnl_held); |
| 3591 | |
| 3592 | hdd_remove_adapter(hdd_ctx, adapterNode); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3593 | qdf_mem_free(adapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3594 | adapterNode = NULL; |
| 3595 | |
| 3596 | /* Adapter removed. Decrement vdev count */ |
| 3597 | if (hdd_ctx->current_intf_count != 0) |
| 3598 | hdd_ctx->current_intf_count--; |
| 3599 | |
| 3600 | /* Fw will take care incase of concurrency */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3601 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3602 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3603 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3604 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3605 | } |
| 3606 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3607 | /** |
| 3608 | * hdd_close_all_adapters - Close all open adapters |
| 3609 | * @hdd_ctx: Hdd context |
| 3610 | * rtnl_held: True if RTNL lock held |
| 3611 | * |
| 3612 | * Close all open adapters. |
| 3613 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3614 | * Return: QDF status code |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3615 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3616 | 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] | 3617 | { |
| 3618 | hdd_adapter_list_node_t *pHddAdapterNode; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3619 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3620 | |
| 3621 | ENTER(); |
| 3622 | |
| 3623 | do { |
| 3624 | status = hdd_remove_front_adapter(hdd_ctx, &pHddAdapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3625 | if (pHddAdapterNode && QDF_STATUS_SUCCESS == status) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3626 | wlan_hdd_release_intf_addr(hdd_ctx, |
| 3627 | pHddAdapterNode->pAdapter->macAddressCurrent.bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3628 | hdd_cleanup_adapter(hdd_ctx, pHddAdapterNode->pAdapter, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3629 | rtnl_held); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3630 | qdf_mem_free(pHddAdapterNode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3631 | /* Adapter removed. Decrement vdev count */ |
| 3632 | if (hdd_ctx->current_intf_count != 0) |
| 3633 | hdd_ctx->current_intf_count--; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3634 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3635 | } while (NULL != pHddAdapterNode && QDF_STATUS_E_EMPTY != status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3636 | |
| 3637 | EXIT(); |
| 3638 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3639 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3640 | } |
| 3641 | |
| 3642 | void wlan_hdd_reset_prob_rspies(hdd_adapter_t *pHostapdAdapter) |
| 3643 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3644 | struct qdf_mac_addr *bssid = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3645 | tSirUpdateIE updateIE; |
| 3646 | switch (pHostapdAdapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3647 | case QDF_STA_MODE: |
| 3648 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3649 | { |
| 3650 | hdd_station_ctx_t *pHddStaCtx = |
| 3651 | WLAN_HDD_GET_STATION_CTX_PTR(pHostapdAdapter); |
Srinivas Girigowda | 8b98396 | 2015-11-18 22:14:34 -0800 | [diff] [blame] | 3652 | bssid = &pHddStaCtx->conn_info.bssId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3653 | break; |
| 3654 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3655 | case QDF_SAP_MODE: |
| 3656 | case QDF_P2P_GO_MODE: |
| 3657 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3658 | { |
Srinivas Girigowda | 8b98396 | 2015-11-18 22:14:34 -0800 | [diff] [blame] | 3659 | bssid = &pHostapdAdapter->macAddressCurrent; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3660 | break; |
| 3661 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3662 | case QDF_FTM_MODE: |
| 3663 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3664 | default: |
| 3665 | /* |
| 3666 | * wlan_hdd_reset_prob_rspies should not have been called |
| 3667 | * for these kind of devices |
| 3668 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3669 | hdd_err("Unexpected request for the current device type %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3670 | pHostapdAdapter->device_mode); |
| 3671 | return; |
| 3672 | } |
| 3673 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 3674 | qdf_copy_macaddr(&updateIE.bssid, bssid); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3675 | updateIE.smeSessionId = pHostapdAdapter->sessionId; |
| 3676 | updateIE.ieBufferlength = 0; |
| 3677 | updateIE.pAdditionIEBuffer = NULL; |
| 3678 | updateIE.append = true; |
| 3679 | updateIE.notify = false; |
| 3680 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(pHostapdAdapter), |
| 3681 | &updateIE, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3682 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3683 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3684 | } |
| 3685 | } |
| 3686 | |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 3687 | /** |
| 3688 | * hdd_wait_for_sme_close_sesion() - Close and wait for SME session close |
| 3689 | * @hdd_ctx: HDD context which is already NULL validated |
| 3690 | * @adapter: HDD adapter which is already NULL validated |
| 3691 | * |
| 3692 | * Close the SME session and wait for its completion, if needed. |
| 3693 | * |
| 3694 | * Return: None |
| 3695 | */ |
| 3696 | static void hdd_wait_for_sme_close_sesion(hdd_context_t *hdd_ctx, |
| 3697 | hdd_adapter_t *adapter) |
| 3698 | { |
Rajeev Kumar | 9591d2b | 2017-01-13 16:05:06 -0800 | [diff] [blame] | 3699 | int ret; |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 3700 | unsigned long rc; |
| 3701 | |
| 3702 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 3703 | hdd_err("session is not opened:%d", adapter->sessionId); |
| 3704 | return; |
| 3705 | } |
| 3706 | |
| 3707 | INIT_COMPLETION(adapter->session_close_comp_var); |
| 3708 | if (QDF_STATUS_SUCCESS == |
| 3709 | sme_close_session(hdd_ctx->hHal, adapter->sessionId, |
| 3710 | hdd_sme_close_session_callback, |
| 3711 | adapter)) { |
| 3712 | /* |
| 3713 | * Block on a completion variable. Can't wait |
| 3714 | * forever though. |
| 3715 | */ |
| 3716 | rc = wait_for_completion_timeout( |
| 3717 | &adapter->session_close_comp_var, |
| 3718 | msecs_to_jiffies |
| 3719 | (WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
Sandeep Puligilla | ada7292 | 2016-09-29 19:31:21 -0700 | [diff] [blame] | 3720 | if (!rc) { |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 3721 | hdd_err("failure waiting for session_close_comp_var"); |
Sandeep Puligilla | ada7292 | 2016-09-29 19:31:21 -0700 | [diff] [blame] | 3722 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3723 | hdd_ndp_session_end_handler(adapter); |
| 3724 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Hanumanth Reddy Pothula | 3370212 | 2016-10-07 17:27:04 +0530 | [diff] [blame] | 3725 | return; |
Sandeep Puligilla | ada7292 | 2016-09-29 19:31:21 -0700 | [diff] [blame] | 3726 | } |
Rajeev Kumar | 9591d2b | 2017-01-13 16:05:06 -0800 | [diff] [blame] | 3727 | ret = hdd_release_and_destroy_vdev(adapter); |
| 3728 | if (ret) |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 3729 | hdd_err("vdev delete failed"); |
| 3730 | |
Hanumanth Reddy Pothula | 3370212 | 2016-10-07 17:27:04 +0530 | [diff] [blame] | 3731 | adapter->sessionId = HDD_SESSION_ID_INVALID; |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 3732 | } |
| 3733 | } |
| 3734 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3735 | 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] | 3736 | const bool bCloseSession) |
| 3737 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3738 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3739 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(adapter); |
| 3740 | union iwreq_data wrqu; |
| 3741 | tSirUpdateIE updateIE; |
| 3742 | unsigned long rc; |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 3743 | hdd_scaninfo_t *scan_info = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3744 | |
| 3745 | ENTER(); |
| 3746 | |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 3747 | scan_info = &adapter->scan_info; |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3748 | hdd_notice("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3749 | wlan_hdd_netif_queue_control(adapter, WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 3750 | WLAN_CONTROL_PATH); |
| 3751 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3752 | case QDF_STA_MODE: |
| 3753 | case QDF_P2P_CLIENT_MODE: |
| 3754 | case QDF_IBSS_MODE: |
| 3755 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3756 | case QDF_NDI_MODE: |
| 3757 | if ((QDF_NDI_MODE == adapter->device_mode) || |
| 3758 | hdd_conn_is_connected( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3759 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)) || |
| 3760 | hdd_is_connecting( |
| 3761 | WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3762 | INIT_COMPLETION(adapter->disconnect_comp_var); |
| 3763 | /* |
| 3764 | * For NDI do not use pWextState from sta_ctx, if needed |
| 3765 | * extract from ndi_ctx. |
| 3766 | */ |
| 3767 | if (QDF_NDI_MODE == adapter->device_mode) |
| 3768 | qdf_ret_status = sme_roam_disconnect( |
| 3769 | hdd_ctx->hHal, |
| 3770 | adapter->sessionId, |
| 3771 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
| 3772 | else if (pWextState->roamProfile.BSSType == |
| 3773 | eCSR_BSS_TYPE_START_IBSS) |
| 3774 | qdf_ret_status = sme_roam_disconnect( |
| 3775 | hdd_ctx->hHal, |
| 3776 | adapter->sessionId, |
| 3777 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3778 | else |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3779 | qdf_ret_status = sme_roam_disconnect( |
| 3780 | hdd_ctx->hHal, |
| 3781 | adapter->sessionId, |
| 3782 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3783 | /* success implies disconnect command got queued up successfully */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3784 | if (qdf_ret_status == QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3785 | rc = wait_for_completion_timeout( |
| 3786 | &adapter->disconnect_comp_var, |
| 3787 | msecs_to_jiffies |
| 3788 | (WLAN_WAIT_TIME_DISCONNECT)); |
| 3789 | if (!rc) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3790 | hdd_err("wait on disconnect_comp_var failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3791 | } |
| 3792 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3793 | hdd_err("failed to post disconnect event to SME"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3794 | } |
| 3795 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 3796 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 3797 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 3798 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 3799 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 3800 | } |
| 3801 | if (scan_info != NULL && scan_info->mScanPending) { |
Mahesh A Saptasagar | ebb47fa | 2016-07-21 18:11:38 +0530 | [diff] [blame] | 3802 | wlan_hdd_scan_abort(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3803 | } |
Himanshu Agarwal | 3d95b90 | 2016-08-24 16:27:03 +0530 | [diff] [blame] | 3804 | hdd_lro_disable(hdd_ctx, adapter); |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 3805 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3806 | |
| 3807 | #ifdef WLAN_OPEN_SOURCE |
| 3808 | cancel_work_sync(&adapter->ipv4NotifierWorkQueue); |
| 3809 | #endif |
| 3810 | |
| 3811 | hdd_deregister_tx_flow_control(adapter); |
| 3812 | |
| 3813 | #ifdef WLAN_NS_OFFLOAD |
| 3814 | #ifdef WLAN_OPEN_SOURCE |
| 3815 | cancel_work_sync(&adapter->ipv6NotifierWorkQueue); |
| 3816 | #endif |
| 3817 | #endif |
| 3818 | |
| 3819 | /* |
| 3820 | * It is possible that the caller of this function does not |
| 3821 | * wish to close the session |
| 3822 | */ |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 3823 | if (true == bCloseSession) { |
| 3824 | if (0 != wlan_hdd_try_disconnect(adapter)) { |
| 3825 | hdd_err("Error: Can't disconnect adapter"); |
| 3826 | return QDF_STATUS_E_FAILURE; |
| 3827 | } |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 3828 | hdd_wait_for_sme_close_sesion(hdd_ctx, adapter); |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 3829 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3830 | break; |
| 3831 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3832 | case QDF_SAP_MODE: |
| 3833 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3834 | if (hdd_ctx->config->conc_custom_rule1 && |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3835 | (QDF_SAP_MODE == adapter->device_mode)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3836 | /* |
| 3837 | * Before stopping the sap adapter, lets make sure there |
| 3838 | * is no sap restart work pending. |
| 3839 | */ |
| 3840 | cds_flush_work(&hdd_ctx->sap_start_work); |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3841 | hdd_info("Canceled the pending SAP restart work"); |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 3842 | cds_change_sap_restart_required_status(false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3843 | } |
| 3844 | /* Any softap specific cleanup here... */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3845 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3846 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 3847 | |
| 3848 | hdd_deregister_tx_flow_control(adapter); |
| 3849 | |
| 3850 | mutex_lock(&hdd_ctx->sap_lock); |
| 3851 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3852 | QDF_STATUS status; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 3853 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3854 | |
| 3855 | /* Stop Bss. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3856 | status = wlansap_stop_bss( |
| 3857 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3858 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3859 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3860 | hdd_hostapd_state_t *hostapd_state = |
| 3861 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 3862 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3863 | qdf_stop_bss_event); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 3864 | qdf_status = |
| 3865 | qdf_wait_single_event(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 3866 | qdf_stop_bss_event, |
| 3867 | SME_CMD_TIMEOUT_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3868 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 3869 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3870 | hdd_err("failure waiting for wlansap_stop_bss %d", |
| 3871 | qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3872 | } |
| 3873 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3874 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3875 | } |
| 3876 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 3877 | cds_decr_session_set_pcl( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3878 | adapter->device_mode, |
| 3879 | adapter->sessionId); |
| 3880 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 3881 | qdf_copy_macaddr(&updateIE.bssid, |
Srinivas Girigowda | 8b98396 | 2015-11-18 22:14:34 -0800 | [diff] [blame] | 3882 | &adapter->macAddressCurrent); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3883 | updateIE.smeSessionId = adapter->sessionId; |
| 3884 | updateIE.ieBufferlength = 0; |
| 3885 | updateIE.pAdditionIEBuffer = NULL; |
| 3886 | updateIE.append = false; |
| 3887 | updateIE.notify = false; |
| 3888 | /* Probe bcn reset */ |
| 3889 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 3890 | &updateIE, eUPDATE_IE_PROBE_BCN) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3891 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3892 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3893 | } |
| 3894 | /* Assoc resp reset */ |
| 3895 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 3896 | &updateIE, |
| 3897 | eUPDATE_IE_ASSOC_RESP) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3898 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3899 | hdd_err("Could not pass on ASSOC_RSP data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3900 | } |
| 3901 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 3902 | wlan_hdd_reset_prob_rspies(adapter); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 3903 | qdf_mem_free(adapter->sessionCtx.ap.beacon); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3904 | adapter->sessionCtx.ap.beacon = NULL; |
| 3905 | } |
| 3906 | mutex_unlock(&hdd_ctx->sap_lock); |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 3907 | if (true == bCloseSession) |
| 3908 | hdd_wait_for_sme_close_sesion(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3909 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3910 | case QDF_OCB_MODE: |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 3911 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3912 | (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX), |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 3913 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.staId[0]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3914 | break; |
| 3915 | default: |
| 3916 | break; |
| 3917 | } |
| 3918 | |
| 3919 | EXIT(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3920 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3921 | } |
| 3922 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 3923 | /** |
| 3924 | * hdd_deinit_all_adapters - deinit all adapters |
| 3925 | * @hdd_ctx: HDD context |
| 3926 | * @rtnl_held: True if RTNL lock held |
| 3927 | * |
| 3928 | */ |
| 3929 | void hdd_deinit_all_adapters(hdd_context_t *hdd_ctx, bool rtnl_held) |
| 3930 | { |
| 3931 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 3932 | QDF_STATUS status; |
| 3933 | hdd_adapter_t *adapter; |
| 3934 | |
| 3935 | ENTER(); |
| 3936 | |
| 3937 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 3938 | |
| 3939 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 3940 | adapter = adapter_node->pAdapter; |
| 3941 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
| 3942 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 3943 | adapter_node = next; |
| 3944 | } |
| 3945 | |
| 3946 | EXIT(); |
| 3947 | } |
| 3948 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3949 | QDF_STATUS hdd_stop_all_adapters(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3950 | { |
| 3951 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3952 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3953 | hdd_adapter_t *adapter; |
| 3954 | |
| 3955 | ENTER(); |
| 3956 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 3957 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 3958 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3959 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 3960 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3961 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3962 | adapter = adapterNode->pAdapter; |
| 3963 | hdd_stop_adapter(hdd_ctx, adapter, true); |
| 3964 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 3965 | adapterNode = pNext; |
| 3966 | } |
| 3967 | |
| 3968 | EXIT(); |
| 3969 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3970 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3971 | } |
| 3972 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3973 | QDF_STATUS hdd_reset_all_adapters(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3974 | { |
| 3975 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3976 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3977 | hdd_adapter_t *adapter; |
| 3978 | |
| 3979 | ENTER(); |
| 3980 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 3981 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 3982 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3983 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 3984 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3985 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3986 | adapter = adapterNode->pAdapter; |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3987 | hdd_notice("Disabling queues"); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 3988 | if (hdd_ctx->config->sap_internal_restart && |
| 3989 | adapter->device_mode == QDF_SAP_MODE) { |
| 3990 | wlan_hdd_netif_queue_control(adapter, |
| 3991 | WLAN_NETIF_TX_DISABLE, |
| 3992 | WLAN_CONTROL_PATH); |
| 3993 | hdd_sap_indicate_disconnect_for_sta(adapter); |
| 3994 | hdd_cleanup_actionframe(hdd_ctx, adapter); |
| 3995 | hdd_sap_destroy_events(adapter); |
| 3996 | } else |
| 3997 | wlan_hdd_netif_queue_control(adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3998 | WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 3999 | WLAN_CONTROL_PATH); |
| 4000 | |
| 4001 | adapter->sessionCtx.station.hdd_ReassocScenario = false; |
| 4002 | |
| 4003 | hdd_deinit_tx_rx(adapter); |
Tushnim Bhattacharyya | 4adb368 | 2016-01-07 15:07:12 -0800 | [diff] [blame] | 4004 | cds_decr_session_set_pcl(adapter->device_mode, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4005 | adapter->sessionId); |
| 4006 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 4007 | hdd_wmm_adapter_close(adapter); |
| 4008 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4009 | } |
| 4010 | |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 4011 | /* |
| 4012 | * If adapter is SAP, set session ID to invalid since SAP |
| 4013 | * session will be cleanup during SSR. |
| 4014 | */ |
| 4015 | if (adapter->device_mode == QDF_SAP_MODE) |
| 4016 | wlansap_set_invalid_session( |
| 4017 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 4018 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4019 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4020 | adapterNode = pNext; |
| 4021 | } |
| 4022 | |
| 4023 | EXIT(); |
| 4024 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4025 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4026 | } |
| 4027 | |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 4028 | bool hdd_check_for_opened_interfaces(hdd_context_t *hdd_ctx) |
| 4029 | { |
| 4030 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 4031 | QDF_STATUS status; |
| 4032 | bool close_modules = true; |
| 4033 | |
| 4034 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 4035 | while ((NULL != adapter_node) && (QDF_STATUS_SUCCESS == status)) { |
| 4036 | if (test_bit(DEVICE_IFACE_OPENED, |
| 4037 | &adapter_node->pAdapter->event_flags)) { |
| 4038 | hdd_info("Still other ifaces are up cannot close modules"); |
| 4039 | close_modules = false; |
| 4040 | break; |
| 4041 | } |
| 4042 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 4043 | adapter_node = next; |
| 4044 | } |
| 4045 | |
| 4046 | return close_modules; |
| 4047 | } |
| 4048 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4049 | /** |
| 4050 | * hdd_is_interface_up()- Checkfor interface up before ssr |
| 4051 | * @hdd_ctx: HDD context |
| 4052 | * |
| 4053 | * check if there are any wlan interfaces before SSR accordingly start |
| 4054 | * the interface. |
| 4055 | * |
| 4056 | * Return: 0 if interface was opened else false |
| 4057 | */ |
| 4058 | static bool hdd_is_interface_up(hdd_adapter_t *adapter) |
| 4059 | { |
| 4060 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 4061 | return true; |
| 4062 | else |
| 4063 | return false; |
| 4064 | } |
| 4065 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4066 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
Abhishek Singh | b5e38ef | 2017-01-02 12:09:34 +0530 | [diff] [blame] | 4067 | && !defined(WITH_BACKPORTS) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4068 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 4069 | struct ieee80211_channel *channel, |
| 4070 | const u8 *bssid, const u8 *ssid, |
| 4071 | size_t ssid_len) |
| 4072 | { |
| 4073 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 4074 | ssid, ssid_len, |
| 4075 | WLAN_CAPABILITY_ESS, |
| 4076 | WLAN_CAPABILITY_ESS); |
| 4077 | } |
| 4078 | #else |
| 4079 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 4080 | struct ieee80211_channel *channel, |
| 4081 | const u8 *bssid, const u8 *ssid, |
| 4082 | size_t ssid_len) |
| 4083 | { |
| 4084 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 4085 | ssid, ssid_len, |
| 4086 | IEEE80211_BSS_TYPE_ESS, |
| 4087 | IEEE80211_PRIVACY_ANY); |
| 4088 | } |
| 4089 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4090 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4091 | #if defined CFG80211_CONNECT_BSS |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4092 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
| 4093 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)) |
| 4094 | /** |
| 4095 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 4096 | * @timeout_reason: reason for connect timeout |
| 4097 | * |
| 4098 | * This function is used to convert host timeout |
| 4099 | * reason enum to kernel specific enum. |
| 4100 | * |
| 4101 | * Return: nl timeout enum |
| 4102 | */ |
| 4103 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 4104 | tSirResultCodes timeout_reason) |
| 4105 | { |
| 4106 | switch (timeout_reason) { |
| 4107 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 4108 | return NL80211_TIMEOUT_SCAN; |
| 4109 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 4110 | return NL80211_TIMEOUT_AUTH; |
| 4111 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 4112 | return NL80211_TIMEOUT_ASSOC; |
| 4113 | default: |
| 4114 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 4115 | } |
| 4116 | } |
| 4117 | |
| 4118 | /** |
| 4119 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 4120 | * @dev: network device |
| 4121 | * @bssid: bssid to which we want to associate |
| 4122 | * @timeout_reason: reason for connect timeout |
| 4123 | * |
| 4124 | * This API is used to send connection timeout reason to supplicant |
| 4125 | * |
| 4126 | * Return: void |
| 4127 | */ |
| 4128 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 4129 | const u8 *bssid, |
| 4130 | tSirResultCodes timeout_reason) |
| 4131 | { |
| 4132 | enum nl80211_timeout_reason nl_timeout_reason; |
| 4133 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 4134 | |
| 4135 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 4136 | nl_timeout_reason); |
| 4137 | } |
| 4138 | |
| 4139 | /** |
| 4140 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 4141 | * @dev: network device |
| 4142 | * @bssid: bssid to which we want to associate |
| 4143 | * @req_ie: Request Information Element |
| 4144 | * @req_ie_len: len of the req IE |
| 4145 | * @resp_ie: Response IE |
| 4146 | * @resp_ie_len: len of ht response IE |
| 4147 | * @status: status |
| 4148 | * @gfp: Kernel Flag |
| 4149 | * @timeout_reason: reason for connect timeout |
| 4150 | * |
| 4151 | * Return: void |
| 4152 | */ |
| 4153 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 4154 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 4155 | size_t req_ie_len, const u8 *resp_ie, |
| 4156 | size_t resp_ie_len, int status, gfp_t gfp, |
| 4157 | tSirResultCodes timeout_reason) |
| 4158 | { |
| 4159 | enum nl80211_timeout_reason nl_timeout_reason; |
| 4160 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 4161 | |
| 4162 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 4163 | resp_ie, resp_ie_len, status, gfp, |
| 4164 | nl_timeout_reason); |
| 4165 | } |
| 4166 | #else |
| 4167 | #if defined CFG80211_CONNECT_TIMEOUT |
| 4168 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 4169 | const u8 *bssid, |
| 4170 | tSirResultCodes timeout_reason) |
| 4171 | { |
| 4172 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 4173 | } |
| 4174 | #endif |
| 4175 | |
| 4176 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 4177 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 4178 | size_t req_ie_len, const u8 *resp_ie, |
| 4179 | size_t resp_ie_len, int status, gfp_t gfp, |
| 4180 | tSirResultCodes timeout_reason) |
| 4181 | { |
| 4182 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 4183 | resp_ie, resp_ie_len, status, gfp); |
| 4184 | } |
| 4185 | #endif |
| 4186 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4187 | /** |
| 4188 | * hdd_connect_bss() - API to send connection status to supplicant |
| 4189 | * @dev: network device |
| 4190 | * @bssid: bssid to which we want to associate |
| 4191 | * @req_ie: Request Information Element |
| 4192 | * @req_ie_len: len of the req IE |
| 4193 | * @resp_ie: Response IE |
| 4194 | * @resp_ie_len: len of ht response IE |
| 4195 | * @status: status |
| 4196 | * @gfp: Kernel Flag |
| 4197 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4198 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4199 | * |
| 4200 | * The API is a wrapper to send connection status to supplicant |
| 4201 | * |
| 4202 | * Return: Void |
| 4203 | */ |
| 4204 | #if defined CFG80211_CONNECT_TIMEOUT |
| 4205 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 4206 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 4207 | size_t req_ie_len, const u8 *resp_ie, |
| 4208 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4209 | bool connect_timeout, |
| 4210 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4211 | { |
| 4212 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4213 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4214 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4215 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 4216 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4217 | } |
| 4218 | #else |
| 4219 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 4220 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 4221 | size_t req_ie_len, const u8 *resp_ie, |
| 4222 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4223 | bool connect_timeout, |
| 4224 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4225 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4226 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 4227 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4228 | } |
| 4229 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4230 | |
| 4231 | /** |
| 4232 | * hdd_connect_result() - API to send connection status to supplicant |
| 4233 | * @dev: network device |
| 4234 | * @bssid: bssid to which we want to associate |
| 4235 | * @roam_info: information about connected bss |
| 4236 | * @req_ie: Request Information Element |
| 4237 | * @req_ie_len: len of the req IE |
| 4238 | * @resp_ie: Response IE |
| 4239 | * @resp_ie_len: len of ht response IE |
| 4240 | * @status: status |
| 4241 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4242 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4243 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4244 | * |
| 4245 | * The API is a wrapper to send connection status to supplicant |
| 4246 | * and allow runtime suspend |
| 4247 | * |
| 4248 | * Return: Void |
| 4249 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4250 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
| 4251 | tCsrRoamInfo *roam_info, const u8 *req_ie, |
| 4252 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4253 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4254 | bool connect_timeout, |
| 4255 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4256 | { |
| 4257 | hdd_adapter_t *padapter = (hdd_adapter_t *) netdev_priv(dev); |
| 4258 | struct cfg80211_bss *bss = NULL; |
| 4259 | |
| 4260 | if (WLAN_STATUS_SUCCESS == status) { |
| 4261 | struct ieee80211_channel *chan; |
| 4262 | int freq; |
| 4263 | int chan_no = roam_info->pBssDesc->channelId; |
| 4264 | |
| 4265 | if (chan_no <= 14) |
| 4266 | freq = ieee80211_channel_to_frequency(chan_no, |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 4267 | NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4268 | else |
| 4269 | freq = ieee80211_channel_to_frequency(chan_no, |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 4270 | NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4271 | |
| 4272 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
| 4273 | bss = hdd_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
| 4274 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 4275 | roam_info->u.pConnectedProfile->SSID.length); |
| 4276 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 4277 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4278 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 4279 | req_ie_len, resp_ie, resp_ie_len, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4280 | status, gfp, connect_timeout, timeout_reason); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 4281 | |
| 4282 | qdf_runtime_pm_allow_suspend(padapter->connect_rpm_ctx.connect); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4283 | } |
| 4284 | #else |
| 4285 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
| 4286 | tCsrRoamInfo *roam_info, const u8 *req_ie, |
| 4287 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4288 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4289 | bool connect_timeout, |
| 4290 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4291 | { |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 4292 | hdd_adapter_t *padapter = (hdd_adapter_t *) netdev_priv(dev); |
| 4293 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4294 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 4295 | resp_ie, resp_ie_len, status, gfp); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 4296 | qdf_runtime_pm_allow_suspend(padapter->connect_rpm_ctx.connect); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4297 | } |
| 4298 | #endif |
| 4299 | |
| 4300 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4301 | QDF_STATUS hdd_start_all_adapters(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4302 | { |
| 4303 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4304 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4305 | hdd_adapter_t *adapter; |
| 4306 | #ifndef MSM_PLATFORM |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4307 | struct qdf_mac_addr bcastMac = QDF_MAC_ADDR_BROADCAST_INITIALIZER; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4308 | #endif |
| 4309 | eConnectionState connState; |
| 4310 | |
| 4311 | ENTER(); |
| 4312 | |
| 4313 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4314 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4315 | adapter = adapterNode->pAdapter; |
| 4316 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4317 | if (!hdd_is_interface_up(adapter)) |
Hanumanth Reddy Pothula | c1c4d2b | 2016-09-22 15:45:16 +0530 | [diff] [blame] | 4318 | goto get_adapter; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4319 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4320 | hdd_wmm_init(adapter); |
| 4321 | |
| 4322 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4323 | case QDF_STA_MODE: |
| 4324 | case QDF_P2P_CLIENT_MODE: |
| 4325 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4326 | |
| 4327 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 4328 | ->conn_info.connState; |
| 4329 | |
| 4330 | hdd_init_station_mode(adapter); |
| 4331 | /* Open the gates for HDD to receive Wext commands */ |
| 4332 | adapter->isLinkUpSvcNeeded = false; |
| 4333 | adapter->scan_info.mScanPending = false; |
| 4334 | |
| 4335 | /* Indicate disconnect event to supplicant if associated previously */ |
| 4336 | if (eConnectionState_Associated == connState || |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 4337 | eConnectionState_IbssConnected == connState || |
| 4338 | eConnectionState_NotConnected == connState || |
| 4339 | eConnectionState_IbssDisconnected == connState || |
| 4340 | eConnectionState_Disconnecting == connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4341 | union iwreq_data wrqu; |
| 4342 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 4343 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 4344 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 4345 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 4346 | &wrqu, NULL); |
| 4347 | adapter->sessionCtx.station. |
| 4348 | hdd_ReassocScenario = false; |
| 4349 | |
| 4350 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 4351 | wlan_hdd_cfg80211_indicate_disconnect( |
| 4352 | adapter->dev, false, |
| 4353 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4354 | } else if (eConnectionState_Connecting == connState) { |
| 4355 | /* |
| 4356 | * Indicate connect failure to supplicant if we were in the |
| 4357 | * process of connecting |
| 4358 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4359 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4360 | NULL, 0, NULL, 0, |
| 4361 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
| 4362 | GFP_KERNEL, false, |
| 4363 | 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4364 | } |
| 4365 | |
| 4366 | hdd_register_tx_flow_control(adapter, |
| 4367 | hdd_tx_resume_timer_expired_handler, |
| 4368 | hdd_tx_resume_cb); |
| 4369 | |
| 4370 | break; |
| 4371 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4372 | case QDF_SAP_MODE: |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 4373 | if (hdd_ctx->config->sap_internal_restart) |
| 4374 | hdd_init_ap_mode(adapter, true); |
| 4375 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4376 | break; |
| 4377 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4378 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4379 | #ifdef MSM_PLATFORM |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4380 | hdd_err("[SSR] send stop ap to supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4381 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 4382 | #else |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4383 | hdd_err("[SSR] send restart supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4384 | /* event supplicant to restart */ |
| 4385 | cfg80211_del_sta(adapter->dev, |
| 4386 | (const u8 *)&bcastMac.bytes[0], |
| 4387 | GFP_KERNEL); |
| 4388 | #endif |
| 4389 | break; |
| 4390 | |
| 4391 | default: |
| 4392 | break; |
| 4393 | } |
Hanumanth Reddy Pothula | c1c4d2b | 2016-09-22 15:45:16 +0530 | [diff] [blame] | 4394 | get_adapter: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4395 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4396 | adapterNode = pNext; |
| 4397 | } |
| 4398 | |
| 4399 | EXIT(); |
| 4400 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4401 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4402 | } |
| 4403 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4404 | QDF_STATUS hdd_get_front_adapter(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4405 | hdd_adapter_list_node_t **padapterNode) |
| 4406 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4407 | QDF_STATUS status; |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4408 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4409 | status = qdf_list_peek_front(&hdd_ctx->hddAdapters, |
| 4410 | (qdf_list_node_t **) padapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4411 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4412 | return status; |
| 4413 | } |
| 4414 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4415 | QDF_STATUS hdd_get_next_adapter(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4416 | hdd_adapter_list_node_t *adapterNode, |
| 4417 | hdd_adapter_list_node_t **pNextAdapterNode) |
| 4418 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4419 | QDF_STATUS status; |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4420 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4421 | status = qdf_list_peek_next(&hdd_ctx->hddAdapters, |
| 4422 | (qdf_list_node_t *) adapterNode, |
| 4423 | (qdf_list_node_t **) pNextAdapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4424 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4425 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4426 | return status; |
| 4427 | } |
| 4428 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4429 | QDF_STATUS hdd_remove_adapter(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4430 | hdd_adapter_list_node_t *adapterNode) |
| 4431 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4432 | QDF_STATUS status; |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4433 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4434 | status = qdf_list_remove_node(&hdd_ctx->hddAdapters, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4435 | &adapterNode->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4436 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4437 | return status; |
| 4438 | } |
| 4439 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4440 | QDF_STATUS hdd_remove_front_adapter(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4441 | hdd_adapter_list_node_t **padapterNode) |
| 4442 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4443 | QDF_STATUS status; |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4444 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4445 | status = qdf_list_remove_front(&hdd_ctx->hddAdapters, |
| 4446 | (qdf_list_node_t **) padapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4447 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4448 | return status; |
| 4449 | } |
| 4450 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4451 | QDF_STATUS hdd_add_adapter_back(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4452 | hdd_adapter_list_node_t *adapterNode) |
| 4453 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4454 | QDF_STATUS status; |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4455 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4456 | status = qdf_list_insert_back(&hdd_ctx->hddAdapters, |
| 4457 | (qdf_list_node_t *) adapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4458 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4459 | return status; |
| 4460 | } |
| 4461 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4462 | QDF_STATUS hdd_add_adapter_front(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4463 | hdd_adapter_list_node_t *adapterNode) |
| 4464 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4465 | QDF_STATUS status; |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4466 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4467 | status = qdf_list_insert_front(&hdd_ctx->hddAdapters, |
| 4468 | (qdf_list_node_t *) adapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4469 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4470 | return status; |
| 4471 | } |
| 4472 | |
| 4473 | hdd_adapter_t *hdd_get_adapter_by_macaddr(hdd_context_t *hdd_ctx, |
| 4474 | tSirMacAddr macAddr) |
| 4475 | { |
| 4476 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 4477 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4478 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4479 | |
| 4480 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4481 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4482 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4483 | adapter = adapterNode->pAdapter; |
| 4484 | |
| 4485 | if (adapter |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4486 | && !qdf_mem_cmp(adapter->macAddressCurrent.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4487 | macAddr, sizeof(tSirMacAddr))) { |
| 4488 | return adapter; |
| 4489 | } |
| 4490 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4491 | adapterNode = pNext; |
| 4492 | } |
| 4493 | |
| 4494 | return NULL; |
| 4495 | |
| 4496 | } |
| 4497 | |
| 4498 | hdd_adapter_t *hdd_get_adapter_by_vdev(hdd_context_t *hdd_ctx, |
| 4499 | uint32_t vdev_id) |
| 4500 | { |
| 4501 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 4502 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4503 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4504 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4505 | qdf_status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4506 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4507 | while ((NULL != adapterNode) && (QDF_STATUS_SUCCESS == qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4508 | adapter = adapterNode->pAdapter; |
| 4509 | |
| 4510 | if (adapter->sessionId == vdev_id) |
| 4511 | return adapter; |
| 4512 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4513 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4514 | hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4515 | adapterNode = pNext; |
| 4516 | } |
| 4517 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4518 | hdd_err("vdev_id %d does not exist with host", vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4519 | |
| 4520 | return NULL; |
| 4521 | } |
| 4522 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 4523 | /** |
| 4524 | * hdd_get_adapter_by_sme_session_id() - Return adapter with |
| 4525 | * the sessionid |
| 4526 | * @hdd_ctx: hdd context. |
| 4527 | * @sme_session_id: sme session is for the adapter to get. |
| 4528 | * |
| 4529 | * This function is used to get the adapter with provided session id |
| 4530 | * |
| 4531 | * Return: adapter pointer if found |
| 4532 | * |
| 4533 | */ |
| 4534 | hdd_adapter_t *hdd_get_adapter_by_sme_session_id(hdd_context_t *hdd_ctx, |
| 4535 | uint32_t sme_session_id) |
| 4536 | { |
| 4537 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 4538 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4539 | QDF_STATUS qdf_status; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 4540 | |
| 4541 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4542 | qdf_status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 4543 | |
| 4544 | while ((NULL != adapter_node) && |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4545 | (QDF_STATUS_SUCCESS == qdf_status)) { |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 4546 | adapter = adapter_node->pAdapter; |
| 4547 | |
| 4548 | if (adapter && |
| 4549 | adapter->sessionId == sme_session_id) |
| 4550 | return adapter; |
| 4551 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4552 | qdf_status = |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 4553 | hdd_get_next_adapter(hdd_ctx, |
| 4554 | adapter_node, &next); |
| 4555 | adapter_node = next; |
| 4556 | } |
| 4557 | return NULL; |
| 4558 | } |
| 4559 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4560 | /** |
| 4561 | * hdd_get_adapter() - to get adapter matching the mode |
| 4562 | * @hdd_ctx: hdd context |
| 4563 | * @mode: adapter mode |
| 4564 | * |
| 4565 | * This routine will return the pointer to adapter matching |
| 4566 | * with the passed mode. |
| 4567 | * |
| 4568 | * Return: pointer to adapter or null |
| 4569 | */ |
| 4570 | hdd_adapter_t *hdd_get_adapter(hdd_context_t *hdd_ctx, |
| 4571 | enum tQDF_ADAPTER_MODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4572 | { |
| 4573 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 4574 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4575 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4576 | |
| 4577 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4578 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4579 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4580 | adapter = adapterNode->pAdapter; |
| 4581 | |
| 4582 | if (adapter && (mode == adapter->device_mode)) |
| 4583 | return adapter; |
| 4584 | |
| 4585 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4586 | adapterNode = pNext; |
| 4587 | } |
| 4588 | |
| 4589 | return NULL; |
| 4590 | |
| 4591 | } |
| 4592 | |
| 4593 | /** |
| 4594 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 4595 | * @hdd_ctx: Pointer to the HDD context. |
| 4596 | * @mode: Device mode for which operating channel is required. |
| 4597 | * Suported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4598 | * QDF_STA_MODE, |
| 4599 | * QDF_P2P_CLIENT_MODE, |
| 4600 | * QDF_SAP_MODE, |
| 4601 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4602 | * |
| 4603 | * This API returns the operating channel of the requested device mode |
| 4604 | * |
| 4605 | * Return: channel number. "0" id the requested device is not found OR it is |
| 4606 | * not connected. |
| 4607 | */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4608 | uint8_t hdd_get_operating_channel(hdd_context_t *hdd_ctx, |
| 4609 | enum tQDF_ADAPTER_MODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4610 | { |
| 4611 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4612 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4613 | hdd_adapter_t *adapter; |
| 4614 | uint8_t operatingChannel = 0; |
| 4615 | |
| 4616 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4617 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4618 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4619 | adapter = adapterNode->pAdapter; |
| 4620 | |
| 4621 | if (mode == adapter->device_mode) { |
| 4622 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4623 | case QDF_STA_MODE: |
| 4624 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4625 | if (hdd_conn_is_connected |
| 4626 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 4627 | (adapter))) { |
| 4628 | operatingChannel = |
| 4629 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 4630 | (adapter))->conn_info. |
| 4631 | operationChannel; |
| 4632 | } |
| 4633 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4634 | case QDF_SAP_MODE: |
| 4635 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4636 | /* softap connection info */ |
| 4637 | if (test_bit |
| 4638 | (SOFTAP_BSS_STARTED, |
| 4639 | &adapter->event_flags)) |
| 4640 | operatingChannel = |
| 4641 | (WLAN_HDD_GET_AP_CTX_PTR |
| 4642 | (adapter))->operatingChannel; |
| 4643 | break; |
| 4644 | default: |
| 4645 | break; |
| 4646 | } |
| 4647 | |
| 4648 | break; /* Found the device of interest. break the loop */ |
| 4649 | } |
| 4650 | |
| 4651 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4652 | adapterNode = pNext; |
| 4653 | } |
| 4654 | return operatingChannel; |
| 4655 | } |
| 4656 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4657 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(hdd_context_t * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4658 | hdd_ctx) |
| 4659 | { |
| 4660 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4661 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4662 | hdd_adapter_t *adapter; |
| 4663 | |
| 4664 | ENTER(); |
| 4665 | |
| 4666 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4667 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4668 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4669 | adapter = adapterNode->pAdapter; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4670 | if ((adapter->device_mode == QDF_STA_MODE) || |
| 4671 | (adapter->device_mode == QDF_P2P_CLIENT_MODE) || |
| 4672 | (adapter->device_mode == QDF_IBSS_MODE) || |
| 4673 | (adapter->device_mode == QDF_P2P_DEVICE_MODE) || |
| 4674 | (adapter->device_mode == QDF_SAP_MODE) || |
| 4675 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4676 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 4677 | hdd_unregister_wext(adapter->dev); |
| 4678 | } |
| 4679 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4680 | adapterNode = pNext; |
| 4681 | } |
| 4682 | |
| 4683 | EXIT(); |
| 4684 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4685 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4686 | } |
| 4687 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4688 | 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] | 4689 | { |
| 4690 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4691 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4692 | hdd_adapter_t *adapter; |
| 4693 | |
| 4694 | ENTER(); |
| 4695 | |
| 4696 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4697 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4698 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4699 | adapter = adapterNode->pAdapter; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4700 | if ((adapter->device_mode == QDF_STA_MODE) || |
| 4701 | (adapter->device_mode == QDF_P2P_CLIENT_MODE) || |
| 4702 | (adapter->device_mode == QDF_IBSS_MODE) || |
| 4703 | (adapter->device_mode == QDF_P2P_DEVICE_MODE) || |
| 4704 | (adapter->device_mode == QDF_SAP_MODE) || |
| 4705 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4706 | hdd_abort_mac_scan(hdd_ctx, adapter->sessionId, |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4707 | INVALID_SCAN_ID, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4708 | eCSR_SCAN_ABORT_DEFAULT); |
| 4709 | } |
| 4710 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4711 | adapterNode = pNext; |
| 4712 | } |
| 4713 | |
| 4714 | EXIT(); |
| 4715 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4716 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4717 | } |
| 4718 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 4719 | /** |
| 4720 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 4721 | * adapters |
| 4722 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 4723 | * |
| 4724 | * return: QDF_STATUS_SUCCESS |
| 4725 | */ |
| 4726 | static QDF_STATUS hdd_abort_sched_scan_all_adapters(hdd_context_t *hdd_ctx) |
| 4727 | { |
| 4728 | hdd_adapter_list_node_t *adapter_node = NULL, *next_node = NULL; |
| 4729 | QDF_STATUS status; |
| 4730 | hdd_adapter_t *adapter; |
| 4731 | int err; |
| 4732 | |
| 4733 | ENTER(); |
| 4734 | |
| 4735 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 4736 | |
| 4737 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 4738 | adapter = adapter_node->pAdapter; |
| 4739 | if ((adapter->device_mode == QDF_STA_MODE) || |
| 4740 | (adapter->device_mode == QDF_P2P_CLIENT_MODE) || |
| 4741 | (adapter->device_mode == QDF_IBSS_MODE) || |
| 4742 | (adapter->device_mode == QDF_P2P_DEVICE_MODE) || |
| 4743 | (adapter->device_mode == QDF_SAP_MODE) || |
| 4744 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
| 4745 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 4746 | if (err) |
| 4747 | hdd_err("Unable to stop scheduled scan"); |
| 4748 | } |
| 4749 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next_node); |
| 4750 | adapter_node = next_node; |
| 4751 | } |
| 4752 | |
| 4753 | EXIT(); |
| 4754 | |
| 4755 | return QDF_STATUS_SUCCESS; |
| 4756 | } |
| 4757 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4758 | #ifdef WLAN_NS_OFFLOAD |
| 4759 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4760 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4761 | * @hdd_ctx: Pointer to hdd context |
| 4762 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4763 | * Unregister for IPv6 address change notifications. |
| 4764 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4765 | * Return: None |
| 4766 | */ |
| 4767 | static void hdd_wlan_unregister_ip6_notifier(hdd_context_t *hdd_ctx) |
| 4768 | { |
| 4769 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
| 4770 | |
| 4771 | return; |
| 4772 | } |
| 4773 | |
| 4774 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4775 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4776 | * @hdd_ctx: Pointer to hdd context |
| 4777 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4778 | * Register for IPv6 address change notifications. |
| 4779 | * |
| 4780 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4781 | */ |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4782 | static int hdd_wlan_register_ip6_notifier(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4783 | { |
| 4784 | int ret; |
| 4785 | |
| 4786 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 4787 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4788 | if (ret) { |
| 4789 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 4790 | goto out; |
| 4791 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4792 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4793 | hdd_info("Registered IPv6 notifier"); |
| 4794 | out: |
| 4795 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4796 | } |
| 4797 | #else |
| 4798 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4799 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4800 | * @hdd_ctx: Pointer to hdd context |
| 4801 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4802 | * Unregister for IPv6 address change notifications. |
| 4803 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4804 | * Return: None |
| 4805 | */ |
| 4806 | static void hdd_wlan_unregister_ip6_notifier(hdd_context_t *hdd_ctx) |
| 4807 | { |
| 4808 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4809 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4810 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4811 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4812 | * @hdd_ctx: Pointer to hdd context |
| 4813 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4814 | * Register for IPv6 address change notifications. |
| 4815 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4816 | * Return: None |
| 4817 | */ |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4818 | static int hdd_wlan_register_ip6_notifier(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4819 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4820 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4821 | } |
| 4822 | #endif |
| 4823 | |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 4824 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 4825 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4826 | * hdd_logging_sock_activate_svc() - Activate logging |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 4827 | * @hdd_ctx: HDD context |
| 4828 | * |
| 4829 | * Activates the logging service |
| 4830 | * |
| 4831 | * Return: Zero in case of success, negative value otherwise |
| 4832 | */ |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4833 | static int hdd_logging_sock_activate_svc(hdd_context_t *hdd_ctx) |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 4834 | { |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4835 | int ret; |
| 4836 | struct hdd_config *config = hdd_ctx->config; |
| 4837 | |
| 4838 | if (!config->wlanLoggingEnable) |
| 4839 | return 0; |
| 4840 | |
| 4841 | ret = wlan_logging_sock_activate_svc(config->wlanLoggingFEToConsole, |
| 4842 | config->wlanLoggingNumBuf); |
| 4843 | if (ret) |
| 4844 | hdd_err("wlan_logging_sock_activate_svc failed: %d", ret); |
| 4845 | return ret; |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 4846 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4847 | |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 4848 | /** |
| 4849 | * wlan_hdd_logging_sock_deactivate_svc() - Deactivate logging |
| 4850 | * @hdd_ctx: HDD context |
| 4851 | * |
| 4852 | * Deactivates the logging service |
| 4853 | * |
| 4854 | * Return: 0 on deactivating the logging service |
| 4855 | */ |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4856 | static int hdd_logging_sock_deactivate_svc(hdd_context_t *hdd_ctx) |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 4857 | { |
| 4858 | if (hdd_ctx && hdd_ctx->config->wlanLoggingEnable) |
| 4859 | return wlan_logging_sock_deactivate_svc(); |
| 4860 | |
| 4861 | return 0; |
| 4862 | } |
| 4863 | #else |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4864 | 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] | 4865 | { |
| 4866 | return 0; |
| 4867 | } |
| 4868 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4869 | 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] | 4870 | { |
| 4871 | return 0; |
| 4872 | } |
| 4873 | #endif |
| 4874 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4875 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4876 | * hdd_register_notifiers - Register netdev notifiers. |
| 4877 | * @hdd_ctx: HDD context |
| 4878 | * |
| 4879 | * Register netdev notifiers like IPv4 and IPv6. |
| 4880 | * |
| 4881 | * Return: 0 on success and errno on failure |
| 4882 | */ |
| 4883 | static int hdd_register_notifiers(hdd_context_t *hdd_ctx) |
| 4884 | { |
| 4885 | int ret; |
| 4886 | |
| 4887 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 4888 | if (ret) { |
| 4889 | hdd_err("register_netdevice_notifier failed: %d", ret); |
| 4890 | goto out; |
| 4891 | } |
| 4892 | |
| 4893 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 4894 | if (ret) |
| 4895 | goto unregister_notifier; |
| 4896 | |
| 4897 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 4898 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 4899 | if (ret) { |
| 4900 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 4901 | goto unregister_ip6_notifier; |
| 4902 | } |
| 4903 | |
| 4904 | return 0; |
| 4905 | |
| 4906 | unregister_ip6_notifier: |
| 4907 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 4908 | unregister_notifier: |
| 4909 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 4910 | out: |
| 4911 | return ret; |
| 4912 | |
| 4913 | } |
| 4914 | |
| 4915 | /** |
| 4916 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 4917 | * @hdd_ctx: HDD context |
| 4918 | * |
| 4919 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 4920 | * |
| 4921 | * Return: None. |
| 4922 | */ |
| 4923 | static void hdd_unregister_notifiers(hdd_context_t *hdd_ctx) |
| 4924 | { |
| 4925 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 4926 | |
| 4927 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 4928 | |
| 4929 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 4930 | } |
| 4931 | |
| 4932 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4933 | * hdd_exit_netlink_services - Exit netlink services |
| 4934 | * @hdd_ctx: HDD context |
| 4935 | * |
| 4936 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 4937 | * nl service. |
| 4938 | * |
| 4939 | * Return: None. |
| 4940 | */ |
| 4941 | static void hdd_exit_netlink_services(hdd_context_t *hdd_ctx) |
| 4942 | { |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4943 | hdd_close_cesium_nl_sock(); |
| 4944 | |
| 4945 | ptt_sock_deactivate_svc(); |
| 4946 | |
| 4947 | nl_srv_exit(); |
| 4948 | } |
| 4949 | |
| 4950 | /** |
| 4951 | * hdd_init_netlink_services- Init netlink services |
| 4952 | * @hdd_ctx: HDD context |
| 4953 | * |
| 4954 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 4955 | * nl service. |
| 4956 | * |
| 4957 | * Return: 0 on success and errno on failure. |
| 4958 | */ |
| 4959 | static int hdd_init_netlink_services(hdd_context_t *hdd_ctx) |
| 4960 | { |
| 4961 | int ret; |
| 4962 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 4963 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4964 | if (ret) { |
| 4965 | hdd_alert("nl_srv_init failed: %d", ret); |
| 4966 | goto out; |
| 4967 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 4968 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4969 | |
| 4970 | ret = oem_activate_service(hdd_ctx); |
| 4971 | if (ret) { |
| 4972 | hdd_alert("oem_activate_service failed: %d", ret); |
| 4973 | goto err_nl_srv; |
| 4974 | } |
| 4975 | |
| 4976 | ret = ptt_sock_activate_svc(); |
| 4977 | if (ret) { |
| 4978 | hdd_alert("ptt_sock_activate_svc failed: %d", ret); |
| 4979 | goto err_nl_srv; |
| 4980 | } |
| 4981 | |
| 4982 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 4983 | if (ret) |
| 4984 | hdd_warn("hdd_open_cesium_nl_sock failed"); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4985 | |
| 4986 | ret = cnss_diag_activate_service(); |
| 4987 | if (ret) { |
| 4988 | hdd_alert("cnss_diag_activate_service failed: %d", ret); |
| 4989 | goto err_close_cesium; |
| 4990 | } |
| 4991 | |
| 4992 | return 0; |
| 4993 | |
| 4994 | err_close_cesium: |
| 4995 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4996 | ptt_sock_deactivate_svc(); |
| 4997 | err_nl_srv: |
| 4998 | nl_srv_exit(); |
| 4999 | out: |
| 5000 | return ret; |
| 5001 | } |
| 5002 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5003 | /** |
| 5004 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 5005 | * @hdd_ctx: HDD context. |
| 5006 | * |
| 5007 | * Destroy RX wakelock. |
| 5008 | * |
| 5009 | * Return: None. |
| 5010 | */ |
| 5011 | static void hdd_rx_wake_lock_destroy(hdd_context_t *hdd_ctx) |
| 5012 | { |
| 5013 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 5014 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5015 | |
| 5016 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5017 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 5018 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5019 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5020 | * Create RX wakelock. |
| 5021 | * |
| 5022 | * Return: None. |
| 5023 | */ |
| 5024 | static void hdd_rx_wake_lock_create(hdd_context_t *hdd_ctx) |
| 5025 | { |
| 5026 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 5027 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5028 | |
| 5029 | /** |
| 5030 | * hdd_roc_context_init() - Init ROC context |
| 5031 | * @hdd_ctx: HDD context. |
| 5032 | * |
| 5033 | * Initialize ROC context. |
| 5034 | * |
| 5035 | * Return: 0 on success and errno on failure. |
| 5036 | */ |
| 5037 | static int hdd_roc_context_init(hdd_context_t *hdd_ctx) |
| 5038 | { |
| 5039 | qdf_spinlock_create(&hdd_ctx->hdd_roc_req_q_lock); |
| 5040 | qdf_list_create(&hdd_ctx->hdd_roc_req_q, MAX_ROC_REQ_QUEUE_ENTRY); |
| 5041 | |
| 5042 | INIT_DELAYED_WORK(&hdd_ctx->roc_req_work, wlan_hdd_roc_request_dequeue); |
| 5043 | |
| 5044 | return 0; |
| 5045 | } |
| 5046 | |
| 5047 | /** |
| 5048 | * hdd_roc_context_destroy() - Destroy ROC context |
| 5049 | * @hdd_ctx: HDD context. |
| 5050 | * |
| 5051 | * Destroy roc list and flush the pending roc work. |
| 5052 | * |
| 5053 | * Return: None. |
| 5054 | */ |
| 5055 | static void hdd_roc_context_destroy(hdd_context_t *hdd_ctx) |
| 5056 | { |
| 5057 | flush_delayed_work(&hdd_ctx->roc_req_work); |
| 5058 | qdf_list_destroy(&hdd_ctx->hdd_roc_req_q); |
Houston Hoffman | 2eac7c4 | 2016-12-12 12:22:52 -0800 | [diff] [blame] | 5059 | qdf_spinlock_destroy(&hdd_ctx->hdd_roc_req_q_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5060 | } |
| 5061 | |
| 5062 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5063 | * hdd_context_deinit() - Deinitialize HDD context |
| 5064 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5065 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5066 | * Deinitialize HDD context along with all the feature specific contexts but |
| 5067 | * do not free hdd context itself. Caller of this API is supposed to free |
| 5068 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5069 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5070 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5071 | */ |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5072 | static int hdd_context_deinit(hdd_context_t *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5073 | { |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5074 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5075 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5076 | hdd_roc_context_destroy(hdd_ctx); |
| 5077 | |
| 5078 | hdd_sap_context_destroy(hdd_ctx); |
| 5079 | |
| 5080 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 5081 | |
| 5082 | hdd_tdls_context_destroy(hdd_ctx); |
| 5083 | |
| 5084 | hdd_scan_context_destroy(hdd_ctx); |
| 5085 | |
| 5086 | qdf_list_destroy(&hdd_ctx->hddAdapters); |
| 5087 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5088 | return 0; |
| 5089 | } |
| 5090 | |
| 5091 | /** |
| 5092 | * hdd_context_destroy() - Destroy HDD context |
| 5093 | * @hdd_ctx: HDD context to be destroyed. |
| 5094 | * |
| 5095 | * Free config and HDD context as well as destroy all the resources. |
| 5096 | * |
| 5097 | * Return: None |
| 5098 | */ |
| 5099 | static void hdd_context_destroy(hdd_context_t *hdd_ctx) |
| 5100 | { |
| 5101 | if (QDF_GLOBAL_FTM_MODE != hdd_get_conparam()) |
| 5102 | hdd_logging_sock_deactivate_svc(hdd_ctx); |
| 5103 | |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 5104 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 5105 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5106 | hdd_context_deinit(hdd_ctx); |
| 5107 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5108 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5109 | hdd_ctx->config = NULL; |
| 5110 | |
| 5111 | wiphy_free(hdd_ctx->wiphy); |
| 5112 | } |
| 5113 | |
| 5114 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5115 | * hdd_wlan_exit() - HDD WLAN exit function |
| 5116 | * @hdd_ctx: Pointer to the HDD Context |
| 5117 | * |
| 5118 | * This is the driver exit point (invoked during rmmod) |
| 5119 | * |
| 5120 | * Return: None |
| 5121 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 5122 | static void hdd_wlan_exit(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5123 | { |
| 5124 | v_CONTEXT_t p_cds_context = hdd_ctx->pcds_context; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5125 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5126 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5127 | int driver_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5128 | |
| 5129 | ENTER(); |
| 5130 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5131 | if (QDF_TIMER_STATE_RUNNING == |
| 5132 | qdf_mc_timer_get_current_state(&hdd_ctx->iface_change_timer)) { |
| 5133 | hdd_info("Stpp interface change timer"); |
| 5134 | qdf_mc_timer_stop(&hdd_ctx->iface_change_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5135 | } |
| 5136 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5137 | if (!QDF_IS_STATUS_SUCCESS |
| 5138 | (qdf_mc_timer_destroy(&hdd_ctx->iface_change_timer))) |
| 5139 | hdd_err("Cannot delete interface change timer"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5140 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5141 | |
| 5142 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5143 | |
Nitesh Shah | 61c10d9 | 2016-10-19 19:29:15 +0530 | [diff] [blame] | 5144 | qdf_mc_timer_destroy(&hdd_ctx->tdls_source_timer); |
| 5145 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 5146 | hdd_bus_bandwidth_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5147 | |
| 5148 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 5149 | if (QDF_TIMER_STATE_RUNNING == |
| 5150 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 5151 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5152 | } |
| 5153 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5154 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 5155 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5156 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5157 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 5158 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 5159 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 5160 | hdd_ctx->last_acs_channel_list = NULL; |
| 5161 | hdd_ctx->num_of_channels = 0; |
| 5162 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5163 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5164 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5165 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 5166 | driver_status = hdd_ctx->driver_status; |
| 5167 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 5168 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5169 | /* |
| 5170 | * Powersave Offload Case |
| 5171 | * Disable Idle Power Save Mode |
| 5172 | */ |
| 5173 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 5174 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5175 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 5176 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 5177 | /* |
| 5178 | * Cancel any outstanding scan requests. We are about to close |
| 5179 | * all of our adapters, but an adapter structure is what SME |
| 5180 | * passes back to our callback function. Hence if there |
| 5181 | * are any outstanding scan requests then there is a |
| 5182 | * race condition between when the adapter is closed and |
| 5183 | * when the callback is invoked. We try to resolve that |
| 5184 | * race condition here by canceling any outstanding scans |
| 5185 | * before we close the adapters. |
| 5186 | * Note that the scans may be cancelled in an asynchronous |
| 5187 | * manner, so ideally there needs to be some kind of |
| 5188 | * synchronization. Rather than introduce a new |
| 5189 | * synchronization here, we will utilize the fact that we are |
| 5190 | * about to Request Full Power, and since that is synchronized, |
| 5191 | * the expectation is that by the time Request Full Power has |
| 5192 | * completed, all scans will be cancelled |
| 5193 | */ |
Jeff Johnson | f337b0c | 2017-03-10 10:48:30 -0800 | [diff] [blame] | 5194 | hdd_cleanup_scan_queue(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5195 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5196 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5197 | hdd_stop_all_adapters(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5198 | } |
| 5199 | |
| 5200 | /* |
| 5201 | * Close the scheduler before calling cds_close to make sure no thread |
| 5202 | * is scheduled after the each module close is called i.e after all the |
| 5203 | * data structures are freed. |
| 5204 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5205 | qdf_status = cds_sched_close(p_cds_context); |
| 5206 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5207 | hdd_alert("Failed to close CDS Scheduler"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 5208 | QDF_ASSERT(QDF_IS_STATUS_SUCCESS(qdf_status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5209 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5210 | |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 5211 | hdd_wlan_stop_modules(hdd_ctx); |
| 5212 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 5213 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
| 5214 | qdf_spinlock_destroy(&hdd_ctx->sta_update_info_lock); |
| 5215 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
| 5216 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5217 | /* |
| 5218 | * Close CDS |
| 5219 | * This frees pMac(HAL) context. There should not be any call |
| 5220 | * that requires pMac access after this. |
| 5221 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5222 | |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 5223 | hdd_green_ap_deinit(hdd_ctx); |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 5224 | hdd_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5225 | |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 5226 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 5227 | hdd_close_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5228 | |
| 5229 | hdd_ipa_cleanup(hdd_ctx); |
| 5230 | |
| 5231 | /* Free up RoC request queue and flush workqueue */ |
| 5232 | cds_flush_work(&hdd_ctx->roc_req_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5233 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 5234 | wlansap_global_deinit(); |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 5235 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5236 | wiphy_unregister(wiphy); |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 5237 | wlan_hdd_cfg80211_deinit(wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5238 | |
Jeff Johnson | f7f66f0 | 2016-09-23 14:50:11 -0700 | [diff] [blame] | 5239 | hdd_lpass_notify_stop(hdd_ctx); |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 5240 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5241 | hdd_exit_netlink_services(hdd_ctx); |
| 5242 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5243 | hdd_context_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5244 | } |
| 5245 | |
| 5246 | void __hdd_wlan_exit(void) |
| 5247 | { |
| 5248 | hdd_context_t *hdd_ctx; |
| 5249 | |
| 5250 | ENTER(); |
| 5251 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5252 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5253 | if (!hdd_ctx) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5254 | hdd_alert("Invalid HDD Context"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5255 | EXIT(); |
| 5256 | return; |
| 5257 | } |
| 5258 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 5259 | /* Check IPA HW Pipe shutdown */ |
| 5260 | hdd_ipa_uc_force_pipe_shutdown(hdd_ctx); |
| 5261 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 5262 | memdump_deinit(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 5263 | hdd_driver_memdump_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 5264 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5265 | /* Do all the cleanup before deregistering the driver */ |
| 5266 | hdd_wlan_exit(hdd_ctx); |
Mohit Khanna | ebf8a86 | 2016-04-28 17:53:59 -0700 | [diff] [blame] | 5267 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5268 | EXIT(); |
| 5269 | } |
| 5270 | |
| 5271 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 5272 | /** |
| 5273 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
| 5274 | * @data: pointer to hdd_context_t |
| 5275 | * |
| 5276 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 5277 | * Then new ACS request will do a fresh scan without reusing the cached |
| 5278 | * scan information. |
| 5279 | * |
| 5280 | * Return: void |
| 5281 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 5282 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5283 | { |
| 5284 | hdd_context_t *hdd_ctx = (hdd_context_t *) data; |
| 5285 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5286 | hdd_notice("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5287 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 5288 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 5289 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 5290 | hdd_ctx->last_acs_channel_list = NULL; |
| 5291 | hdd_ctx->num_of_channels = 0; |
| 5292 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5293 | |
| 5294 | if (!hdd_ctx->hHal) |
| 5295 | return; |
| 5296 | sme_scan_flush_result(hdd_ctx->hHal); |
| 5297 | } |
| 5298 | #endif |
| 5299 | |
| 5300 | #ifdef QCA_HT_2040_COEX |
| 5301 | /** |
| 5302 | * hdd_wlan_set_ht2040_mode() - notify FW with HT20/HT40 mode |
| 5303 | * @adapter: pointer to adapter |
| 5304 | * @staId: station id |
| 5305 | * @macAddrSTA: station MAC address |
| 5306 | * @channel_type: channel type |
| 5307 | * |
| 5308 | * This function notifies FW with HT20/HT40 mode |
| 5309 | * |
| 5310 | * Return: 0 if successful, error number otherwise |
| 5311 | */ |
| 5312 | 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] | 5313 | struct qdf_mac_addr macAddrSTA, int channel_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5314 | { |
| 5315 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5316 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5317 | hdd_context_t *hdd_ctx = NULL; |
| 5318 | |
| 5319 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 5320 | |
| 5321 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 5322 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5323 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 5324 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5325 | if (!hdd_ctx->hHal) |
| 5326 | return -EINVAL; |
| 5327 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5328 | qdf_status = sme_notify_ht2040_mode(hdd_ctx->hHal, staId, macAddrSTA, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5329 | adapter->sessionId, channel_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5330 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5331 | hdd_err("Fail to send notification with ht2040 mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5332 | return -EINVAL; |
| 5333 | } |
| 5334 | |
| 5335 | return 0; |
| 5336 | } |
| 5337 | #endif |
| 5338 | |
| 5339 | /** |
| 5340 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 5341 | * @state: state |
| 5342 | * |
| 5343 | * This function notifies FW with modem power status |
| 5344 | * |
| 5345 | * Return: 0 if successful, error number otherwise |
| 5346 | */ |
| 5347 | int hdd_wlan_notify_modem_power_state(int state) |
| 5348 | { |
| 5349 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5350 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5351 | hdd_context_t *hdd_ctx; |
| 5352 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5353 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5354 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 5355 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5356 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 5357 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5358 | if (!hdd_ctx->hHal) |
| 5359 | return -EINVAL; |
| 5360 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5361 | qdf_status = sme_notify_modem_power_state(hdd_ctx->hHal, state); |
| 5362 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5363 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5364 | state); |
| 5365 | return -EINVAL; |
| 5366 | } |
| 5367 | return 0; |
| 5368 | } |
| 5369 | |
| 5370 | /** |
| 5371 | * |
| 5372 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 5373 | * @adapter - Pointer to the HDD |
| 5374 | * |
| 5375 | * Return: None |
| 5376 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5377 | QDF_STATUS hdd_post_cds_enable_config(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5378 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5379 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5380 | |
| 5381 | /* |
| 5382 | * Send ready indication to the HDD. This will kick off the MAC |
| 5383 | * into a 'running' state and should kick off an initial scan. |
| 5384 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5385 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->hHal); |
| 5386 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5387 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 5388 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5389 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5390 | } |
| 5391 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5392 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5393 | } |
| 5394 | |
| 5395 | /* wake lock APIs for HDD */ |
| 5396 | void hdd_prevent_suspend(uint32_t reason) |
| 5397 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5398 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5399 | } |
| 5400 | |
| 5401 | void hdd_allow_suspend(uint32_t reason) |
| 5402 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5403 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5404 | } |
| 5405 | |
| 5406 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 5407 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 5408 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 5409 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5410 | } |
| 5411 | |
| 5412 | /** |
| 5413 | * hdd_exchange_version_and_caps() - exchange version and capability with target |
| 5414 | * @hdd_ctx: Pointer to HDD context |
| 5415 | * |
| 5416 | * This is the HDD function to exchange version and capability information |
| 5417 | * between Host and Target |
| 5418 | * |
| 5419 | * This function gets reported version of FW. |
| 5420 | * It also finds the version of target headers used to compile the host; |
| 5421 | * It compares the above two and prints a warning if they are different; |
| 5422 | * It gets the SW and HW version string; |
| 5423 | * Finally, it exchanges capabilities between host and target i.e. host |
| 5424 | * and target exchange a msg indicating the features they support through a |
| 5425 | * bitmap |
| 5426 | * |
| 5427 | * Return: None |
| 5428 | */ |
| 5429 | void hdd_exchange_version_and_caps(hdd_context_t *hdd_ctx) |
| 5430 | { |
| 5431 | |
| 5432 | tSirVersionType versionCompiled; |
| 5433 | tSirVersionType versionReported; |
| 5434 | tSirVersionString versionString; |
| 5435 | uint8_t fwFeatCapsMsgSupported = 0; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5436 | QDF_STATUS vstatus; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5437 | |
| 5438 | memset(&versionCompiled, 0, sizeof(versionCompiled)); |
| 5439 | memset(&versionReported, 0, sizeof(versionReported)); |
| 5440 | |
| 5441 | /* retrieve and display WCNSS version information */ |
| 5442 | do { |
| 5443 | |
| 5444 | vstatus = sme_get_wcnss_wlan_compiled_version(hdd_ctx->hHal, |
| 5445 | &versionCompiled); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5446 | if (!QDF_IS_STATUS_SUCCESS(vstatus)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5447 | hdd_alert("unable to retrieve WCNSS WLAN compiled version"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5448 | break; |
| 5449 | } |
| 5450 | |
| 5451 | vstatus = sme_get_wcnss_wlan_reported_version(hdd_ctx->hHal, |
| 5452 | &versionReported); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5453 | if (!QDF_IS_STATUS_SUCCESS(vstatus)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5454 | hdd_alert("unable to retrieve WCNSS WLAN reported version"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5455 | break; |
| 5456 | } |
| 5457 | |
| 5458 | if ((versionCompiled.major != versionReported.major) || |
| 5459 | (versionCompiled.minor != versionReported.minor) || |
| 5460 | (versionCompiled.version != versionReported.version) || |
| 5461 | (versionCompiled.revision != versionReported.revision)) { |
| 5462 | pr_err("%s: WCNSS WLAN Version %u.%u.%u.%u, " |
| 5463 | "Host expected %u.%u.%u.%u\n", |
| 5464 | WLAN_MODULE_NAME, |
| 5465 | (int)versionReported.major, |
| 5466 | (int)versionReported.minor, |
| 5467 | (int)versionReported.version, |
| 5468 | (int)versionReported.revision, |
| 5469 | (int)versionCompiled.major, |
| 5470 | (int)versionCompiled.minor, |
| 5471 | (int)versionCompiled.version, |
| 5472 | (int)versionCompiled.revision); |
| 5473 | } else { |
| 5474 | pr_info("%s: WCNSS WLAN version %u.%u.%u.%u\n", |
| 5475 | WLAN_MODULE_NAME, |
| 5476 | (int)versionReported.major, |
| 5477 | (int)versionReported.minor, |
| 5478 | (int)versionReported.version, |
| 5479 | (int)versionReported.revision); |
| 5480 | } |
| 5481 | |
| 5482 | vstatus = sme_get_wcnss_software_version(hdd_ctx->hHal, |
| 5483 | versionString, |
| 5484 | sizeof(versionString)); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5485 | if (!QDF_IS_STATUS_SUCCESS(vstatus)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5486 | hdd_alert("unable to retrieve WCNSS software version string"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5487 | break; |
| 5488 | } |
| 5489 | |
| 5490 | pr_info("%s: WCNSS software version %s\n", |
| 5491 | WLAN_MODULE_NAME, versionString); |
| 5492 | |
| 5493 | vstatus = sme_get_wcnss_hardware_version(hdd_ctx->hHal, |
| 5494 | versionString, |
| 5495 | sizeof(versionString)); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5496 | if (!QDF_IS_STATUS_SUCCESS(vstatus)) { |
Jeff Johnson | b7082ae | 2016-08-23 13:13:30 -0700 | [diff] [blame] | 5497 | hdd_alert("unable to retrieve WCNSS hardware version string"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5498 | break; |
| 5499 | } |
| 5500 | |
| 5501 | pr_info("%s: WCNSS hardware version %s\n", |
| 5502 | WLAN_MODULE_NAME, versionString); |
| 5503 | |
| 5504 | /* |
| 5505 | * 1.Check if FW version is greater than 0.1.1.0. Only then |
| 5506 | * send host-FW capability exchange message |
| 5507 | * 2.Host-FW capability exchange message is only present on |
| 5508 | * target 1.1 so send the message only if it the target is 1.1 |
| 5509 | * minor numbers for different target branches: |
| 5510 | * 0 -> (1.0)Mainline Build |
| 5511 | * 1 -> (1.1)Mainline Build |
| 5512 | * 2->(1.04) Stability Build |
| 5513 | */ |
| 5514 | if (((versionReported.major > 0) || (versionReported.minor > 1) |
| 5515 | || ((versionReported.minor >= 1) |
| 5516 | && (versionReported.version >= 1))) |
| 5517 | && ((versionReported.major == 1) |
| 5518 | && (versionReported.minor >= 1))) |
| 5519 | fwFeatCapsMsgSupported = 1; |
| 5520 | |
| 5521 | if (fwFeatCapsMsgSupported) { |
| 5522 | /* |
| 5523 | * Indicate if IBSS heartbeat monitoring needs to be |
| 5524 | * offloaded |
| 5525 | */ |
| 5526 | if (!hdd_ctx->config->enableIbssHeartBeatOffload) { |
| 5527 | sme_disable_feature_capablity |
| 5528 | (IBSS_HEARTBEAT_OFFLOAD); |
| 5529 | } |
| 5530 | |
| 5531 | sme_feature_caps_exchange(hdd_ctx->hHal); |
| 5532 | } |
| 5533 | |
| 5534 | } while (0); |
| 5535 | |
| 5536 | } |
| 5537 | |
| 5538 | /* Initialize channel list in sme based on the country code */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5539 | QDF_STATUS hdd_set_sme_chan_list(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5540 | { |
| 5541 | return sme_init_chan_list(hdd_ctx->hHal, hdd_ctx->reg.alpha2, |
| 5542 | hdd_ctx->reg.cc_src); |
| 5543 | } |
| 5544 | |
| 5545 | /** |
| 5546 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 5547 | * @hdd_ctx: Pointer to the hdd context |
| 5548 | * |
| 5549 | * HDD function to know if hardware supports 5GHz |
| 5550 | * |
| 5551 | * Return: true if hardware supports 5GHz |
| 5552 | */ |
| 5553 | bool hdd_is_5g_supported(hdd_context_t *hdd_ctx) |
| 5554 | { |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 5555 | if (!hdd_ctx || !hdd_ctx->config) |
| 5556 | return true; |
| 5557 | |
| 5558 | if (hdd_ctx->config->nBandCapability != eCSR_BAND_24) |
| 5559 | return true; |
| 5560 | else |
| 5561 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5562 | } |
| 5563 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 5564 | static int hdd_wiphy_init(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5565 | { |
| 5566 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 5567 | int ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5568 | |
| 5569 | wiphy = hdd_ctx->wiphy; |
| 5570 | |
| 5571 | /* |
| 5572 | * The channel information in |
| 5573 | * wiphy needs to be initialized before wiphy registration |
| 5574 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 5575 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 5576 | if (ret_val) { |
| 5577 | hdd_alert("regulatory init failed"); |
| 5578 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5579 | } |
| 5580 | |
| 5581 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 5582 | wiphy->wowlan = &wowlan_support_reg_init; |
| 5583 | #else |
| 5584 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 5585 | WIPHY_WOWLAN_MAGIC_PKT | |
| 5586 | WIPHY_WOWLAN_DISCONNECT | |
| 5587 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 5588 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 5589 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 5590 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 5591 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 5592 | |
| 5593 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 5594 | WOW_MAX_FILTERS_PER_LIST); |
| 5595 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 5596 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 5597 | #endif |
| 5598 | |
| 5599 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 5600 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
| 5601 | if (0 > ret_val) |
| 5602 | hdd_err("wiphy registration failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5603 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 5604 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5605 | } |
| 5606 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 5607 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5608 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 5609 | * @hdd_ctx - handle to hdd context |
| 5610 | * @tx_packets - transmit packet count |
| 5611 | * @rx_packets - receive packet count |
| 5612 | * |
| 5613 | * The function controls the bus bandwidth and dynamic control of |
| 5614 | * tcp delayed ack configuration |
| 5615 | * |
| 5616 | * Returns: None |
| 5617 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5618 | #ifdef MSM_PLATFORM |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 5619 | static void hdd_pld_request_bus_bandwidth(hdd_context_t *hdd_ctx, |
| 5620 | const uint64_t tx_packets, |
| 5621 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5622 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5623 | uint64_t total = tx_packets + rx_packets; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5624 | uint64_t temp_rx = 0; |
| 5625 | uint64_t temp_tx = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5626 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5627 | enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
| 5628 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 5629 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5630 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5631 | if (total > hdd_ctx->config->busBandwidthHighThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5632 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5633 | else if (total > hdd_ctx->config->busBandwidthMediumThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5634 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 5635 | else if (total > hdd_ctx->config->busBandwidthLowThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5636 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 5637 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5638 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5639 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5640 | hdd_ctx->hdd_txrx_hist[hdd_ctx->hdd_txrx_hist_idx].next_vote_level = |
| 5641 | next_vote_level; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5642 | |
| 5643 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 5644 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 5645 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5646 | hdd_ctx->cur_vote_level = next_vote_level; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5647 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 5648 | if (next_vote_level == PLD_BUS_WIDTH_LOW) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 5649 | if (hdd_ctx->hbw_requested) { |
| 5650 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 5651 | hdd_ctx->hbw_requested = false; |
| 5652 | } |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 5653 | if (cds_sched_handle_throughput_req(false)) |
Jeff Johnson | b7082ae | 2016-08-23 13:13:30 -0700 | [diff] [blame] | 5654 | hdd_err("low bandwidth set rx affinity fail"); |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 5655 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 5656 | if (!hdd_ctx->hbw_requested) { |
| 5657 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 5658 | hdd_ctx->hbw_requested = true; |
| 5659 | } |
| 5660 | |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 5661 | if (cds_sched_handle_throughput_req(true)) |
Jeff Johnson | b7082ae | 2016-08-23 13:13:30 -0700 | [diff] [blame] | 5662 | hdd_err("high bandwidth set rx affinity fail"); |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 5663 | } |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 5664 | hdd_napi_apply_throughput_policy(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5665 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5666 | |
| 5667 | /* fine-tuning parameters for RX Flows */ |
| 5668 | temp_rx = (rx_packets + hdd_ctx->prev_rx) / 2; |
| 5669 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5670 | hdd_ctx->prev_rx = rx_packets; |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 5671 | if (temp_rx > hdd_ctx->config->tcpDelackThresholdHigh) { |
| 5672 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 5673 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 5674 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 5675 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 5676 | } else { |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5677 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 5678 | hdd_ctx->rx_high_ind_cnt = 0; |
| 5679 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5680 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5681 | hdd_ctx->hdd_txrx_hist[hdd_ctx->hdd_txrx_hist_idx].next_rx_level = |
| 5682 | next_rx_level; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5683 | |
| 5684 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 5685 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5686 | next_rx_level, temp_rx); |
| 5687 | hdd_ctx->cur_rx_level = next_rx_level; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 5688 | /* Send throughput indication only if it is enabled. |
| 5689 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 5690 | * to default delayed ack. Note that this will disable the |
| 5691 | * dynamic delayed ack mechanism across the system |
| 5692 | */ |
| 5693 | if (hdd_ctx->config->enable_tcp_delack) |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 5694 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 5695 | WLAN_SVC_WLAN_TP_IND, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5696 | &next_rx_level, |
| 5697 | sizeof(next_rx_level)); |
| 5698 | } |
| 5699 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5700 | /* fine-tuning parameters for TX Flows */ |
| 5701 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 5702 | hdd_ctx->prev_tx = tx_packets; |
| 5703 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 5704 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 5705 | else |
| 5706 | next_tx_level = WLAN_SVC_TP_LOW; |
| 5707 | |
| 5708 | if (hdd_ctx->cur_tx_level != next_tx_level) { |
| 5709 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 5710 | next_tx_level, temp_tx); |
| 5711 | hdd_ctx->cur_tx_level = next_tx_level; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 5712 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 5713 | WLAN_SVC_WLAN_TP_TX_IND, |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5714 | &next_tx_level, |
| 5715 | sizeof(next_tx_level)); |
| 5716 | } |
| 5717 | |
| 5718 | hdd_ctx->hdd_txrx_hist[hdd_ctx->hdd_txrx_hist_idx].next_tx_level = |
| 5719 | next_tx_level; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5720 | hdd_ctx->hdd_txrx_hist_idx++; |
| 5721 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5722 | } |
| 5723 | |
| 5724 | #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] | 5725 | static void hdd_bus_bw_work_handler(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5726 | { |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 5727 | hdd_context_t *hdd_ctx = container_of(work, hdd_context_t, |
| 5728 | bus_bw_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5729 | hdd_adapter_t *adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 5730 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 5731 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 5732 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5733 | uint64_t total_tx = 0, total_rx = 0; |
| 5734 | hdd_adapter_list_node_t *adapterNode = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5735 | QDF_STATUS status = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 5736 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5737 | bool connected = false; |
| 5738 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 5739 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 5740 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 5741 | return; |
| 5742 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5743 | for (status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5744 | NULL != adapterNode && QDF_STATUS_SUCCESS == status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5745 | status = |
| 5746 | hdd_get_next_adapter(hdd_ctx, adapterNode, &adapterNode)) { |
| 5747 | |
| 5748 | if (adapterNode->pAdapter == NULL) |
| 5749 | continue; |
| 5750 | adapter = adapterNode->pAdapter; |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 5751 | /* |
| 5752 | * Validate magic so we don't end up accessing |
| 5753 | * an invalid adapter. |
| 5754 | */ |
| 5755 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 5756 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5757 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5758 | if ((adapter->device_mode == QDF_STA_MODE || |
| 5759 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5760 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.connState |
| 5761 | != eConnectionState_Associated) { |
| 5762 | |
| 5763 | continue; |
| 5764 | } |
| 5765 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5766 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 5767 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5768 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->bApActive == false) { |
| 5769 | |
| 5770 | continue; |
| 5771 | } |
| 5772 | |
| 5773 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 5774 | adapter->prev_tx_packets); |
| 5775 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 5776 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 5777 | |
| 5778 | if (adapter->device_mode == QDF_SAP_MODE || |
| 5779 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 5780 | adapter->device_mode == QDF_IBSS_MODE) { |
| 5781 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 5782 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 5783 | cds_get_context(QDF_MODULE_ID_SOC), |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 5784 | adapter->sessionId, |
| 5785 | &fwd_tx_packets, &fwd_rx_packets); |
| 5786 | if (ret == A_OK) { |
| 5787 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 5788 | fwd_tx_packets, |
| 5789 | adapter->prev_fwd_tx_packets); |
| 5790 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 5791 | fwd_tx_packets, |
| 5792 | adapter->prev_fwd_rx_packets); |
| 5793 | } |
| 5794 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5795 | |
| 5796 | total_rx += adapter->stats.rx_packets; |
| 5797 | total_tx += adapter->stats.tx_packets; |
| 5798 | |
| 5799 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 5800 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 5801 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 5802 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 5803 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5804 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 5805 | connected = true; |
| 5806 | } |
| 5807 | |
| 5808 | hdd_ctx->hdd_txrx_hist[hdd_ctx->hdd_txrx_hist_idx].total_rx = total_rx; |
| 5809 | hdd_ctx->hdd_txrx_hist[hdd_ctx->hdd_txrx_hist_idx].total_tx = total_tx; |
| 5810 | hdd_ctx->hdd_txrx_hist[hdd_ctx->hdd_txrx_hist_idx].interval_rx = |
| 5811 | rx_packets; |
| 5812 | hdd_ctx->hdd_txrx_hist[hdd_ctx->hdd_txrx_hist_idx].interval_tx = |
| 5813 | tx_packets; |
| 5814 | |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 5815 | /* add intra bss forwarded tx and rx packets */ |
| 5816 | tx_packets += fwd_tx_packets_diff; |
| 5817 | rx_packets += fwd_rx_packets_diff; |
| 5818 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5819 | hdd_ipa_uc_stat_query(hdd_ctx, &ipa_tx_packets, &ipa_rx_packets); |
| 5820 | tx_packets += (uint64_t)ipa_tx_packets; |
| 5821 | rx_packets += (uint64_t)ipa_rx_packets; |
| 5822 | |
| 5823 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5824 | hdd_err("bus bandwidth timer running in disconnected state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5825 | return; |
| 5826 | } |
| 5827 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5828 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5829 | |
| 5830 | hdd_ipa_set_perf_level(hdd_ctx, tx_packets, rx_packets); |
| 5831 | hdd_ipa_uc_stat_request(adapter, 2); |
| 5832 | |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 5833 | /* ensure periodic timer should still be running before restarting it */ |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 5834 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 5835 | if (hdd_ctx->bus_bw_timer_running) |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 5836 | qdf_timer_mod(&hdd_ctx->bus_bw_timer, |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 5837 | hdd_ctx->config->busBandwidthComputeInterval); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 5838 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5839 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 5840 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 5841 | /** |
| 5842 | * __hdd_bus_bw_cbk() - Bus bandwidth data structure callback. |
| 5843 | * @arg: Argument of timer function |
| 5844 | * |
| 5845 | * Schedule a workqueue in this function where all the processing is done. |
| 5846 | * |
| 5847 | * Return: None. |
| 5848 | */ |
| 5849 | static void __hdd_bus_bw_cbk(void *arg) |
| 5850 | { |
| 5851 | hdd_context_t *hdd_ctx = (hdd_context_t *) arg; |
| 5852 | |
| 5853 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 5854 | return; |
| 5855 | |
| 5856 | schedule_work(&hdd_ctx->bus_bw_work); |
| 5857 | } |
| 5858 | |
| 5859 | /** |
| 5860 | * hdd_bus_bw_cbk() - Wrapper for bus bw callback for SSR protection. |
| 5861 | * @arg: Argument of timer function |
| 5862 | * |
| 5863 | * Return: None. |
| 5864 | */ |
| 5865 | static void hdd_bus_bw_cbk(void *arg) |
| 5866 | { |
| 5867 | cds_ssr_protect(__func__); |
| 5868 | __hdd_bus_bw_cbk(arg); |
| 5869 | cds_ssr_unprotect(__func__); |
| 5870 | } |
| 5871 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 5872 | int hdd_bus_bandwidth_init(hdd_context_t *hdd_ctx) |
| 5873 | { |
| 5874 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 5875 | INIT_WORK(&hdd_ctx->bus_bw_work, |
| 5876 | hdd_bus_bw_work_handler); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 5877 | hdd_ctx->bus_bw_timer_running = false; |
| 5878 | qdf_spinlock_create(&hdd_ctx->bus_bw_timer_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 5879 | qdf_timer_init(NULL, |
| 5880 | &hdd_ctx->bus_bw_timer, |
| 5881 | hdd_bus_bw_cbk, (void *)hdd_ctx, |
| 5882 | QDF_TIMER_TYPE_SW); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 5883 | |
| 5884 | return 0; |
| 5885 | } |
| 5886 | |
| 5887 | void hdd_bus_bandwidth_destroy(hdd_context_t *hdd_ctx) |
| 5888 | { |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 5889 | if (hdd_ctx->bus_bw_timer_running) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 5890 | hdd_reset_tcp_delack(hdd_ctx); |
| 5891 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 5892 | hdd_info("wait for bus bw work to flush"); |
| 5893 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 5894 | qdf_timer_free(&hdd_ctx->bus_bw_timer); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 5895 | hdd_ctx->bus_bw_timer_running = false; |
| 5896 | qdf_spinlock_destroy(&hdd_ctx->bus_bw_timer_lock); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 5897 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5898 | #endif |
| 5899 | |
| 5900 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 5901 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 5902 | * @hdd_ctx: hdd context |
| 5903 | * |
| 5904 | * Return: 0 for success or error code |
| 5905 | */ |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 5906 | 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] | 5907 | { |
| 5908 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 5909 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
| 5910 | if (hdd_ctx->hdd_txrx_hist == NULL) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5911 | hdd_err("Failed malloc for hdd_txrx_hist"); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 5912 | return -ENOMEM; |
| 5913 | } |
| 5914 | return 0; |
| 5915 | } |
| 5916 | |
| 5917 | /** |
| 5918 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 5919 | * @hdd_ctx: hdd context |
| 5920 | * |
| 5921 | * Return: none |
| 5922 | */ |
| 5923 | void wlan_hdd_deinit_tx_rx_histogram(hdd_context_t *hdd_ctx) |
| 5924 | { |
| 5925 | if (hdd_ctx->hdd_txrx_hist) { |
| 5926 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 5927 | hdd_ctx->hdd_txrx_hist = NULL; |
| 5928 | } |
| 5929 | } |
| 5930 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5931 | static uint8_t *convert_level_to_string(uint32_t level) |
| 5932 | { |
| 5933 | switch (level) { |
| 5934 | /* initialize the wlan sub system */ |
| 5935 | case WLAN_SVC_TP_NONE: |
| 5936 | return "NONE"; |
| 5937 | case WLAN_SVC_TP_LOW: |
| 5938 | return "LOW"; |
| 5939 | case WLAN_SVC_TP_MEDIUM: |
| 5940 | return "MED"; |
| 5941 | case WLAN_SVC_TP_HIGH: |
| 5942 | return "HIGH"; |
| 5943 | default: |
| 5944 | return "INVAL"; |
| 5945 | } |
| 5946 | } |
| 5947 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 5948 | |
| 5949 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5950 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 5951 | * @hdd_ctx: hdd context |
| 5952 | * |
| 5953 | * Return: none |
| 5954 | */ |
| 5955 | void wlan_hdd_display_tx_rx_histogram(hdd_context_t *hdd_ctx) |
| 5956 | { |
| 5957 | int i; |
| 5958 | |
| 5959 | #ifdef MSM_PLATFORM |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5960 | hdd_err("BW compute Interval: %dms", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5961 | hdd_ctx->config->busBandwidthComputeInterval); |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5962 | hdd_err("BW High TH: %d BW Med TH: %d BW Low TH: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5963 | hdd_ctx->config->busBandwidthHighThreshold, |
| 5964 | hdd_ctx->config->busBandwidthMediumThreshold, |
| 5965 | hdd_ctx->config->busBandwidthLowThreshold); |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5966 | hdd_err("Enable TCP DEL ACK: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5967 | hdd_ctx->config->enable_tcp_delack); |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5968 | hdd_err("TCP DEL High TH: %d TCP DEL Low TH: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5969 | hdd_ctx->config->tcpDelackThresholdHigh, |
| 5970 | hdd_ctx->config->tcpDelackThresholdLow); |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5971 | hdd_err("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] | 5972 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5973 | #endif |
| 5974 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5975 | hdd_err("Total entries: %d Current index: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5976 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
| 5977 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5978 | hdd_err("index, total_rx, interval_rx, total_tx, interval_tx, bus_bw_level, RX TP Level, TX TP Level"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5979 | |
| 5980 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5981 | hdd_err("%d: %llu, %llu, %llu, %llu, %s, %s, %s", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5982 | i, hdd_ctx->hdd_txrx_hist[i].total_rx, |
| 5983 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
| 5984 | hdd_ctx->hdd_txrx_hist[i].total_tx, |
| 5985 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5986 | convert_level_to_string( |
| 5987 | hdd_ctx->hdd_txrx_hist[i].next_vote_level), |
| 5988 | convert_level_to_string( |
| 5989 | hdd_ctx->hdd_txrx_hist[i].next_rx_level), |
| 5990 | convert_level_to_string( |
| 5991 | hdd_ctx->hdd_txrx_hist[i].next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5992 | } |
| 5993 | return; |
| 5994 | } |
| 5995 | |
| 5996 | /** |
| 5997 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 5998 | * @hdd_ctx: hdd context |
| 5999 | * |
| 6000 | * Return: none |
| 6001 | */ |
| 6002 | void wlan_hdd_clear_tx_rx_histogram(hdd_context_t *hdd_ctx) |
| 6003 | { |
| 6004 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6005 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 6006 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6007 | } |
| 6008 | |
| 6009 | /** |
| 6010 | * wlan_hdd_display_netif_queue_history() - display netif queue operation history |
| 6011 | * @pHddCtx: hdd context |
| 6012 | * |
| 6013 | * Return: none |
| 6014 | */ |
| 6015 | void wlan_hdd_display_netif_queue_history(hdd_context_t *hdd_ctx) |
| 6016 | { |
| 6017 | |
| 6018 | hdd_adapter_t *adapter = NULL; |
| 6019 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6020 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6021 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6022 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6023 | |
| 6024 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6025 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6026 | adapter = adapter_node->pAdapter; |
| 6027 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6028 | hdd_err("\nNetif queue operation statistics:"); |
| 6029 | hdd_err("Session_id %d device mode %d", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6030 | adapter->sessionId, adapter->device_mode); |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6031 | hdd_err("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6032 | curr_time = qdf_system_ticks(); |
| 6033 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6034 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6035 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6036 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6037 | unpause = adapter->total_unpause_time; |
| 6038 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6039 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6040 | pause = adapter->total_pause_time; |
| 6041 | } |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6042 | hdd_err("Total: %ums Pause: %ums Unpause: %ums", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6043 | qdf_system_ticks_to_msecs(total), |
| 6044 | qdf_system_ticks_to_msecs(pause), |
| 6045 | qdf_system_ticks_to_msecs(unpause)); |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6046 | hdd_err("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6047 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6048 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 6049 | qdf_time_t pause_delta = 0; |
| 6050 | |
| 6051 | if (adapter->pause_map & (1 << i)) |
| 6052 | pause_delta = delta; |
| 6053 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6054 | hdd_err("%s: %d: %d: %ums", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6055 | hdd_reason_type_to_string(i), |
| 6056 | adapter->queue_oper_stats[i].pause_count, |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6057 | adapter->queue_oper_stats[i].unpause_count, |
| 6058 | qdf_system_ticks_to_msecs( |
| 6059 | adapter->queue_oper_stats[i].total_pause_time + |
| 6060 | pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6061 | } |
| 6062 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6063 | hdd_err("\nNetif queue operation history:"); |
| 6064 | hdd_err("Total entries: %d current index %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6065 | WLAN_HDD_MAX_HISTORY_ENTRY, adapter->history_index); |
| 6066 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6067 | hdd_err("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6068 | |
| 6069 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6070 | hdd_err("%d: %u: %s: %s: %x", |
Anurag Chouhan | 50220ce | 2016-02-18 20:11:33 +0530 | [diff] [blame] | 6071 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6072 | adapter->queue_oper_history[i].time), |
| 6073 | hdd_action_type_to_string( |
| 6074 | adapter->queue_oper_history[i].netif_action), |
| 6075 | hdd_reason_type_to_string( |
| 6076 | adapter->queue_oper_history[i].netif_reason), |
| 6077 | adapter->queue_oper_history[i].pause_map); |
| 6078 | } |
| 6079 | |
| 6080 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 6081 | adapter_node = next; |
| 6082 | } |
| 6083 | |
| 6084 | |
| 6085 | } |
| 6086 | |
| 6087 | /** |
| 6088 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 6089 | * @hdd_ctx: hdd context |
| 6090 | * |
| 6091 | * Return: none |
| 6092 | */ |
| 6093 | void wlan_hdd_clear_netif_queue_history(hdd_context_t *hdd_ctx) |
| 6094 | { |
| 6095 | hdd_adapter_t *adapter = NULL; |
| 6096 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6097 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6098 | |
| 6099 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6100 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6101 | adapter = adapter_node->pAdapter; |
| 6102 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6103 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6104 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6105 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6106 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6107 | adapter->history_index = 0; |
| 6108 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 6109 | adapter->total_pause_time = 0; |
| 6110 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6111 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 6112 | adapter_node = next; |
| 6113 | } |
| 6114 | } |
| 6115 | |
| 6116 | /** |
| 6117 | * hdd_11d_scan_done() - callback for 11d scan completion of flushing results |
| 6118 | * @halHandle: Hal handle |
| 6119 | * @pContext: Pointer to the context |
| 6120 | * @sessionId: Session ID |
| 6121 | * @scanId: Scan ID |
| 6122 | * @status: Status |
| 6123 | * |
| 6124 | * This is the callback to be executed when 11d scan is completed to flush out |
| 6125 | * the scan results |
| 6126 | * |
| 6127 | * 11d scan is done during driver load and is a passive scan on all |
| 6128 | * channels supported by the device, 11d scans may find some APs on |
| 6129 | * frequencies which are forbidden to be used in the regulatory domain |
| 6130 | * the device is operating in. If these APs are notified to the supplicant |
| 6131 | * it may try to connect to these APs, thus flush out all the scan results |
| 6132 | * which are present in SME after 11d scan is done. |
| 6133 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6134 | * Return: QDF_STATUS_SUCCESS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6135 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6136 | static QDF_STATUS hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6137 | uint8_t sessionId, uint32_t scanId, |
| 6138 | eCsrScanStatus status) |
| 6139 | { |
| 6140 | ENTER(); |
| 6141 | |
| 6142 | sme_scan_flush_result(halHandle); |
| 6143 | |
| 6144 | EXIT(); |
| 6145 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6146 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6147 | } |
| 6148 | |
| 6149 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 6150 | /** |
| 6151 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 6152 | * @hdd_ctx: hdd global context |
| 6153 | * |
| 6154 | * Return: none |
| 6155 | */ |
| 6156 | static void hdd_init_offloaded_packets_ctx(hdd_context_t *hdd_ctx) |
| 6157 | { |
| 6158 | uint8_t i; |
| 6159 | |
| 6160 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 6161 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 6162 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 6163 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 6164 | } |
| 6165 | } |
| 6166 | #else |
| 6167 | static void hdd_init_offloaded_packets_ctx(hdd_context_t *hdd_ctx) |
| 6168 | { |
| 6169 | } |
| 6170 | #endif |
| 6171 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 6172 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 6173 | /** |
| 6174 | * wlan_hdd_set_wow_pulse() - call SME to send wmi cmd of wow pulse |
| 6175 | * @phddctx: hdd_context_t structure pointer |
| 6176 | * @enable: enable or disable this behaviour |
| 6177 | * |
| 6178 | * Return: int |
| 6179 | */ |
| 6180 | static int wlan_hdd_set_wow_pulse(hdd_context_t *phddctx, bool enable) |
| 6181 | { |
| 6182 | struct hdd_config *pcfg_ini = phddctx->config; |
| 6183 | struct wow_pulse_mode wow_pulse_set_info; |
| 6184 | QDF_STATUS status; |
| 6185 | |
| 6186 | hdd_notice("wow pulse enable flag is %d", enable); |
| 6187 | |
| 6188 | if (false == phddctx->config->wow_pulse_support) |
| 6189 | return 0; |
| 6190 | |
| 6191 | /* prepare the request to send to SME */ |
| 6192 | if (enable == true) { |
| 6193 | wow_pulse_set_info.wow_pulse_enable = true; |
| 6194 | wow_pulse_set_info.wow_pulse_pin = |
| 6195 | pcfg_ini->wow_pulse_pin; |
| 6196 | wow_pulse_set_info.wow_pulse_interval_low = |
| 6197 | pcfg_ini->wow_pulse_interval_low; |
| 6198 | wow_pulse_set_info.wow_pulse_interval_high = |
| 6199 | pcfg_ini->wow_pulse_interval_high; |
| 6200 | } else { |
| 6201 | wow_pulse_set_info.wow_pulse_enable = false; |
| 6202 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 6203 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 6204 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 6205 | } |
| 6206 | hdd_notice("enable %d pin %d low %d high %d", |
| 6207 | wow_pulse_set_info.wow_pulse_enable, |
| 6208 | wow_pulse_set_info.wow_pulse_pin, |
| 6209 | wow_pulse_set_info.wow_pulse_interval_low, |
| 6210 | wow_pulse_set_info.wow_pulse_interval_high); |
| 6211 | |
| 6212 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 6213 | if (QDF_STATUS_E_FAILURE == status) { |
| 6214 | hdd_notice("sme_set_wow_pulse failure!"); |
| 6215 | return -EIO; |
| 6216 | } |
| 6217 | hdd_notice("sme_set_wow_pulse success!"); |
| 6218 | return 0; |
| 6219 | } |
| 6220 | #else |
| 6221 | static inline int wlan_hdd_set_wow_pulse(hdd_context_t *phddctx, bool enable) |
| 6222 | { |
| 6223 | return 0; |
| 6224 | } |
| 6225 | #endif |
| 6226 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6227 | #ifdef WLAN_FEATURE_FASTPATH |
| 6228 | /** |
| 6229 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 6230 | * @hdd_cfg: hdd config |
| 6231 | * @context: lower layer context |
| 6232 | * |
| 6233 | * Return: none |
| 6234 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6235 | void hdd_enable_fastpath(struct hdd_config *hdd_cfg, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6236 | void *context) |
| 6237 | { |
| 6238 | if (hdd_cfg->fastpath_enable) |
| 6239 | hif_enable_fastpath(context); |
| 6240 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6241 | #endif |
| 6242 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6243 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6244 | /** |
| 6245 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 6246 | * @context: hdd context pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6247 | * @level: thermal level |
| 6248 | * |
| 6249 | * Change IPA data path to SW path when the thermal throttle level greater |
| 6250 | * than 0, and restore the original data path when throttle level is 0 |
| 6251 | * |
| 6252 | * Return: none |
| 6253 | */ |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 6254 | 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] | 6255 | { |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 6256 | hdd_context_t *hdd_ctx = context; |
| 6257 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6258 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 6259 | if (level > THROTTLE_LEVEL_0) |
| 6260 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, true); |
| 6261 | else |
| 6262 | /* restore original concurrency mode */ |
| 6263 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, hdd_ctx->mcc_mode); |
| 6264 | } |
| 6265 | |
| 6266 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6267 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 6268 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 6269 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6270 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6271 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 6272 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 6273 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6274 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6275 | * Return: Channel number to restart SAP in case of success. In case of any |
| 6276 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6277 | */ |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6278 | static uint8_t hdd_get_safe_channel_from_pcl_and_acs_range( |
| 6279 | hdd_adapter_t *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6280 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6281 | struct sir_pcl_list pcl; |
| 6282 | QDF_STATUS status; |
| 6283 | uint32_t i, j; |
| 6284 | tHalHandle *hal_handle; |
| 6285 | hdd_context_t *hdd_ctx; |
| 6286 | bool found = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6287 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6288 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6289 | if (!hdd_ctx) { |
| 6290 | hdd_err("invalid HDD context"); |
| 6291 | return INVALID_CHANNEL_ID; |
| 6292 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6293 | |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 6294 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 6295 | if (!hal_handle) { |
| 6296 | hdd_err("invalid HAL handle"); |
| 6297 | return INVALID_CHANNEL_ID; |
| 6298 | } |
| 6299 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6300 | status = cds_get_pcl_for_existing_conn(CDS_SAP_MODE, |
| 6301 | pcl.pcl_list, &pcl.pcl_len, |
| 6302 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list)); |
| 6303 | if (QDF_IS_STATUS_ERROR(status)) { |
| 6304 | hdd_err("Get PCL failed"); |
| 6305 | return INVALID_CHANNEL_ID; |
| 6306 | } |
| 6307 | |
| 6308 | if (!pcl.pcl_len) { |
| 6309 | hdd_alert("pcl length is zero. this is not expected"); |
| 6310 | return INVALID_CHANNEL_ID; |
| 6311 | } |
| 6312 | |
| 6313 | hdd_info("start:%d end:%d", |
| 6314 | adapter->sessionCtx.ap.sapConfig.acs_cfg.start_ch, |
| 6315 | adapter->sessionCtx.ap.sapConfig.acs_cfg.end_ch); |
| 6316 | |
| 6317 | /* PCL already takes unsafe channel into account */ |
| 6318 | for (i = 0; i < pcl.pcl_len; i++) { |
| 6319 | hdd_info("chan[%d]:%d", i, pcl.pcl_list[i]); |
| 6320 | if ((pcl.pcl_list[i] >= |
| 6321 | adapter->sessionCtx.ap.sapConfig.acs_cfg.start_ch) && |
| 6322 | (pcl.pcl_list[i] <= |
| 6323 | adapter->sessionCtx.ap.sapConfig.acs_cfg.end_ch)) { |
| 6324 | hdd_info("found PCL safe chan:%d", pcl.pcl_list[i]); |
| 6325 | return pcl.pcl_list[i]; |
| 6326 | } |
| 6327 | } |
| 6328 | |
| 6329 | hdd_info("no safe channel from PCL found in ACS range"); |
| 6330 | |
| 6331 | /* Try for safe channel from all valid channel */ |
| 6332 | pcl.pcl_len = MAX_NUM_CHAN; |
| 6333 | status = sme_get_cfg_valid_channels(hal_handle, pcl.pcl_list, |
| 6334 | &pcl.pcl_len); |
| 6335 | if (QDF_IS_STATUS_ERROR(status)) { |
| 6336 | hdd_err("error in getting valid channel list"); |
| 6337 | return INVALID_CHANNEL_ID; |
| 6338 | } |
| 6339 | |
| 6340 | for (i = 0; i < pcl.pcl_len; i++) { |
| 6341 | hdd_info("chan[%d]:%d", i, pcl.pcl_list[i]); |
| 6342 | found = false; |
| 6343 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 6344 | if (pcl.pcl_list[i] == |
| 6345 | hdd_ctx->unsafe_channel_list[j]) { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6346 | hdd_info("unsafe chan:%d", pcl.pcl_list[i]); |
| 6347 | found = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6348 | break; |
| 6349 | } |
| 6350 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6351 | |
| 6352 | if (found) |
| 6353 | continue; |
| 6354 | |
| 6355 | if ((pcl.pcl_list[i] >= |
| 6356 | adapter->sessionCtx.ap.sapConfig.acs_cfg.start_ch) && |
| 6357 | (pcl.pcl_list[i] <= |
| 6358 | adapter->sessionCtx.ap.sapConfig.acs_cfg.end_ch)) { |
| 6359 | hdd_info("found safe chan:%d", pcl.pcl_list[i]); |
| 6360 | return pcl.pcl_list[i]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6361 | } |
| 6362 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6363 | |
| 6364 | return INVALID_CHANNEL_ID; |
| 6365 | } |
| 6366 | |
| 6367 | /** |
| 6368 | * hdd_restart_sap() - Restarts SAP on the given channel |
| 6369 | * @adapter: AP adapter |
| 6370 | * @channel: Channel |
| 6371 | * |
| 6372 | * Restarts the SAP interface by invoking the function which executes the |
| 6373 | * callback to perform channel switch using (E)CSA. |
| 6374 | * |
| 6375 | * Return: None |
| 6376 | */ |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 6377 | void hdd_restart_sap(hdd_adapter_t *adapter, uint8_t channel) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6378 | { |
| 6379 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 6380 | tHalHandle *hal_handle; |
| 6381 | |
| 6382 | if (!adapter) { |
| 6383 | hdd_err("invalid adapter"); |
| 6384 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6385 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6386 | |
| 6387 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 6388 | |
| 6389 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 6390 | if (!hal_handle) { |
| 6391 | hdd_err("invalid HAL handle"); |
| 6392 | return; |
| 6393 | } |
| 6394 | |
| 6395 | hdd_ap_ctx->sapConfig.channel = channel; |
| 6396 | hdd_ap_ctx->sapConfig.ch_params.ch_width = |
| 6397 | hdd_ap_ctx->sapConfig.ch_width_orig; |
| 6398 | |
| 6399 | hdd_info("chan:%d width:%d", |
| 6400 | channel, hdd_ap_ctx->sapConfig.ch_width_orig); |
| 6401 | |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 6402 | cds_set_channel_params(hdd_ap_ctx->sapConfig.channel, |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6403 | hdd_ap_ctx->sapConfig.sec_ch, |
| 6404 | &hdd_ap_ctx->sapConfig.ch_params); |
| 6405 | |
| 6406 | cds_change_sap_channel_with_csa(adapter, hdd_ap_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6407 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 6408 | |
| 6409 | int hdd_update_acs_timer_reason(hdd_adapter_t *adapter, uint8_t reason) |
| 6410 | { |
| 6411 | struct hdd_external_acs_timer_context *timer_context; |
| 6412 | |
| 6413 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 6414 | |
| 6415 | if (QDF_TIMER_STATE_RUNNING == |
| 6416 | qdf_mc_timer_get_current_state(&adapter->sessionCtx. |
| 6417 | ap.vendor_acs_timer)) { |
| 6418 | qdf_mc_timer_stop(&adapter->sessionCtx.ap.vendor_acs_timer); |
| 6419 | } |
| 6420 | timer_context = (struct hdd_external_acs_timer_context *) |
| 6421 | adapter->sessionCtx.ap.vendor_acs_timer.user_data; |
| 6422 | timer_context->reason = reason; |
| 6423 | qdf_mc_timer_start(&adapter->sessionCtx.ap.vendor_acs_timer, |
| 6424 | WLAN_VENDOR_ACS_WAIT_TIME); |
| 6425 | /* Update config to application */ |
| 6426 | hdd_cfg80211_update_acs_config(adapter, reason); |
| 6427 | hdd_notice("Updated ACS config to nl with reason %d", reason); |
| 6428 | |
| 6429 | return 0; |
| 6430 | } |
| 6431 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6432 | /** |
| 6433 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 6434 | * @hdd_ctx: hdd context pointer |
| 6435 | * |
| 6436 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 6437 | * and if ACS is enabled, driver will ask userspace to restart the |
| 6438 | * sap. User space on LTE coex indication restart driver. |
| 6439 | * |
| 6440 | * Return - none |
| 6441 | */ |
| 6442 | void hdd_unsafe_channel_restart_sap(hdd_context_t *hdd_ctxt) |
| 6443 | { |
| 6444 | QDF_STATUS status; |
| 6445 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 6446 | hdd_adapter_t *adapter_temp; |
| 6447 | uint32_t i; |
| 6448 | bool found = false; |
| 6449 | uint8_t restart_chan; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6450 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6451 | status = hdd_get_front_adapter(hdd_ctxt, &adapter_node); |
| 6452 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 6453 | adapter_temp = adapter_node->pAdapter; |
| 6454 | |
| 6455 | if (!adapter_temp) { |
| 6456 | hdd_err("adapter is NULL, moving to next one"); |
| 6457 | goto next_adapater; |
| 6458 | } |
| 6459 | |
| 6460 | if (!((adapter_temp->device_mode == QDF_SAP_MODE) && |
| 6461 | (adapter_temp->sessionCtx.ap.sapConfig.acs_cfg.acs_mode))) { |
| 6462 | hdd_info("skip device mode:%d acs:%d", |
| 6463 | adapter_temp->device_mode, |
| 6464 | adapter_temp->sessionCtx.ap.sapConfig. |
| 6465 | acs_cfg.acs_mode); |
| 6466 | goto next_adapater; |
| 6467 | } |
| 6468 | |
| 6469 | found = false; |
| 6470 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 6471 | if (adapter_temp->sessionCtx.ap.operatingChannel == |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6472 | hdd_ctxt->unsafe_channel_list[i]) { |
| 6473 | found = true; |
| 6474 | hdd_info("operating ch:%d is unsafe", |
| 6475 | adapter_temp->sessionCtx.ap.operatingChannel); |
| 6476 | break; |
| 6477 | } |
| 6478 | } |
| 6479 | |
| 6480 | if (!found) { |
| 6481 | hdd_info("ch:%d is safe. no need to change channel", |
| 6482 | adapter_temp->sessionCtx.ap.operatingChannel); |
| 6483 | goto next_adapater; |
| 6484 | } |
| 6485 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 6486 | if (hdd_ctxt->config->vendor_acs_support && |
| 6487 | hdd_ctxt->config->acs_support_for_dfs_ltecoex) { |
| 6488 | hdd_update_acs_timer_reason(adapter_temp, |
| 6489 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
| 6490 | goto next_adapater; |
| 6491 | } else |
| 6492 | restart_chan = |
| 6493 | hdd_get_safe_channel_from_pcl_and_acs_range( |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6494 | adapter_temp); |
| 6495 | if (!restart_chan) { |
| 6496 | hdd_alert("fail to restart SAP"); |
| 6497 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 6498 | /* |
| 6499 | * SAP restart due to unsafe channel. While |
| 6500 | * restarting the SAP, make sure to clear |
| 6501 | * acs_channel, channel to reset to |
| 6502 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 6503 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 6504 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 6505 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
| 6506 | adapter_temp->sessionCtx.ap.sapConfig.channel = |
| 6507 | AUTO_CHANNEL_SELECT; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6508 | hdd_info("sending coex indication"); |
| 6509 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 6510 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
| 6511 | hdd_restart_sap(adapter_temp, restart_chan); |
| 6512 | } |
| 6513 | |
| 6514 | next_adapater: |
| 6515 | status = hdd_get_next_adapter(hdd_ctxt, adapter_node, &next); |
| 6516 | adapter_node = next; |
| 6517 | } |
| 6518 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6519 | /** |
| 6520 | * hdd_ch_avoid_cb() - Avoid notified channels from FW handler |
| 6521 | * @adapter: HDD adapter pointer |
| 6522 | * @indParam: Channel avoid notification parameter |
| 6523 | * |
| 6524 | * Avoid channel notification from FW handler. |
| 6525 | * FW will send un-safe channel list to avoid over wrapping. |
| 6526 | * hostapd should not use notified channel |
| 6527 | * |
| 6528 | * Return: None |
| 6529 | */ |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6530 | void hdd_ch_avoid_cb(void *hdd_context, void *indi_param) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6531 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6532 | hdd_context_t *hdd_ctxt; |
| 6533 | tSirChAvoidIndType *ch_avoid_indi; |
| 6534 | uint8_t range_loop; |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6535 | enum channel_enum channel_loop, start_channel_idx = INVALID_CHANNEL, |
| 6536 | end_channel_idx = INVALID_CHANNEL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6537 | uint16_t start_channel; |
| 6538 | uint16_t end_channel; |
| 6539 | v_CONTEXT_t cds_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6540 | tHddAvoidFreqList hdd_avoid_freq_list; |
| 6541 | uint32_t i; |
| 6542 | |
| 6543 | /* Basic sanity */ |
| 6544 | if (!hdd_context || !indi_param) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6545 | hdd_err("Invalid arguments"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6546 | return; |
| 6547 | } |
| 6548 | |
| 6549 | hdd_ctxt = (hdd_context_t *) hdd_context; |
| 6550 | ch_avoid_indi = (tSirChAvoidIndType *) indi_param; |
| 6551 | cds_context = hdd_ctxt->pcds_context; |
| 6552 | |
| 6553 | /* Make unsafe channel list */ |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6554 | hdd_notice("band count %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6555 | ch_avoid_indi->avoid_range_count); |
| 6556 | |
| 6557 | /* generate vendor specific event */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6558 | qdf_mem_zero((void *)&hdd_avoid_freq_list, sizeof(tHddAvoidFreqList)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6559 | for (i = 0; i < ch_avoid_indi->avoid_range_count; i++) { |
| 6560 | hdd_avoid_freq_list.avoidFreqRange[i].startFreq = |
| 6561 | ch_avoid_indi->avoid_freq_range[i].start_freq; |
| 6562 | hdd_avoid_freq_list.avoidFreqRange[i].endFreq = |
| 6563 | ch_avoid_indi->avoid_freq_range[i].end_freq; |
| 6564 | } |
| 6565 | hdd_avoid_freq_list.avoidFreqRangeCount = |
| 6566 | ch_avoid_indi->avoid_range_count; |
| 6567 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6568 | /* clear existing unsafe channel cache */ |
| 6569 | hdd_ctxt->unsafe_channel_count = 0; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6570 | qdf_mem_zero(hdd_ctxt->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6571 | sizeof(hdd_ctxt->unsafe_channel_list)); |
| 6572 | |
| 6573 | for (range_loop = 0; range_loop < ch_avoid_indi->avoid_range_count; |
| 6574 | range_loop++) { |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6575 | if (hdd_ctxt->unsafe_channel_count >= NUM_CHANNELS) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6576 | hdd_warn("LTE Coex unsafe channel list full"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6577 | break; |
| 6578 | } |
| 6579 | |
| 6580 | start_channel = ieee80211_frequency_to_channel( |
| 6581 | ch_avoid_indi->avoid_freq_range[range_loop].start_freq); |
| 6582 | end_channel = ieee80211_frequency_to_channel( |
| 6583 | ch_avoid_indi->avoid_freq_range[range_loop].end_freq); |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6584 | hdd_notice("start %d : %d, end %d : %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6585 | ch_avoid_indi->avoid_freq_range[range_loop].start_freq, |
| 6586 | start_channel, |
| 6587 | ch_avoid_indi->avoid_freq_range[range_loop].end_freq, |
| 6588 | end_channel); |
| 6589 | |
| 6590 | /* do not process frequency bands that are not mapped to |
| 6591 | * predefined channels |
| 6592 | */ |
| 6593 | if (start_channel == 0 || end_channel == 0) |
| 6594 | continue; |
| 6595 | |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6596 | for (channel_loop = CHAN_ENUM_1; channel_loop <= |
| 6597 | CHAN_ENUM_184; channel_loop++) { |
Amar Singhal | 7a1726a | 2015-10-14 16:28:11 -0700 | [diff] [blame] | 6598 | if (CDS_CHANNEL_FREQ(channel_loop) >= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6599 | ch_avoid_indi->avoid_freq_range[ |
| 6600 | range_loop].start_freq) { |
| 6601 | start_channel_idx = channel_loop; |
| 6602 | break; |
| 6603 | } |
| 6604 | } |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6605 | for (channel_loop = CHAN_ENUM_1; channel_loop <= |
| 6606 | CHAN_ENUM_184; channel_loop++) { |
Amar Singhal | 7a1726a | 2015-10-14 16:28:11 -0700 | [diff] [blame] | 6607 | if (CDS_CHANNEL_FREQ(channel_loop) >= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6608 | ch_avoid_indi->avoid_freq_range[ |
| 6609 | range_loop].end_freq) { |
| 6610 | end_channel_idx = channel_loop; |
Amar Singhal | 7a1726a | 2015-10-14 16:28:11 -0700 | [diff] [blame] | 6611 | if (CDS_CHANNEL_FREQ(channel_loop) > |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6612 | ch_avoid_indi->avoid_freq_range[ |
| 6613 | range_loop].end_freq) |
| 6614 | end_channel_idx--; |
| 6615 | break; |
| 6616 | } |
| 6617 | } |
| 6618 | |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6619 | if (start_channel_idx == INVALID_CHANNEL || |
| 6620 | end_channel_idx == INVALID_CHANNEL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6621 | continue; |
| 6622 | |
| 6623 | for (channel_loop = start_channel_idx; channel_loop <= |
| 6624 | end_channel_idx; channel_loop++) { |
| 6625 | hdd_ctxt->unsafe_channel_list[ |
Amar Singhal | 7a1726a | 2015-10-14 16:28:11 -0700 | [diff] [blame] | 6626 | hdd_ctxt->unsafe_channel_count++] = |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 6627 | CDS_CHANNEL_NUM(channel_loop); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6628 | if (hdd_ctxt->unsafe_channel_count >= |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6629 | NUM_CHANNELS) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6630 | hdd_warn("LTECoex unsafe ch list full"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6631 | break; |
| 6632 | } |
| 6633 | } |
| 6634 | } |
| 6635 | |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6636 | hdd_notice("number of unsafe channels is %d ", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6637 | hdd_ctxt->unsafe_channel_count); |
| 6638 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6639 | if (pld_set_wlan_unsafe_channel(hdd_ctxt->parent_dev, |
| 6640 | hdd_ctxt->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6641 | hdd_ctxt->unsafe_channel_count)) { |
| 6642 | hdd_err("Failed to set unsafe channel"); |
| 6643 | |
| 6644 | /* clear existing unsafe channel cache */ |
| 6645 | hdd_ctxt->unsafe_channel_count = 0; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6646 | qdf_mem_zero(hdd_ctxt->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6647 | sizeof(hdd_ctxt->unsafe_channel_list)); |
| 6648 | |
| 6649 | return; |
| 6650 | } |
| 6651 | |
| 6652 | for (channel_loop = 0; |
| 6653 | channel_loop < hdd_ctxt->unsafe_channel_count; channel_loop++) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6654 | hdd_notice("channel %d is not safe ", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6655 | hdd_ctxt->unsafe_channel_list[channel_loop]); |
| 6656 | } |
| 6657 | |
Kondabattini, Ganesh | cf7b60f | 2016-08-10 16:31:55 +0530 | [diff] [blame] | 6658 | /* |
| 6659 | * first update the unsafe channel list to the platform driver and |
| 6660 | * send the avoid freq event to the application |
| 6661 | */ |
| 6662 | wlan_hdd_send_avoid_freq_event(hdd_ctxt, &hdd_avoid_freq_list); |
| 6663 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6664 | if (!hdd_ctxt->unsafe_channel_count) { |
| 6665 | hdd_info("no unsafe channels - not restarting SAP"); |
| 6666 | return; |
| 6667 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6668 | hdd_unsafe_channel_restart_sap(hdd_ctxt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6669 | return; |
| 6670 | } |
| 6671 | |
| 6672 | /** |
| 6673 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 6674 | * @hdd_ctx: HDD global context |
| 6675 | * |
| 6676 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6677 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6678 | * down to the lower layers. Then subscribe to subsequent channel |
| 6679 | * avoidance events. |
| 6680 | * |
| 6681 | * Return: None |
| 6682 | */ |
| 6683 | static void hdd_init_channel_avoidance(hdd_context_t *hdd_ctx) |
| 6684 | { |
| 6685 | uint16_t unsafe_channel_count; |
| 6686 | int index; |
| 6687 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6688 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 6689 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6690 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6691 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6692 | |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6693 | hdd_notice("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6694 | hdd_ctx->unsafe_channel_count); |
| 6695 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6696 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6697 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6698 | |
| 6699 | for (index = 0; index < unsafe_channel_count; index++) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6700 | hdd_notice("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6701 | hdd_ctx->unsafe_channel_list[index]); |
| 6702 | |
| 6703 | } |
| 6704 | |
| 6705 | /* Plug in avoid channel notification callback */ |
| 6706 | sme_add_ch_avoid_callback(hdd_ctx->hHal, hdd_ch_avoid_cb); |
| 6707 | } |
| 6708 | #else |
| 6709 | static void hdd_init_channel_avoidance(hdd_context_t *hdd_ctx) |
| 6710 | { |
| 6711 | } |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 6712 | 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] | 6713 | { |
| 6714 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6715 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6716 | |
| 6717 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 6718 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 6719 | * user space |
| 6720 | * @frame_ind: Management frame data to be informed. |
| 6721 | * |
| 6722 | * This function is used to indicate management frame to |
| 6723 | * user space |
| 6724 | * |
| 6725 | * Return: None |
| 6726 | * |
| 6727 | */ |
| 6728 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 6729 | { |
| 6730 | hdd_context_t *hdd_ctx = NULL; |
| 6731 | hdd_adapter_t *adapter = NULL; |
| 6732 | void *cds_context = NULL; |
| 6733 | int i; |
| 6734 | |
| 6735 | /* Get the global VOSS context.*/ |
| 6736 | cds_context = cds_get_global_context(); |
| 6737 | if (!cds_context) { |
| 6738 | hdd_err("Global CDS context is Null"); |
| 6739 | return; |
| 6740 | } |
| 6741 | /* Get the HDD context.*/ |
| 6742 | hdd_ctx = (hdd_context_t *)cds_get_context(QDF_MODULE_ID_HDD); |
| 6743 | |
| 6744 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 6745 | return; |
| 6746 | |
| 6747 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
| 6748 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 6749 | adapter = |
| 6750 | hdd_get_adapter_by_sme_session_id(hdd_ctx, i); |
| 6751 | if (adapter) |
| 6752 | break; |
| 6753 | } |
| 6754 | } else { |
| 6755 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 6756 | frame_ind->sessionId); |
| 6757 | } |
| 6758 | |
| 6759 | if ((NULL != adapter) && |
| 6760 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 6761 | __hdd_indicate_mgmt_frame(adapter, |
| 6762 | frame_ind->frame_len, |
| 6763 | frame_ind->frameBuf, |
| 6764 | frame_ind->frameType, |
| 6765 | frame_ind->rxChan, |
| 6766 | frame_ind->rxRssi); |
| 6767 | return; |
| 6768 | } |
| 6769 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 6770 | static void hdd_lte_coex_restart_sap(hdd_adapter_t *adapter, |
| 6771 | hdd_context_t *hdd_ctx) |
| 6772 | { |
| 6773 | uint8_t restart_chan = 0; |
| 6774 | |
| 6775 | restart_chan = |
| 6776 | hdd_get_safe_channel_from_pcl_and_acs_range(adapter); |
| 6777 | if (!restart_chan) { |
| 6778 | hdd_alert("fail to restart SAP"); |
| 6779 | } else { |
| 6780 | /* SAP restart due to unsafe channel. While restarting |
| 6781 | * the SAP, make sure to clear acs_channel, channel to |
| 6782 | * reset to 0. Otherwise these settings will override |
| 6783 | * the ACS while restart. |
| 6784 | */ |
| 6785 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
| 6786 | adapter->sessionCtx.ap.sapConfig.channel = |
| 6787 | AUTO_CHANNEL_SELECT; |
| 6788 | hdd_info("sending coex indication"); |
| 6789 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 6790 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
| 6791 | hdd_restart_sap(adapter, restart_chan); |
| 6792 | } |
| 6793 | } |
| 6794 | |
| 6795 | void hdd_acs_response_timeout_handler(void *context) |
| 6796 | { |
| 6797 | struct hdd_external_acs_timer_context *timer_context = |
| 6798 | (struct hdd_external_acs_timer_context *)context; |
| 6799 | hdd_adapter_t *adapter; |
| 6800 | hdd_context_t *hdd_ctx; |
| 6801 | uint8_t reason; |
| 6802 | |
| 6803 | ENTER(); |
| 6804 | if (!timer_context) { |
| 6805 | hdd_err("invlaid timer context"); |
| 6806 | return; |
| 6807 | } |
| 6808 | adapter = timer_context->adapter; |
| 6809 | reason = timer_context->reason; |
| 6810 | |
| 6811 | |
| 6812 | if ((!adapter) || |
| 6813 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 6814 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 6815 | return; |
| 6816 | } |
| 6817 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6818 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 6819 | return; |
| 6820 | |
| 6821 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 6822 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 6823 | else |
| 6824 | return; |
| 6825 | |
| 6826 | hdd_err("ACS timeout happened for %s reason %d", |
| 6827 | adapter->dev->name, reason); |
| 6828 | switch (reason) { |
| 6829 | /* SAP init case */ |
| 6830 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 6831 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 6832 | false); |
| 6833 | wlan_hdd_cfg80211_start_acs(adapter); |
| 6834 | break; |
| 6835 | /* DFS detected on current channel */ |
| 6836 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 6837 | wlan_sap_update_next_channel( |
| 6838 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
| 6839 | sme_update_new_channel_event(WLAN_HDD_GET_HAL_CTX(adapter), |
| 6840 | adapter->sessionId); |
| 6841 | break; |
| 6842 | /* LTE coex event on current channel */ |
| 6843 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 6844 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 6845 | break; |
| 6846 | default: |
| 6847 | hdd_info("invalid reason for timer invoke"); |
| 6848 | |
| 6849 | } |
| 6850 | } |
| 6851 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 6852 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6853 | * wlan_hdd_disable_all_dual_mac_features() - Disable dual mac features |
| 6854 | * @hdd_ctx: HDD context |
| 6855 | * |
| 6856 | * Disables all the dual mac features like DBS, Agile DFS etc. |
| 6857 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6858 | * Return: QDF_STATUS_SUCCESS on success |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6859 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6860 | 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] | 6861 | { |
| 6862 | struct sir_dual_mac_config cfg; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6863 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6864 | |
| 6865 | if (!hdd_ctx) { |
| 6866 | hdd_err("HDD context is NULL"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6867 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6868 | } |
| 6869 | |
| 6870 | cfg.scan_config = 0; |
| 6871 | cfg.fw_mode_config = 0; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 6872 | cfg.set_dual_mac_cb = cds_soc_set_dual_mac_cfg_cb; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6873 | |
| 6874 | hdd_debug("Disabling all dual mac features..."); |
| 6875 | |
| 6876 | status = sme_soc_set_dual_mac_config(hdd_ctx->hHal, cfg); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6877 | if (status != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6878 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 6879 | return status; |
| 6880 | } |
| 6881 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6882 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6883 | } |
| 6884 | |
| 6885 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6886 | * hdd_override_ini_config - Override INI config |
| 6887 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6888 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6889 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6890 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6891 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6892 | */ |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6893 | static void hdd_override_ini_config(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6894 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6895 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6896 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
| 6897 | hdd_ctx->config->enableDFSChnlScan = enable_dfs_chan_scan; |
| 6898 | hdd_notice("Module enable_dfs_chan_scan set to %d", |
| 6899 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6900 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6901 | if (0 == enable_11d || 1 == enable_11d) { |
| 6902 | hdd_ctx->config->Is11dSupportEnabled = enable_11d; |
| 6903 | hdd_notice("Module enable_11d set to %d", enable_11d); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6904 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 6905 | |
| 6906 | if (!hdd_ipa_is_present(hdd_ctx)) |
| 6907 | hdd_ctx->config->IpaConfig = 0; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6908 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6909 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6910 | /** |
| 6911 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 6912 | * @hdd_ctx - HDD context |
| 6913 | * |
| 6914 | * Set trace level for each module based on INI config. |
| 6915 | * |
| 6916 | * Return: None |
| 6917 | */ |
| 6918 | static void hdd_set_trace_level_for_each(hdd_context_t *hdd_ctx) |
| 6919 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6920 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMI, |
| 6921 | hdd_ctx->config->qdf_trace_enable_wdi); |
| 6922 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD, |
| 6923 | hdd_ctx->config->qdf_trace_enable_hdd); |
| 6924 | hdd_qdf_trace_enable(QDF_MODULE_ID_SME, |
| 6925 | hdd_ctx->config->qdf_trace_enable_sme); |
| 6926 | hdd_qdf_trace_enable(QDF_MODULE_ID_PE, |
| 6927 | hdd_ctx->config->qdf_trace_enable_pe); |
| 6928 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMA, |
| 6929 | hdd_ctx->config->qdf_trace_enable_wma); |
| 6930 | hdd_qdf_trace_enable(QDF_MODULE_ID_SYS, |
| 6931 | hdd_ctx->config->qdf_trace_enable_sys); |
| 6932 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF, |
| 6933 | hdd_ctx->config->qdf_trace_enable_qdf); |
| 6934 | hdd_qdf_trace_enable(QDF_MODULE_ID_SAP, |
| 6935 | hdd_ctx->config->qdf_trace_enable_sap); |
| 6936 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SOFTAP, |
| 6937 | hdd_ctx->config->qdf_trace_enable_hdd_sap); |
| 6938 | hdd_qdf_trace_enable(QDF_MODULE_ID_BMI, |
| 6939 | hdd_ctx->config->qdf_trace_enable_bmi); |
| 6940 | hdd_qdf_trace_enable(QDF_MODULE_ID_CFG, |
| 6941 | hdd_ctx->config->qdf_trace_enable_cfg); |
| 6942 | hdd_qdf_trace_enable(QDF_MODULE_ID_EPPING, |
| 6943 | hdd_ctx->config->qdf_trace_enable_epping); |
| 6944 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF_DEVICE, |
| 6945 | hdd_ctx->config->qdf_trace_enable_qdf_devices); |
| 6946 | hdd_qdf_trace_enable(QDF_MODULE_ID_TXRX, |
Bhargav Shah | 480a90f | 2015-06-24 15:10:14 +0530 | [diff] [blame] | 6947 | hdd_ctx->config->cfd_trace_enable_txrx); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6948 | hdd_qdf_trace_enable(QDF_MODULE_ID_HTC, |
| 6949 | hdd_ctx->config->qdf_trace_enable_htc); |
| 6950 | hdd_qdf_trace_enable(QDF_MODULE_ID_HIF, |
| 6951 | hdd_ctx->config->qdf_trace_enable_hif); |
| 6952 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SAP_DATA, |
| 6953 | hdd_ctx->config->qdf_trace_enable_hdd_sap_data); |
| 6954 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_DATA, |
| 6955 | hdd_ctx->config->qdf_trace_enable_hdd_data); |
Bhargav Shah | 480a90f | 2015-06-24 15:10:14 +0530 | [diff] [blame] | 6956 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6957 | hdd_cfg_print(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6958 | } |
| 6959 | |
| 6960 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6961 | * hdd_context_init() - Initialize HDD context |
| 6962 | * @hdd_ctx: HDD context. |
| 6963 | * |
| 6964 | * Initialize HDD context along with all the feature specific contexts. |
| 6965 | * |
| 6966 | * return: 0 on success and errno on failure. |
| 6967 | */ |
| 6968 | static int hdd_context_init(hdd_context_t *hdd_ctx) |
| 6969 | { |
| 6970 | int ret; |
| 6971 | |
| 6972 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 6973 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 6974 | |
| 6975 | hdd_init_ll_stats_ctx(); |
| 6976 | |
| 6977 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 6978 | init_completion(&hdd_ctx->ready_to_suspend); |
| 6979 | |
| 6980 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 6981 | qdf_spinlock_create(&hdd_ctx->sta_update_info_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6982 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 6983 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6984 | qdf_list_create(&hdd_ctx->hddAdapters, MAX_NUMBER_OF_ADAPTERS); |
| 6985 | |
| 6986 | init_completion(&hdd_ctx->set_antenna_mode_cmpl); |
| 6987 | |
| 6988 | ret = hdd_scan_context_init(hdd_ctx); |
| 6989 | if (ret) |
| 6990 | goto list_destroy; |
| 6991 | |
Nitesh Shah | d1266d7 | 2017-01-25 22:07:07 +0530 | [diff] [blame] | 6992 | hdd_tdls_context_init(hdd_ctx, false); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6993 | |
| 6994 | hdd_rx_wake_lock_create(hdd_ctx); |
| 6995 | |
| 6996 | ret = hdd_sap_context_init(hdd_ctx); |
| 6997 | if (ret) |
| 6998 | goto scan_destroy; |
| 6999 | |
| 7000 | ret = hdd_roc_context_init(hdd_ctx); |
| 7001 | if (ret) |
| 7002 | goto sap_destroy; |
| 7003 | |
| 7004 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 7005 | |
| 7006 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 7007 | |
| 7008 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 7009 | hdd_ctx->config); |
| 7010 | if (ret) |
| 7011 | goto roc_destroy; |
| 7012 | |
| 7013 | return 0; |
| 7014 | |
| 7015 | roc_destroy: |
| 7016 | hdd_roc_context_destroy(hdd_ctx); |
| 7017 | |
| 7018 | sap_destroy: |
| 7019 | hdd_sap_context_destroy(hdd_ctx); |
| 7020 | |
| 7021 | scan_destroy: |
| 7022 | hdd_scan_context_destroy(hdd_ctx); |
| 7023 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 7024 | hdd_tdls_context_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7025 | list_destroy: |
| 7026 | qdf_list_destroy(&hdd_ctx->hddAdapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 7027 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7028 | return ret; |
| 7029 | } |
| 7030 | |
| 7031 | /** |
| 7032 | * hdd_context_create() - Allocate and inialize HDD context. |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7033 | * @dev: Device Pointer to the underlying device |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7034 | * |
| 7035 | * Allocate and initialize HDD context. HDD context is allocated as part of |
| 7036 | * wiphy allocation and then context is initialized. |
| 7037 | * |
| 7038 | * Return: HDD context on success and ERR_PTR on failure |
| 7039 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 7040 | static hdd_context_t *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7041 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7042 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7043 | int ret = 0; |
| 7044 | hdd_context_t *hdd_ctx; |
| 7045 | v_CONTEXT_t p_cds_context; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 7046 | int qdf_print_idx = -1; |
| 7047 | |
| 7048 | struct category_info cinfo[MAX_SUPPORTED_CATEGORY] = { |
| 7049 | [QDF_MODULE_ID_TLSHIM] = {QDF_TRACE_LEVEL_ALL}, |
| 7050 | [QDF_MODULE_ID_WMI] = {QDF_TRACE_LEVEL_ALL}, |
| 7051 | [QDF_MODULE_ID_HTT] = {QDF_TRACE_LEVEL_ALL}, |
| 7052 | [QDF_MODULE_ID_HDD] = {QDF_TRACE_LEVEL_ALL}, |
| 7053 | [QDF_MODULE_ID_SME] = {QDF_TRACE_LEVEL_ALL}, |
| 7054 | [QDF_MODULE_ID_PE] = {QDF_TRACE_LEVEL_ALL}, |
| 7055 | [QDF_MODULE_ID_WMA] = {QDF_TRACE_LEVEL_ALL}, |
| 7056 | [QDF_MODULE_ID_SYS] = {QDF_TRACE_LEVEL_ALL}, |
| 7057 | [QDF_MODULE_ID_QDF] = {QDF_TRACE_LEVEL_ALL}, |
| 7058 | [QDF_MODULE_ID_SAP] = {QDF_TRACE_LEVEL_ALL}, |
| 7059 | [QDF_MODULE_ID_HDD_SOFTAP] = {QDF_TRACE_LEVEL_ALL}, |
| 7060 | [QDF_MODULE_ID_HDD_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 7061 | [QDF_MODULE_ID_HDD_SAP_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 7062 | [QDF_MODULE_ID_HIF] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 7063 | [QDF_MODULE_ID_HTC] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 7064 | [QDF_MODULE_ID_TXRX] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 7065 | [QDF_MODULE_ID_QDF_DEVICE] = {QDF_TRACE_LEVEL_ALL}, |
| 7066 | [QDF_MODULE_ID_CFG] = {QDF_TRACE_LEVEL_ALL}, |
| 7067 | [QDF_MODULE_ID_BMI] = {QDF_TRACE_LEVEL_ALL}, |
| 7068 | [QDF_MODULE_ID_EPPING] = {QDF_TRACE_LEVEL_ALL}, |
Ashish Kumar Dhanotiya | f928edf | 2017-02-06 14:43:24 +0530 | [diff] [blame] | 7069 | [QDF_MODULE_ID_QVIT] = {QDF_TRACE_LEVEL_ALL}, |
| 7070 | [QDF_MODULE_ID_DP] = {QDF_TRACE_LEVEL_ALL}, |
| 7071 | [QDF_MODULE_ID_SOC] = {QDF_TRACE_LEVEL_ALL}, |
| 7072 | [QDF_MODULE_ID_OS_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 7073 | [QDF_MODULE_ID_TARGET_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 7074 | [QDF_MODULE_ID_SCHEDULER] = {QDF_TRACE_LEVEL_ALL}, |
Mukul Sharma | 4d7d6b0 | 2017-02-13 20:45:22 +0530 | [diff] [blame] | 7075 | [QDF_MODULE_ID_MGMT_TXRX] = {QDF_TRACE_LEVEL_ALL}, |
Abhishek Singh | 9679dbf | 2017-02-15 11:35:41 +0530 | [diff] [blame] | 7076 | [QDF_MODULE_ID_PMO] = {QDF_TRACE_LEVEL_ALL}, |
Tushnim Bhattacharyya | 6796d8d | 2017-03-17 11:06:03 -0700 | [diff] [blame] | 7077 | [QDF_MODULE_ID_SCAN] = {QDF_TRACE_LEVEL_ALL}, |
| 7078 | [QDF_MODULE_ID_POLICY_MGR] = {QDF_TRACE_LEVEL_ALL}, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 7079 | }; |
| 7080 | |
| 7081 | status = qdf_print_setup(); |
| 7082 | if (status != QDF_STATUS_SUCCESS) { |
| 7083 | pr_err("QDF print control object setup failed\n"); |
| 7084 | ret = -EINVAL; |
| 7085 | goto err_out; |
| 7086 | } |
| 7087 | /* Register the module here with QDF */ |
| 7088 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, |
| 7089 | "MCL_WLAN"); |
| 7090 | |
| 7091 | /* if qdf_print_idx is negative */ |
| 7092 | if (qdf_print_idx < 0) { |
| 7093 | pr_err("QDF print control can not be registered %d\n", |
| 7094 | qdf_print_idx); |
| 7095 | ret = -EINVAL; |
| 7096 | goto err_out; |
| 7097 | } |
| 7098 | |
| 7099 | /* Store the qdf_pidx information into qdf module */ |
| 7100 | qdf_set_pidx(qdf_print_idx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7101 | |
| 7102 | ENTER(); |
| 7103 | |
| 7104 | p_cds_context = cds_get_global_context(); |
| 7105 | if (p_cds_context == NULL) { |
| 7106 | hdd_alert("Failed to get CDS global context"); |
| 7107 | ret = -EINVAL; |
| 7108 | goto err_out; |
| 7109 | } |
| 7110 | |
| 7111 | hdd_ctx = hdd_cfg80211_wiphy_alloc(sizeof(hdd_context_t)); |
| 7112 | |
| 7113 | if (hdd_ctx == NULL) { |
| 7114 | ret = -ENOMEM; |
| 7115 | goto err_out; |
| 7116 | } |
| 7117 | |
| 7118 | hdd_ctx->pcds_context = p_cds_context; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7119 | hdd_ctx->parent_dev = dev; |
Sreelakshmi Konamki | b53c629 | 2017-03-01 13:13:23 +0530 | [diff] [blame] | 7120 | hdd_ctx->last_scan_reject_session_id = 0xFF; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7121 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7122 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7123 | if (hdd_ctx->config == NULL) { |
| 7124 | hdd_alert("Failed to alloc memory for HDD config!"); |
| 7125 | ret = -ENOMEM; |
| 7126 | goto err_free_hdd_context; |
| 7127 | } |
| 7128 | |
| 7129 | /* Read and parse the qcom_cfg.ini file */ |
| 7130 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7131 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7132 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7133 | WLAN_INI_FILE); |
| 7134 | ret = -EINVAL; |
| 7135 | goto err_free_config; |
| 7136 | } |
| 7137 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7138 | hdd_notice("Setting configuredMcastBcastFilter: %d", |
| 7139 | hdd_ctx->config->mcastBcastFilterSetting); |
| 7140 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 7141 | if (hdd_ctx->config->fhostNSOffload) |
| 7142 | hdd_ctx->ns_offload_enable = true; |
| 7143 | |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 7144 | cds_set_fatal_event(hdd_ctx->config->enable_fatal_event); |
| 7145 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7146 | hdd_override_ini_config(hdd_ctx); |
| 7147 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7148 | ((cds_context_type *) (p_cds_context))->pHDDContext = (void *)hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7149 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7150 | ret = hdd_context_init(hdd_ctx); |
| 7151 | |
| 7152 | if (ret) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7153 | goto err_free_config; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7154 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7155 | |
Yuanyuan Liu | 7a97b8f | 2017-01-27 10:42:52 -0800 | [diff] [blame] | 7156 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 7157 | hdd_ctx->config->enable_fw_log); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7158 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7159 | |
| 7160 | /* Uses to enabled logging after SSR */ |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 7161 | hdd_ctx->fw_log_settings.enable = hdd_ctx->config->enable_fw_log; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7162 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7163 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7164 | goto skip_multicast_logging; |
| 7165 | |
| 7166 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 7167 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 7168 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 7169 | if (ret) |
| 7170 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7171 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7172 | ret = hdd_logging_sock_activate_svc(hdd_ctx); |
| 7173 | if (ret) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7174 | goto err_free_histogram; |
| 7175 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7176 | skip_multicast_logging: |
| 7177 | hdd_set_trace_level_for_each(hdd_ctx); |
| 7178 | |
| 7179 | return hdd_ctx; |
| 7180 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7181 | err_free_histogram: |
| 7182 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 7183 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 7184 | err_deinit_hdd_context: |
| 7185 | hdd_context_deinit(hdd_ctx); |
| 7186 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7187 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7188 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7189 | |
| 7190 | err_free_hdd_context: |
| 7191 | wiphy_free(hdd_ctx->wiphy); |
| 7192 | |
| 7193 | err_out: |
| 7194 | return ERR_PTR(ret); |
| 7195 | } |
| 7196 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7197 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 7198 | /** |
| 7199 | * hdd_open_p2p_interface - Open P2P interface |
| 7200 | * @hdd_ctx: HDD context |
| 7201 | * @rtnl_held: True if RTNL lock held |
| 7202 | * |
| 7203 | * Open P2P interface during probe. This function called to open the P2P |
| 7204 | * interface at probe along with STA interface. |
| 7205 | * |
| 7206 | * Return: 0 on success and errno on failure |
| 7207 | */ |
| 7208 | static int hdd_open_p2p_interface(hdd_context_t *hdd_ctx, bool rtnl_held) |
| 7209 | { |
| 7210 | hdd_adapter_t *adapter; |
| 7211 | uint8_t *p2p_dev_addr; |
| 7212 | |
| 7213 | if (hdd_ctx->config->isP2pDeviceAddrAdministrated && |
| 7214 | !(hdd_ctx->config->intfMacAddr[0].bytes[0] & 0x02)) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7215 | qdf_mem_copy(hdd_ctx->p2pDeviceAddress.bytes, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7216 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 7217 | sizeof(tSirMacAddr)); |
| 7218 | |
| 7219 | /* |
| 7220 | * Generate the P2P Device Address. This consists of |
| 7221 | * the device's primary MAC address with the locally |
| 7222 | * administered bit set. |
| 7223 | */ |
| 7224 | hdd_ctx->p2pDeviceAddress.bytes[0] |= 0x02; |
| 7225 | } else { |
| 7226 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx); |
| 7227 | if (p2p_dev_addr == NULL) { |
| 7228 | hdd_alert("Failed to allocate mac_address for p2p_device"); |
| 7229 | return -ENOSPC; |
| 7230 | } |
| 7231 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7232 | qdf_mem_copy(&hdd_ctx->p2pDeviceAddress.bytes[0], p2p_dev_addr, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7233 | QDF_MAC_ADDR_SIZE); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7234 | } |
| 7235 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7236 | adapter = hdd_open_adapter(hdd_ctx, QDF_P2P_DEVICE_MODE, "p2p%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7237 | &hdd_ctx->p2pDeviceAddress.bytes[0], |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 7238 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7239 | |
| 7240 | if (NULL == adapter) { |
| 7241 | hdd_alert("Failed to do hdd_open_adapter for P2P Device Interface"); |
| 7242 | return -ENOSPC; |
| 7243 | } |
| 7244 | |
| 7245 | return 0; |
| 7246 | } |
| 7247 | #else |
Manishekar Chandrasekaran | c81ba24 | 2016-07-18 17:44:44 +0530 | [diff] [blame] | 7248 | static inline int hdd_open_p2p_interface(hdd_context_t *hdd_ctx, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7249 | bool rtnl_held) |
| 7250 | { |
| 7251 | return 0; |
| 7252 | } |
| 7253 | #endif |
| 7254 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7255 | static int hdd_open_ocb_interface(hdd_context_t *hdd_ctx, bool rtnl_held) |
| 7256 | { |
| 7257 | hdd_adapter_t *adapter; |
| 7258 | int ret = 0; |
| 7259 | |
| 7260 | adapter = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, "wlanocb%d", |
| 7261 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 7262 | NET_NAME_UNKNOWN, rtnl_held); |
| 7263 | if (adapter == NULL) { |
| 7264 | hdd_err("Failed to open 802.11p interface"); |
| 7265 | ret = -ENOSPC; |
| 7266 | } |
| 7267 | |
| 7268 | return ret; |
| 7269 | } |
| 7270 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7271 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 7272 | * hdd_start_station_adapter()- Start the Station Adapter |
| 7273 | * @adapter: HDD adapter |
| 7274 | * |
| 7275 | * This function initializes the adapter for the station mode. |
| 7276 | * |
| 7277 | * Return: 0 on success or errno on failure. |
| 7278 | */ |
| 7279 | int hdd_start_station_adapter(hdd_adapter_t *adapter) |
| 7280 | { |
| 7281 | QDF_STATUS status; |
| 7282 | |
| 7283 | ENTER_DEV(adapter->dev); |
| 7284 | |
| 7285 | status = hdd_init_station_mode(adapter); |
| 7286 | |
| 7287 | if (QDF_STATUS_SUCCESS != status) { |
| 7288 | hdd_err("Error Initializing station mode: %d", status); |
| 7289 | return qdf_status_to_os_return(status); |
| 7290 | } |
| 7291 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7292 | hdd_register_tx_flow_control(adapter, |
| 7293 | hdd_tx_resume_timer_expired_handler, |
| 7294 | hdd_tx_resume_cb); |
| 7295 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 7296 | EXIT(); |
| 7297 | return 0; |
| 7298 | } |
| 7299 | |
| 7300 | /** |
| 7301 | * hdd_start_ap_adapter()- Start AP Adapter |
| 7302 | * @adapter: HDD adapter |
| 7303 | * |
| 7304 | * This function initializes the adapter for the AP mode. |
| 7305 | * |
| 7306 | * Return: 0 on success errno on failure. |
| 7307 | */ |
| 7308 | int hdd_start_ap_adapter(hdd_adapter_t *adapter) |
| 7309 | { |
| 7310 | QDF_STATUS status; |
| 7311 | |
| 7312 | ENTER(); |
| 7313 | |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 7314 | status = hdd_init_ap_mode(adapter, false); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 7315 | |
| 7316 | if (QDF_STATUS_SUCCESS != status) { |
| 7317 | hdd_err("Error Initializing the AP mode: %d", status); |
| 7318 | return qdf_status_to_os_return(status); |
| 7319 | } |
| 7320 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7321 | hdd_register_tx_flow_control(adapter, |
| 7322 | hdd_softap_tx_resume_timer_expired_handler, |
| 7323 | hdd_softap_tx_resume_cb); |
| 7324 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 7325 | EXIT(); |
| 7326 | return 0; |
| 7327 | } |
| 7328 | |
| 7329 | /** |
| 7330 | * hdd_start_ftm_adapter()- Start FTM adapter |
| 7331 | * @adapter: HDD adapter |
| 7332 | * |
| 7333 | * This function initializes the adapter for the FTM mode. |
| 7334 | * |
| 7335 | * Return: 0 on success or errno on failure. |
| 7336 | */ |
| 7337 | int hdd_start_ftm_adapter(hdd_adapter_t *adapter) |
| 7338 | { |
| 7339 | QDF_STATUS qdf_status; |
| 7340 | |
| 7341 | ENTER_DEV(adapter->dev); |
| 7342 | |
| 7343 | qdf_status = hdd_init_tx_rx(adapter); |
| 7344 | |
| 7345 | if (QDF_STATUS_SUCCESS != qdf_status) { |
| 7346 | hdd_err("Failed to start FTM adapter: %d", qdf_status); |
| 7347 | return qdf_status_to_os_return(qdf_status); |
| 7348 | } |
| 7349 | |
| 7350 | return 0; |
| 7351 | EXIT(); |
| 7352 | } |
| 7353 | |
| 7354 | /** |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7355 | * hdd_open_interfaces - Open all required interfaces |
| 7356 | * hdd_ctx: HDD context |
| 7357 | * rtnl_held: True if RTNL lock is held |
| 7358 | * |
| 7359 | * Open all the interfaces like STA, P2P and OCB based on the configuration. |
| 7360 | * |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7361 | * Return: 0 if all interfaces were created, otherwise negative errno |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7362 | */ |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7363 | 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] | 7364 | { |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7365 | hdd_adapter_t *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7366 | int ret; |
| 7367 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7368 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_STANDALONE) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7369 | /* Create only 802.11p interface */ |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7370 | return hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7371 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7372 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, "wlan%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7373 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 7374 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7375 | |
| 7376 | if (adapter == NULL) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7377 | return -ENOSPC; |
| 7378 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 7379 | /* fast roaming is allowed only on first STA, i.e. wlan adapter */ |
| 7380 | adapter->fast_roaming_allowed = true; |
| 7381 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7382 | ret = hdd_open_p2p_interface(hdd_ctx, rtnl_held); |
| 7383 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7384 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7385 | |
| 7386 | /* Open 802.11p Interface */ |
| 7387 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_CONCURRENT) { |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7388 | ret = hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
| 7389 | if (ret) |
| 7390 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7391 | } |
| 7392 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7393 | return 0; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7394 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7395 | err_close_adapters: |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7396 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7397 | return ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7398 | } |
| 7399 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7400 | /** |
| 7401 | * hdd_update_country_code - Update country code |
| 7402 | * @hdd_ctx: HDD context |
| 7403 | * @adapter: Primary adapter context |
| 7404 | * |
| 7405 | * Update country code based on module parameter country_code at SME and wait |
| 7406 | * for the settings to take effect. |
| 7407 | * |
| 7408 | * Return: 0 on success and errno on failure |
| 7409 | */ |
| 7410 | static int hdd_update_country_code(hdd_context_t *hdd_ctx, |
| 7411 | hdd_adapter_t *adapter) |
| 7412 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7413 | QDF_STATUS status; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7414 | int ret = 0; |
| 7415 | unsigned long rc; |
| 7416 | |
| 7417 | if (country_code == NULL) |
| 7418 | return 0; |
| 7419 | |
| 7420 | INIT_COMPLETION(adapter->change_country_code); |
| 7421 | |
| 7422 | status = sme_change_country_code(hdd_ctx->hHal, |
| 7423 | wlan_hdd_change_country_code_callback, |
| 7424 | country_code, adapter, |
| 7425 | hdd_ctx->pcds_context, eSIR_TRUE, |
| 7426 | eSIR_TRUE); |
| 7427 | |
| 7428 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7429 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7430 | hdd_err("SME Change Country code from module param fail ret=%d", |
| 7431 | ret); |
| 7432 | return -EINVAL; |
| 7433 | } |
| 7434 | |
| 7435 | rc = wait_for_completion_timeout(&adapter->change_country_code, |
| 7436 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 7437 | if (!rc) { |
| 7438 | hdd_err("SME while setting country code timed out"); |
| 7439 | ret = -ETIMEDOUT; |
| 7440 | } |
| 7441 | |
| 7442 | return ret; |
| 7443 | } |
| 7444 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7445 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 7446 | /** |
| 7447 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 7448 | * @cds_cfg: CDS Configuration |
| 7449 | * @hdd_ctx: Pointer to hdd context |
| 7450 | * |
| 7451 | * Return: none |
| 7452 | */ |
| 7453 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 7454 | *cds_cfg, |
| 7455 | hdd_context_t *hdd_ctx) |
| 7456 | { |
| 7457 | cds_cfg->tx_flow_stop_queue_th = |
| 7458 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 7459 | cds_cfg->tx_flow_start_queue_offset = |
| 7460 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 7461 | } |
| 7462 | #else |
| 7463 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 7464 | *cds_cfg, |
| 7465 | hdd_context_t *hdd_ctx) |
| 7466 | { |
| 7467 | } |
| 7468 | #endif |
| 7469 | |
| 7470 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 7471 | /** |
| 7472 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 7473 | * @cds_cfg: CDS Configuration |
| 7474 | * @hdd_ctx: Pointer to hdd context |
| 7475 | * |
| 7476 | * Return: none |
| 7477 | */ |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 7478 | 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] | 7479 | hdd_context_t *hdd_ctx) |
| 7480 | { |
| 7481 | cds_cfg->ra_ratelimit_interval = |
| 7482 | hdd_ctx->config->RArateLimitInterval; |
| 7483 | cds_cfg->is_ra_ratelimit_enabled = |
| 7484 | hdd_ctx->config->IsRArateLimitEnabled; |
| 7485 | } |
| 7486 | #else |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 7487 | 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] | 7488 | hdd_context_t *hdd_ctx) |
| 7489 | { |
| 7490 | } |
| 7491 | #endif |
| 7492 | |
| 7493 | /** |
| 7494 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 7495 | * @hdd_ctx: HDD Context |
| 7496 | * |
| 7497 | * Return: 0 for Success, errno on failure |
| 7498 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 7499 | static int hdd_update_cds_config(hdd_context_t *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7500 | { |
| 7501 | struct cds_config_info *cds_cfg; |
| 7502 | |
| 7503 | cds_cfg = (struct cds_config_info *)qdf_mem_malloc(sizeof(*cds_cfg)); |
| 7504 | if (!cds_cfg) { |
| 7505 | hdd_err("failed to allocate cds config"); |
| 7506 | return -ENOMEM; |
| 7507 | } |
| 7508 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7509 | cds_cfg->driver_type = DRIVER_TYPE_PRODUCTION; |
Kiran Kumar Lokere | 7006e0a | 2017-03-07 19:28:36 -0800 | [diff] [blame] | 7510 | if (!hdd_ctx->config->nMaxPsPoll || |
| 7511 | !hdd_ctx->config->enablePowersaveOffload) { |
| 7512 | cds_cfg->powersave_offload_enabled = |
| 7513 | hdd_ctx->config->enablePowersaveOffload; |
| 7514 | } else { |
| 7515 | if ((hdd_ctx->config->enablePowersaveOffload == |
| 7516 | PS_QPOWER_NODEEPSLEEP) || |
| 7517 | (hdd_ctx->config->enablePowersaveOffload == |
| 7518 | PS_LEGACY_NODEEPSLEEP)) |
| 7519 | cds_cfg->powersave_offload_enabled = |
| 7520 | PS_LEGACY_NODEEPSLEEP; |
| 7521 | else |
| 7522 | cds_cfg->powersave_offload_enabled = |
| 7523 | PS_LEGACY_DEEPSLEEP; |
| 7524 | hdd_info("Qpower disabled in cds config, %d", |
| 7525 | cds_cfg->powersave_offload_enabled); |
| 7526 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7527 | cds_cfg->sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 7528 | cds_cfg->sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 7529 | cds_cfg->sta_maxlimod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 7530 | cds_cfg->wow_enable = hdd_ctx->config->wowEnable; |
| 7531 | cds_cfg->max_wow_filters = hdd_ctx->config->maxWoWFilters; |
| 7532 | |
| 7533 | /* Here ol_ini_info is used to store ini status of arp offload |
| 7534 | * ns offload and others. Currently 1st bit is used for arp |
| 7535 | * off load and 2nd bit for ns offload currently, rest bits are unused |
| 7536 | */ |
| 7537 | if (hdd_ctx->config->fhostArpOffload) |
| 7538 | cds_cfg->ol_ini_info = cds_cfg->ol_ini_info | 0x1; |
| 7539 | if (hdd_ctx->config->fhostNSOffload) |
| 7540 | cds_cfg->ol_ini_info = cds_cfg->ol_ini_info | 0x2; |
| 7541 | |
| 7542 | /* |
| 7543 | * Copy the DFS Phyerr Filtering Offload status. |
| 7544 | * This parameter reflects the value of the |
| 7545 | * dfs_phyerr_filter_offload flag as set in the ini. |
| 7546 | */ |
| 7547 | cds_cfg->dfs_phyerr_filter_offload = |
| 7548 | hdd_ctx->config->fDfsPhyerrFilterOffload; |
| 7549 | if (hdd_ctx->config->ssdp) |
| 7550 | cds_cfg->ssdp = hdd_ctx->config->ssdp; |
| 7551 | |
| 7552 | cds_cfg->enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 7553 | cds_cfg->ap_maxoffload_peers = hdd_ctx->config->apMaxOffloadPeers; |
| 7554 | |
| 7555 | cds_cfg->ap_maxoffload_reorderbuffs = |
| 7556 | hdd_ctx->config->apMaxOffloadReorderBuffs; |
| 7557 | |
| 7558 | cds_cfg->ap_disable_intrabss_fwd = |
| 7559 | hdd_ctx->config->apDisableIntraBssFwd; |
| 7560 | |
| 7561 | cds_cfg->dfs_pri_multiplier = |
| 7562 | hdd_ctx->config->dfsRadarPriMultiplier; |
| 7563 | cds_cfg->reorder_offload = |
| 7564 | hdd_ctx->config->reorderOffloadSupport; |
| 7565 | |
| 7566 | /* IPA micro controller data path offload resource config item */ |
| 7567 | cds_cfg->uc_offload_enabled = hdd_ipa_uc_is_enabled(hdd_ctx); |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 7568 | if (!is_power_of_2(hdd_ctx->config->IpaUcTxBufCount)) { |
| 7569 | /* IpaUcTxBufCount should be power of 2 */ |
| 7570 | hdd_err("Round down IpaUcTxBufCount %d to nearest power of 2", |
| 7571 | hdd_ctx->config->IpaUcTxBufCount); |
| 7572 | hdd_ctx->config->IpaUcTxBufCount = |
| 7573 | rounddown_pow_of_two( |
| 7574 | hdd_ctx->config->IpaUcTxBufCount); |
| 7575 | if (!hdd_ctx->config->IpaUcTxBufCount) { |
| 7576 | hdd_err("Failed to round down IpaUcTxBufCount"); |
| 7577 | return -EINVAL; |
| 7578 | } |
| 7579 | hdd_err("IpaUcTxBufCount rounded down to %d", |
| 7580 | hdd_ctx->config->IpaUcTxBufCount); |
| 7581 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7582 | cds_cfg->uc_txbuf_count = hdd_ctx->config->IpaUcTxBufCount; |
| 7583 | cds_cfg->uc_txbuf_size = hdd_ctx->config->IpaUcTxBufSize; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 7584 | if (!is_power_of_2(hdd_ctx->config->IpaUcRxIndRingCount)) { |
| 7585 | /* IpaUcRxIndRingCount should be power of 2 */ |
| 7586 | hdd_err("Round down IpaUcRxIndRingCount %d to nearest power of 2", |
| 7587 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 7588 | hdd_ctx->config->IpaUcRxIndRingCount = |
| 7589 | rounddown_pow_of_two( |
| 7590 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 7591 | if (!hdd_ctx->config->IpaUcRxIndRingCount) { |
| 7592 | hdd_err("Failed to round down IpaUcRxIndRingCount"); |
| 7593 | return -EINVAL; |
| 7594 | } |
| 7595 | hdd_err("IpaUcRxIndRingCount rounded down to %d", |
| 7596 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 7597 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7598 | cds_cfg->uc_rxind_ringcount = |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 7599 | hdd_ctx->config->IpaUcRxIndRingCount; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7600 | cds_cfg->uc_tx_partition_base = |
| 7601 | hdd_ctx->config->IpaUcTxPartitionBase; |
| 7602 | cds_cfg->max_scan = hdd_ctx->config->max_scan_count; |
| 7603 | |
| 7604 | cds_cfg->ip_tcp_udp_checksum_offload = |
| 7605 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 7606 | cds_cfg->enable_rxthread = hdd_ctx->enableRxThread; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7607 | cds_cfg->ce_classify_enabled = |
| 7608 | hdd_ctx->config->ce_classify_enabled; |
Dustin Brown | d3fc9ee | 2016-09-14 13:57:27 -0700 | [diff] [blame] | 7609 | cds_cfg->bpf_packet_filter_enable = |
| 7610 | hdd_ctx->config->bpf_packet_filter_enable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7611 | cds_cfg->tx_chain_mask_cck = hdd_ctx->config->tx_chain_mask_cck; |
| 7612 | cds_cfg->self_gen_frm_pwr = hdd_ctx->config->self_gen_frm_pwr; |
| 7613 | cds_cfg->max_station = hdd_ctx->config->maxNumberOfPeers; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 7614 | cds_cfg->sub_20_channel_width = WLAN_SUB_20_CH_WIDTH_NONE; |
Manjunathappa Prakash | fff753c | 2016-09-01 19:34:56 -0700 | [diff] [blame] | 7615 | cds_cfg->flow_steering_enabled = hdd_ctx->config->flow_steering_enable; |
Naveen Rawat | 91df30a | 2016-10-12 21:26:18 -0700 | [diff] [blame] | 7616 | cds_cfg->self_recovery_enabled = hdd_ctx->config->enableSelfRecovery; |
Sandeep Puligilla | afa5289 | 2016-10-26 19:03:16 -0700 | [diff] [blame] | 7617 | cds_cfg->fw_timeout_crash = hdd_ctx->config->fw_timeout_crash; |
Dustin Brown | 13995f0 | 2017-01-12 15:38:42 -0800 | [diff] [blame] | 7618 | cds_cfg->active_bpf_mode = hdd_ctx->config->active_bpf_mode; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7619 | |
| 7620 | hdd_ra_populate_cds_config(cds_cfg, hdd_ctx); |
| 7621 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
| 7622 | hdd_nan_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 7623 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7624 | cds_init_ini_config(cds_cfg); |
| 7625 | return 0; |
| 7626 | } |
| 7627 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7628 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 7629 | * hdd_update_user_config() - API to update user configuration |
| 7630 | * parameters to obj mgr which are used by multiple components |
| 7631 | * @hdd_ctx: HDD Context |
| 7632 | * |
| 7633 | * Return: 0 for Success, errno on failure |
| 7634 | */ |
| 7635 | static int hdd_update_user_config(hdd_context_t *hdd_ctx) |
| 7636 | { |
| 7637 | struct wlan_objmgr_psoc_user_config *user_config; |
| 7638 | |
| 7639 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
| 7640 | if (user_config == NULL) { |
| 7641 | hdd_alert("Failed to alloc memory for user_config!"); |
| 7642 | return -ENOMEM; |
| 7643 | } |
| 7644 | |
| 7645 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
| 7646 | user_config->dual_mac_feature_disable = |
| 7647 | hdd_ctx->config->dual_mac_feature_disable; |
| 7648 | user_config->indoor_channel_support = |
| 7649 | hdd_ctx->config->indoor_channel_support; |
| 7650 | user_config->is_11d_support_enabled = |
| 7651 | hdd_ctx->config->Is11dSupportEnabled; |
| 7652 | user_config->is_11h_support_enabled = |
| 7653 | hdd_ctx->config->Is11hSupportEnabled; |
| 7654 | user_config->optimize_chan_avoid_event = |
| 7655 | hdd_ctx->config->goptimize_chan_avoid_event; |
| 7656 | user_config->skip_dfs_chnl_in_p2p_search = |
| 7657 | hdd_ctx->config->skipDfsChnlInP2pSearch; |
Naveen Rawat | 222b2e9 | 2017-03-16 09:52:21 -0700 | [diff] [blame] | 7658 | user_config->band_capability = hdd_ctx->config->nBandCapability; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 7659 | wlan_objmgr_psoc_set_user_config(hdd_ctx->hdd_psoc, user_config); |
| 7660 | |
| 7661 | qdf_mem_free(user_config); |
| 7662 | return 0; |
| 7663 | } |
| 7664 | |
| 7665 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7666 | * hdd_init_thermal_info - Initialize thermal level |
| 7667 | * @hdd_ctx: HDD context |
| 7668 | * |
| 7669 | * Initialize thermal level at SME layer and set the thermal level callback |
| 7670 | * which would be called when a configured thermal threshold is hit. |
| 7671 | * |
| 7672 | * Return: 0 on success and errno on failure |
| 7673 | */ |
| 7674 | static int hdd_init_thermal_info(hdd_context_t *hdd_ctx) |
| 7675 | { |
| 7676 | tSmeThermalParams thermal_param; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7677 | QDF_STATUS status; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7678 | |
| 7679 | thermal_param.smeThermalMgmtEnabled = |
| 7680 | hdd_ctx->config->thermalMitigationEnable; |
| 7681 | thermal_param.smeThrottlePeriod = hdd_ctx->config->throttlePeriod; |
| 7682 | |
Poddar, Siddarth | 8390502 | 2016-04-16 17:56:08 -0700 | [diff] [blame] | 7683 | thermal_param.sme_throttle_duty_cycle_tbl[0] = |
| 7684 | hdd_ctx->config->throttle_dutycycle_level0; |
| 7685 | thermal_param.sme_throttle_duty_cycle_tbl[1] = |
| 7686 | hdd_ctx->config->throttle_dutycycle_level1; |
| 7687 | thermal_param.sme_throttle_duty_cycle_tbl[2] = |
| 7688 | hdd_ctx->config->throttle_dutycycle_level2; |
| 7689 | thermal_param.sme_throttle_duty_cycle_tbl[3] = |
| 7690 | hdd_ctx->config->throttle_dutycycle_level3; |
| 7691 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7692 | thermal_param.smeThermalLevels[0].smeMinTempThreshold = |
| 7693 | hdd_ctx->config->thermalTempMinLevel0; |
| 7694 | thermal_param.smeThermalLevels[0].smeMaxTempThreshold = |
| 7695 | hdd_ctx->config->thermalTempMaxLevel0; |
| 7696 | thermal_param.smeThermalLevels[1].smeMinTempThreshold = |
| 7697 | hdd_ctx->config->thermalTempMinLevel1; |
| 7698 | thermal_param.smeThermalLevels[1].smeMaxTempThreshold = |
| 7699 | hdd_ctx->config->thermalTempMaxLevel1; |
| 7700 | thermal_param.smeThermalLevels[2].smeMinTempThreshold = |
| 7701 | hdd_ctx->config->thermalTempMinLevel2; |
| 7702 | thermal_param.smeThermalLevels[2].smeMaxTempThreshold = |
| 7703 | hdd_ctx->config->thermalTempMaxLevel2; |
| 7704 | thermal_param.smeThermalLevels[3].smeMinTempThreshold = |
| 7705 | hdd_ctx->config->thermalTempMinLevel3; |
| 7706 | thermal_param.smeThermalLevels[3].smeMaxTempThreshold = |
| 7707 | hdd_ctx->config->thermalTempMaxLevel3; |
| 7708 | |
| 7709 | status = sme_init_thermal_info(hdd_ctx->hHal, thermal_param); |
| 7710 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7711 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 7712 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7713 | |
| 7714 | sme_add_set_thermal_level_callback(hdd_ctx->hHal, |
| 7715 | hdd_set_thermal_level_cb); |
| 7716 | |
| 7717 | return 0; |
| 7718 | |
| 7719 | } |
| 7720 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7721 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 7722 | /** |
| 7723 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 7724 | * |
| 7725 | * Hold RTNL lock |
| 7726 | * |
| 7727 | * Return: True if held and false otherwise |
| 7728 | */ |
| 7729 | static inline bool hdd_hold_rtnl_lock(void) |
| 7730 | { |
| 7731 | rtnl_lock(); |
| 7732 | return true; |
| 7733 | } |
| 7734 | |
| 7735 | /** |
| 7736 | * hdd_release_rtnl_lock - Release RTNL lock |
| 7737 | * |
| 7738 | * Release RTNL lock |
| 7739 | * |
| 7740 | * Return: None |
| 7741 | */ |
| 7742 | static inline void hdd_release_rtnl_lock(void) |
| 7743 | { |
| 7744 | rtnl_unlock(); |
| 7745 | } |
| 7746 | #else |
| 7747 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 7748 | static inline void hdd_release_rtnl_lock(void) { } |
| 7749 | #endif |
| 7750 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 7751 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7752 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7753 | /* MAX iwpriv command support */ |
| 7754 | #define PKTLOG_SET_BUFF_SIZE 3 |
| 7755 | #define MAX_PKTLOG_SIZE 16 |
| 7756 | |
| 7757 | /** |
| 7758 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 7759 | * @hdd_ctx: hdd context |
| 7760 | * @set_value2: pktlog buffer size value |
| 7761 | * |
| 7762 | * |
| 7763 | * Return: 0 for success or error. |
| 7764 | */ |
| 7765 | static int hdd_pktlog_set_buff_size(hdd_context_t *hdd_ctx, int set_value2) |
| 7766 | { |
| 7767 | struct sir_wifi_start_log start_log = { 0 }; |
| 7768 | QDF_STATUS status; |
| 7769 | |
| 7770 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 7771 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 7772 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 7773 | start_log.user_triggered = 1; |
| 7774 | start_log.size = set_value2; |
| 7775 | |
| 7776 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 7777 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 7778 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 7779 | EXIT(); |
| 7780 | return -EINVAL; |
| 7781 | } |
| 7782 | |
| 7783 | return 0; |
| 7784 | } |
| 7785 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7786 | /** |
| 7787 | * hdd_process_pktlog_command() - process pktlog command |
| 7788 | * @hdd_ctx: hdd context |
| 7789 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7790 | * @set_value2: pktlog buffer size value |
| 7791 | * |
| 7792 | * This function process pktlog command. |
| 7793 | * set_value2 only matters when set_value is 3 (set buff size) |
| 7794 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7795 | * |
| 7796 | * Return: 0 for success or error. |
| 7797 | */ |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7798 | int hdd_process_pktlog_command(hdd_context_t *hdd_ctx, uint32_t set_value, |
| 7799 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7800 | { |
| 7801 | int ret; |
| 7802 | bool enable; |
| 7803 | uint8_t user_triggered = 0; |
| 7804 | |
| 7805 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 7806 | if (0 != ret) |
| 7807 | return ret; |
| 7808 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7809 | hdd_info("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7810 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7811 | if (set_value > PKTLOG_SET_BUFF_SIZE) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7812 | hdd_err("invalid pktlog value %d", set_value); |
| 7813 | return -EINVAL; |
| 7814 | } |
| 7815 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7816 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 7817 | if (set_value2 <= 0) { |
| 7818 | hdd_err("invalid pktlog size %d", set_value2); |
| 7819 | return -EINVAL; |
| 7820 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
| 7821 | hdd_err("Pktlog buff size is too large. max value is 16MB.\n"); |
| 7822 | return -EINVAL; |
| 7823 | } |
| 7824 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
| 7825 | } |
| 7826 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7827 | /* |
| 7828 | * set_value = 0 then disable packetlog |
| 7829 | * set_value = 1 enable packetlog forcefully |
| 7830 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 7831 | * enable packetlog with AUTO type. |
| 7832 | */ |
| 7833 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 7834 | true : false; |
| 7835 | |
| 7836 | if (1 == set_value) { |
| 7837 | enable = true; |
| 7838 | user_triggered = 1; |
| 7839 | } |
| 7840 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7841 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7842 | } |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 7843 | /** |
| 7844 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 7845 | * @hdd_ctx: HDD context |
| 7846 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7847 | * @user_triggered: triggered through iwpriv |
| 7848 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 7849 | * |
| 7850 | * Return: 0 on success; error number otherwise |
| 7851 | */ |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7852 | int hdd_pktlog_enable_disable(hdd_context_t *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7853 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 7854 | { |
| 7855 | struct sir_wifi_start_log start_log; |
| 7856 | QDF_STATUS status; |
| 7857 | |
| 7858 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 7859 | start_log.verbose_level = |
| 7860 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7861 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 7862 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7863 | start_log.size = size; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 7864 | /* |
| 7865 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 7866 | * commands. Host uses this flag to decide whether to send pktlog |
| 7867 | * disable command to fw without sending pktlog enable command |
| 7868 | * previously. For eg, If vendor sends pktlog disable command without |
| 7869 | * sending pktlog enable command, then host discards the packet |
| 7870 | * but for iwpriv command, host will send it to fw. |
| 7871 | */ |
| 7872 | start_log.is_iwpriv_command = 1; |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 7873 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 7874 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 7875 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 7876 | EXIT(); |
| 7877 | return -EINVAL; |
| 7878 | } |
| 7879 | |
| 7880 | return 0; |
| 7881 | } |
| 7882 | #endif /* REMOVE_PKT_LOG */ |
| 7883 | |
| 7884 | |
Chandrasekaran Manishekar | cde33d7 | 2016-04-14 19:03:39 +0530 | [diff] [blame] | 7885 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 7886 | /** |
| 7887 | * hdd_register_for_sap_restart_with_channel_switch() - Register for SAP channel |
| 7888 | * switch without restart |
| 7889 | * |
| 7890 | * Registers callback function to change the operating channel of SAP by using |
| 7891 | * channel switch announcements instead of restarting SAP. |
| 7892 | * |
| 7893 | * Return: QDF_STATUS |
| 7894 | */ |
| 7895 | QDF_STATUS hdd_register_for_sap_restart_with_channel_switch(void) |
| 7896 | { |
| 7897 | QDF_STATUS status; |
| 7898 | |
| 7899 | status = cds_register_sap_restart_channel_switch_cb( |
| 7900 | (void *)hdd_sap_restart_with_channel_switch); |
| 7901 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 7902 | hdd_err("restart cb registration failed"); |
| 7903 | |
| 7904 | return status; |
| 7905 | } |
| 7906 | #endif |
| 7907 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7908 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7909 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 7910 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7911 | * @dev: Device Pointer |
| 7912 | * @num: Number of Valid Mac address |
| 7913 | * |
| 7914 | * Return: Pointer to MAC address buffer |
| 7915 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7916 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 7917 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7918 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7919 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7920 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7921 | |
| 7922 | /** |
| 7923 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 7924 | * @hdd_ctx: HDD Context |
| 7925 | * @num: Number of random mac addresses needed |
| 7926 | * |
| 7927 | * Generate random addresses using bit manipulation on the base mac address |
| 7928 | * |
| 7929 | * Return: None |
| 7930 | */ |
| 7931 | static void hdd_populate_random_mac_addr(hdd_context_t *hdd_ctx, uint32_t num) |
| 7932 | { |
| 7933 | uint32_t start_idx = QDF_MAX_CONCURRENCY_PERSONA - num; |
| 7934 | uint32_t iter; |
| 7935 | struct hdd_config *ini = hdd_ctx->config; |
| 7936 | uint8_t *buf = NULL; |
| 7937 | uint8_t macaddr_b3, tmp_br3; |
| 7938 | uint8_t *src = ini->intfMacAddr[0].bytes; |
| 7939 | |
| 7940 | for (iter = start_idx; iter < QDF_MAX_CONCURRENCY_PERSONA; ++iter) { |
| 7941 | buf = ini->intfMacAddr[iter].bytes; |
| 7942 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 7943 | macaddr_b3 = buf[3]; |
| 7944 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + iter) & |
| 7945 | INTF_MACADDR_MASK; |
| 7946 | macaddr_b3 += tmp_br3; |
| 7947 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 7948 | buf[0] |= 0x02; |
| 7949 | buf[3] = macaddr_b3; |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 7950 | hdd_info(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7951 | } |
| 7952 | } |
| 7953 | |
| 7954 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7955 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7956 | * @hdd_ctx: HDD Context |
| 7957 | * |
| 7958 | * API to get mac addresses from platform driver and update the driver |
| 7959 | * structures and configure FW with the base mac address. |
| 7960 | * Return: int |
| 7961 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7962 | static int hdd_platform_wlan_mac(hdd_context_t *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7963 | { |
| 7964 | uint32_t no_of_mac_addr, iter; |
| 7965 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 7966 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 7967 | uint8_t *addr, *buf; |
| 7968 | struct device *dev = hdd_ctx->parent_dev; |
| 7969 | struct hdd_config *ini = hdd_ctx->config; |
| 7970 | tSirMacAddr mac_addr; |
| 7971 | QDF_STATUS status; |
| 7972 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7973 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7974 | |
| 7975 | if (no_of_mac_addr == 0 || !addr) { |
| 7976 | hdd_warn("Platform Driver Doesn't have wlan mac addresses"); |
| 7977 | return -EINVAL; |
| 7978 | } |
| 7979 | |
| 7980 | if (no_of_mac_addr > max_mac_addr) |
| 7981 | no_of_mac_addr = max_mac_addr; |
| 7982 | |
| 7983 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 7984 | |
| 7985 | for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { |
| 7986 | buf = ini->intfMacAddr[iter].bytes; |
| 7987 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 7988 | hdd_info(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7989 | } |
| 7990 | |
| 7991 | status = sme_set_custom_mac_addr(mac_addr); |
| 7992 | |
| 7993 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 7994 | return -EAGAIN; |
| 7995 | if (no_of_mac_addr < max_mac_addr) |
| 7996 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 7997 | no_of_mac_addr); |
| 7998 | return 0; |
| 7999 | } |
| 8000 | |
| 8001 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 8002 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 8003 | * @hdd_ctx: HDD Context |
| 8004 | * |
| 8005 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 8006 | * will generate its own MAC and update it to FW. |
| 8007 | * |
| 8008 | * Return: 0 for success |
| 8009 | * Non-zero error code for failure |
| 8010 | */ |
| 8011 | static int hdd_update_mac_addr_to_fw(hdd_context_t *hdd_ctx) |
| 8012 | { |
| 8013 | tSirMacAddr customMacAddr; |
| 8014 | QDF_STATUS status; |
| 8015 | |
| 8016 | qdf_mem_copy(&customMacAddr, |
| 8017 | &hdd_ctx->config->intfMacAddr[0].bytes[0], |
| 8018 | sizeof(tSirMacAddr)); |
| 8019 | status = sme_set_custom_mac_addr(customMacAddr); |
| 8020 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8021 | return -EAGAIN; |
| 8022 | return 0; |
| 8023 | } |
| 8024 | |
| 8025 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8026 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 8027 | * @hdd_ctx: HDD Context |
| 8028 | * |
| 8029 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 8030 | * is provisioned with mac addresses, driver uses it, else it will use |
| 8031 | * wlan_mac.bin to update HW MAC addresses. |
| 8032 | * |
| 8033 | * Return: None |
| 8034 | */ |
| 8035 | static void hdd_initialize_mac_address(hdd_context_t *hdd_ctx) |
| 8036 | { |
| 8037 | QDF_STATUS status; |
| 8038 | int ret; |
| 8039 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 8040 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8041 | if (ret == 0) |
| 8042 | return; |
| 8043 | |
| 8044 | hdd_warn("Can't update mac config via platform driver ret:%d", ret); |
| 8045 | |
| 8046 | status = hdd_update_mac_config(hdd_ctx); |
| 8047 | |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 8048 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 8049 | return; |
| 8050 | |
| 8051 | hdd_warn("can't update mac config via wlan_mac.bin, using MAC from ini file or auto-gen"); |
| 8052 | |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 8053 | if (hdd_ctx->update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 8054 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 8055 | if (ret != 0) { |
| 8056 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
| 8057 | QDF_ASSERT(ret); |
| 8058 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 8059 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8060 | } |
| 8061 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8062 | /** |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 8063 | * hdd_tsf_init() - Initialize the TSF synchronization interface |
| 8064 | * @hdd_ctx: HDD global context |
| 8065 | * |
| 8066 | * When TSF synchronization via GPIO is supported by the driver and |
| 8067 | * has been enabled in the configuration file, this function plumbs |
| 8068 | * the GPIO value down to firmware via SME. |
| 8069 | * |
| 8070 | * Return: None |
| 8071 | */ |
| 8072 | #ifdef WLAN_FEATURE_TSF |
| 8073 | static void hdd_tsf_init(hdd_context_t *hdd_ctx) |
| 8074 | { |
| 8075 | QDF_STATUS status; |
| 8076 | |
| 8077 | if (hdd_ctx->config->tsf_gpio_pin == TSF_GPIO_PIN_INVALID) |
| 8078 | return; |
| 8079 | |
| 8080 | status = sme_set_tsf_gpio(hdd_ctx->hHal, |
| 8081 | hdd_ctx->config->tsf_gpio_pin); |
| 8082 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8083 | hdd_err("Set tsf GPIO failed, status: %d", status); |
| 8084 | } |
| 8085 | #else |
| 8086 | static void hdd_tsf_init(hdd_context_t *hdd_ctx) |
| 8087 | { |
| 8088 | } |
| 8089 | #endif |
| 8090 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 8091 | static int hdd_set_smart_chainmask_enabled(hdd_context_t *hdd_ctx) |
| 8092 | { |
| 8093 | int vdev_id = 0; |
| 8094 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
| 8095 | int value = hdd_ctx->config->smart_chainmask_enabled; |
| 8096 | int vpdev = PDEV_CMD; |
| 8097 | int ret; |
| 8098 | |
| 8099 | ret = wma_cli_set_command(vdev_id, param_id, value, vpdev); |
| 8100 | if (ret) |
| 8101 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 8102 | |
| 8103 | return ret; |
| 8104 | } |
| 8105 | |
| 8106 | static int hdd_set_alternative_chainmask_enabled(hdd_context_t *hdd_ctx) |
| 8107 | { |
| 8108 | int vdev_id = 0; |
| 8109 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
| 8110 | int value = hdd_ctx->config->alternative_chainmask_enabled; |
| 8111 | int vpdev = PDEV_CMD; |
| 8112 | int ret; |
| 8113 | |
| 8114 | ret = wma_cli_set_command(vdev_id, param_id, value, vpdev); |
| 8115 | if (ret) |
| 8116 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 8117 | ret); |
| 8118 | |
| 8119 | return ret; |
| 8120 | } |
| 8121 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 8122 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8123 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 8124 | * @hdd_ctx: HDD context |
| 8125 | * |
| 8126 | * Pre configurations to be done at lower layer before calling cds enable. |
| 8127 | * |
| 8128 | * Return: 0 on success and errno on failure. |
| 8129 | */ |
| 8130 | static int hdd_pre_enable_configure(hdd_context_t *hdd_ctx) |
| 8131 | { |
| 8132 | int ret; |
| 8133 | QDF_STATUS status; |
| 8134 | tSirRetStatus hal_status; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 8135 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8136 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 8137 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8138 | /* |
| 8139 | * Set 802.11p config |
| 8140 | * TODO-OCB: This has been temporarily added here to ensure this |
| 8141 | * parameter is set in CSR when we init the channel list. This should |
| 8142 | * be removed once the 5.9 GHz channels are added to the regulatory |
| 8143 | * domain. |
| 8144 | */ |
| 8145 | hdd_set_dot11p_config(hdd_ctx); |
| 8146 | |
| 8147 | /* |
| 8148 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 8149 | * The cfg download must occur before we update the SME config |
| 8150 | * since the SME config operation must access the cfg database |
| 8151 | */ |
| 8152 | status = hdd_set_sme_config(hdd_ctx); |
| 8153 | |
| 8154 | if (QDF_STATUS_SUCCESS != status) { |
| 8155 | hdd_alert("Failed hdd_set_sme_config: %d", status); |
| 8156 | ret = qdf_status_to_os_return(status); |
| 8157 | goto out; |
| 8158 | } |
| 8159 | |
| 8160 | ret = wma_cli_set_command(0, WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS, |
| 8161 | hdd_ctx->config->tx_chain_mask_1ss, |
| 8162 | PDEV_CMD); |
| 8163 | if (0 != ret) { |
| 8164 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 8165 | goto out; |
| 8166 | } |
| 8167 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 8168 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 8169 | if (ret) |
| 8170 | goto out; |
| 8171 | |
| 8172 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 8173 | if (ret) |
| 8174 | goto out; |
| 8175 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8176 | hdd_program_country_code(hdd_ctx); |
| 8177 | |
| 8178 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 8179 | if (status != QDF_STATUS_SUCCESS) { |
| 8180 | hdd_alert("Failed to init channel list: %d", status); |
| 8181 | ret = qdf_status_to_os_return(status); |
| 8182 | goto out; |
| 8183 | } |
| 8184 | |
| 8185 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 8186 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8187 | hdd_alert("config update failed"); |
| 8188 | ret = -EINVAL; |
| 8189 | goto out; |
| 8190 | } |
| 8191 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8192 | /* |
| 8193 | * Set the MAC Address Currently this is used by HAL to add self sta. |
| 8194 | * Remove this once self sta is added as part of session open. |
| 8195 | */ |
| 8196 | hal_status = cfg_set_str(hdd_ctx->hHal, WNI_CFG_STA_ID, |
| 8197 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 8198 | sizeof(hdd_ctx->config->intfMacAddr[0])); |
| 8199 | |
| 8200 | if (!IS_SIR_STATUS_SUCCESS(hal_status)) { |
| 8201 | hdd_err("Failed to set MAC Address. HALStatus is %08d [x%08x]", |
| 8202 | hal_status, hal_status); |
| 8203 | ret = -EINVAL; |
| 8204 | goto out; |
| 8205 | } |
| 8206 | |
| 8207 | hdd_init_channel_avoidance(hdd_ctx); |
| 8208 | |
| 8209 | out: |
| 8210 | return ret; |
| 8211 | } |
| 8212 | |
| 8213 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 8214 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
| 8215 | * @context_ptr - hdd context pointer |
| 8216 | * @event_ptr - event structure pointer |
| 8217 | * |
| 8218 | * This is the p2p listen offload stop event handler, it sends vendor |
| 8219 | * event back to supplicant to notify the stop reason. |
| 8220 | * |
| 8221 | * Return: None |
| 8222 | */ |
| 8223 | static void wlan_hdd_p2p_lo_event_callback(void *context_ptr, |
| 8224 | void *event_ptr) |
| 8225 | { |
| 8226 | hdd_context_t *hdd_ctx = (hdd_context_t *)context_ptr; |
| 8227 | struct sir_p2p_lo_event *evt = event_ptr; |
| 8228 | struct sk_buff *vendor_event; |
| 8229 | |
| 8230 | ENTER(); |
| 8231 | |
| 8232 | if (hdd_ctx == NULL) { |
| 8233 | hdd_err("Invalid HDD context pointer"); |
| 8234 | return; |
| 8235 | } |
| 8236 | |
| 8237 | vendor_event = |
| 8238 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
| 8239 | NULL, sizeof(uint32_t) + NLMSG_HDRLEN, |
| 8240 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 8241 | GFP_KERNEL); |
| 8242 | |
| 8243 | if (!vendor_event) { |
| 8244 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 8245 | return; |
| 8246 | } |
| 8247 | |
| 8248 | if (nla_put_u32(vendor_event, |
| 8249 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 8250 | evt->reason_code)) { |
| 8251 | hdd_err("nla put failed"); |
| 8252 | kfree_skb(vendor_event); |
| 8253 | return; |
| 8254 | } |
| 8255 | |
| 8256 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 8257 | } |
| 8258 | |
| 8259 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 8260 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 8261 | * @hdd_ctx: HDD context |
| 8262 | * |
| 8263 | * This function sends the adaptive dwell time config configuration to the |
| 8264 | * firmware via WMA |
| 8265 | * |
| 8266 | * Return: 0 - success, < 0 - failure |
| 8267 | */ |
| 8268 | static int hdd_adaptive_dwelltime_init(hdd_context_t *hdd_ctx) |
| 8269 | { |
| 8270 | QDF_STATUS status; |
| 8271 | struct adaptive_dwelltime_params dwelltime_params; |
| 8272 | |
| 8273 | dwelltime_params.is_enabled = |
| 8274 | hdd_ctx->config->adaptive_dwell_mode_enabled; |
| 8275 | dwelltime_params.dwelltime_mode = |
| 8276 | hdd_ctx->config->global_adapt_dwelltime_mode; |
| 8277 | dwelltime_params.lpf_weight = |
| 8278 | hdd_ctx->config->adapt_dwell_lpf_weight; |
| 8279 | dwelltime_params.passive_mon_intval = |
| 8280 | hdd_ctx->config->adapt_dwell_passive_mon_intval; |
| 8281 | dwelltime_params.wifi_act_threshold = |
| 8282 | hdd_ctx->config->adapt_dwell_wifi_act_threshold; |
| 8283 | |
| 8284 | status = sme_set_adaptive_dwelltime_config(hdd_ctx->hHal, |
| 8285 | &dwelltime_params); |
| 8286 | |
| 8287 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 8288 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8289 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 8290 | return -EAGAIN; |
| 8291 | } |
| 8292 | return 0; |
| 8293 | } |
| 8294 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 8295 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 8296 | /** |
| 8297 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 8298 | * @hdd_ctx: HDD context |
| 8299 | * |
| 8300 | * Set auto shutdown callback to get indications from firmware to indicate |
| 8301 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 8302 | * |
| 8303 | * Return: 0 on success and errno on failure. |
| 8304 | */ |
| 8305 | static int hdd_set_auto_shutdown_cb(hdd_context_t *hdd_ctx) |
| 8306 | { |
| 8307 | QDF_STATUS status; |
| 8308 | |
| 8309 | if (!hdd_ctx->config->WlanAutoShutdown) |
| 8310 | return 0; |
| 8311 | |
| 8312 | status = sme_set_auto_shutdown_cb(hdd_ctx->hHal, |
| 8313 | wlan_hdd_auto_shutdown_cb); |
| 8314 | if (status != QDF_STATUS_SUCCESS) |
| 8315 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 8316 | status); |
| 8317 | |
| 8318 | return qdf_status_to_os_return(status); |
| 8319 | } |
| 8320 | #else |
| 8321 | static int hdd_set_auto_shutdown_cb(hdd_context_t *hdd_ctx) |
| 8322 | { |
| 8323 | return 0; |
| 8324 | } |
| 8325 | #endif |
| 8326 | |
| 8327 | /** |
| 8328 | * hdd_features_init() - Init features |
| 8329 | * @hdd_ctx: HDD context |
| 8330 | * @adapter: Primary adapter context |
| 8331 | * |
| 8332 | * Initialize features and their feature context after WLAN firmware is up. |
| 8333 | * |
| 8334 | * Return: 0 on success and errno on failure. |
| 8335 | */ |
| 8336 | static int hdd_features_init(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter) |
| 8337 | { |
| 8338 | tSirTxPowerLimit hddtxlimit; |
| 8339 | QDF_STATUS status; |
| 8340 | int ret; |
| 8341 | |
| 8342 | ENTER(); |
| 8343 | |
| 8344 | ret = hdd_update_country_code(hdd_ctx, adapter); |
| 8345 | if (ret) { |
| 8346 | hdd_err("Failed to update country code: %d", ret); |
| 8347 | goto out; |
| 8348 | } |
| 8349 | |
| 8350 | /* FW capabilities received, Set the Dot11 mode */ |
| 8351 | sme_setdef_dot11mode(hdd_ctx->hHal); |
Kiran Kumar Lokere | 1aa9c9a | 2016-10-05 18:50:59 -0700 | [diff] [blame] | 8352 | sme_set_prefer_80MHz_over_160MHz(hdd_ctx->hHal, |
| 8353 | hdd_ctx->config->sta_prefer_80MHz_over_160MHz); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 8354 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 8355 | |
| 8356 | if (hdd_ctx->config->fIsImpsEnabled) |
| 8357 | hdd_set_idle_ps_config(hdd_ctx, true); |
| 8358 | else |
| 8359 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 8360 | |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 8361 | if (hdd_ctx->config->enable_go_cts2self_for_sta) |
| 8362 | sme_set_cts2self_for_p2p_go(hdd_ctx->hHal); |
| 8363 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 8364 | if (hdd_lro_init(hdd_ctx)) |
| 8365 | hdd_err("Unable to initialize LRO in fw"); |
| 8366 | |
| 8367 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 8368 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 8369 | |
| 8370 | ret = hdd_init_thermal_info(hdd_ctx); |
| 8371 | if (ret) { |
| 8372 | hdd_err("Error while initializing thermal information"); |
| 8373 | goto deregister_frames; |
| 8374 | } |
| 8375 | |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 8376 | if (cds_is_packet_log_enabled()) |
| 8377 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
| 8378 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 8379 | hddtxlimit.txPower2g = hdd_ctx->config->TxPower2g; |
| 8380 | hddtxlimit.txPower5g = hdd_ctx->config->TxPower5g; |
| 8381 | status = sme_txpower_limit(hdd_ctx->hHal, &hddtxlimit); |
| 8382 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8383 | hdd_err("Error setting txlimit in sme: %d", status); |
| 8384 | |
| 8385 | hdd_tsf_init(hdd_ctx); |
| 8386 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 8387 | ret = hdd_register_cb(hdd_ctx); |
| 8388 | if (ret) { |
| 8389 | hdd_err("Failed to register HDD callbacks!"); |
| 8390 | goto deregister_frames; |
| 8391 | } |
| 8392 | |
| 8393 | if (hdd_ctx->config->dual_mac_feature_disable) { |
| 8394 | status = wlan_hdd_disable_all_dual_mac_features(hdd_ctx); |
| 8395 | if (status != QDF_STATUS_SUCCESS) { |
| 8396 | hdd_err("Failed to disable dual mac features"); |
| 8397 | goto deregister_cb; |
| 8398 | } |
| 8399 | } |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 8400 | if (hdd_ctx->config->goptimize_chan_avoid_event) { |
| 8401 | status = sme_enable_disable_chanavoidind_event( |
| 8402 | hdd_ctx->hHal, 0); |
| 8403 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8404 | hdd_err("Failed to disable Chan Avoidance Indication"); |
| 8405 | goto deregister_cb; |
| 8406 | } |
| 8407 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 8408 | |
| 8409 | /* register P2P Listen Offload event callback */ |
| 8410 | if (wma_is_p2p_lo_capable()) |
| 8411 | sme_register_p2p_lo_event(hdd_ctx->hHal, hdd_ctx, |
| 8412 | wlan_hdd_p2p_lo_event_callback); |
| 8413 | |
| 8414 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 8415 | |
| 8416 | if (ret) |
| 8417 | goto deregister_cb; |
| 8418 | |
| 8419 | EXIT(); |
| 8420 | return 0; |
| 8421 | |
| 8422 | deregister_cb: |
| 8423 | hdd_deregister_cb(hdd_ctx); |
| 8424 | deregister_frames: |
| 8425 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 8426 | out: |
| 8427 | return -EINVAL; |
| 8428 | |
| 8429 | } |
| 8430 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 8431 | #ifdef NAPIER_SCAN |
| 8432 | /** |
| 8433 | * |
| 8434 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 8435 | * @adapter - Pointer to the HDD |
| 8436 | * |
| 8437 | * Return: None |
| 8438 | */ |
| 8439 | static inline QDF_STATUS hdd_register_bcn_cb(hdd_context_t *hdd_ctx) |
| 8440 | { |
| 8441 | QDF_STATUS status; |
| 8442 | |
| 8443 | status = ucfg_scan_register_bcn_cb(hdd_ctx->hdd_psoc, |
| 8444 | wlan_cfg80211_inform_bss_frame, |
| 8445 | SCAN_CB_TYPE_INFORM_BCN); |
| 8446 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8447 | hdd_err("failed with status code %08d [x%08x]", |
| 8448 | status, status); |
| 8449 | return status; |
| 8450 | } |
| 8451 | |
| 8452 | return QDF_STATUS_SUCCESS; |
| 8453 | } |
| 8454 | #else |
| 8455 | static inline QDF_STATUS hdd_register_bcn_cb(hdd_context_t *hdd_ctx) |
| 8456 | { |
| 8457 | return QDF_STATUS_SUCCESS; |
| 8458 | } |
| 8459 | |
| 8460 | #endif |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 8461 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 8462 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8463 | * hdd_configure_cds() - Configure cds modules |
| 8464 | * @hdd_ctx: HDD context |
| 8465 | * @adapter: Primary adapter context |
| 8466 | * |
| 8467 | * Enable Cds modules after WLAN firmware is up. |
| 8468 | * |
| 8469 | * Return: 0 on success and errno on failure. |
| 8470 | */ |
| 8471 | int hdd_configure_cds(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter) |
| 8472 | { |
| 8473 | int ret; |
| 8474 | QDF_STATUS status; |
| 8475 | /* structure of function pointers to be used by CDS */ |
| 8476 | struct cds_sme_cbacks sme_cbacks; |
| 8477 | |
| 8478 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 8479 | if (ret) { |
| 8480 | hdd_err("Failed to pre-configure cds"); |
| 8481 | goto out; |
| 8482 | } |
| 8483 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 8484 | /* Always get latest IPA resources allocated from cds_open and configure |
| 8485 | * IPA module before configuring them to FW. Sequence required as crash |
| 8486 | * observed otherwise. |
| 8487 | */ |
| 8488 | if (hdd_ipa_uc_is_enabled(hdd_ctx)) { |
| 8489 | if (hdd_ipa_uc_ol_init(hdd_ctx)) { |
| 8490 | hdd_err("Failed to setup pipes"); |
| 8491 | goto out; |
| 8492 | } |
| 8493 | } |
| 8494 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8495 | /* |
| 8496 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 8497 | * else |
| 8498 | */ |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 8499 | status = cds_enable(hdd_ctx->hdd_psoc, hdd_ctx->pcds_context); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8500 | |
| 8501 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8502 | hdd_alert("cds_enable failed"); |
| 8503 | goto out; |
| 8504 | } |
| 8505 | |
| 8506 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 8507 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8508 | hdd_alert("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 8509 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8510 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 8511 | status = hdd_register_bcn_cb(hdd_ctx); |
| 8512 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8513 | hdd_alert("hdd_post_cds_enable_config failed"); |
| 8514 | goto cds_disable; |
| 8515 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8516 | |
| 8517 | ret = hdd_features_init(hdd_ctx, adapter); |
| 8518 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 8519 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8520 | |
| 8521 | sme_cbacks.sme_get_valid_channels = sme_get_cfg_valid_channels; |
| 8522 | sme_cbacks.sme_get_nss_for_vdev = sme_get_vdev_type_nss; |
| 8523 | status = cds_init_policy_mgr(&sme_cbacks); |
| 8524 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8525 | hdd_err("Policy manager initialization failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 8526 | goto hdd_features_deinit; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8527 | } |
| 8528 | |
| 8529 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 8530 | |
| 8531 | hdd_features_deinit: |
| 8532 | hdd_deregister_cb(hdd_ctx); |
| 8533 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 8534 | cds_disable: |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 8535 | cds_disable(hdd_ctx->hdd_psoc, hdd_ctx->pcds_context); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 8536 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8537 | out: |
| 8538 | return -EINVAL; |
| 8539 | } |
| 8540 | |
| 8541 | /** |
| 8542 | * hdd_deconfigure_cds() -De-Configure cds |
| 8543 | * @hdd_ctx: HDD context |
| 8544 | * |
| 8545 | * Deconfigure Cds modules before WLAN firmware is down. |
| 8546 | * |
| 8547 | * Return: 0 on success and errno on failure. |
| 8548 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 8549 | static int hdd_deconfigure_cds(hdd_context_t *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8550 | { |
| 8551 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 8552 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8553 | |
| 8554 | ENTER(); |
| 8555 | /* De-register the SME callbacks */ |
| 8556 | hdd_deregister_cb(hdd_ctx); |
| 8557 | |
| 8558 | /* De-init Policy Manager */ |
| 8559 | if (!QDF_IS_STATUS_SUCCESS(cds_deinit_policy_mgr())) { |
| 8560 | hdd_err("Failed to deinit policy manager"); |
| 8561 | /* Proceed and complete the clean up */ |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 8562 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8563 | } |
| 8564 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 8565 | qdf_status = cds_disable(hdd_ctx->hdd_psoc, hdd_ctx->pcds_context); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8566 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 8567 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 8568 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 8569 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8570 | } |
| 8571 | |
| 8572 | EXIT(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 8573 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8574 | } |
| 8575 | |
| 8576 | |
| 8577 | /** |
| 8578 | * hdd_wlan_stop_modules - Single driver state machine for stoping modules |
| 8579 | * @hdd_ctx: HDD context |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8580 | * |
| 8581 | * This function maintains the driver state machine it will be invoked from |
| 8582 | * exit, shutdown and con_mode change handler. Depending on the driver state |
| 8583 | * shall perform the stopping/closing of the modules. |
| 8584 | * |
| 8585 | * Return: 0 for success; non-zero for failure |
| 8586 | */ |
Prashanth Bhatta | 2ac92bd | 2016-10-11 16:08:00 -0700 | [diff] [blame] | 8587 | int hdd_wlan_stop_modules(hdd_context_t *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8588 | { |
| 8589 | void *hif_ctx; |
| 8590 | qdf_device_t qdf_ctx; |
| 8591 | QDF_STATUS qdf_status; |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8592 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8593 | p_cds_sched_context cds_sched_context = NULL; |
| 8594 | |
| 8595 | ENTER(); |
| 8596 | |
| 8597 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 8598 | if (!qdf_ctx) { |
| 8599 | hdd_err("QDF device context NULL"); |
| 8600 | return -EINVAL; |
| 8601 | } |
| 8602 | |
| 8603 | cds_sched_context = get_cds_sched_ctxt(); |
| 8604 | if (!cds_sched_context) { |
| 8605 | hdd_err("cds scheduler context NULL"); |
| 8606 | return -EINVAL; |
| 8607 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8608 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 8609 | hdd_ctx->stop_modules_in_progress = true; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8610 | |
| 8611 | hdd_info("Present Driver Status: %d", hdd_ctx->driver_status); |
| 8612 | |
| 8613 | switch (hdd_ctx->driver_status) { |
| 8614 | case DRIVER_MODULES_UNINITIALIZED: |
| 8615 | hdd_info("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8616 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8617 | case DRIVER_MODULES_CLOSED: |
| 8618 | hdd_info("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8619 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8620 | case DRIVER_MODULES_ENABLED: |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 8621 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8622 | if (hdd_deconfigure_cds(hdd_ctx)) { |
| 8623 | hdd_alert("Failed to de-configure CDS"); |
| 8624 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8625 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8626 | } |
| 8627 | hdd_info("successfully Disabled the CDS modules!"); |
| 8628 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
| 8629 | break; |
| 8630 | case DRIVER_MODULES_OPENED: |
| 8631 | hdd_info("Closing CDS modules!"); |
| 8632 | break; |
| 8633 | default: |
| 8634 | hdd_err("Trying to stop wlan in a wrong state: %d", |
| 8635 | hdd_ctx->driver_status); |
| 8636 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8637 | ret = -EINVAL; |
| 8638 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8639 | } |
| 8640 | |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 8641 | qdf_status = cds_post_disable(hdd_ctx->pcds_context); |
| 8642 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 8643 | hdd_err("Failed to process post CDS disable Modules! :%d", |
| 8644 | qdf_status); |
| 8645 | ret = -EINVAL; |
| 8646 | QDF_ASSERT(0); |
| 8647 | } |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 8648 | qdf_status = cds_close(hdd_ctx->hdd_psoc, hdd_ctx->pcds_context); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8649 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 8650 | hdd_warn("Failed to stop CDS:%d", qdf_status); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 8651 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8652 | QDF_ASSERT(0); |
| 8653 | } |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 8654 | |
Rajeev Kumar | ecf87ff | 2017-01-13 15:46:07 -0800 | [diff] [blame] | 8655 | ret = hdd_release_and_destroy_pdev(hdd_ctx); |
| 8656 | if (ret) |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 8657 | hdd_err("Pdev delete failed"); |
| 8658 | |
Rajeev Kumar | 99e4cf6 | 2017-01-13 15:31:19 -0800 | [diff] [blame] | 8659 | ret = hdd_release_and_destroy_psoc(hdd_ctx); |
| 8660 | if (ret) |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 8661 | hdd_err("Psoc delete failed"); |
| 8662 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8663 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 8664 | if (!hif_ctx) { |
| 8665 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8666 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8667 | } |
| 8668 | |
| 8669 | hdd_hif_close(hif_ctx); |
| 8670 | |
| 8671 | ol_cds_free(); |
| 8672 | |
Arunk Khandavalli | 649c009 | 2016-11-22 21:20:43 +0530 | [diff] [blame] | 8673 | if (!cds_is_driver_recovering() && !cds_is_driver_unloading()) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8674 | ret = pld_power_off(qdf_ctx->dev); |
| 8675 | if (ret) |
| 8676 | hdd_err("CNSS power down failed put device into Low power mode:%d", |
| 8677 | ret); |
| 8678 | } |
| 8679 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
| 8680 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8681 | done: |
| 8682 | hdd_ctx->stop_modules_in_progress = false; |
| 8683 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8684 | EXIT(); |
| 8685 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8686 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8687 | |
| 8688 | } |
| 8689 | |
| 8690 | /** |
| 8691 | * hdd_iface_change_callback() - Function invoked when stop modules expires |
| 8692 | * @priv: pointer to hdd context |
| 8693 | * |
| 8694 | * This function is invoked when the timer waiting for the interface change |
| 8695 | * expires, it shall cut-down the power to wlan and stop all the modules. |
| 8696 | * |
| 8697 | * Return: void |
| 8698 | */ |
| 8699 | static void hdd_iface_change_callback(void *priv) |
| 8700 | { |
| 8701 | hdd_context_t *hdd_ctx = (hdd_context_t *) priv; |
| 8702 | int ret; |
| 8703 | int status = wlan_hdd_validate_context(hdd_ctx); |
| 8704 | |
| 8705 | if (status) |
| 8706 | return; |
| 8707 | |
| 8708 | ENTER(); |
| 8709 | hdd_info("Interface change timer expired close the modules!"); |
Prashanth Bhatta | 2ac92bd | 2016-10-11 16:08:00 -0700 | [diff] [blame] | 8710 | ret = hdd_wlan_stop_modules(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8711 | if (ret) |
| 8712 | hdd_alert("Failed to stop modules"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8713 | EXIT(); |
| 8714 | } |
| 8715 | |
| 8716 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 8717 | * hdd_state_info_dump() - prints state information of hdd layer |
| 8718 | * @buf: buffer pointer |
| 8719 | * @size: size of buffer to be filled |
| 8720 | * |
| 8721 | * This function is used to dump state information of hdd layer |
| 8722 | * |
| 8723 | * Return: None |
| 8724 | */ |
| 8725 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 8726 | { |
| 8727 | hdd_context_t *hdd_ctx; |
| 8728 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 8729 | QDF_STATUS status; |
| 8730 | hdd_station_ctx_t *hdd_sta_ctx; |
| 8731 | hdd_adapter_t *adapter; |
| 8732 | uint16_t len = 0; |
| 8733 | char *buf = *buf_ptr; |
| 8734 | |
| 8735 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 8736 | if (!hdd_ctx) { |
| 8737 | hdd_err("Failed to get hdd context "); |
| 8738 | return; |
| 8739 | } |
| 8740 | |
| 8741 | hdd_notice("size of buffer: %d", *size); |
| 8742 | |
| 8743 | len += scnprintf(buf + len, *size - len, |
| 8744 | "\n isWiphySuspended %d", hdd_ctx->isWiphySuspended); |
| 8745 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 8746 | "\n is_scheduler_suspended %d", |
| 8747 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 8748 | |
| 8749 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 8750 | |
| 8751 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 8752 | adapter = adapter_node->pAdapter; |
| 8753 | if (adapter->dev) |
| 8754 | len += scnprintf(buf + len, *size - len, |
| 8755 | "\n device name: %s", adapter->dev->name); |
| 8756 | len += scnprintf(buf + len, *size - len, |
| 8757 | "\n device_mode: %d", adapter->device_mode); |
| 8758 | switch (adapter->device_mode) { |
| 8759 | case QDF_STA_MODE: |
| 8760 | case QDF_P2P_CLIENT_MODE: |
| 8761 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 8762 | len += scnprintf(buf + len, *size - len, |
| 8763 | "\n connState: %d", |
| 8764 | hdd_sta_ctx->conn_info.connState); |
| 8765 | break; |
| 8766 | |
| 8767 | default: |
| 8768 | break; |
| 8769 | } |
| 8770 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 8771 | adapter_node = next; |
| 8772 | } |
| 8773 | |
| 8774 | *size -= len; |
| 8775 | *buf_ptr += len; |
| 8776 | } |
| 8777 | |
| 8778 | /** |
| 8779 | * hdd_register_debug_callback() - registration function for hdd layer |
| 8780 | * to print hdd state information |
| 8781 | * |
| 8782 | * Return: None |
| 8783 | */ |
| 8784 | static void hdd_register_debug_callback(void) |
| 8785 | { |
| 8786 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 8787 | } |
| 8788 | |
| 8789 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8790 | * hdd_wlan_startup() - HDD init function |
| 8791 | * @dev: Pointer to the underlying device |
| 8792 | * |
| 8793 | * This is the driver startup code executed once a WLAN device has been detected |
| 8794 | * |
| 8795 | * Return: 0 for success, < 0 for failure |
| 8796 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8797 | int hdd_wlan_startup(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8798 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8799 | QDF_STATUS status; |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8800 | hdd_context_t *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8801 | int ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8802 | bool rtnl_held; |
Manjeet Singh | e7ecb7c | 2016-09-03 12:34:53 +0530 | [diff] [blame] | 8803 | int set_value; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8804 | |
| 8805 | ENTER(); |
| 8806 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8807 | hdd_ctx = hdd_context_create(dev); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8808 | |
| 8809 | if (IS_ERR(hdd_ctx)) |
| 8810 | return PTR_ERR(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8811 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8812 | qdf_mc_timer_init(&hdd_ctx->iface_change_timer, QDF_TIMER_TYPE_SW, |
| 8813 | hdd_iface_change_callback, (void *)hdd_ctx); |
| 8814 | |
| 8815 | mutex_init(&hdd_ctx->iface_change_lock); |
| 8816 | |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 8817 | ret = hdd_init_netlink_services(hdd_ctx); |
| 8818 | if (ret) |
| 8819 | goto err_hdd_free_context; |
| 8820 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 8821 | hdd_request_manager_init(); |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 8822 | hdd_green_ap_init(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8823 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8824 | ret = hdd_wlan_start_modules(hdd_ctx, NULL, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8825 | if (ret) { |
| 8826 | hdd_alert("Failed to start modules: %d", ret); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 8827 | goto err_exit_nl_srv; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8828 | } |
| 8829 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 8830 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8831 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8832 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 8833 | hdd_notice("Failed to set wow pulse"); |
| 8834 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8835 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8836 | |
| 8837 | if (NULL == hdd_ctx->hHal) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8838 | hdd_alert("HAL context is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8839 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8840 | } |
| 8841 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8842 | ret = hdd_wiphy_init(hdd_ctx); |
| 8843 | if (ret) { |
| 8844 | hdd_alert("Failed to initialize wiphy: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8845 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8846 | } |
| 8847 | |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 8848 | if (hdd_ctx->config->enable_dp_trace) |
| 8849 | qdf_dp_trace_init(); |
| 8850 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8851 | if (hdd_ipa_init(hdd_ctx) == QDF_STATUS_E_FAILURE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8852 | goto err_wiphy_unregister; |
| 8853 | |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 8854 | wlan_hdd_init_chan_info(hdd_ctx); |
| 8855 | |
Yuanyuan Liu | c98370e | 2016-10-13 11:22:13 -0700 | [diff] [blame] | 8856 | hdd_initialize_mac_address(hdd_ctx); |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 8857 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8858 | rtnl_held = hdd_hold_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8859 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8860 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 8861 | if (ret) { |
| 8862 | hdd_alert("Failed to open interfaces: %d", ret); |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 8863 | goto err_release_rtnl_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8864 | } |
| 8865 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8866 | hdd_release_rtnl_lock(); |
| 8867 | rtnl_held = false; |
| 8868 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 8869 | wlan_hdd_update_11n_mode(hdd_ctx->config); |
| 8870 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8871 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 8872 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8873 | QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8874 | hdd_skip_acs_scan_timer_handler, |
| 8875 | (void *)hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8876 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8877 | hdd_err("Failed to init ACS Skip timer"); |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 8878 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8879 | #endif |
| 8880 | |
Nitesh Shah | 61c10d9 | 2016-10-19 19:29:15 +0530 | [diff] [blame] | 8881 | qdf_mc_timer_init(&hdd_ctx->tdls_source_timer, |
| 8882 | QDF_TIMER_TYPE_SW, |
| 8883 | wlan_hdd_change_tdls_mode, |
| 8884 | hdd_ctx); |
| 8885 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8886 | hdd_bus_bandwidth_init(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8887 | |
Jeff Johnson | 9afc501 | 2016-09-23 13:56:27 -0700 | [diff] [blame] | 8888 | hdd_lpass_notify_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8889 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 8890 | if (hdd_ctx->rps) |
| 8891 | hdd_set_rps_cpu_mask(hdd_ctx); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 8892 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 8893 | ret = hdd_register_notifiers(hdd_ctx); |
| 8894 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8895 | goto err_close_adapters; |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 8896 | |
| 8897 | status = wlansap_global_init(); |
| 8898 | if (QDF_IS_STATUS_ERROR(status)) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8899 | goto err_close_adapters; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 8900 | |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 8901 | hdd_runtime_suspend_context_init(hdd_ctx); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 8902 | memdump_init(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 8903 | hdd_driver_memdump_init(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 8904 | |
bings | 612b9c4 | 2016-11-07 10:52:03 +0800 | [diff] [blame] | 8905 | if (hdd_enable_egap(hdd_ctx)) |
| 8906 | hdd_err("enhance green ap is not enabled"); |
| 8907 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8908 | if (hdd_ctx->config->fIsImpsEnabled) |
| 8909 | hdd_set_idle_ps_config(hdd_ctx, true); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 8910 | |
Manjeet Singh | e7ecb7c | 2016-09-03 12:34:53 +0530 | [diff] [blame] | 8911 | if (hdd_ctx->config->sifs_burst_duration) { |
| 8912 | set_value = (SIFS_BURST_DUR_MULTIPLIER) * |
| 8913 | hdd_ctx->config->sifs_burst_duration; |
| 8914 | |
| 8915 | if ((set_value > 0) && (set_value <= SIFS_BURST_DUR_MAX)) |
| 8916 | wma_cli_set_command(0, (int)WMI_PDEV_PARAM_BURST_DUR, |
| 8917 | set_value, PDEV_CMD); |
| 8918 | } |
| 8919 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8920 | qdf_mc_timer_start(&hdd_ctx->iface_change_timer, |
| 8921 | hdd_ctx->config->iface_change_wait_time * 5000); |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 8922 | |
Selvaraj, Sridhar | 1ffa0ec | 2017-03-10 09:52:12 +0530 | [diff] [blame] | 8923 | complete(&wlan_start_comp); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8924 | goto success; |
| 8925 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8926 | err_close_adapters: |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 8927 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8928 | |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 8929 | err_release_rtnl_lock: |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 8930 | if (rtnl_held) |
| 8931 | hdd_release_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8932 | |
Anurag Chouhan | ce6a405 | 2016-09-14 18:20:42 +0530 | [diff] [blame] | 8933 | hdd_ipa_cleanup(hdd_ctx); |
Yun Park | 6a46ad8 | 2016-01-04 16:48:19 -0800 | [diff] [blame] | 8934 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8935 | err_wiphy_unregister: |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8936 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8937 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8938 | err_stop_modules: |
Prashanth Bhatta | 2ac92bd | 2016-10-11 16:08:00 -0700 | [diff] [blame] | 8939 | hdd_wlan_stop_modules(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8940 | |
| 8941 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8942 | status = cds_sched_close(hdd_ctx->pcds_context); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8943 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8944 | hdd_alert("Failed to close CDS Scheduler"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 8945 | QDF_ASSERT(QDF_IS_STATUS_SUCCESS(status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8946 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8947 | |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 8948 | err_exit_nl_srv: |
Houston Hoffman | 47a4a05 | 2016-11-14 23:22:44 -0800 | [diff] [blame] | 8949 | hdd_green_ap_deinit(hdd_ctx); |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 8950 | hdd_request_manager_deinit(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 8951 | hdd_exit_netlink_services(hdd_ctx); |
| 8952 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8953 | cds_deinit_ini_config(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8954 | err_hdd_free_context: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8955 | qdf_mc_timer_destroy(&hdd_ctx->iface_change_timer); |
| 8956 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8957 | hdd_context_destroy(hdd_ctx); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 8958 | QDF_BUG(1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8959 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8960 | return -EIO; |
| 8961 | |
| 8962 | success: |
| 8963 | EXIT(); |
| 8964 | return 0; |
| 8965 | } |
| 8966 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8967 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8968 | * hdd_wlan_update_target_info() - update target type info |
| 8969 | * @hdd_ctx: HDD context |
| 8970 | * @context: hif context |
| 8971 | * |
| 8972 | * Update target info received from firmware in hdd context |
| 8973 | * Return:None |
| 8974 | */ |
| 8975 | |
| 8976 | void hdd_wlan_update_target_info(hdd_context_t *hdd_ctx, void *context) |
| 8977 | { |
| 8978 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 8979 | |
| 8980 | if (!tgt_info) { |
| 8981 | hdd_err("Target info is Null"); |
| 8982 | return; |
| 8983 | } |
| 8984 | |
| 8985 | hdd_ctx->target_type = tgt_info->target_type; |
| 8986 | } |
| 8987 | |
| 8988 | /** |
| 8989 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 8990 | * @hdd_ctx: HDD context |
| 8991 | * |
| 8992 | * Register the HDD callbacks to CDS/SME. |
| 8993 | * |
| 8994 | * Return: 0 for success or Error code for failure |
| 8995 | */ |
| 8996 | int hdd_register_cb(hdd_context_t *hdd_ctx) |
| 8997 | { |
| 8998 | QDF_STATUS status; |
| 8999 | int ret = 0; |
| 9000 | |
| 9001 | ENTER(); |
| 9002 | |
| 9003 | sme_register11d_scan_done_callback(hdd_ctx->hHal, hdd_11d_scan_done); |
| 9004 | |
| 9005 | sme_register_oem_data_rsp_callback(hdd_ctx->hHal, |
| 9006 | hdd_send_oem_data_rsp_msg); |
| 9007 | |
| 9008 | status = sme_fw_mem_dump_register_cb(hdd_ctx->hHal, |
| 9009 | wlan_hdd_cfg80211_fw_mem_dump_cb); |
| 9010 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9011 | hdd_err("Failed to register memdump callback"); |
| 9012 | ret = -EINVAL; |
| 9013 | return ret; |
| 9014 | } |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 9015 | sme_register_mgmt_frame_ind_callback(hdd_ctx->hHal, |
| 9016 | hdd_indicate_mgmt_frame); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 9017 | sme_set_tsfcb(hdd_ctx->hHal, hdd_get_tsf_cb, hdd_ctx); |
| 9018 | sme_nan_register_callback(hdd_ctx->hHal, |
| 9019 | wlan_hdd_cfg80211_nan_callback); |
| 9020 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 9021 | wlan_hdd_cfg80211_stats_ext_callback); |
| 9022 | |
| 9023 | sme_ext_scan_register_callback(hdd_ctx->hHal, |
| 9024 | wlan_hdd_cfg80211_extscan_callback); |
| 9025 | |
| 9026 | status = cds_register_sap_restart_channel_switch_cb( |
| 9027 | (void *)hdd_sap_restart_with_channel_switch); |
| 9028 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9029 | hdd_err("restart cb registration failed"); |
| 9030 | ret = -EINVAL; |
| 9031 | return ret; |
| 9032 | } |
| 9033 | |
| 9034 | sme_set_rssi_threshold_breached_cb(hdd_ctx->hHal, |
| 9035 | hdd_rssi_threshold_breached); |
| 9036 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 9037 | sme_set_link_layer_stats_ind_cb(hdd_ctx->hHal, |
| 9038 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 9039 | |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 9040 | status = sme_set_lost_link_info_cb(hdd_ctx->hHal, |
| 9041 | hdd_lost_link_info_cb); |
| 9042 | /* print error and not block the startup process */ |
| 9043 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9044 | hdd_err("set lost link info callback failed"); |
| 9045 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 9046 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 9047 | |
| 9048 | EXIT(); |
| 9049 | |
| 9050 | return ret; |
| 9051 | } |
| 9052 | |
| 9053 | /** |
| 9054 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 9055 | * @hdd_ctx: HDD context |
| 9056 | * |
| 9057 | * De-Register the HDD callbacks to CDS/SME. |
| 9058 | * |
| 9059 | * Return: void |
| 9060 | */ |
| 9061 | void hdd_deregister_cb(hdd_context_t *hdd_ctx) |
| 9062 | { |
| 9063 | QDF_STATUS status; |
| 9064 | |
| 9065 | ENTER(); |
| 9066 | |
| 9067 | status = sme_deregister_for_dcc_stats_event(hdd_ctx->hHal); |
| 9068 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9069 | hdd_err("De-register of dcc stats callback failed: %d", |
| 9070 | status); |
| 9071 | |
| 9072 | sme_reset_link_layer_stats_ind_cb(hdd_ctx->hHal); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 9073 | sme_reset_rssi_threshold_breached_cb(hdd_ctx->hHal); |
| 9074 | |
| 9075 | status = cds_deregister_sap_restart_channel_switch_cb(); |
| 9076 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9077 | hdd_err("De-register restart cb registration failed: %d", |
| 9078 | status); |
| 9079 | |
| 9080 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 9081 | wlan_hdd_cfg80211_stats_ext_callback); |
| 9082 | |
| 9083 | sme_nan_deregister_callback(hdd_ctx->hHal); |
| 9084 | status = sme_reset_tsfcb(hdd_ctx->hHal); |
| 9085 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9086 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 9087 | status); |
| 9088 | status = sme_fw_mem_dump_unregister_cb(hdd_ctx->hHal); |
| 9089 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9090 | hdd_err("Failed to de-register the fw mem dump callback: %d", |
| 9091 | status); |
| 9092 | |
| 9093 | sme_deregister_oem_data_rsp_callback(hdd_ctx->hHal); |
| 9094 | sme_deregister11d_scan_done_callback(hdd_ctx->hHal); |
| 9095 | |
| 9096 | EXIT(); |
| 9097 | } |
| 9098 | |
| 9099 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9100 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
| 9101 | * @adapter: Pointer to the HDD |
| 9102 | * @enable: bool value |
| 9103 | * |
| 9104 | * This to take counter measure to handle deauth req from HDD |
| 9105 | * |
| 9106 | * Return: None |
| 9107 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9108 | QDF_STATUS hdd_softap_sta_deauth(hdd_adapter_t *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9109 | struct tagCsrDelStaParams *pDelStaParams) |
| 9110 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9111 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9112 | |
| 9113 | ENTER(); |
| 9114 | |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 9115 | hdd_notice("hdd_softap_sta_deauth:(%p, false)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9116 | (WLAN_HDD_GET_CTX(adapter))->pcds_context); |
| 9117 | |
| 9118 | /* Ignore request to deauth bcmc station */ |
| 9119 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9120 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9121 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9122 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9123 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 9124 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9125 | |
| 9126 | EXIT(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9127 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9128 | } |
| 9129 | |
| 9130 | /** |
| 9131 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
| 9132 | * @adapter: Pointer to the HDD |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 9133 | * @p_del_sta_params: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9134 | * |
| 9135 | * This to take counter measure to handle deauth req from HDD |
| 9136 | * |
| 9137 | * Return: None |
| 9138 | */ |
| 9139 | void hdd_softap_sta_disassoc(hdd_adapter_t *adapter, |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 9140 | struct tagCsrDelStaParams *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9141 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9142 | ENTER(); |
| 9143 | |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 9144 | hdd_err("hdd_softap_sta_disassoc:(%p, false)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9145 | (WLAN_HDD_GET_CTX(adapter))->pcds_context); |
| 9146 | |
| 9147 | /* Ignore request to disassoc bcmc station */ |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 9148 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9149 | return; |
| 9150 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9151 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 9152 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9153 | } |
| 9154 | |
| 9155 | void hdd_softap_tkip_mic_fail_counter_measure(hdd_adapter_t *adapter, |
| 9156 | bool enable) |
| 9157 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9158 | ENTER(); |
| 9159 | |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 9160 | hdd_err("hdd_softap_tkip_mic_fail_counter_measure:(%p, false)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9161 | (WLAN_HDD_GET_CTX(adapter))->pcds_context); |
| 9162 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9163 | wlansap_set_counter_measure(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 9164 | (bool) enable); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9165 | } |
| 9166 | |
| 9167 | /** |
| 9168 | * hdd_issta_p2p_clientconnected() - check if sta or p2p client is connected |
| 9169 | * @hdd_ctx: HDD Context |
| 9170 | * |
| 9171 | * API to find if there is any STA or P2P-Client is connected |
| 9172 | * |
| 9173 | * Return: true if connected; false otherwise |
| 9174 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9175 | QDF_STATUS hdd_issta_p2p_clientconnected(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9176 | { |
| 9177 | return sme_is_sta_p2p_client_connected(hdd_ctx->hHal); |
| 9178 | } |
| 9179 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9180 | /** |
| 9181 | * wlan_hdd_disable_roaming() - disable roaming on all STAs except the input one |
| 9182 | * @adapter: HDD adapter pointer |
| 9183 | * |
| 9184 | * This function loop through each adapter and disable roaming on each STA |
| 9185 | * device mode except the input adapter. |
| 9186 | * |
| 9187 | * Note: On the input adapter roaming is not enabled yet hence no need to |
| 9188 | * disable. |
| 9189 | * |
| 9190 | * Return: None |
| 9191 | */ |
| 9192 | void wlan_hdd_disable_roaming(hdd_adapter_t *adapter) |
| 9193 | { |
| 9194 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 9195 | hdd_adapter_t *adapterIdx = NULL; |
| 9196 | hdd_adapter_list_node_t *adapterNode = NULL; |
| 9197 | hdd_adapter_list_node_t *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9198 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9199 | |
| 9200 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
| 9201 | hdd_ctx->config->isRoamOffloadScanEnabled && |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9202 | QDF_STA_MODE == adapter->device_mode && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9203 | cds_is_sta_active_connection_exists()) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 9204 | hdd_notice("Connect received on STA sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9205 | adapter->sessionId); |
| 9206 | /* |
| 9207 | * Loop through adapter and disable roaming for each STA device |
| 9208 | * mode except the input adapter. |
| 9209 | */ |
| 9210 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 9211 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9212 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9213 | adapterIdx = adapterNode->pAdapter; |
| 9214 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9215 | if (QDF_STA_MODE == adapterIdx->device_mode |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9216 | && adapter->sessionId != adapterIdx->sessionId) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 9217 | hdd_notice("Disable Roaming on sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9218 | adapterIdx->sessionId); |
| 9219 | sme_stop_roaming(WLAN_HDD_GET_HAL_CTX |
| 9220 | (adapterIdx), |
| 9221 | adapterIdx->sessionId, 0); |
| 9222 | } |
| 9223 | |
| 9224 | status = hdd_get_next_adapter(hdd_ctx, |
| 9225 | adapterNode, |
| 9226 | &pNext); |
| 9227 | adapterNode = pNext; |
| 9228 | } |
| 9229 | } |
| 9230 | } |
| 9231 | |
| 9232 | /** |
| 9233 | * wlan_hdd_enable_roaming() - enable roaming on all STAs except the input one |
| 9234 | * @adapter: HDD adapter pointer |
| 9235 | * |
| 9236 | * This function loop through each adapter and enable roaming on each STA |
| 9237 | * device mode except the input adapter. |
| 9238 | * Note: On the input adapter no need to enable roaming because link got |
| 9239 | * disconnected on this. |
| 9240 | * |
| 9241 | * Return: None |
| 9242 | */ |
| 9243 | void wlan_hdd_enable_roaming(hdd_adapter_t *adapter) |
| 9244 | { |
| 9245 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 9246 | hdd_adapter_t *adapterIdx = NULL; |
| 9247 | hdd_adapter_list_node_t *adapterNode = NULL; |
| 9248 | hdd_adapter_list_node_t *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9249 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9250 | |
| 9251 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
| 9252 | hdd_ctx->config->isRoamOffloadScanEnabled && |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9253 | QDF_STA_MODE == adapter->device_mode && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9254 | cds_is_sta_active_connection_exists()) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 9255 | hdd_notice("Disconnect received on STA sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9256 | adapter->sessionId); |
| 9257 | /* |
| 9258 | * Loop through adapter and enable roaming for each STA device |
| 9259 | * mode except the input adapter. |
| 9260 | */ |
| 9261 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 9262 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9263 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9264 | adapterIdx = adapterNode->pAdapter; |
| 9265 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9266 | if (QDF_STA_MODE == adapterIdx->device_mode |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9267 | && adapter->sessionId != adapterIdx->sessionId) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 9268 | hdd_notice("Enabling Roaming on sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9269 | adapterIdx->sessionId); |
| 9270 | sme_start_roaming(WLAN_HDD_GET_HAL_CTX |
| 9271 | (adapterIdx), |
| 9272 | adapterIdx->sessionId, |
| 9273 | REASON_CONNECT); |
| 9274 | } |
| 9275 | |
| 9276 | status = hdd_get_next_adapter(hdd_ctx, |
| 9277 | adapterNode, |
| 9278 | &pNext); |
| 9279 | adapterNode = pNext; |
| 9280 | } |
| 9281 | } |
| 9282 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9283 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 9284 | /** |
| 9285 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 9286 | * @skb: sk buffer pointer |
| 9287 | * |
| 9288 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 9289 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 9290 | * |
| 9291 | * Return: None |
| 9292 | */ |
| 9293 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 9294 | { |
| 9295 | #ifdef CNSS_GENL |
| 9296 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 9297 | #else |
| 9298 | nl_srv_bcast(skb); |
| 9299 | #endif |
| 9300 | } |
| 9301 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 9302 | 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] | 9303 | { |
| 9304 | struct sk_buff *skb; |
| 9305 | struct nlmsghdr *nlh; |
| 9306 | tAniMsgHdr *ani_hdr; |
| 9307 | void *nl_data = NULL; |
| 9308 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 9309 | struct radio_index_tlv *radio_info; |
| 9310 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9311 | |
| 9312 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 9313 | flags = GFP_ATOMIC; |
| 9314 | |
| 9315 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 9316 | |
| 9317 | if (skb == NULL) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 9318 | hdd_err("alloc_skb failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9319 | return; |
| 9320 | } |
| 9321 | |
| 9322 | nlh = (struct nlmsghdr *)skb->data; |
| 9323 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 9324 | nlh->nlmsg_flags = 0; |
| 9325 | nlh->nlmsg_seq = 0; |
| 9326 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 9327 | |
| 9328 | ani_hdr = NLMSG_DATA(nlh); |
| 9329 | ani_hdr->type = type; |
| 9330 | |
| 9331 | switch (type) { |
| 9332 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 9333 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9334 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9335 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 9336 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9337 | ani_hdr->length = 0; |
| 9338 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9339 | break; |
| 9340 | case WLAN_SVC_WLAN_STATUS_IND: |
| 9341 | case WLAN_SVC_WLAN_VERSION_IND: |
| 9342 | case WLAN_SVC_DFS_CAC_START_IND: |
| 9343 | case WLAN_SVC_DFS_CAC_END_IND: |
| 9344 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 9345 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 9346 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 9347 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 9348 | case WLAN_SVC_RPS_ENABLE_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9349 | ani_hdr->length = len; |
| 9350 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 9351 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 9352 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9353 | break; |
| 9354 | |
| 9355 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 9356 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9357 | type); |
| 9358 | kfree_skb(skb); |
| 9359 | return; |
| 9360 | } |
| 9361 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 9362 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 9363 | * Add radio index at the end of the svc event in TLV format |
| 9364 | * to maintain the backward compatibility with userspace |
| 9365 | * applications. |
| 9366 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 9367 | |
| 9368 | tlv_len = 0; |
| 9369 | |
| 9370 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 9371 | < WLAN_NL_MAX_PAYLOAD) { |
| 9372 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 9373 | sizeof(*ani_hdr) + len); |
| 9374 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 9375 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 9376 | radio_info->radio = radio; |
| 9377 | tlv_len = sizeof(*radio_info); |
| 9378 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO, |
| 9379 | "Added radio index tlv - radio index %d", |
| 9380 | radio_info->radio); |
| 9381 | } |
| 9382 | |
| 9383 | nlh->nlmsg_len += tlv_len; |
| 9384 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 9385 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 9386 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9387 | |
| 9388 | return; |
| 9389 | } |
| 9390 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9391 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 9392 | void wlan_hdd_auto_shutdown_cb(void) |
| 9393 | { |
Mahesh Kumar Kalikot Veetil | d214d55 | 2016-09-14 15:15:49 -0700 | [diff] [blame] | 9394 | hdd_context_t *hdd_ctx = cds_get_global_context(); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 9395 | |
| 9396 | if (!hdd_ctx) |
| 9397 | return; |
| 9398 | |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9399 | hdd_err("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 9400 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 9401 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9402 | } |
| 9403 | |
| 9404 | void wlan_hdd_auto_shutdown_enable(hdd_context_t *hdd_ctx, bool enable) |
| 9405 | { |
| 9406 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9407 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9408 | hdd_adapter_t *adapter; |
| 9409 | bool ap_connected = false, sta_connected = false; |
| 9410 | tHalHandle hal_handle; |
| 9411 | |
| 9412 | hal_handle = hdd_ctx->hHal; |
| 9413 | if (hal_handle == NULL) |
| 9414 | return; |
| 9415 | |
| 9416 | if (hdd_ctx->config->WlanAutoShutdown == 0) |
| 9417 | return; |
| 9418 | |
| 9419 | if (enable == false) { |
| 9420 | if (sme_set_auto_shutdown_timer(hal_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9421 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9422 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9423 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 9424 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 9425 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9426 | return; |
| 9427 | } |
| 9428 | |
| 9429 | /* To enable shutdown timer check conncurrency */ |
| 9430 | if (cds_concurrent_open_sessions_running()) { |
| 9431 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 9432 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9433 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9434 | adapter = adapterNode->pAdapter; |
| 9435 | if (adapter |
| 9436 | && adapter->device_mode == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9437 | QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9438 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 9439 | conn_info.connState == |
| 9440 | eConnectionState_Associated) { |
| 9441 | sta_connected = true; |
| 9442 | break; |
| 9443 | } |
| 9444 | } |
| 9445 | if (adapter |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9446 | && adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9447 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
| 9448 | bApActive == true) { |
| 9449 | ap_connected = true; |
| 9450 | break; |
| 9451 | } |
| 9452 | } |
| 9453 | status = hdd_get_next_adapter(hdd_ctx, |
| 9454 | adapterNode, |
| 9455 | &pNext); |
| 9456 | adapterNode = pNext; |
| 9457 | } |
| 9458 | } |
| 9459 | |
| 9460 | if (ap_connected == true || sta_connected == true) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9461 | hdd_notice("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9462 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9463 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 9464 | |
| 9465 | if (sme_set_auto_shutdown_timer(hal_handle, |
| 9466 | hdd_ctx->config->WlanAutoShutdown) |
| 9467 | != QDF_STATUS_SUCCESS) |
| 9468 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 9469 | else |
| 9470 | hdd_notice("Auto Shutdown timer for %d seconds enabled", |
| 9471 | hdd_ctx->config->WlanAutoShutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9472 | } |
| 9473 | #endif |
| 9474 | |
| 9475 | hdd_adapter_t *hdd_get_con_sap_adapter(hdd_adapter_t *this_sap_adapter, |
| 9476 | bool check_start_bss) |
| 9477 | { |
| 9478 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
| 9479 | hdd_adapter_t *adapter, *con_sap_adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9480 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9481 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 9482 | |
| 9483 | con_sap_adapter = NULL; |
| 9484 | |
| 9485 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9486 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9487 | adapter = adapterNode->pAdapter; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9488 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 9489 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9490 | adapter != this_sap_adapter) { |
| 9491 | if (check_start_bss) { |
| 9492 | if (test_bit(SOFTAP_BSS_STARTED, |
| 9493 | &adapter->event_flags)) { |
| 9494 | con_sap_adapter = adapter; |
| 9495 | break; |
| 9496 | } |
| 9497 | } else { |
| 9498 | con_sap_adapter = adapter; |
| 9499 | break; |
| 9500 | } |
| 9501 | } |
| 9502 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 9503 | adapterNode = pNext; |
| 9504 | } |
| 9505 | |
| 9506 | return con_sap_adapter; |
| 9507 | } |
| 9508 | |
| 9509 | #ifdef MSM_PLATFORM |
| 9510 | void hdd_start_bus_bw_compute_timer(hdd_adapter_t *adapter) |
| 9511 | { |
| 9512 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 9513 | |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 9514 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 9515 | if (!hdd_ctx->bus_bw_timer_running) { |
| 9516 | hdd_ctx->bus_bw_timer_running = true; |
| 9517 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
| 9518 | hdd_ctx->config->busBandwidthComputeInterval); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9519 | |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 9520 | } |
| 9521 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 9522 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9523 | } |
| 9524 | |
| 9525 | void hdd_stop_bus_bw_compute_timer(hdd_adapter_t *adapter) |
| 9526 | { |
| 9527 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9528 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9529 | bool can_stop = true; |
| 9530 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 9531 | |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 9532 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 9533 | if (!hdd_ctx->bus_bw_timer_running) { |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 9534 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9535 | /* trying to stop timer, when not running is not good */ |
Srinivas Girigowda | 0ee9644 | 2016-08-17 19:10:56 -0700 | [diff] [blame] | 9536 | hdd_info("bus band width compute timer is not running"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9537 | return; |
| 9538 | } |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 9539 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9540 | |
| 9541 | if (cds_concurrent_open_sessions_running()) { |
| 9542 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 9543 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9544 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9545 | adapter = adapterNode->pAdapter; |
| 9546 | if (adapter |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9547 | && (adapter->device_mode == QDF_STA_MODE |
| 9548 | || adapter->device_mode == QDF_P2P_CLIENT_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9549 | && WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 9550 | conn_info.connState == |
| 9551 | eConnectionState_Associated) { |
| 9552 | can_stop = false; |
| 9553 | break; |
| 9554 | } |
| 9555 | if (adapter |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9556 | && (adapter->device_mode == QDF_SAP_MODE |
| 9557 | || adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9558 | && WLAN_HDD_GET_AP_CTX_PTR(adapter)->bApActive == |
| 9559 | true) { |
| 9560 | can_stop = false; |
| 9561 | break; |
| 9562 | } |
| 9563 | status = hdd_get_next_adapter(hdd_ctx, |
| 9564 | adapterNode, |
| 9565 | &pNext); |
| 9566 | adapterNode = pNext; |
| 9567 | } |
| 9568 | } |
| 9569 | |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 9570 | if (can_stop == true) { |
Chris Guo | c0c95bf | 2016-11-10 14:28:25 +0800 | [diff] [blame] | 9571 | /* reset the ipa perf level */ |
| 9572 | hdd_ipa_set_perf_level(hdd_ctx, 0, 0); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 9573 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 9574 | qdf_timer_stop(&hdd_ctx->bus_bw_timer); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 9575 | hdd_ctx->bus_bw_timer_running = false; |
| 9576 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 9577 | hdd_reset_tcp_delack(hdd_ctx); |
| 9578 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9579 | } |
| 9580 | #endif |
| 9581 | |
| 9582 | /** |
| 9583 | * wlan_hdd_check_custom_con_channel_rules() - This function checks the sap's |
| 9584 | * and sta's operating channel. |
| 9585 | * @sta_adapter: Describe the first argument to foobar. |
| 9586 | * @ap_adapter: Describe the second argument to foobar. |
| 9587 | * @roam_profile: Roam profile of AP to which STA wants to connect. |
| 9588 | * @concurrent_chnl_same: If both SAP and STA channels are same then |
| 9589 | * set this flag to true else false. |
| 9590 | * |
| 9591 | * This function checks the sap's operating channel and sta's operating channel. |
| 9592 | * if both are same then it will return false else it will restart the sap in |
| 9593 | * sta's channel and return true. |
| 9594 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9595 | * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9596 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9597 | 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] | 9598 | hdd_adapter_t *ap_adapter, |
| 9599 | tCsrRoamProfile *roam_profile, |
| 9600 | tScanResultHandle *scan_cache, |
| 9601 | bool *concurrent_chnl_same) |
| 9602 | { |
| 9603 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 9604 | uint8_t channel_id; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9605 | QDF_STATUS status; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9606 | enum tQDF_ADAPTER_MODE device_mode = ap_adapter->device_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9607 | *concurrent_chnl_same = true; |
| 9608 | |
| 9609 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 9610 | status = |
| 9611 | sme_get_ap_channel_from_scan_cache(WLAN_HDD_GET_HAL_CTX(sta_adapter), |
| 9612 | roam_profile, |
| 9613 | scan_cache, |
| 9614 | &channel_id); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9615 | if ((QDF_STATUS_SUCCESS == status)) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9616 | if ((QDF_SAP_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9617 | (channel_id < SIR_11A_CHANNEL_BEGIN)) { |
| 9618 | if (hdd_ap_ctx->operatingChannel != channel_id) { |
| 9619 | *concurrent_chnl_same = false; |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9620 | hdd_info("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9621 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9622 | } else if ((QDF_P2P_GO_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9623 | (channel_id >= SIR_11A_CHANNEL_BEGIN)) { |
| 9624 | if (hdd_ap_ctx->operatingChannel != channel_id) { |
| 9625 | *concurrent_chnl_same = false; |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9626 | hdd_info("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9627 | } |
| 9628 | } |
| 9629 | } else { |
| 9630 | /* |
| 9631 | * Lets handle worst case scenario here, Scan cache lookup is |
| 9632 | * failed so we have to stop the SAP to avoid any channel |
| 9633 | * discrepancy between SAP's channel and STA's channel. |
| 9634 | * Return the status as failure so caller function could know |
| 9635 | * that scan look up is failed. |
| 9636 | */ |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9637 | hdd_err("Finding AP from scan cache failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9638 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9639 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9640 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9641 | } |
| 9642 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9643 | /** |
| 9644 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 9645 | * @ap_adapter: SAP adapter |
| 9646 | * |
| 9647 | * This function will process the stopping of sap adapter. |
| 9648 | * |
| 9649 | * Return: None |
| 9650 | */ |
| 9651 | void wlan_hdd_stop_sap(hdd_adapter_t *ap_adapter) |
| 9652 | { |
| 9653 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 9654 | hdd_hostapd_state_t *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 9655 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9656 | hdd_context_t *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9657 | |
| 9658 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9659 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9660 | return; |
| 9661 | } |
| 9662 | |
| 9663 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 9664 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 9665 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9666 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 9667 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9668 | mutex_lock(&hdd_ctx->sap_lock); |
| 9669 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 9670 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9671 | hdd_cleanup_actionframe(hdd_ctx, ap_adapter); |
| 9672 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9673 | hdd_info("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 9674 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9675 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9676 | sapContext)) { |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 9677 | qdf_status = qdf_wait_single_event(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 9678 | qdf_stop_bss_event, |
| 9679 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 9680 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9681 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9682 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9683 | return; |
| 9684 | } |
| 9685 | } |
| 9686 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | 4adb368 | 2016-01-07 15:07:12 -0800 | [diff] [blame] | 9687 | cds_decr_session_set_pcl(ap_adapter->device_mode, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9688 | ap_adapter->sessionId); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9689 | hdd_info("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9690 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9691 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9692 | } |
| 9693 | mutex_unlock(&hdd_ctx->sap_lock); |
| 9694 | return; |
| 9695 | } |
| 9696 | |
| 9697 | /** |
| 9698 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 9699 | * @ap_adapter: SAP adapter |
| 9700 | * |
| 9701 | * This function will process the starting of sap adapter. |
| 9702 | * |
| 9703 | * Return: None |
| 9704 | */ |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 9705 | void wlan_hdd_start_sap(hdd_adapter_t *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9706 | { |
| 9707 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 9708 | hdd_hostapd_state_t *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 9709 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9710 | hdd_context_t *hdd_ctx; |
| 9711 | tsap_Config_t *sap_config; |
| 9712 | |
| 9713 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9714 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9715 | return; |
| 9716 | } |
| 9717 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9718 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 9719 | hdd_err("SoftAp role has not been enabled"); |
| 9720 | return; |
| 9721 | } |
| 9722 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9723 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 9724 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 9725 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 9726 | sap_config = &ap_adapter->sessionCtx.ap.sapConfig; |
| 9727 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9728 | mutex_lock(&hdd_ctx->sap_lock); |
| 9729 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 9730 | goto end; |
| 9731 | |
| 9732 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9733 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9734 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
| 9735 | goto end; |
| 9736 | } |
| 9737 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 9738 | qdf_event_reset(&hostapd_state->qdf_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9739 | if (wlansap_start_bss(hdd_ap_ctx->sapContext, hdd_hostapd_sap_event_cb, |
| 9740 | &hdd_ap_ctx->sapConfig, |
| 9741 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9742 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9743 | goto end; |
| 9744 | |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9745 | hdd_info("Waiting for SAP to start"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 9746 | qdf_status = qdf_wait_single_event(&hostapd_state->qdf_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 9747 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 9748 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9749 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9750 | goto end; |
| 9751 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9752 | hdd_info("SAP Start Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9753 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Krunal Soni | b37bb35 | 2016-12-20 14:12:21 -0800 | [diff] [blame] | 9754 | if (hostapd_state->bssState == BSS_START) |
| 9755 | cds_incr_active_session(ap_adapter->device_mode, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9756 | ap_adapter->sessionId); |
| 9757 | hostapd_state->bCommit = true; |
| 9758 | |
| 9759 | end: |
| 9760 | mutex_unlock(&hdd_ctx->sap_lock); |
| 9761 | return; |
| 9762 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9763 | |
| 9764 | /** |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 9765 | * wlan_hdd_soc_set_antenna_mode_cb() - Callback for set dual |
| 9766 | * mac scan config |
| 9767 | * @status: Status of set antenna mode |
| 9768 | * |
| 9769 | * Callback on setting the dual mac configuration |
| 9770 | * |
| 9771 | * Return: None |
| 9772 | */ |
| 9773 | void wlan_hdd_soc_set_antenna_mode_cb( |
| 9774 | enum set_antenna_mode_status status) |
| 9775 | { |
| 9776 | hdd_context_t *hdd_ctx; |
| 9777 | |
| 9778 | hdd_info("Status: %d", status); |
| 9779 | |
| 9780 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 9781 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 9782 | return; |
| 9783 | |
| 9784 | /* Signal the completion of set dual mac config */ |
| 9785 | complete(&hdd_ctx->set_antenna_mode_cmpl); |
| 9786 | } |
| 9787 | |
| 9788 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9789 | * hdd_get_fw_version() - Get FW version |
| 9790 | * @hdd_ctx: pointer to HDD context. |
| 9791 | * @major_spid: FW version - major spid. |
| 9792 | * @minor_spid: FW version - minor spid |
| 9793 | * @ssid: FW version - ssid |
| 9794 | * @crmid: FW version - crmid |
| 9795 | * |
| 9796 | * This function is called to get the firmware build version stored |
| 9797 | * as part of the HDD context |
| 9798 | * |
| 9799 | * Return: None |
| 9800 | */ |
| 9801 | void hdd_get_fw_version(hdd_context_t *hdd_ctx, |
| 9802 | uint32_t *major_spid, uint32_t *minor_spid, |
| 9803 | uint32_t *siid, uint32_t *crmid) |
| 9804 | { |
| 9805 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 9806 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 9807 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 9808 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 9809 | } |
| 9810 | |
| 9811 | #ifdef QCA_CONFIG_SMP |
| 9812 | /** |
| 9813 | * wlan_hdd_get_cpu() - get cpu_index |
| 9814 | * |
| 9815 | * Return: cpu_index |
| 9816 | */ |
| 9817 | int wlan_hdd_get_cpu(void) |
| 9818 | { |
| 9819 | int cpu_index = get_cpu(); |
| 9820 | put_cpu(); |
| 9821 | return cpu_index; |
| 9822 | } |
| 9823 | #endif |
| 9824 | |
| 9825 | /** |
| 9826 | * hdd_get_fwpath() - get framework path |
| 9827 | * |
| 9828 | * This function is used to get the string written by |
| 9829 | * userspace to start the wlan driver |
| 9830 | * |
| 9831 | * Return: string |
| 9832 | */ |
| 9833 | const char *hdd_get_fwpath(void) |
| 9834 | { |
| 9835 | return fwpath.string; |
| 9836 | } |
| 9837 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9838 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9839 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9840 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9841 | * This function initilizes CDS global context with the help of cds_init. This |
| 9842 | * has to be the first function called after probe to get a valid global |
| 9843 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9844 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9845 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9846 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9847 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9848 | { |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9849 | v_CONTEXT_t p_cds_context = NULL; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9850 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9851 | |
Houston Hoffman | 9e06e54 | 2016-12-12 12:06:26 -0800 | [diff] [blame] | 9852 | p_cds_context = cds_init(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9853 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9854 | wlan_logging_sock_init_svc(); |
| 9855 | #endif |
| 9856 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9857 | if (p_cds_context == NULL) { |
| 9858 | hdd_alert("Failed to allocate CDS context"); |
| 9859 | ret = -ENOMEM; |
| 9860 | goto err_out; |
| 9861 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9862 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9863 | hdd_trace_init(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 9864 | hdd_register_debug_callback(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9865 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9866 | err_out: |
| 9867 | return ret; |
| 9868 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9869 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9870 | /** |
| 9871 | * hdd_deinit() - Deinitialize Driver |
| 9872 | * |
| 9873 | * This function frees CDS global context with the help of cds_deinit. This |
| 9874 | * has to be the last function call in remove callback to free the global |
| 9875 | * context. |
| 9876 | */ |
| 9877 | void hdd_deinit(void) |
| 9878 | { |
| 9879 | cds_deinit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9880 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9881 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9882 | wlan_logging_sock_deinit_svc(); |
| 9883 | #endif |
| 9884 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9885 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9886 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9887 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9888 | /** |
| 9889 | * __hdd_module_init - Module init helper |
| 9890 | * |
| 9891 | * Module init helper function used by both module and static driver. |
| 9892 | * |
| 9893 | * Return: 0 for success, errno on failure |
| 9894 | */ |
| 9895 | static int __hdd_module_init(void) |
| 9896 | { |
| 9897 | int ret = 0; |
Arun Khandavalli | 13cb5da | 2017-01-19 15:43:52 +0530 | [diff] [blame] | 9898 | unsigned long rc; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9899 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9900 | pr_err("%s: Loading driver v%s\n", WLAN_MODULE_NAME, |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9901 | QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9902 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 9903 | pld_init(); |
| 9904 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 9905 | ret = hdd_init(); |
| 9906 | if (ret) { |
| 9907 | pr_err("hdd_init failed %x\n", ret); |
| 9908 | goto err_hdd_init; |
| 9909 | } |
| 9910 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 9911 | dispatcher_init(); |
| 9912 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 9913 | qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9914 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9915 | hdd_set_conparam((uint32_t) con_mode); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9916 | |
Arun Khandavalli | 13cb5da | 2017-01-19 15:43:52 +0530 | [diff] [blame] | 9917 | init_completion(&wlan_start_comp); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9918 | ret = wlan_hdd_register_driver(); |
| 9919 | if (ret) { |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 9920 | pr_err("%s: driver load failure, err %d\n", WLAN_MODULE_NAME, |
| 9921 | ret); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9922 | goto out; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9923 | } |
| 9924 | |
Arun Khandavalli | 13cb5da | 2017-01-19 15:43:52 +0530 | [diff] [blame] | 9925 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 9926 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 9927 | |
| 9928 | if (!rc) { |
| 9929 | hdd_alert("Timed-out waiting for wlan_hdd_register_driver"); |
| 9930 | QDF_BUG(0); |
| 9931 | goto out; |
| 9932 | } |
| 9933 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 9934 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9935 | |
| 9936 | return 0; |
| 9937 | out: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 9938 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 9939 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 9940 | hdd_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 9941 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 9942 | err_hdd_init: |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 9943 | pld_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 9944 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9945 | return ret; |
| 9946 | } |
| 9947 | |
| 9948 | /** |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 9949 | * hdd_wait_for_recovery_completion() - Wait for cds recovery completion |
| 9950 | * |
| 9951 | * Block the unloading of the driver until the cds recovery is completed |
| 9952 | * |
| 9953 | * Return: None |
| 9954 | */ |
| 9955 | static void hdd_wait_for_recovery_completion(void) |
| 9956 | { |
| 9957 | int retry = 0; |
| 9958 | |
| 9959 | /* Wait for recovery to complete */ |
| 9960 | while (cds_is_driver_recovering()) { |
| 9961 | hdd_alert("Recovery in progress; wait here!!!"); |
| 9962 | msleep(1000); |
| 9963 | if (retry++ == HDD_MOD_EXIT_SSR_MAX_RETRIES) { |
| 9964 | hdd_alert("SSR never completed, fatal error"); |
| 9965 | QDF_BUG(0); |
| 9966 | } |
| 9967 | } |
| 9968 | } |
| 9969 | |
| 9970 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9971 | * __hdd_module_exit - Module exit helper |
| 9972 | * |
| 9973 | * Module exit helper function used by both module and static driver. |
| 9974 | */ |
| 9975 | static void __hdd_module_exit(void) |
| 9976 | { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 9977 | int qdf_print_idx = -1; |
| 9978 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9979 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 9980 | QWLAN_VERSIONSTR); |
| 9981 | |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 9982 | hdd_wait_for_recovery_completion(); |
| 9983 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9984 | wlan_hdd_unregister_driver(); |
| 9985 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 9986 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9987 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 9988 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 9989 | hdd_deinit(); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 9990 | pld_deinit(); |
| 9991 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 9992 | qdf_print_idx = qdf_get_pidx(); |
| 9993 | qdf_print_ctrl_cleanup(qdf_print_idx); |
| 9994 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9995 | return; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9996 | } |
| 9997 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9998 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9999 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10000 | * wlan_boot_cb() - Wlan boot callback |
| 10001 | * @kobj: object whose directory we're creating the link in. |
| 10002 | * @attr: attribute the user is interacting with |
| 10003 | * @buff: the buffer containing the user data |
| 10004 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10005 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10006 | * This callback is invoked when the fs is ready to start the |
| 10007 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10008 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10009 | * 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] | 10010 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10011 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 10012 | struct kobj_attribute *attr, |
| 10013 | const char *buf, |
| 10014 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10015 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10016 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10017 | if (wlan_loader->loaded_state) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 10018 | pr_err("%s: wlan driver already initialized\n", __func__); |
| 10019 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10020 | } |
| 10021 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10022 | if (__hdd_module_init()) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 10023 | pr_err("%s: wlan driver initialization failed\n", __func__); |
| 10024 | return -EIO; |
| 10025 | } |
| 10026 | |
| 10027 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10028 | |
| 10029 | return count; |
| 10030 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10031 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10032 | |
| 10033 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 10034 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 10035 | * |
| 10036 | * Return: None |
| 10037 | * |
| 10038 | */ |
| 10039 | static void hdd_sysfs_cleanup(void) |
| 10040 | { |
| 10041 | |
| 10042 | /* remove from group */ |
| 10043 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 10044 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 10045 | wlan_loader->attr_group); |
| 10046 | |
| 10047 | /* unlink the object from parent */ |
| 10048 | kobject_del(wlan_loader->boot_wlan_obj); |
| 10049 | |
| 10050 | /* free the object */ |
| 10051 | kobject_put(wlan_loader->boot_wlan_obj); |
| 10052 | |
| 10053 | kfree(wlan_loader->attr_group); |
| 10054 | kfree(wlan_loader); |
| 10055 | |
| 10056 | wlan_loader = NULL; |
| 10057 | } |
| 10058 | |
| 10059 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10060 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 10061 | * ready |
| 10062 | * |
| 10063 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 10064 | * when the filesystem is ready. |
| 10065 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 10066 | * QDF API cannot be used here since this function is called even before |
| 10067 | * initializing WLAN driver. |
| 10068 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 10069 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10070 | */ |
| 10071 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10072 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 10073 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10074 | |
| 10075 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
| 10076 | if (!wlan_loader) { |
| 10077 | pr_err("%s: memory alloc failed\n", __func__); |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 10078 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10079 | } |
| 10080 | |
| 10081 | wlan_loader->boot_wlan_obj = NULL; |
| 10082 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 10083 | GFP_KERNEL); |
| 10084 | if (!wlan_loader->attr_group) { |
| 10085 | pr_err("%s: malloc attr_group failed\n", __func__); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10086 | goto error_return; |
| 10087 | } |
| 10088 | |
| 10089 | wlan_loader->loaded_state = 0; |
| 10090 | wlan_loader->attr_group->attrs = attrs; |
| 10091 | |
| 10092 | wlan_loader->boot_wlan_obj = kobject_create_and_add("boot_wlan", |
| 10093 | kernel_kobj); |
| 10094 | if (!wlan_loader->boot_wlan_obj) { |
| 10095 | pr_err("%s: sysfs create and add failed\n", __func__); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10096 | goto error_return; |
| 10097 | } |
| 10098 | |
| 10099 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 10100 | wlan_loader->attr_group); |
| 10101 | if (ret) { |
| 10102 | pr_err("%s: sysfs create group failed %d\n", __func__, ret); |
| 10103 | goto error_return; |
| 10104 | } |
| 10105 | |
| 10106 | return 0; |
| 10107 | |
| 10108 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 10109 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10110 | |
| 10111 | return ret; |
| 10112 | } |
| 10113 | |
| 10114 | /** |
| 10115 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 10116 | * |
| 10117 | * Return: 0 on success or errno on failure |
| 10118 | */ |
| 10119 | static int wlan_deinit_sysfs(void) |
| 10120 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10121 | if (!wlan_loader) { |
| 10122 | hdd_alert("wlan loader context is Null!"); |
| 10123 | return -EINVAL; |
| 10124 | } |
| 10125 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 10126 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10127 | return 0; |
| 10128 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10129 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 10130 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10131 | |
| 10132 | #ifdef MODULE |
| 10133 | /** |
| 10134 | * __hdd_module_init - Module init helper |
| 10135 | * |
| 10136 | * Module init helper function used by both module and static driver. |
| 10137 | * |
| 10138 | * Return: 0 for success, errno on failure |
| 10139 | */ |
| 10140 | static int hdd_module_init(void) |
| 10141 | { |
| 10142 | int ret = 0; |
| 10143 | |
| 10144 | pr_err("%s: Loading driver v%s\n", WLAN_MODULE_NAME, |
| 10145 | QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
| 10146 | |
| 10147 | if (__hdd_module_init()) { |
| 10148 | pr_err("%s: Failed to register handler\n", __func__); |
| 10149 | ret = -EINVAL; |
| 10150 | } |
| 10151 | |
| 10152 | return ret; |
| 10153 | } |
| 10154 | #else |
| 10155 | static int __init hdd_module_init(void) |
| 10156 | { |
| 10157 | int ret = -EINVAL; |
| 10158 | |
| 10159 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 10160 | if (ret) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10161 | pr_err("Failed to create sysfs entry for loading wlan"); |
| 10162 | |
| 10163 | return ret; |
| 10164 | } |
| 10165 | #endif |
| 10166 | |
| 10167 | |
| 10168 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10169 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10170 | * hdd_module_exit() - Exit function |
| 10171 | * |
| 10172 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 10173 | * |
| 10174 | * Return: None |
| 10175 | */ |
| 10176 | static void __exit hdd_module_exit(void) |
| 10177 | { |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10178 | __hdd_module_exit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10179 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10180 | #else |
| 10181 | static void __exit hdd_module_exit(void) |
| 10182 | { |
| 10183 | __hdd_module_exit(); |
| 10184 | wlan_deinit_sysfs(); |
| 10185 | } |
| 10186 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10187 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10188 | static int fwpath_changed_handler(const char *kmessage, struct kernel_param *kp) |
| 10189 | { |
| 10190 | return param_set_copystring(kmessage, kp); |
| 10191 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10192 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10193 | /** |
| 10194 | * is_con_mode_valid() check con mode is valid or not |
| 10195 | * @mode: global con mode |
| 10196 | * |
| 10197 | * Return: TRUE on success FALSE on failure |
| 10198 | */ |
| 10199 | static bool is_con_mode_valid(enum tQDF_GLOBAL_CON_MODE mode) |
| 10200 | { |
| 10201 | switch (mode) { |
| 10202 | case QDF_GLOBAL_MONITOR_MODE: |
| 10203 | case QDF_GLOBAL_FTM_MODE: |
| 10204 | case QDF_GLOBAL_EPPING_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10205 | case QDF_GLOBAL_MISSION_MODE: |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10206 | return true; |
| 10207 | default: |
| 10208 | return false; |
| 10209 | } |
| 10210 | } |
| 10211 | |
| 10212 | /** |
| 10213 | * hdd_get_adpter_mode() - returns adapter mode based on global con mode |
| 10214 | * @mode: global con mode |
| 10215 | * |
| 10216 | * Return: adapter mode |
| 10217 | */ |
| 10218 | static enum tQDF_ADAPTER_MODE hdd_get_adpter_mode( |
| 10219 | enum tQDF_GLOBAL_CON_MODE mode) |
| 10220 | { |
| 10221 | |
| 10222 | switch (mode) { |
| 10223 | case QDF_GLOBAL_MISSION_MODE: |
| 10224 | return QDF_STA_MODE; |
| 10225 | case QDF_GLOBAL_MONITOR_MODE: |
| 10226 | return QDF_MONITOR_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10227 | case QDF_GLOBAL_EPPING_MODE: |
| 10228 | return QDF_EPPING_MODE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10229 | case QDF_GLOBAL_FTM_MODE: |
| 10230 | return QDF_FTM_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10231 | case QDF_GLOBAL_QVIT_MODE: |
| 10232 | return QDF_QVIT_MODE; |
| 10233 | default: |
| 10234 | return QDF_MAX_NO_OF_MODE; |
| 10235 | } |
| 10236 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10237 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10238 | static void hdd_cleanup_present_mode(hdd_context_t *hdd_ctx, |
| 10239 | enum tQDF_GLOBAL_CON_MODE curr_mode) |
| 10240 | { |
Ashish Kumar Dhanotiya | 0024313 | 2017-01-24 16:37:34 +0530 | [diff] [blame] | 10241 | int driver_status; |
| 10242 | |
| 10243 | driver_status = hdd_ctx->driver_status; |
| 10244 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10245 | switch (curr_mode) { |
| 10246 | case QDF_GLOBAL_MISSION_MODE: |
| 10247 | case QDF_GLOBAL_MONITOR_MODE: |
| 10248 | case QDF_GLOBAL_FTM_MODE: |
Ashish Kumar Dhanotiya | 0024313 | 2017-01-24 16:37:34 +0530 | [diff] [blame] | 10249 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 10250 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
| 10251 | hdd_stop_all_adapters(hdd_ctx); |
| 10252 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10253 | hdd_deinit_all_adapters(hdd_ctx, false); |
| 10254 | hdd_close_all_adapters(hdd_ctx, false); |
| 10255 | break; |
| 10256 | case QDF_GLOBAL_EPPING_MODE: |
| 10257 | epping_disable(); |
| 10258 | epping_close(); |
| 10259 | break; |
| 10260 | default: |
| 10261 | return; |
| 10262 | } |
| 10263 | } |
| 10264 | |
| 10265 | static int hdd_register_req_mode(hdd_context_t *hdd_ctx, |
| 10266 | enum tQDF_GLOBAL_CON_MODE mode) |
| 10267 | { |
| 10268 | hdd_adapter_t *adapter; |
| 10269 | int ret = 0; |
| 10270 | bool rtnl_held; |
| 10271 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 10272 | QDF_STATUS status; |
| 10273 | |
| 10274 | if (!qdf_dev) { |
| 10275 | hdd_err("qdf device context is Null return!"); |
| 10276 | return -EINVAL; |
| 10277 | } |
| 10278 | |
| 10279 | rtnl_held = hdd_hold_rtnl_lock(); |
| 10280 | switch (mode) { |
| 10281 | case QDF_GLOBAL_MISSION_MODE: |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10282 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 10283 | if (ret) |
| 10284 | hdd_alert("Failed to open interfaces: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10285 | break; |
| 10286 | case QDF_GLOBAL_FTM_MODE: |
| 10287 | adapter = hdd_open_adapter(hdd_ctx, QDF_FTM_MODE, "wlan%d", |
| 10288 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 10289 | NET_NAME_UNKNOWN, rtnl_held); |
| 10290 | if (adapter == NULL) |
| 10291 | ret = -EINVAL; |
| 10292 | break; |
| 10293 | case QDF_GLOBAL_MONITOR_MODE: |
| 10294 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
| 10295 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 10296 | NET_NAME_UNKNOWN, rtnl_held); |
| 10297 | if (adapter == NULL) |
| 10298 | ret = -EINVAL; |
| 10299 | break; |
| 10300 | case QDF_GLOBAL_EPPING_MODE: |
| 10301 | status = epping_open(); |
| 10302 | if (status != QDF_STATUS_SUCCESS) { |
| 10303 | hdd_err("Failed to open in eeping mode: %d", status); |
| 10304 | ret = -EINVAL; |
| 10305 | break; |
| 10306 | } |
| 10307 | ret = epping_enable(qdf_dev->dev); |
| 10308 | if (ret) { |
| 10309 | hdd_err("Failed to enable in epping mode : %d", ret); |
| 10310 | epping_close(); |
| 10311 | } |
| 10312 | break; |
| 10313 | default: |
| 10314 | hdd_info("Mode not supported"); |
| 10315 | ret = -ENOTSUPP; |
| 10316 | break; |
| 10317 | } |
| 10318 | hdd_release_rtnl_lock(); |
| 10319 | rtnl_held = false; |
| 10320 | return ret; |
| 10321 | } |
| 10322 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10323 | /** |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 10324 | * __con_mode_handler() - Handles module param con_mode change |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10325 | * @kmessage: con mode name on which driver to be bring up |
| 10326 | * @kp: The associated kernel parameter |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 10327 | * @hdd_ctx: Pointer to the global HDD context |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10328 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10329 | * This function is invoked when user updates con mode using sys entry, |
| 10330 | * to initialize and bring-up driver in that specific mode. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10331 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10332 | * Return - 0 on success and failure code on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10333 | */ |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10334 | static int __con_mode_handler(const char *kmessage, struct kernel_param *kp, |
| 10335 | hdd_context_t *hdd_ctx) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10336 | { |
| 10337 | int ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10338 | hdd_adapter_t *adapter; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10339 | enum tQDF_GLOBAL_CON_MODE curr_mode; |
| 10340 | enum tQDF_ADAPTER_MODE adapter_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10341 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 10342 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 10343 | if (ret) |
| 10344 | return ret; |
| 10345 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10346 | cds_set_load_in_progress(true); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10347 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10348 | hdd_info("con_mode handler: %s", kmessage); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10349 | ret = param_set_int(kmessage, kp); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10350 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10351 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10352 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10353 | if (!(is_con_mode_valid(con_mode))) { |
| 10354 | hdd_err("invlaid con_mode %d", con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10355 | ret = -EINVAL; |
| 10356 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10357 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10358 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10359 | curr_mode = hdd_get_conparam(); |
| 10360 | if (curr_mode == con_mode) { |
| 10361 | hdd_err("curr mode: %d is same as user triggered mode %d", |
| 10362 | curr_mode, con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10363 | ret = 0; |
| 10364 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10365 | } |
| 10366 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10367 | /* Cleanup present mode before switching to new mode */ |
| 10368 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 10369 | |
Prashanth Bhatta | 2ac92bd | 2016-10-11 16:08:00 -0700 | [diff] [blame] | 10370 | ret = hdd_wlan_stop_modules(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10371 | if (ret) { |
| 10372 | hdd_err("Stop wlan modules failed"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10373 | goto reset_flags; |
| 10374 | } |
| 10375 | |
| 10376 | hdd_set_conparam(con_mode); |
| 10377 | |
| 10378 | /* Register for new con_mode & then kick_start modules again */ |
| 10379 | ret = hdd_register_req_mode(hdd_ctx, con_mode); |
| 10380 | if (ret) { |
| 10381 | hdd_err("Failed to register for new mode"); |
| 10382 | goto reset_flags; |
| 10383 | } |
| 10384 | |
| 10385 | adapter_mode = hdd_get_adpter_mode(con_mode); |
| 10386 | if (adapter_mode == QDF_MAX_NO_OF_MODE) { |
| 10387 | hdd_err("invalid adapter"); |
| 10388 | ret = -EINVAL; |
| 10389 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10390 | } |
| 10391 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 10392 | adapter = hdd_get_adapter(hdd_ctx, adapter_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10393 | if (!adapter) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10394 | hdd_err("Failed to get adapter:%d", adapter_mode); |
| 10395 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10396 | } |
| 10397 | |
| 10398 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 10399 | if (ret) { |
| 10400 | hdd_err("Start wlan modules failed: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10401 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10402 | } |
| 10403 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10404 | if (con_mode == QDF_GLOBAL_MONITOR_MODE || |
| 10405 | con_mode == QDF_GLOBAL_FTM_MODE) { |
| 10406 | if (hdd_start_adapter(adapter)) { |
| 10407 | hdd_err("Failed to start %s adapter", kmessage); |
| 10408 | ret = -EINVAL; |
| 10409 | goto reset_flags; |
| 10410 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10411 | } |
| 10412 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 10413 | hdd_info("Mode successfully changed to %s", kmessage); |
| 10414 | ret = 0; |
| 10415 | |
| 10416 | reset_flags: |
| 10417 | cds_set_load_in_progress(false); |
| 10418 | return ret; |
| 10419 | } |
| 10420 | |
| 10421 | |
| 10422 | static int con_mode_handler(const char *kmessage, struct kernel_param *kp) |
| 10423 | { |
| 10424 | int ret; |
| 10425 | hdd_context_t *hdd_ctx; |
| 10426 | |
| 10427 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10428 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 10429 | if (ret) |
| 10430 | return ret; |
| 10431 | |
| 10432 | cds_ssr_protect(__func__); |
| 10433 | ret = __con_mode_handler(kmessage, kp, hdd_ctx); |
| 10434 | cds_ssr_unprotect(__func__); |
| 10435 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10436 | return ret; |
| 10437 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10438 | |
| 10439 | /** |
| 10440 | * hdd_get_conparam() - driver exit point |
| 10441 | * |
| 10442 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 10443 | * |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10444 | * Return: enum tQDF_GLOBAL_CON_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10445 | */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10446 | enum tQDF_GLOBAL_CON_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10447 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10448 | return (enum tQDF_GLOBAL_CON_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10449 | } |
| 10450 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 10451 | void hdd_set_conparam(uint32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10452 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 10453 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10454 | } |
| 10455 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 10456 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10457 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 10458 | * @hdd_ctx: HDD context |
| 10459 | * |
| 10460 | * Cleans up the pre cac interface, if it exists |
| 10461 | * |
| 10462 | * Return: None |
| 10463 | */ |
| 10464 | void hdd_clean_up_pre_cac_interface(hdd_context_t *hdd_ctx) |
| 10465 | { |
| 10466 | uint8_t session_id; |
| 10467 | QDF_STATUS status; |
| 10468 | struct hdd_adapter_s *precac_adapter; |
| 10469 | |
| 10470 | status = wlan_sap_get_pre_cac_vdev_id(hdd_ctx->hHal, &session_id); |
| 10471 | if (QDF_IS_STATUS_ERROR(status)) { |
| 10472 | hdd_err("failed to get pre cac vdev id"); |
| 10473 | return; |
| 10474 | } |
| 10475 | |
| 10476 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, session_id); |
| 10477 | if (!precac_adapter) { |
| 10478 | hdd_err("invalid pre cac adapater"); |
| 10479 | return; |
| 10480 | } |
| 10481 | |
| 10482 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 10483 | wlan_hdd_sap_pre_cac_failure, |
| 10484 | (void *)precac_adapter); |
| 10485 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 10486 | |
| 10487 | } |
| 10488 | |
| 10489 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 10490 | * hdd_update_ol_config - API to update ol configuration parameters |
| 10491 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 10492 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 10493 | * Return: void |
| 10494 | */ |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 10495 | static void hdd_update_ol_config(hdd_context_t *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 10496 | { |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 10497 | struct ol_config_info cfg; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 10498 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 10499 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 10500 | if (!ol_ctx) |
| 10501 | return; |
| 10502 | |
| 10503 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
| 10504 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 10505 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 10506 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 10507 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 10508 | |
| 10509 | ol_init_ini_config(ol_ctx, &cfg); |
| 10510 | } |
| 10511 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 10512 | #ifdef FEATURE_RUNTIME_PM |
| 10513 | /** |
| 10514 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 10515 | * @hdd_ctx: hdd context |
| 10516 | * @cfg: pointer to the configuration memory being populated |
| 10517 | * |
| 10518 | * Return: void |
| 10519 | */ |
| 10520 | static void hdd_populate_runtime_cfg(hdd_context_t *hdd_ctx, |
| 10521 | struct hif_config_info *cfg) |
| 10522 | { |
| 10523 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
| 10524 | cfg->runtime_pm_delay = hdd_ctx->config->runtime_pm_delay; |
| 10525 | } |
| 10526 | #else |
| 10527 | static void hdd_populate_runtime_cfg(hdd_context_t *hdd_ctx, |
| 10528 | struct hif_config_info *cfg) |
| 10529 | { |
| 10530 | } |
| 10531 | #endif |
| 10532 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 10533 | /** |
| 10534 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 10535 | * @hdd_ctx: HDD Context |
| 10536 | * |
| 10537 | * Return: void |
| 10538 | */ |
| 10539 | static void hdd_update_hif_config(hdd_context_t *hdd_ctx) |
| 10540 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 10541 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 10542 | struct hif_config_info cfg; |
| 10543 | |
| 10544 | if (!scn) |
| 10545 | return; |
| 10546 | |
| 10547 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 10548 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 10549 | hif_init_ini_config(scn, &cfg); |
| 10550 | } |
| 10551 | |
| 10552 | /** |
| 10553 | * hdd_update_config() - Initialize driver per module ini parameters |
| 10554 | * @hdd_ctx: HDD Context |
| 10555 | * |
| 10556 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 10557 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 10558 | */ |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 10559 | int hdd_update_config(hdd_context_t *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 10560 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 10561 | int ret; |
| 10562 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 10563 | hdd_update_ol_config(hdd_ctx); |
| 10564 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 10565 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 10566 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 10567 | else |
| 10568 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 10569 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 10570 | |
| 10571 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 10572 | } |
| 10573 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 10574 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 10575 | /** |
| 10576 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 10577 | * @psoc_cfg: pmo psoc Configuration |
| 10578 | * @hdd_ctx: Pointer to hdd context |
| 10579 | * |
| 10580 | * Return: none |
| 10581 | */ |
| 10582 | static inline void hdd_ra_populate_pmo_config( |
| 10583 | struct pmo_psoc_cfg *psoc_cfg, |
| 10584 | hdd_context_t *hdd_ctx) |
| 10585 | { |
| 10586 | psoc_cfg->ra_ratelimit_interval = |
| 10587 | hdd_ctx->config->RArateLimitInterval; |
| 10588 | psoc_cfg->ra_ratelimit_enable = |
| 10589 | hdd_ctx->config->IsRArateLimitEnabled; |
| 10590 | } |
| 10591 | #else |
| 10592 | static inline void hdd_ra_populate_pmo_config( |
| 10593 | struct cds_config_info *cds_cfg, |
| 10594 | hdd_context_t *hdd_ctx) |
| 10595 | { |
| 10596 | } |
| 10597 | #endif |
| 10598 | /** |
| 10599 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 10600 | * @hdd_ctx: HDD context |
| 10601 | * |
| 10602 | * Return: void |
| 10603 | */ |
| 10604 | static int hdd_update_pmo_config(hdd_context_t *hdd_ctx) |
| 10605 | { |
| 10606 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 10607 | struct pmo_psoc_cfg psoc_cfg; |
| 10608 | QDF_STATUS status; |
| 10609 | |
| 10610 | /* |
| 10611 | * Value of hdd_ctx->wowEnable can be, |
| 10612 | * 0 - Disable both magic pattern match and pattern byte match. |
| 10613 | * 1 - Enable magic pattern match on all interfaces. |
| 10614 | * 2 - Enable pattern byte match on all interfaces. |
| 10615 | * 3 - Enable both magic patter and pattern byte match on |
| 10616 | * all interfaces. |
| 10617 | */ |
| 10618 | psoc_cfg.magic_ptrn_enable = |
| 10619 | (hdd_ctx->config->wowEnable & 0x01) ? true : false; |
| 10620 | psoc_cfg.ptrn_match_enable_all_vdev = |
| 10621 | (hdd_ctx->config->wowEnable & 0x02) ? true : false; |
| 10622 | psoc_cfg.bpf_enable = |
| 10623 | hdd_ctx->config->bpf_packet_filter_enable; |
| 10624 | psoc_cfg.arp_offload_enable = hdd_ctx->config->fhostArpOffload; |
| 10625 | psoc_cfg.ns_offload_enable_static = hdd_ctx->config->fhostNSOffload; |
| 10626 | if (hdd_ctx->config->fhostNSOffload) |
| 10627 | psoc_cfg.ns_offload_enable_dynamic = true; |
| 10628 | psoc_cfg.ssdp = hdd_ctx->config->ssdp; |
| 10629 | psoc_cfg.enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 10630 | psoc_cfg.active_mode_offload = |
| 10631 | hdd_ctx->config->active_mode_offload; |
| 10632 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
| 10633 | psoc_cfg.max_wow_filters = hdd_ctx->config->maxWoWFilters; |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 10634 | psoc_cfg.sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 10635 | psoc_cfg.sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 10636 | psoc_cfg.sta_max_li_mod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 10637 | psoc_cfg.power_save_mode = |
| 10638 | hdd_ctx->config->enablePowersaveOffload; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 10639 | |
| 10640 | hdd_ra_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 10641 | hdd_nan_populate_pmo_config(&psoc_cfg, hdd_ctx); |
| 10642 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 10643 | status = pmo_ucfg_update_psoc_config(psoc, &psoc_cfg); |
| 10644 | if (status != QDF_STATUS_SUCCESS) { |
| 10645 | hdd_err("failed pmo psoc configuration"); |
| 10646 | return -EINVAL; |
| 10647 | } |
| 10648 | |
| 10649 | return 0; |
| 10650 | } |
| 10651 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 10652 | #ifdef NAPIER_SCAN |
| 10653 | /** |
| 10654 | * hdd_update_scan_config - API to update scan configuration parameters |
| 10655 | * @hdd_ctx: HDD context |
| 10656 | * |
| 10657 | * Return: 0 if success else err |
| 10658 | */ |
| 10659 | static int hdd_update_scan_config(hdd_context_t *hdd_ctx) |
| 10660 | { |
| 10661 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 10662 | struct scan_user_cfg scan_cfg; |
| 10663 | struct hdd_config *cfg = hdd_ctx->config; |
| 10664 | QDF_STATUS status; |
| 10665 | |
| 10666 | scan_cfg.active_dwell = cfg->nActiveMaxChnTime; |
| 10667 | scan_cfg.passive_dwell = cfg->nPassiveMaxChnTime; |
| 10668 | scan_cfg.conc_active_dwell = cfg->nActiveMaxChnTimeConc; |
| 10669 | scan_cfg.conc_passive_dwell = cfg->nPassiveMaxChnTimeConc; |
| 10670 | scan_cfg.conc_max_rest_time = cfg->nRestTimeConc; |
| 10671 | scan_cfg.conc_min_rest_time = cfg->min_rest_time_conc; |
| 10672 | scan_cfg.conc_idle_time = cfg->idle_time_conc; |
| 10673 | scan_cfg.scan_cache_aging_time = cfg->scanAgingTimeout; |
| 10674 | scan_cfg.scan_dwell_time_mode = cfg->scan_adaptive_dwell_mode; |
| 10675 | |
| 10676 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 10677 | if (status != QDF_STATUS_SUCCESS) { |
| 10678 | hdd_err("failed pmo psoc configuration"); |
| 10679 | return -EINVAL; |
| 10680 | } |
| 10681 | |
| 10682 | return 0; |
| 10683 | } |
| 10684 | #else |
| 10685 | static int hdd_update_scan_config(hdd_context_t *hdd_ctx) |
| 10686 | { |
| 10687 | return 0; |
| 10688 | } |
| 10689 | #endif |
| 10690 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 10691 | int hdd_update_components_config(hdd_context_t *hdd_ctx) |
| 10692 | { |
| 10693 | int ret; |
| 10694 | |
| 10695 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 10696 | if (ret) |
| 10697 | return ret; |
| 10698 | ret = hdd_update_scan_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 10699 | |
| 10700 | return ret; |
| 10701 | } |
| 10702 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 10703 | /** |
| 10704 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 10705 | * @mode : cfg80211 DFS mode |
| 10706 | * |
| 10707 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 10708 | */ |
| 10709 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 10710 | { |
| 10711 | switch (mode) { |
| 10712 | case DFS_MODE_ENABLE: |
| 10713 | return ACS_DFS_MODE_ENABLE; |
| 10714 | break; |
| 10715 | case DFS_MODE_DISABLE: |
| 10716 | return ACS_DFS_MODE_DISABLE; |
| 10717 | break; |
| 10718 | case DFS_MODE_DEPRIORITIZE: |
| 10719 | return ACS_DFS_MODE_DEPRIORITIZE; |
| 10720 | break; |
| 10721 | default: |
| 10722 | hdd_err("ACS dfs mode is NONE"); |
| 10723 | return ACS_DFS_MODE_NONE; |
| 10724 | } |
| 10725 | } |
| 10726 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 10727 | /** |
| 10728 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 10729 | * @hddctx: pointer to hdd context |
| 10730 | * @set_value: enable/disable |
| 10731 | * |
| 10732 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 10733 | * Host(even though it is duplicate). When Host send vendor command |
| 10734 | * disable,FW doesn't perform any action. Whenever any change in |
| 10735 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 10736 | * |
| 10737 | * return - 0 on success, appropriate error values on failure. |
| 10738 | */ |
| 10739 | int hdd_enable_disable_ca_event(hdd_context_t *hddctx, uint8_t set_value) |
| 10740 | { |
| 10741 | QDF_STATUS status; |
| 10742 | |
| 10743 | if (0 != wlan_hdd_validate_context(hddctx)) { |
| 10744 | return -EAGAIN; |
| 10745 | } |
| 10746 | |
| 10747 | if (!hddctx->config->goptimize_chan_avoid_event) { |
| 10748 | hdd_warn("goptimize_chan_avoid_event ini param disabled"); |
| 10749 | return -EINVAL; |
| 10750 | } |
| 10751 | |
| 10752 | status = sme_enable_disable_chanavoidind_event(hddctx->hHal, set_value); |
| 10753 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10754 | hdd_err("Failed to send chan avoid command to SME"); |
| 10755 | return -EINVAL; |
| 10756 | } |
| 10757 | return 0; |
| 10758 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 10759 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 10760 | /** |
| 10761 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 10762 | * @value: value to set |
| 10763 | * |
| 10764 | * This function will set the passed value to roaming in progress flag. |
| 10765 | * |
| 10766 | * Return: None |
| 10767 | */ |
| 10768 | void hdd_set_roaming_in_progress(bool value) |
| 10769 | { |
| 10770 | hdd_context_t *hdd_ctx; |
| 10771 | |
| 10772 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10773 | if (!hdd_ctx) { |
| 10774 | hdd_err("HDD context is NULL"); |
| 10775 | return; |
| 10776 | } |
| 10777 | |
| 10778 | hdd_ctx->roaming_in_progress = value; |
| 10779 | hdd_info("Roaming in Progress set to %d", value); |
| 10780 | } |
| 10781 | |
| 10782 | /** |
| 10783 | * hdd_is_roaming_in_progress() - check if roaming is in progress |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 10784 | * @adapter - HDD adapter |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 10785 | * |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 10786 | * 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] | 10787 | */ |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 10788 | bool hdd_is_roaming_in_progress(hdd_adapter_t *adapter) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 10789 | { |
| 10790 | hdd_context_t *hdd_ctx; |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 10791 | bool ret_status = false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 10792 | |
| 10793 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10794 | if (!hdd_ctx) { |
| 10795 | hdd_err("HDD context is NULL"); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 10796 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 10797 | } |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 10798 | hdd_info("dev mode = %d, roaming_in_progress = %d", |
| 10799 | adapter->device_mode, hdd_ctx->roaming_in_progress); |
| 10800 | ret_status = ((adapter->device_mode == QDF_STA_MODE) && |
| 10801 | hdd_ctx->roaming_in_progress); |
| 10802 | |
| 10803 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 10804 | } |
| 10805 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10806 | /* Register the module init/exit functions */ |
| 10807 | module_init(hdd_module_init); |
| 10808 | module_exit(hdd_module_exit); |
| 10809 | |
| 10810 | MODULE_LICENSE("Dual BSD/GPL"); |
| 10811 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 10812 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 10813 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10814 | module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode, |
| 10815 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10816 | |
| 10817 | module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath, |
| 10818 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 10819 | |
| 10820 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 10821 | |
| 10822 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 10823 | |
| 10824 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |