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" |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 57 | #include "qdf_types.h" |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 58 | #include "qdf_trace.h" |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 59 | #include <cdp_txrx_peer_ops.h> |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 60 | #include <cdp_txrx_misc.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 61 | |
| 62 | #include <net/addrconf.h> |
| 63 | #include <linux/wireless.h> |
| 64 | #include <net/cfg80211.h> |
| 65 | #include <linux/inetdevice.h> |
| 66 | #include <net/addrconf.h> |
| 67 | #include "wlan_hdd_cfg80211.h" |
| 68 | #include "wlan_hdd_ext_scan.h" |
| 69 | #include "wlan_hdd_p2p.h" |
| 70 | #include <linux/rtnetlink.h> |
| 71 | #include "sap_api.h" |
| 72 | #include <linux/semaphore.h> |
| 73 | #include <linux/ctype.h> |
| 74 | #include <linux/compat.h> |
| 75 | #ifdef MSM_PLATFORM |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 76 | #include <soc/qcom/subsystem_restart.h> |
| 77 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 78 | #include <wlan_hdd_hostapd.h> |
| 79 | #include <wlan_hdd_softap_tx_rx.h> |
| 80 | #include "cfg_api.h" |
| 81 | #include "qwlan_version.h" |
| 82 | #include "wma_types.h" |
| 83 | #include "wlan_hdd_tdls.h" |
| 84 | #ifdef FEATURE_WLAN_CH_AVOID |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 85 | #include "cds_regdomain.h" |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 86 | #include "cdp_txrx_flow_ctrl_v2.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 87 | #endif /* FEATURE_WLAN_CH_AVOID */ |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 88 | #include "pld_common.h" |
Tushnim Bhattacharyya | 15596cf | 2016-02-12 11:57:02 -0800 | [diff] [blame] | 89 | #include "wlan_hdd_ocb.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 90 | #include "wlan_hdd_nan.h" |
| 91 | #include "wlan_hdd_debugfs.h" |
| 92 | #include "wlan_hdd_driver_ops.h" |
| 93 | #include "epping_main.h" |
| 94 | #include "wlan_hdd_memdump.h" |
| 95 | |
| 96 | #include <wlan_hdd_ipa.h> |
| 97 | #include "hif.h" |
| 98 | #include "wma.h" |
| 99 | #include "cds_concurrency.h" |
Manikandan Mohan | dcc21ba | 2016-03-15 14:31:56 -0700 | [diff] [blame] | 100 | #include "wlan_hdd_tsf.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 101 | #include "wlan_hdd_green_ap.h" |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 102 | #include "bmi.h" |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 103 | #include <wlan_hdd_regulatory.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 104 | #include "wlan_hdd_lpass.h" |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 105 | #include "nan_api.h" |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 106 | #include <wlan_hdd_napi.h> |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 107 | #include "wlan_hdd_disa.h" |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 108 | #include <dispatcher_init_deinit.h> |
Rajeev Kumar | 699debf | 2017-01-06 14:17:00 -0800 | [diff] [blame] | 109 | #include "wlan_hdd_object_manager.h" |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 110 | #include "cds_utils.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 111 | |
| 112 | #ifdef MODULE |
| 113 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 114 | #else |
| 115 | #define WLAN_MODULE_NAME "wlan" |
| 116 | #endif |
| 117 | |
| 118 | #ifdef TIMER_MANAGER |
| 119 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 120 | #else |
| 121 | #define TIMER_MANAGER_STR "" |
| 122 | #endif |
| 123 | |
| 124 | #ifdef MEMORY_DEBUG |
| 125 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 126 | #else |
| 127 | #define MEMORY_DEBUG_STR "" |
| 128 | #endif |
| 129 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 130 | #ifndef MODULE |
| 131 | static struct gwlan_loader *wlan_loader; |
| 132 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 133 | struct kobj_attribute *attr, |
| 134 | const char *buf, size_t count); |
| 135 | struct gwlan_loader { |
| 136 | bool loaded_state; |
| 137 | struct kobject *boot_wlan_obj; |
| 138 | struct attribute_group *attr_group; |
| 139 | }; |
| 140 | |
| 141 | static struct kobj_attribute wlan_boot_attribute = |
| 142 | __ATTR(boot_wlan, 0220, NULL, wlan_boot_cb); |
| 143 | |
| 144 | static struct attribute *attrs[] = { |
| 145 | &wlan_boot_attribute.attr, |
| 146 | NULL, |
| 147 | }; |
| 148 | |
| 149 | #define MODULE_INITIALIZED 1 |
| 150 | #endif |
| 151 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 152 | /* the Android framework expects this param even though we don't use it */ |
| 153 | #define BUF_LEN 20 |
| 154 | static char fwpath_buffer[BUF_LEN]; |
| 155 | static struct kparam_string fwpath = { |
| 156 | .string = fwpath_buffer, |
| 157 | .maxlen = BUF_LEN, |
| 158 | }; |
| 159 | |
| 160 | static char *country_code; |
| 161 | static int enable_11d = -1; |
| 162 | static int enable_dfs_chan_scan = -1; |
| 163 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 164 | /* |
| 165 | * spinlock for synchronizing asynchronous request/response |
| 166 | * (full description of use in wlan_hdd_main.h) |
| 167 | */ |
| 168 | DEFINE_SPINLOCK(hdd_context_lock); |
| 169 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 170 | #define WLAN_NLINK_CESIUM 30 |
| 171 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 172 | static qdf_wake_lock_t wlan_wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 173 | |
| 174 | #define WOW_MAX_FILTER_LISTS 1 |
| 175 | #define WOW_MAX_FILTERS_PER_LIST 4 |
| 176 | #define WOW_MIN_PATTERN_SIZE 6 |
| 177 | #define WOW_MAX_PATTERN_SIZE 64 |
| 178 | |
| 179 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 180 | static const struct wiphy_wowlan_support wowlan_support_reg_init = { |
| 181 | .flags = WIPHY_WOWLAN_ANY | |
| 182 | WIPHY_WOWLAN_MAGIC_PKT | |
| 183 | WIPHY_WOWLAN_DISCONNECT | |
| 184 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 185 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 186 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 187 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 188 | WIPHY_WOWLAN_RFKILL_RELEASE, |
| 189 | .n_patterns = WOW_MAX_FILTER_LISTS * WOW_MAX_FILTERS_PER_LIST, |
| 190 | .pattern_min_len = WOW_MIN_PATTERN_SIZE, |
| 191 | .pattern_max_len = WOW_MAX_PATTERN_SIZE, |
| 192 | }; |
| 193 | #endif |
| 194 | |
| 195 | /* internal function declaration */ |
| 196 | |
| 197 | struct sock *cesium_nl_srv_sock; |
| 198 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 199 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 200 | void wlan_hdd_auto_shutdown_cb(void); |
| 201 | #endif |
| 202 | |
| 203 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 204 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
| 205 | * @hdd_ctx: pointer to hdd_context_t |
| 206 | * |
| 207 | * Return: none |
| 208 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 209 | static void hdd_set_rps_cpu_mask(hdd_context_t *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 210 | { |
| 211 | hdd_adapter_t *adapter; |
| 212 | hdd_adapter_list_node_t *adapter_node, *next; |
| 213 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 214 | |
| 215 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 216 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 217 | adapter = adapter_node->pAdapter; |
| 218 | if (NULL != adapter) |
| 219 | hdd_send_rps_ind(adapter); |
| 220 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 221 | adapter_node = next; |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 226 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 227 | * @vdev_id: vdev_id |
| 228 | * @action: action type |
| 229 | * @reason: reason type |
| 230 | * |
| 231 | * Return: none |
| 232 | */ |
| 233 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 234 | enum netif_action_type action, enum netif_reason_type reason) |
| 235 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 236 | hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 237 | hdd_adapter_t *adapter; |
| 238 | |
| 239 | if (!hdd_ctx) { |
| 240 | hdd_err("hdd ctx is NULL"); |
| 241 | return; |
| 242 | } |
| 243 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 244 | |
| 245 | wlan_hdd_netif_queue_control(adapter, action, reason); |
| 246 | return; |
| 247 | } |
| 248 | |
| 249 | /* |
| 250 | * Store WLAN driver version info in a global variable such that crash debugger |
| 251 | * can extract it from driver debug symbol and crashdump for post processing |
| 252 | */ |
| 253 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR; |
| 254 | |
| 255 | /** |
| 256 | * hdd_device_mode_to_string() - return string conversion of device mode |
| 257 | * @device_mode: device mode |
| 258 | * |
| 259 | * This utility function helps log string conversion of device mode. |
| 260 | * |
| 261 | * Return: string conversion of device mode, if match found; |
| 262 | * "Unknown" otherwise. |
| 263 | */ |
| 264 | const char *hdd_device_mode_to_string(uint8_t device_mode) |
| 265 | { |
| 266 | switch (device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 267 | CASE_RETURN_STRING(QDF_STA_MODE); |
| 268 | CASE_RETURN_STRING(QDF_SAP_MODE); |
| 269 | CASE_RETURN_STRING(QDF_P2P_CLIENT_MODE); |
| 270 | CASE_RETURN_STRING(QDF_P2P_GO_MODE); |
| 271 | CASE_RETURN_STRING(QDF_FTM_MODE); |
| 272 | CASE_RETURN_STRING(QDF_IBSS_MODE); |
| 273 | CASE_RETURN_STRING(QDF_P2P_DEVICE_MODE); |
| 274 | CASE_RETURN_STRING(QDF_OCB_MODE); |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 275 | CASE_RETURN_STRING(QDF_NDI_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 276 | default: |
| 277 | return "Unknown"; |
| 278 | } |
| 279 | } |
| 280 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 281 | /** |
| 282 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 283 | * @adapter: HDD adapter |
| 284 | * @chan_number: Channel number |
| 285 | * @chan_bw: Bandwidth |
| 286 | * |
| 287 | * Checks if the given bandwidth is valid for the given channel number. |
| 288 | * |
| 289 | * Return: 0 for success, non-zero for failure |
| 290 | */ |
| 291 | int hdd_validate_channel_and_bandwidth(hdd_adapter_t *adapter, |
| 292 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 293 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 294 | { |
| 295 | uint8_t chan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 296 | uint32_t len = WNI_CFG_VALID_CHANNEL_LIST_LEN, i; |
| 297 | bool found = false; |
| 298 | tHalHandle hal; |
| 299 | |
| 300 | hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 301 | if (!hal) { |
| 302 | hdd_err("Invalid HAL context"); |
| 303 | return -EINVAL; |
| 304 | } |
| 305 | |
| 306 | if (0 != sme_cfg_get_str(hal, WNI_CFG_VALID_CHANNEL_LIST, chan, &len)) { |
| 307 | hdd_err("No valid channel list"); |
| 308 | return -EOPNOTSUPP; |
| 309 | } |
| 310 | |
| 311 | for (i = 0; i < len; i++) { |
| 312 | if (chan[i] == chan_number) { |
| 313 | found = true; |
| 314 | break; |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | if (found == false) { |
| 319 | hdd_err("Channel not in driver's valid channel list"); |
| 320 | return -EOPNOTSUPP; |
| 321 | } |
| 322 | |
| 323 | if ((!CDS_IS_CHANNEL_24GHZ(chan_number)) && |
| 324 | (!CDS_IS_CHANNEL_5GHZ(chan_number))) { |
| 325 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 326 | return -EINVAL; |
| 327 | } |
| 328 | |
| 329 | if (CDS_IS_CHANNEL_24GHZ(chan_number)) { |
| 330 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 331 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 332 | return -EINVAL; |
| 333 | } |
| 334 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 335 | (chan_bw != CH_WIDTH_MAX)) { |
| 336 | hdd_err("Only BW20 possible on channel 14"); |
| 337 | return -EINVAL; |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | if (CDS_IS_CHANNEL_5GHZ(chan_number)) { |
| 342 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 343 | (chan_bw != CH_WIDTH_MAX)) { |
| 344 | hdd_err("Only BW20 possible on channel 165"); |
| 345 | return -EINVAL; |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | return 0; |
| 350 | } |
| 351 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 352 | static int __hdd_netdev_notifier_call(struct notifier_block *nb, |
| 353 | unsigned long state, void *data) |
| 354 | { |
| 355 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 356 | struct netdev_notifier_info *dev_notif_info = data; |
| 357 | struct net_device *dev = dev_notif_info->dev; |
| 358 | #else |
| 359 | struct net_device *dev = data; |
| 360 | #endif |
| 361 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 362 | hdd_context_t *hdd_ctx; |
| 363 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 364 | ENTER_DEV(dev); |
| 365 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 366 | /* Make sure that this callback corresponds to our device. */ |
| 367 | if ((strncmp(dev->name, "wlan", 4)) && (strncmp(dev->name, "p2p", 3))) |
| 368 | return NOTIFY_DONE; |
| 369 | |
Samuel Ahn | c9c48ca | 2016-09-19 15:46:36 +0530 | [diff] [blame] | 370 | if ((adapter->magic != WLAN_HDD_ADAPTER_MAGIC) || |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 371 | (adapter->dev != dev)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 372 | hdd_err("device adapter is not matching!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 373 | return NOTIFY_DONE; |
| 374 | } |
| 375 | |
| 376 | if (!dev->ieee80211_ptr) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 377 | hdd_err("ieee80211_ptr is NULL!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 378 | return NOTIFY_DONE; |
| 379 | } |
| 380 | |
| 381 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 382 | if (NULL == hdd_ctx) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 383 | hdd_alert("HDD Context Null Pointer"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 384 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 385 | return NOTIFY_DONE; |
| 386 | } |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 387 | if (cds_is_driver_recovering()) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 388 | return NOTIFY_DONE; |
| 389 | |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 390 | hdd_notice("%s New Net Device State = %lu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 391 | dev->name, state); |
| 392 | |
| 393 | switch (state) { |
| 394 | case NETDEV_REGISTER: |
| 395 | break; |
| 396 | |
| 397 | case NETDEV_UNREGISTER: |
| 398 | break; |
| 399 | |
| 400 | case NETDEV_UP: |
| 401 | sme_ch_avoid_update_req(hdd_ctx->hHal); |
| 402 | break; |
| 403 | |
| 404 | case NETDEV_DOWN: |
| 405 | break; |
| 406 | |
| 407 | case NETDEV_CHANGE: |
| 408 | if (true == adapter->isLinkUpSvcNeeded) |
| 409 | complete(&adapter->linkup_event_var); |
| 410 | break; |
| 411 | |
| 412 | case NETDEV_GOING_DOWN: |
| 413 | if (adapter->scan_info.mScanPending != false) { |
| 414 | unsigned long rc; |
| 415 | INIT_COMPLETION(adapter->scan_info. |
| 416 | abortscan_event_var); |
| 417 | hdd_abort_mac_scan(adapter->pHddCtx, |
| 418 | adapter->sessionId, |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 419 | INVALID_SCAN_ID, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 420 | eCSR_SCAN_ABORT_DEFAULT); |
| 421 | rc = wait_for_completion_timeout( |
| 422 | &adapter->scan_info.abortscan_event_var, |
| 423 | msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN)); |
| 424 | if (!rc) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 425 | hdd_err("Timeout occurred while waiting for abortscan"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 426 | } |
| 427 | } else { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 428 | hdd_notice("Scan is not Pending from user"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 429 | } |
| 430 | break; |
| 431 | |
| 432 | default: |
| 433 | break; |
| 434 | } |
| 435 | |
| 436 | return NOTIFY_DONE; |
| 437 | } |
| 438 | |
| 439 | /** |
| 440 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 441 | * @nb: pointer to notifier block |
| 442 | * @state: state |
| 443 | * @ndev: ndev pointer |
| 444 | * |
| 445 | * Return: 0 on success, error number otherwise. |
| 446 | */ |
| 447 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 448 | unsigned long state, |
| 449 | void *ndev) |
| 450 | { |
| 451 | int ret; |
| 452 | |
| 453 | cds_ssr_protect(__func__); |
| 454 | ret = __hdd_netdev_notifier_call(nb, state, ndev); |
| 455 | cds_ssr_unprotect(__func__); |
| 456 | |
| 457 | return ret; |
| 458 | } |
| 459 | |
| 460 | struct notifier_block hdd_netdev_notifier = { |
| 461 | .notifier_call = hdd_netdev_notifier_call, |
| 462 | }; |
| 463 | |
| 464 | /* variable to hold the insmod parameters */ |
| 465 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 466 | |
| 467 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 468 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 469 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 470 | /** |
| 471 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 472 | * @ch_width: NL channel width |
| 473 | * |
| 474 | * Converts the NL channel width to the driver's internal representation |
| 475 | * |
| 476 | * Return: Converted channel width. In case of non matching NL channel width, |
| 477 | * CH_WIDTH_MAX will be returned. |
| 478 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 479 | 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] | 480 | { |
| 481 | switch (ch_width) { |
| 482 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 483 | case NL80211_CHAN_WIDTH_20: |
| 484 | return CH_WIDTH_20MHZ; |
| 485 | case NL80211_CHAN_WIDTH_40: |
| 486 | return CH_WIDTH_40MHZ; |
| 487 | break; |
| 488 | case NL80211_CHAN_WIDTH_80: |
| 489 | return CH_WIDTH_80MHZ; |
| 490 | case NL80211_CHAN_WIDTH_80P80: |
| 491 | return CH_WIDTH_80P80MHZ; |
| 492 | case NL80211_CHAN_WIDTH_160: |
| 493 | return CH_WIDTH_160MHZ; |
| 494 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 495 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 496 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 497 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 498 | default: |
| 499 | hdd_err("Invalid channel width %d, setting to default", |
| 500 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 501 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 502 | } |
| 503 | } |
| 504 | |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 505 | /* wlan_hdd_find_opclass() - Find operating class for a channel |
| 506 | * @hal: handler to HAL |
| 507 | * @channel: channel id |
| 508 | * @bw_offset: bandwidth offset |
| 509 | * |
| 510 | * Function invokes sme api to find the operating class |
| 511 | * |
| 512 | * Return: operating class |
| 513 | */ |
| 514 | uint8_t wlan_hdd_find_opclass(tHalHandle hal, uint8_t channel, |
| 515 | uint8_t bw_offset) |
| 516 | { |
| 517 | uint8_t opclass = 0; |
| 518 | |
| 519 | sme_get_opclass(hal, channel, bw_offset, &opclass); |
| 520 | return opclass; |
| 521 | } |
| 522 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 523 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 524 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 525 | * @moduleId: Module whose trace level is being configured |
| 526 | * @bitmask: Bitmask of log levels to be enabled |
| 527 | * |
| 528 | * Called immediately after the cfg.ini is read in order to configure |
| 529 | * the desired trace levels. |
| 530 | * |
| 531 | * Return: None |
| 532 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 533 | static void hdd_qdf_trace_enable(QDF_MODULE_ID moduleId, uint32_t bitmask) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 534 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 535 | QDF_TRACE_LEVEL level; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 536 | int qdf_print_idx = -1; |
| 537 | int status = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 538 | /* |
| 539 | * if the bitmask is the default value, then a bitmask was not |
| 540 | * specified in cfg.ini, so leave the logging level alone (it |
| 541 | * will remain at the "compiled in" default value) |
| 542 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 543 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 544 | return; |
| 545 | } |
| 546 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 547 | qdf_print_idx = qdf_get_pidx(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 548 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 549 | /* a mask was specified. start by disabling all logging */ |
| 550 | status = qdf_print_set_category_verbose(qdf_print_idx, moduleId, |
| 551 | QDF_TRACE_LEVEL_NONE, 0); |
| 552 | |
| 553 | if (QDF_STATUS_SUCCESS != status) |
| 554 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 555 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 556 | level = QDF_TRACE_LEVEL_FATAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 557 | while (0 != bitmask) { |
| 558 | if (bitmask & 1) { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 559 | status = qdf_print_set_category_verbose(qdf_print_idx, |
| 560 | moduleId, level, 1); |
| 561 | if (QDF_STATUS_SUCCESS != status) |
| 562 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 563 | } |
| 564 | level++; |
| 565 | bitmask >>= 1; |
| 566 | } |
| 567 | } |
| 568 | |
| 569 | /** |
| 570 | * wlan_hdd_validate_context() - check the HDD context |
| 571 | * @hdd_ctx: HDD context pointer |
| 572 | * |
| 573 | * Return: 0 if the context is valid. Error code otherwise |
| 574 | */ |
| 575 | int wlan_hdd_validate_context(hdd_context_t *hdd_ctx) |
| 576 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 577 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 578 | hdd_err("%pS HDD context is Null", (void *)_RET_IP_); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 579 | return -ENODEV; |
| 580 | } |
| 581 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 582 | if (cds_is_driver_recovering()) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 583 | hdd_err("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
| 584 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 585 | return -EAGAIN; |
| 586 | } |
| 587 | |
Rajeev Kumar | fec3dbe | 2016-01-19 15:23:52 -0800 | [diff] [blame] | 588 | if (cds_is_load_or_unload_in_progress()) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 589 | hdd_err("%pS Unloading/Loading in Progress. Ignore!!!: 0x%x", |
| 590 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 591 | return -EAGAIN; |
| 592 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 593 | |
| 594 | if (hdd_ctx->start_modules_in_progress || |
| 595 | hdd_ctx->stop_modules_in_progress) { |
| 596 | hdd_err("%pS Start/Stop Modules in progress. Ignore!!!", |
| 597 | (void *)_RET_IP_); |
| 598 | return -EAGAIN; |
| 599 | } |
| 600 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 601 | return 0; |
| 602 | } |
| 603 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 604 | /** |
| 605 | * hdd_set_ibss_power_save_params() - update IBSS Power Save params to WMA. |
| 606 | * @hdd_adapter_t Hdd adapter. |
| 607 | * |
| 608 | * This function sets the IBSS power save config parameters to WMA |
| 609 | * which will send it to firmware if FW supports IBSS power save |
| 610 | * before vdev start. |
| 611 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 612 | * 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] | 613 | * on failure. |
| 614 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 615 | QDF_STATUS hdd_set_ibss_power_save_params(hdd_adapter_t *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 616 | { |
| 617 | int ret; |
| 618 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 619 | |
| 620 | if (hdd_ctx == NULL) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 621 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 622 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 623 | } |
| 624 | |
| 625 | ret = wma_cli_set_command(adapter->sessionId, |
| 626 | WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE, |
| 627 | hdd_ctx->config->ibssATIMWinSize, |
| 628 | VDEV_CMD); |
| 629 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 630 | hdd_err("WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 631 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 632 | } |
| 633 | |
| 634 | ret = wma_cli_set_command(adapter->sessionId, |
| 635 | WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED, |
| 636 | hdd_ctx->config->isIbssPowerSaveAllowed, |
| 637 | VDEV_CMD); |
| 638 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 639 | hdd_err("WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED failed %d", |
| 640 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 641 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 642 | } |
| 643 | |
| 644 | ret = wma_cli_set_command(adapter->sessionId, |
| 645 | WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED, |
| 646 | hdd_ctx->config-> |
| 647 | isIbssPowerCollapseAllowed, VDEV_CMD); |
| 648 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 649 | hdd_err("WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED failed %d", |
| 650 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 651 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 652 | } |
| 653 | |
| 654 | ret = wma_cli_set_command(adapter->sessionId, |
| 655 | WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX, |
| 656 | hdd_ctx->config->isIbssAwakeOnTxRx, |
| 657 | VDEV_CMD); |
| 658 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 659 | 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] | 660 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 661 | } |
| 662 | |
| 663 | ret = wma_cli_set_command(adapter->sessionId, |
| 664 | WMA_VDEV_IBSS_SET_INACTIVITY_TIME, |
| 665 | hdd_ctx->config->ibssInactivityCount, |
| 666 | VDEV_CMD); |
| 667 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 668 | hdd_err("WMA_VDEV_IBSS_SET_INACTIVITY_TIME failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 669 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 670 | } |
| 671 | |
| 672 | ret = wma_cli_set_command(adapter->sessionId, |
| 673 | WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME, |
| 674 | hdd_ctx->config->ibssTxSpEndInactivityTime, |
| 675 | VDEV_CMD); |
| 676 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 677 | hdd_err("WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME failed %d", |
| 678 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 679 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 680 | } |
| 681 | |
| 682 | ret = wma_cli_set_command(adapter->sessionId, |
| 683 | WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS, |
| 684 | hdd_ctx->config->ibssPsWarmupTime, |
| 685 | VDEV_CMD); |
| 686 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 687 | hdd_err("WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS failed %d", |
| 688 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 689 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 690 | } |
| 691 | |
| 692 | ret = wma_cli_set_command(adapter->sessionId, |
| 693 | WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW, |
| 694 | hdd_ctx->config->ibssPs1RxChainInAtimEnable, |
| 695 | VDEV_CMD); |
| 696 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 697 | hdd_err("WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW failed %d", |
| 698 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 699 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 700 | } |
| 701 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 702 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 703 | } |
| 704 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 705 | #define INTF_MACADDR_MASK 0x7 |
| 706 | |
| 707 | /** |
| 708 | * hdd_update_macaddr() - update mac address |
| 709 | * @config: hdd configuration |
| 710 | * @hw_macaddr: mac address |
| 711 | * |
| 712 | * Mac address for multiple virtual interface is found as following |
| 713 | * i) The mac address of the first interface is just the actual hw mac address. |
| 714 | * ii) MSM 3 or 4 bits of byte5 of the actual mac address are used to |
| 715 | * define the mac address for the remaining interfaces and locally |
| 716 | * admistered bit is set. INTF_MACADDR_MASK is based on the number of |
| 717 | * supported virtual interfaces, right now this is 0x07 (meaning 8 |
| 718 | * interface). |
| 719 | * Byte[3] of second interface will be hw_macaddr[3](bit5..7) + 1, |
| 720 | * for third interface it will be hw_macaddr[3](bit5..7) + 2, etc. |
| 721 | * |
| 722 | * Return: None |
| 723 | */ |
| 724 | void hdd_update_macaddr(struct hdd_config *config, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 725 | struct qdf_mac_addr hw_macaddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 726 | { |
| 727 | int8_t i; |
| 728 | uint8_t macaddr_b3, tmp_br3; |
| 729 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 730 | qdf_mem_copy(config->intfMacAddr[0].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 731 | QDF_MAC_ADDR_SIZE); |
| 732 | for (i = 1; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 733 | qdf_mem_copy(config->intfMacAddr[i].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 734 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 735 | macaddr_b3 = config->intfMacAddr[i].bytes[3]; |
| 736 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 737 | INTF_MACADDR_MASK; |
| 738 | macaddr_b3 += tmp_br3; |
| 739 | |
| 740 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 741 | * mac address range before collision |
| 742 | */ |
| 743 | macaddr_b3 ^= (1 << 7); |
| 744 | |
| 745 | /* Set locally administered bit */ |
| 746 | config->intfMacAddr[i].bytes[0] |= 0x02; |
| 747 | config->intfMacAddr[i].bytes[3] = macaddr_b3; |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 748 | hdd_notice("config->intfMacAddr[%d]: " |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 749 | MAC_ADDRESS_STR, i, |
| 750 | MAC_ADDR_ARRAY(config->intfMacAddr[i].bytes)); |
| 751 | } |
| 752 | } |
| 753 | |
| 754 | static void hdd_update_tgt_services(hdd_context_t *hdd_ctx, |
| 755 | struct wma_tgt_services *cfg) |
| 756 | { |
| 757 | struct hdd_config *config = hdd_ctx->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 758 | |
| 759 | /* Set up UAPSD */ |
| 760 | config->apUapsdEnabled &= cfg->uapsd; |
| 761 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 762 | /* 11AC mode support */ |
| 763 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 764 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 765 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 766 | |
| 767 | /* ARP offload: override user setting if invalid */ |
| 768 | config->fhostArpOffload &= cfg->arp_offload; |
| 769 | |
| 770 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 771 | /* PNO offload */ |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 772 | hdd_info("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 773 | if (cfg->pno_offload) |
| 774 | config->PnoOffload = true; |
| 775 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 776 | #ifdef FEATURE_WLAN_TDLS |
| 777 | config->fEnableTDLSSupport &= cfg->en_tdls; |
Manjeet Singh | fdd2ac7 | 2016-09-02 18:11:43 +0530 | [diff] [blame] | 778 | config->fEnableTDLSOffChannel = config->fEnableTDLSOffChannel && |
| 779 | cfg->en_tdls_offchan; |
| 780 | config->fEnableTDLSBufferSta = config->fEnableTDLSBufferSta && |
| 781 | cfg->en_tdls_uapsd_buf_sta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 782 | if (config->fTDLSUapsdMask && cfg->en_tdls_uapsd_sleep_sta) { |
| 783 | config->fEnableTDLSSleepSta = true; |
| 784 | } else { |
| 785 | config->fEnableTDLSSleepSta = false; |
| 786 | } |
| 787 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 788 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 789 | config->isRoamOffloadEnabled &= cfg->en_roam_offload; |
| 790 | #endif |
Krishna Kumaar Natarajan | 052c6e6 | 2015-09-28 15:32:55 -0700 | [diff] [blame] | 791 | sme_update_tgt_services(hdd_ctx->hHal, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 792 | |
| 793 | } |
| 794 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 795 | /** |
| 796 | * hdd_update_vdev_nss() - sets the vdev nss |
| 797 | * @hdd_ctx: HDD context |
| 798 | * |
| 799 | * Sets the Nss per vdev type based on INI |
| 800 | * |
| 801 | * Return: None |
| 802 | */ |
| 803 | static void hdd_update_vdev_nss(hdd_context_t *hdd_ctx) |
| 804 | { |
| 805 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 806 | uint8_t max_supp_nss = 1; |
| 807 | |
Naveen Rawat | 10b1c15 | 2017-01-18 11:16:06 -0800 | [diff] [blame] | 808 | if (cfg_ini->enable2x2 && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 809 | max_supp_nss = 2; |
| 810 | |
| 811 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
| 812 | cfg_ini->vdev_type_nss_2g, eCSR_BAND_24); |
| 813 | |
| 814 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
| 815 | cfg_ini->vdev_type_nss_5g, eCSR_BAND_5G); |
| 816 | } |
| 817 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 818 | static void hdd_update_tgt_ht_cap(hdd_context_t *hdd_ctx, |
| 819 | struct wma_tgt_ht_cap *cfg) |
| 820 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 821 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 822 | uint32_t value, val32; |
| 823 | uint16_t val16; |
| 824 | struct hdd_config *pconfig = hdd_ctx->config; |
| 825 | tSirMacHTCapabilityInfo *phtCapInfo; |
| 826 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
| 827 | uint8_t enable_tx_stbc; |
| 828 | |
| 829 | /* check and update RX STBC */ |
| 830 | if (pconfig->enableRxSTBC && !cfg->ht_rx_stbc) |
| 831 | pconfig->enableRxSTBC = cfg->ht_rx_stbc; |
| 832 | |
| 833 | /* get the MPDU density */ |
| 834 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, &value); |
| 835 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 836 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 837 | hdd_err("could not get MPDU DENSITY"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 838 | value = 0; |
| 839 | } |
| 840 | |
| 841 | /* |
| 842 | * MPDU density: |
| 843 | * override user's setting if value is larger |
| 844 | * than the one supported by target |
| 845 | */ |
| 846 | if (value > cfg->mpdu_density) { |
| 847 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, |
| 848 | cfg->mpdu_density); |
| 849 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 850 | if (status == QDF_STATUS_E_FAILURE) |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 851 | hdd_alert("could not set MPDU DENSITY to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 852 | } |
| 853 | |
| 854 | /* get the HT capability info */ |
| 855 | 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] | 856 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 857 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 858 | return; |
| 859 | } |
| 860 | val16 = (uint16_t) val32; |
| 861 | phtCapInfo = (tSirMacHTCapabilityInfo *) &val16; |
| 862 | |
| 863 | /* Set the LDPC capability */ |
| 864 | phtCapInfo->advCodingCap = cfg->ht_rx_ldpc; |
| 865 | |
| 866 | if (pconfig->ShortGI20MhzEnable && !cfg->ht_sgi_20) |
| 867 | pconfig->ShortGI20MhzEnable = cfg->ht_sgi_20; |
| 868 | |
| 869 | if (pconfig->ShortGI40MhzEnable && !cfg->ht_sgi_40) |
| 870 | pconfig->ShortGI40MhzEnable = cfg->ht_sgi_40; |
| 871 | |
| 872 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 873 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 874 | |
| 875 | enable_tx_stbc = pconfig->enableTxSTBC; |
| 876 | |
| 877 | if (pconfig->enable2x2 && (cfg->num_rf_chains == 2)) { |
| 878 | pconfig->enable2x2 = 1; |
| 879 | } else { |
| 880 | pconfig->enable2x2 = 0; |
| 881 | enable_tx_stbc = 0; |
| 882 | |
| 883 | /* 1x1 */ |
| 884 | /* Update Rx Highest Long GI data Rate */ |
| 885 | if (sme_cfg_set_int(hdd_ctx->hHal, |
| 886 | WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 887 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 888 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 889 | 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] | 890 | } |
| 891 | |
| 892 | /* Update Tx Highest Long GI data Rate */ |
| 893 | if (sme_cfg_set_int |
| 894 | (hdd_ctx->hHal, |
| 895 | WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 896 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 897 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 898 | hdd_err("VHT_TX_HIGHEST_SUPP_RATE_1_1 to CCM fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 899 | } |
| 900 | } |
| 901 | if (!(cfg->ht_tx_stbc && pconfig->enable2x2)) |
| 902 | enable_tx_stbc = 0; |
| 903 | phtCapInfo->txSTBC = enable_tx_stbc; |
| 904 | |
| 905 | val32 = val16; |
| 906 | 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] | 907 | if (status != QDF_STATUS_SUCCESS) |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 908 | hdd_alert("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 909 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
| 910 | value = SIZE_OF_SUPPORTED_MCS_SET; |
| 911 | 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] | 912 | &value) == QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 913 | hdd_notice("Read MCS rate set"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 914 | |
| 915 | if (pconfig->enable2x2) { |
| 916 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 917 | mcs_set[value] = |
| 918 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 919 | |
| 920 | status = |
| 921 | sme_cfg_set_str(hdd_ctx->hHal, |
| 922 | WNI_CFG_SUPPORTED_MCS_SET, |
| 923 | mcs_set, |
| 924 | SIZE_OF_SUPPORTED_MCS_SET); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 925 | if (status == QDF_STATUS_E_FAILURE) |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 926 | hdd_alert("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 927 | } |
| 928 | } |
| 929 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 930 | } |
| 931 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 932 | static void hdd_update_tgt_vht_cap(hdd_context_t *hdd_ctx, |
| 933 | struct wma_tgt_vht_cap *cfg) |
| 934 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 935 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 936 | uint32_t value = 0; |
| 937 | struct hdd_config *pconfig = hdd_ctx->config; |
| 938 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 939 | struct ieee80211_supported_band *band_5g = |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 940 | wiphy->bands[NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 941 | uint32_t temp = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 942 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 943 | if (!band_5g) { |
| 944 | hdd_info("5GHz band disabled, skipping capability population"); |
| 945 | return; |
| 946 | } |
| 947 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 948 | /* Get the current MPDU length */ |
| 949 | status = |
| 950 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 951 | &value); |
| 952 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 953 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 954 | hdd_err("could not get MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 955 | value = 0; |
| 956 | } |
| 957 | |
| 958 | /* |
| 959 | * VHT max MPDU length: |
| 960 | * override if user configured value is too high |
| 961 | * that the target cannot support |
| 962 | */ |
| 963 | if (value > cfg->vht_max_mpdu) { |
| 964 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 965 | WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 966 | cfg->vht_max_mpdu); |
| 967 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 968 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 969 | hdd_alert("could not set VHT MAX MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 970 | } |
| 971 | } |
| 972 | |
| 973 | /* Get the current supported chan width */ |
| 974 | status = sme_cfg_get_int(hdd_ctx->hHal, |
| 975 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 976 | &value); |
| 977 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 978 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 979 | hdd_err("could not get MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 980 | value = 0; |
| 981 | } |
| 982 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 983 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, &temp); |
| 984 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 985 | |
| 986 | if (pconfig->enable2x2) |
| 987 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 988 | |
| 989 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, temp) == |
| 990 | QDF_STATUS_E_FAILURE) { |
| 991 | hdd_err("Could not pass VHT_BASIC_MCS_SET to CCM"); |
| 992 | } |
| 993 | |
| 994 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, &temp); |
| 995 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 996 | if (pconfig->enable2x2) |
| 997 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 998 | |
| 999 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, temp) == |
| 1000 | QDF_STATUS_E_FAILURE) { |
| 1001 | hdd_err("Could not pass WNI_CFG_VHT_RX_MCS_MAP to CCM"); |
| 1002 | } |
| 1003 | |
| 1004 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, &temp); |
| 1005 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtTxMCS; |
| 1006 | if (pconfig->enable2x2) |
| 1007 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtTxMCS2x2 << 2); |
| 1008 | |
| 1009 | hdd_info("vhtRxMCS2x2 - %x temp - %u enable2x2 %d", |
| 1010 | pconfig->vhtRxMCS2x2, temp, pconfig->enable2x2); |
| 1011 | |
| 1012 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, temp) == |
| 1013 | QDF_STATUS_E_FAILURE) { |
| 1014 | hdd_err("Could not pass WNI_CFG_VHT_TX_MCS_MAP to CCM"); |
| 1015 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1016 | /* Get the current RX LDPC setting */ |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1017 | 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] | 1018 | &value); |
| 1019 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1020 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1021 | hdd_err("could not get VHT LDPC CODING CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1022 | value = 0; |
| 1023 | } |
| 1024 | |
| 1025 | /* Set the LDPC capability */ |
| 1026 | if (value && !cfg->vht_rx_ldpc) { |
| 1027 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1028 | WNI_CFG_VHT_LDPC_CODING_CAP, |
| 1029 | cfg->vht_rx_ldpc); |
| 1030 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1031 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1032 | hdd_alert("could not set VHT LDPC CODING CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1033 | } |
| 1034 | } |
| 1035 | |
| 1036 | /* Get current GI 80 value */ |
| 1037 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1038 | &value); |
| 1039 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1040 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1041 | hdd_err("could not get SHORT GI 80MHZ"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1042 | value = 0; |
| 1043 | } |
| 1044 | |
| 1045 | /* set the Guard interval 80MHz */ |
| 1046 | if (value && !cfg->vht_short_gi_80) { |
| 1047 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1048 | WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1049 | cfg->vht_short_gi_80); |
| 1050 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1051 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1052 | hdd_alert("could not set SHORT GI 80MHZ to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1053 | } |
| 1054 | } |
| 1055 | |
| 1056 | /* Get current GI 160 value */ |
| 1057 | status = sme_cfg_get_int(hdd_ctx->hHal, |
| 1058 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
| 1059 | &value); |
| 1060 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1061 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1062 | hdd_err("could not get SHORT GI 80 & 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1063 | value = 0; |
| 1064 | } |
| 1065 | |
| 1066 | /* Get VHT TX STBC cap */ |
| 1067 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, &value); |
| 1068 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1069 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1070 | hdd_err("could not get VHT TX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1071 | value = 0; |
| 1072 | } |
| 1073 | |
| 1074 | /* VHT TX STBC cap */ |
| 1075 | if (value && !cfg->vht_tx_stbc) { |
| 1076 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, |
| 1077 | cfg->vht_tx_stbc); |
| 1078 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1079 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1080 | hdd_alert("could not set the VHT TX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1081 | } |
| 1082 | } |
| 1083 | |
| 1084 | /* Get VHT RX STBC cap */ |
| 1085 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, &value); |
| 1086 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1087 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1088 | hdd_err("could not get VHT RX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1089 | value = 0; |
| 1090 | } |
| 1091 | |
| 1092 | /* VHT RX STBC cap */ |
| 1093 | if (value && !cfg->vht_rx_stbc) { |
| 1094 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, |
| 1095 | cfg->vht_rx_stbc); |
| 1096 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1097 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1098 | hdd_alert("could not set the VHT RX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1099 | } |
| 1100 | } |
| 1101 | |
| 1102 | /* Get VHT SU Beamformer cap */ |
| 1103 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1104 | &value); |
| 1105 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1106 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1107 | hdd_err("could not get VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1108 | value = 0; |
| 1109 | } |
| 1110 | |
| 1111 | /* set VHT SU Beamformer cap */ |
| 1112 | if (value && !cfg->vht_su_bformer) { |
| 1113 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1114 | WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1115 | cfg->vht_su_bformer); |
| 1116 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1117 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1118 | hdd_alert("could not set VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1119 | } |
| 1120 | } |
| 1121 | |
| 1122 | /* check and update SU BEAMFORMEE capabality */ |
| 1123 | if (pconfig->enableTxBF && !cfg->vht_su_bformee) |
| 1124 | pconfig->enableTxBF = cfg->vht_su_bformee; |
| 1125 | |
| 1126 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1127 | WNI_CFG_VHT_SU_BEAMFORMEE_CAP, |
| 1128 | pconfig->enableTxBF); |
| 1129 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1130 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1131 | hdd_alert("could not set VHT SU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1132 | } |
| 1133 | |
| 1134 | /* Get VHT MU Beamformer cap */ |
| 1135 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1136 | &value); |
| 1137 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1138 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1139 | hdd_err("could not get VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1140 | value = 0; |
| 1141 | } |
| 1142 | |
| 1143 | /* set VHT MU Beamformer cap */ |
| 1144 | if (value && !cfg->vht_mu_bformer) { |
| 1145 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1146 | WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1147 | cfg->vht_mu_bformer); |
| 1148 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1149 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1150 | hdd_alert("could not set the VHT MU BEAMFORMER CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1151 | } |
| 1152 | } |
| 1153 | |
| 1154 | /* Get VHT MU Beamformee cap */ |
| 1155 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1156 | &value); |
| 1157 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1158 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1159 | hdd_err("could not get VHT MU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1160 | value = 0; |
| 1161 | } |
| 1162 | |
| 1163 | /* set VHT MU Beamformee cap */ |
| 1164 | if (value && !cfg->vht_mu_bformee) { |
| 1165 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1166 | WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1167 | cfg->vht_mu_bformee); |
| 1168 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1169 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1170 | hdd_alert("could not set VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1171 | } |
| 1172 | } |
| 1173 | |
| 1174 | /* Get VHT MAX AMPDU Len exp */ |
| 1175 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1176 | &value); |
| 1177 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1178 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1179 | hdd_err("could not get VHT AMPDU LEN"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1180 | value = 0; |
| 1181 | } |
| 1182 | |
| 1183 | /* |
| 1184 | * VHT max AMPDU len exp: |
| 1185 | * override if user configured value is too high |
| 1186 | * that the target cannot support. |
| 1187 | * Even though Rome publish ampdu_len=7, it can |
| 1188 | * only support 4 because of some h/w bug. |
| 1189 | */ |
| 1190 | |
| 1191 | if (value > cfg->vht_max_ampdu_len_exp) { |
| 1192 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1193 | WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1194 | cfg->vht_max_ampdu_len_exp); |
| 1195 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1196 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1197 | hdd_alert("could not set the VHT AMPDU LEN EXP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1198 | } |
| 1199 | } |
| 1200 | |
| 1201 | /* Get VHT TXOP PS CAP */ |
| 1202 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, &value); |
| 1203 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1204 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1205 | hdd_err("could not get VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1206 | value = 0; |
| 1207 | } |
| 1208 | |
| 1209 | /* set VHT TXOP PS cap */ |
| 1210 | if (value && !cfg->vht_txop_ps) { |
| 1211 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, |
| 1212 | cfg->vht_txop_ps); |
| 1213 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1214 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1215 | hdd_alert("could not set the VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1216 | } |
| 1217 | } |
| 1218 | |
| 1219 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1220 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1221 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1222 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1223 | else |
| 1224 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1225 | |
| 1226 | |
Amar Singhal | 90aaa6a | 2016-03-01 16:53:37 -0800 | [diff] [blame] | 1227 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1228 | band_5g->vht_cap.cap |= |
| 1229 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Amar Singhal | 90aaa6a | 2016-03-01 16:53:37 -0800 | [diff] [blame] | 1230 | else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1231 | band_5g->vht_cap.cap |= |
| 1232 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1233 | |
| 1234 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) |
| 1235 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1236 | |
| 1237 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1238 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1239 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1240 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1241 | |
| 1242 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1243 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1244 | |
| 1245 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1246 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1247 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1248 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1249 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1250 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1251 | |
| 1252 | band_5g->vht_cap.cap |= |
| 1253 | (cfg->vht_max_ampdu_len_exp << |
| 1254 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1255 | |
| 1256 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1257 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1258 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1259 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1260 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1261 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1262 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1263 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1264 | |
| 1265 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1266 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1267 | |
| 1268 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1269 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1270 | /** |
| 1271 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1272 | * @hdd_ctx: Pointer to the HDD context |
| 1273 | * |
| 1274 | * Auto-generate mac address using device serial number. |
| 1275 | * Keep the first 3 bytes of OUI as before and replace |
| 1276 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1277 | * |
| 1278 | * Return: 0 for success |
| 1279 | * Non zero failure code for errors |
| 1280 | */ |
| 1281 | static int hdd_generate_macaddr_auto(hdd_context_t *hdd_ctx) |
| 1282 | { |
| 1283 | unsigned int serialno = 0; |
| 1284 | struct qdf_mac_addr mac_addr = { |
| 1285 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1286 | }; |
| 1287 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1288 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1289 | if (serialno == 0) |
| 1290 | return -EINVAL; |
| 1291 | |
| 1292 | serialno &= 0x00ffffff; |
| 1293 | |
| 1294 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1295 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1296 | mac_addr.bytes[5] = serialno & 0xff; |
| 1297 | |
| 1298 | hdd_update_macaddr(hdd_ctx->config, mac_addr); |
| 1299 | return 0; |
| 1300 | } |
| 1301 | |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1302 | /** |
| 1303 | * hdd_update_ra_rate_limit() - Update RA rate limit from target |
| 1304 | * configuration to cfg_ini in HDD |
| 1305 | * @hdd_ctx: Pointer to hdd_ctx |
| 1306 | * @cfg: target configuration |
| 1307 | * |
| 1308 | * Return: None |
| 1309 | */ |
| 1310 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 1311 | static void hdd_update_ra_rate_limit(hdd_context_t *hdd_ctx, |
| 1312 | struct wma_tgt_cfg *cfg) |
| 1313 | { |
| 1314 | hdd_ctx->config->IsRArateLimitEnabled = cfg->is_ra_rate_limit_enabled; |
| 1315 | } |
| 1316 | #else |
| 1317 | static void hdd_update_ra_rate_limit(hdd_context_t *hdd_ctx, |
| 1318 | struct wma_tgt_cfg *cfg) |
| 1319 | { |
| 1320 | } |
| 1321 | #endif |
| 1322 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1323 | void hdd_update_tgt_cfg(void *context, void *param) |
| 1324 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1325 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1326 | hdd_context_t *hdd_ctx = (hdd_context_t *) context; |
| 1327 | struct wma_tgt_cfg *cfg = param; |
| 1328 | uint8_t temp_band_cap; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1329 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1330 | |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1331 | ret = hdd_create_and_store_pdev(hdd_ctx); |
| 1332 | if (ret) { |
| 1333 | hdd_err("pdev creation fails!"); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1334 | QDF_BUG(0); |
| 1335 | } |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1336 | |
| 1337 | if (cds_cfg) { |
| 1338 | if (hdd_ctx->config->enable_sub_20_channel_width != |
| 1339 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
| 1340 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1341 | cds_cfg->sub_20_channel_width = |
| 1342 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1343 | } else { |
| 1344 | cds_cfg->sub_20_channel_width = |
| 1345 | hdd_ctx->config->enable_sub_20_channel_width; |
| 1346 | } |
| 1347 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1348 | |
| 1349 | /* first store the INI band capability */ |
| 1350 | temp_band_cap = hdd_ctx->config->nBandCapability; |
| 1351 | |
| 1352 | hdd_ctx->config->nBandCapability = cfg->band_cap; |
| 1353 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 1354 | /* |
| 1355 | * now overwrite the target band capability with INI |
| 1356 | * setting if INI setting is a subset |
| 1357 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1358 | |
| 1359 | if ((hdd_ctx->config->nBandCapability == eCSR_BAND_ALL) && |
| 1360 | (temp_band_cap != eCSR_BAND_ALL)) |
| 1361 | hdd_ctx->config->nBandCapability = temp_band_cap; |
| 1362 | else if ((hdd_ctx->config->nBandCapability != eCSR_BAND_ALL) && |
| 1363 | (temp_band_cap != eCSR_BAND_ALL) && |
| 1364 | (hdd_ctx->config->nBandCapability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1365 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1366 | } |
| 1367 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 1368 | if (!cds_is_driver_recovering()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1369 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 1370 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 1371 | } |
| 1372 | |
| 1373 | /* This can be extended to other configurations like ht, vht cap... */ |
| 1374 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 1375 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1376 | hdd_update_macaddr(hdd_ctx->config, cfg->hw_macaddr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1377 | hdd_ctx->update_mac_addr_to_fw = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1378 | } else { |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1379 | static struct qdf_mac_addr default_mac_addr = { |
| 1380 | {0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF} |
| 1381 | }; |
| 1382 | if (qdf_is_macaddr_equal(&hdd_ctx->config->intfMacAddr[0], |
| 1383 | &default_mac_addr)) { |
| 1384 | if (hdd_generate_macaddr_auto(hdd_ctx) != 0) |
| 1385 | hdd_err("Fail to auto-generate MAC, using MAC from ini file " |
| 1386 | MAC_ADDRESS_STR, |
| 1387 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1388 | intfMacAddr[0].bytes)); |
| 1389 | } else { |
| 1390 | hdd_err("Invalid MAC passed from target, using MAC from ini file " |
| 1391 | MAC_ADDRESS_STR, |
| 1392 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1393 | intfMacAddr[0].bytes)); |
| 1394 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1395 | hdd_ctx->update_mac_addr_to_fw = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1396 | } |
| 1397 | |
| 1398 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 1399 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1400 | |
| 1401 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 1402 | |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 1403 | hdd_lpass_target_config(hdd_ctx, cfg); |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 1404 | hdd_green_ap_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1405 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1406 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 1407 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 1408 | |
| 1409 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 1410 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1411 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1412 | |
| 1413 | hdd_update_vdev_nss(hdd_ctx); |
| 1414 | |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1415 | hdd_ctx->config->fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 1416 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1417 | hdd_info("fine_time_meas_cap: 0x%x", |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1418 | hdd_ctx->config->fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1419 | |
| 1420 | hdd_ctx->current_antenna_mode = |
| 1421 | (hdd_ctx->config->enable2x2 == 0x01) ? |
| 1422 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 1423 | hdd_info("Init current antenna mode: %d", |
| 1424 | hdd_ctx->current_antenna_mode); |
| 1425 | |
Rajeev Kumar | dd3bc60 | 2016-08-16 14:21:05 -0700 | [diff] [blame] | 1426 | hdd_info("Target BPF %d Host BPF %d", |
| 1427 | cfg->bpf_enabled, hdd_ctx->config->bpf_packet_filter_enable); |
| 1428 | hdd_ctx->bpf_enabled = (cfg->bpf_enabled && |
| 1429 | hdd_ctx->config->bpf_packet_filter_enable); |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1430 | hdd_update_ra_rate_limit(hdd_ctx, cfg); |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1431 | |
Arun Khandavalli | d454d42 | 2016-08-17 12:47:05 +0530 | [diff] [blame] | 1432 | /* |
| 1433 | * If BPF is enabled, maxWowFilters set to WMA_STA_WOW_DEFAULT_PTRN_MAX |
| 1434 | * because we need atleast WMA_STA_WOW_DEFAULT_PTRN_MAX free slots to |
| 1435 | * configure the STA mode wow pattern. |
| 1436 | */ |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1437 | if (hdd_ctx->bpf_enabled) |
Arun Khandavalli | d454d42 | 2016-08-17 12:47:05 +0530 | [diff] [blame] | 1438 | hdd_ctx->config->maxWoWFilters = WMA_STA_WOW_DEFAULT_PTRN_MAX; |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1439 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 1440 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 1441 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 1442 | /* Configure NAN datapath features */ |
| 1443 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1444 | } |
| 1445 | |
| 1446 | /** |
| 1447 | * hdd_dfs_indicate_radar() - handle radar detection on current SAP channel |
| 1448 | * @context: HDD context pointer |
| 1449 | * @param: HDD radar indication pointer |
| 1450 | * |
Sandeep Puligilla | a8d4eec | 2016-06-30 15:13:11 -0700 | [diff] [blame] | 1451 | * This function is invoked in atomic context when a radar |
| 1452 | * is found on the SAP current operating channel and Data Tx |
| 1453 | * from netif has to be stopped to honor the DFS regulations. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1454 | * Actions: Stop the netif Tx queues,Indicate Radar present |
| 1455 | * in HDD context for future usage. |
| 1456 | * |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1457 | * Return: true to allow radar indication to host else false |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1458 | */ |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1459 | bool hdd_dfs_indicate_radar(void *context, void *param) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1460 | { |
| 1461 | hdd_context_t *hdd_ctx = (hdd_context_t *) context; |
| 1462 | struct wma_dfs_radar_ind *hdd_radar_event = |
| 1463 | (struct wma_dfs_radar_ind *)param; |
| 1464 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 1465 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1466 | QDF_STATUS status; |
Manishekar Chandrasekaran | 11ecd55 | 2016-08-31 12:44:05 +0530 | [diff] [blame] | 1467 | hdd_ap_ctx_t *ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1468 | |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1469 | if (!hdd_ctx || !hdd_radar_event || |
| 1470 | hdd_ctx->config->disableDFSChSwitch) |
| 1471 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1472 | |
| 1473 | if (true == hdd_radar_event->dfs_radar_status) { |
Arif Hussain | 2a7c1f3 | 2016-07-18 14:24:36 -0700 | [diff] [blame] | 1474 | if (qdf_atomic_inc_return(&hdd_ctx->dfs_radar_found) > 1) { |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1475 | /* |
| 1476 | * Application already triggered channel switch |
| 1477 | * on current channel, so return here. |
| 1478 | */ |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1479 | return false; |
| 1480 | } |
| 1481 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1482 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1483 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1484 | adapter = adapterNode->pAdapter; |
Manishekar Chandrasekaran | 11ecd55 | 2016-08-31 12:44:05 +0530 | [diff] [blame] | 1485 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 1486 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 1487 | QDF_P2P_GO_MODE == adapter->device_mode) && |
| 1488 | (CHANNEL_STATE_DFS == |
| 1489 | cds_get_channel_state(ap_ctx->operatingChannel))) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1490 | WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
| 1491 | dfs_cac_block_tx = true; |
Manishekar Chandrasekaran | 11ecd55 | 2016-08-31 12:44:05 +0530 | [diff] [blame] | 1492 | hdd_info("tx blocked for session:%d", |
| 1493 | adapter->sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1494 | } |
| 1495 | |
| 1496 | status = hdd_get_next_adapter(hdd_ctx, |
| 1497 | adapterNode, |
| 1498 | &pNext); |
| 1499 | adapterNode = pNext; |
| 1500 | } |
| 1501 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1502 | |
| 1503 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1504 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1505 | |
| 1506 | /** |
| 1507 | * hdd_is_valid_mac_address() - validate MAC address |
| 1508 | * @pMacAddr: Pointer to the input MAC address |
| 1509 | * |
| 1510 | * This function validates whether the given MAC address is valid or not |
| 1511 | * Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 1512 | * where X is the hexa decimal digit character and separated by ':' |
| 1513 | * This algorithm works even if MAC address is not separated by ':' |
| 1514 | * |
| 1515 | * This code checks given input string mac contains exactly 12 hexadecimal |
| 1516 | * digits and a separator colon : appears in the input string only after |
| 1517 | * an even number of hex digits. |
| 1518 | * |
| 1519 | * Return: 1 for valid and 0 for invalid |
| 1520 | */ |
| 1521 | bool hdd_is_valid_mac_address(const uint8_t *pMacAddr) |
| 1522 | { |
| 1523 | int xdigit = 0; |
| 1524 | int separator = 0; |
| 1525 | while (*pMacAddr) { |
| 1526 | if (isxdigit(*pMacAddr)) { |
| 1527 | xdigit++; |
| 1528 | } else if (':' == *pMacAddr) { |
| 1529 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 1530 | break; |
| 1531 | |
| 1532 | ++separator; |
| 1533 | } else { |
| 1534 | /* Invalid MAC found */ |
| 1535 | return 0; |
| 1536 | } |
| 1537 | ++pMacAddr; |
| 1538 | } |
| 1539 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 1540 | } |
| 1541 | |
| 1542 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 1543 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 1544 | * @dev: Handle to struct net_device to be updated. |
| 1545 | * |
| 1546 | * Return: None |
| 1547 | */ |
| 1548 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 1549 | { |
| 1550 | dev->header_ops = NULL; |
| 1551 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 1552 | dev->hard_header_len = ETH_HLEN; |
| 1553 | dev->mtu = ETH_DATA_LEN; |
| 1554 | dev->addr_len = ETH_ALEN; |
| 1555 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 1556 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 1557 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 1558 | |
| 1559 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 1560 | } |
| 1561 | |
| 1562 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1563 | * __hdd__mon_open() - HDD Open function |
| 1564 | * @dev: Pointer to net_device structure |
| 1565 | * |
| 1566 | * This is called in response to ifconfig up |
| 1567 | * |
| 1568 | * Return: 0 for success; non-zero for failure |
| 1569 | */ |
| 1570 | static int __hdd_mon_open(struct net_device *dev) |
| 1571 | { |
| 1572 | int ret; |
| 1573 | |
| 1574 | ENTER_DEV(dev); |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 1575 | hdd_mon_mode_ether_setup(dev); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1576 | ret = hdd_set_mon_rx_cb(dev); |
| 1577 | return ret; |
| 1578 | } |
| 1579 | |
| 1580 | /** |
| 1581 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 1582 | * @dev: Pointer to net_device structure |
| 1583 | * |
| 1584 | * This is called in response to ifconfig up |
| 1585 | * |
| 1586 | * Return: 0 for success; non-zero for failure |
| 1587 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 1588 | static int hdd_mon_open(struct net_device *dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1589 | { |
| 1590 | int ret; |
| 1591 | |
| 1592 | cds_ssr_protect(__func__); |
| 1593 | ret = __hdd_mon_open(dev); |
| 1594 | cds_ssr_unprotect(__func__); |
| 1595 | |
| 1596 | return ret; |
| 1597 | } |
| 1598 | |
| 1599 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1600 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 1601 | * @adapter: pointer to HDD adapter |
| 1602 | * |
| 1603 | * This function is called to start the device specific adapter for |
| 1604 | * the mode passed in the adapter's device_mode. |
| 1605 | * |
| 1606 | * Return: 0 for success; non-zero for failure |
| 1607 | */ |
| 1608 | int hdd_start_adapter(hdd_adapter_t *adapter) |
| 1609 | { |
| 1610 | |
| 1611 | int ret; |
| 1612 | enum tQDF_ADAPTER_MODE device_mode = adapter->device_mode; |
| 1613 | |
| 1614 | ENTER_DEV(adapter->dev); |
| 1615 | hdd_info("Start_adapter for mode : %d", adapter->device_mode); |
| 1616 | |
| 1617 | switch (device_mode) { |
| 1618 | case QDF_P2P_CLIENT_MODE: |
| 1619 | case QDF_P2P_DEVICE_MODE: |
| 1620 | case QDF_OCB_MODE: |
| 1621 | case QDF_STA_MODE: |
| 1622 | case QDF_MONITOR_MODE: |
| 1623 | ret = hdd_start_station_adapter(adapter); |
| 1624 | if (ret) |
| 1625 | goto err_start_adapter; |
| 1626 | break; |
| 1627 | case QDF_P2P_GO_MODE: |
| 1628 | case QDF_SAP_MODE: |
| 1629 | ret = hdd_start_ap_adapter(adapter); |
| 1630 | if (ret) |
| 1631 | goto err_start_adapter; |
| 1632 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 1633 | case QDF_IBSS_MODE: |
| 1634 | /* |
| 1635 | * For IBSS interface is initialized as part of |
| 1636 | * hdd_init_station_mode() |
| 1637 | */ |
| 1638 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1639 | case QDF_FTM_MODE: |
| 1640 | ret = hdd_start_ftm_adapter(adapter); |
| 1641 | if (ret) |
| 1642 | goto err_start_adapter; |
| 1643 | break; |
| 1644 | default: |
| 1645 | hdd_err("Invalid session type %d", device_mode); |
| 1646 | QDF_ASSERT(0); |
| 1647 | goto err_start_adapter; |
| 1648 | } |
| 1649 | if (hdd_set_fw_params(adapter)) |
| 1650 | hdd_err("Failed to set the FW params for the adapter!"); |
| 1651 | |
| 1652 | /* |
| 1653 | * Action frame registered in one adapter which will |
| 1654 | * applicable to all interfaces |
| 1655 | */ |
| 1656 | wlan_hdd_cfg80211_register_frames(adapter); |
| 1657 | EXIT(); |
| 1658 | return 0; |
| 1659 | err_start_adapter: |
| 1660 | return -EINVAL; |
| 1661 | } |
| 1662 | |
| 1663 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 1664 | * hdd_enable_power_management() - API to Enable Power Management |
| 1665 | * |
| 1666 | * API invokes Bus Interface Layer power management functionality |
| 1667 | * |
| 1668 | * Return: None |
| 1669 | */ |
| 1670 | static void hdd_enable_power_management(void) |
| 1671 | { |
| 1672 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 1673 | |
| 1674 | if (!hif_ctx) { |
| 1675 | hdd_err("Bus Interface Context is Invalid"); |
| 1676 | return; |
| 1677 | } |
| 1678 | |
| 1679 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 1680 | } |
| 1681 | |
| 1682 | /** |
| 1683 | * hdd_disable_power_management() - API to disable Power Management |
| 1684 | * |
| 1685 | * API disable Bus Interface Layer Power management functionality |
| 1686 | * |
| 1687 | * Return: None |
| 1688 | */ |
| 1689 | static void hdd_disable_power_management(void) |
| 1690 | { |
| 1691 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 1692 | |
| 1693 | if (!hif_ctx) { |
| 1694 | hdd_err("Bus Interface Context is Invalid"); |
| 1695 | return; |
| 1696 | } |
| 1697 | |
| 1698 | hif_disable_power_management(hif_ctx); |
| 1699 | } |
| 1700 | |
| 1701 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1702 | * hdd_wlan_start_modules() - Single driver state machine for starting modules |
| 1703 | * @hdd_ctx: HDD context |
| 1704 | * @adapter: HDD adapter |
| 1705 | * @reinit: flag to indicate from SSR or normal path |
| 1706 | * |
| 1707 | * This function maintains the driver state machine it will be invoked from |
| 1708 | * startup, reinit and change interface. Depending on the driver state shall |
| 1709 | * perform the opening of the modules. |
| 1710 | * |
| 1711 | * Return: 0 for success; non-zero for failure |
| 1712 | */ |
| 1713 | int hdd_wlan_start_modules(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, |
| 1714 | bool reinit) |
| 1715 | { |
| 1716 | int ret; |
| 1717 | qdf_device_t qdf_dev; |
| 1718 | QDF_STATUS status; |
| 1719 | p_cds_contextType p_cds_context; |
| 1720 | bool unint = false; |
| 1721 | void *hif_ctx; |
| 1722 | |
| 1723 | ENTER(); |
| 1724 | |
| 1725 | p_cds_context = cds_get_global_context(); |
| 1726 | if (!p_cds_context) { |
| 1727 | hdd_err("Global Context is NULL"); |
| 1728 | QDF_ASSERT(0); |
| 1729 | return -EINVAL; |
| 1730 | } |
| 1731 | |
| 1732 | hdd_info("start modules called in state! :%d reinit: %d", |
| 1733 | hdd_ctx->driver_status, reinit); |
| 1734 | |
| 1735 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 1736 | if (!qdf_dev) { |
| 1737 | hdd_err("QDF Device Context is Invalid return"); |
| 1738 | return -EINVAL; |
| 1739 | } |
| 1740 | |
| 1741 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 1742 | hdd_ctx->start_modules_in_progress = true; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1743 | |
| 1744 | if (QDF_TIMER_STATE_RUNNING == |
| 1745 | qdf_mc_timer_get_current_state(&hdd_ctx->iface_change_timer)) { |
| 1746 | |
| 1747 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 1748 | hdd_info("Interface change Timer running Stop timer"); |
| 1749 | qdf_mc_timer_stop(&hdd_ctx->iface_change_timer); |
| 1750 | } |
| 1751 | |
| 1752 | switch (hdd_ctx->driver_status) { |
| 1753 | case DRIVER_MODULES_UNINITIALIZED: |
| 1754 | unint = true; |
| 1755 | /* Fall through dont add break here */ |
| 1756 | case DRIVER_MODULES_CLOSED: |
| 1757 | if (!reinit && !unint) { |
| 1758 | ret = pld_power_on(qdf_dev->dev); |
| 1759 | if (ret) { |
| 1760 | hdd_err("Failed to Powerup the device: %d", ret); |
| 1761 | goto release_lock; |
| 1762 | } |
| 1763 | } |
| 1764 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 1765 | qdf_dev->bus_type, |
| 1766 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 1767 | HIF_ENABLE_TYPE_PROBE); |
| 1768 | if (ret) { |
| 1769 | hdd_err("Failed to open hif: %d", ret); |
| 1770 | goto power_down; |
| 1771 | } |
| 1772 | |
| 1773 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 1774 | if (!hif_ctx) { |
| 1775 | hdd_err("hif context is null!!"); |
| 1776 | goto power_down; |
| 1777 | } |
| 1778 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1779 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 1780 | if (status != QDF_STATUS_SUCCESS) { |
| 1781 | hdd_err("No Memory to Create BMI Context :%d", status); |
| 1782 | goto hif_close; |
| 1783 | } |
| 1784 | |
Arun Khandavalli | f624663 | 2016-08-17 17:43:06 +0530 | [diff] [blame] | 1785 | ret = hdd_update_config(hdd_ctx); |
| 1786 | if (ret) { |
| 1787 | hdd_err("Failed to update configuration :%d", ret); |
| 1788 | goto ol_cds_free; |
| 1789 | } |
| 1790 | |
Rajeev Kumar | 138ef91 | 2017-01-13 15:19:48 -0800 | [diff] [blame] | 1791 | ret = hdd_create_and_store_psoc(hdd_ctx, DEFAULT_PSOC_ID); |
| 1792 | if (ret) { |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1793 | hdd_err("Psoc creation fails!"); |
| 1794 | goto ol_cds_free; |
| 1795 | } |
| 1796 | |
| 1797 | status = cds_open(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1798 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 1799 | hdd_err("Failed to Open CDS: %d", status); |
Selvaraj, Sridhar | a7dc238 | 2017-01-27 18:29:39 +0530 | [diff] [blame] | 1800 | goto destroy_psoc_object; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1801 | } |
| 1802 | |
| 1803 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
| 1804 | |
| 1805 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
| 1806 | |
| 1807 | status = cds_pre_enable(hdd_ctx->pcds_context); |
| 1808 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 1809 | hdd_err("Failed to pre-enable CDS: %d", status); |
| 1810 | goto close; |
| 1811 | } |
| 1812 | |
| 1813 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 1814 | sme_register_ftm_msg_processor(hdd_ctx->hHal, |
| 1815 | hdd_ftm_mc_process_msg); |
| 1816 | break; |
| 1817 | } |
| 1818 | if (unint) { |
| 1819 | hdd_info("In phase-1 initialization don't enable modules"); |
| 1820 | break; |
| 1821 | } |
| 1822 | /* Fall through dont add break here */ |
| 1823 | case DRIVER_MODULES_OPENED: |
| 1824 | if (!adapter) { |
| 1825 | hdd_alert("adapter is Null"); |
| 1826 | goto close; |
| 1827 | } |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 1828 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 1829 | hdd_err("in ftm mode, no need to configure cds modules"); |
| 1830 | break; |
| 1831 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1832 | if (hdd_configure_cds(hdd_ctx, adapter)) { |
| 1833 | hdd_err("Failed to Enable cds modules"); |
| 1834 | goto close; |
| 1835 | } |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 1836 | hdd_enable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1837 | hdd_info("Driver Modules Successfully Enabled"); |
| 1838 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
| 1839 | break; |
| 1840 | case DRIVER_MODULES_ENABLED: |
| 1841 | hdd_info("Driver modules already Enabled"); |
| 1842 | break; |
| 1843 | default: |
| 1844 | hdd_err("WLAN start invoked in wrong state! :%d\n", |
| 1845 | hdd_ctx->driver_status); |
| 1846 | goto release_lock; |
| 1847 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 1848 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1849 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 1850 | EXIT(); |
| 1851 | return 0; |
| 1852 | |
| 1853 | close: |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1854 | cds_close(hdd_ctx->hdd_psoc, p_cds_context); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1855 | |
Selvaraj, Sridhar | a7dc238 | 2017-01-27 18:29:39 +0530 | [diff] [blame] | 1856 | destroy_psoc_object: |
| 1857 | hdd_release_and_destroy_psoc(hdd_ctx); |
| 1858 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1859 | ol_cds_free: |
| 1860 | ol_cds_free(); |
| 1861 | |
| 1862 | hif_close: |
| 1863 | hdd_hif_close(p_cds_context->pHIFContext); |
| 1864 | power_down: |
| 1865 | if (!reinit && !unint) |
| 1866 | pld_power_off(qdf_dev->dev); |
| 1867 | release_lock: |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 1868 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1869 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 1870 | EXIT(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1871 | return -EINVAL; |
| 1872 | } |
| 1873 | |
| 1874 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1875 | * __hdd_open() - HDD Open function |
| 1876 | * @dev: Pointer to net_device structure |
| 1877 | * |
| 1878 | * This is called in response to ifconfig up |
| 1879 | * |
| 1880 | * Return: 0 for success; non-zero for failure |
| 1881 | */ |
| 1882 | static int __hdd_open(struct net_device *dev) |
| 1883 | { |
| 1884 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1885 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 1886 | int ret; |
| 1887 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 1888 | ENTER_DEV(dev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1889 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1890 | adapter->sessionId, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1891 | |
| 1892 | ret = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 1893 | if (ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1894 | return ret; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 1895 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1896 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1897 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 1898 | if (ret) { |
| 1899 | hdd_err("Failed to start WLAN modules return"); |
| 1900 | return -ret; |
| 1901 | } |
| 1902 | |
| 1903 | |
| 1904 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 1905 | ret = hdd_start_adapter(adapter); |
| 1906 | if (ret) { |
| 1907 | hdd_err("Failed to start adapter :%d", |
| 1908 | adapter->device_mode); |
| 1909 | return ret; |
| 1910 | } |
| 1911 | } |
| 1912 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1913 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 1914 | if (hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1915 | hdd_info("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1916 | /* Enable TX queues only when we are connected */ |
| 1917 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1918 | WLAN_START_ALL_NETIF_QUEUE, |
| 1919 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1920 | } |
| 1921 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 1922 | /* Enable carrier and transmit queues for NDI */ |
| 1923 | if (WLAN_HDD_IS_NDI(adapter)) { |
| 1924 | hdd_notice("Enabling Tx Queues"); |
| 1925 | wlan_hdd_netif_queue_control(adapter, |
| 1926 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 1927 | WLAN_CONTROL_PATH); |
| 1928 | } |
| 1929 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1930 | return ret; |
| 1931 | } |
| 1932 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1933 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1934 | /** |
| 1935 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 1936 | * @dev: Pointer to net_device structure |
| 1937 | * |
| 1938 | * This is called in response to ifconfig up |
| 1939 | * |
| 1940 | * Return: 0 for success; non-zero for failure |
| 1941 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 1942 | static int hdd_open(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1943 | { |
| 1944 | int ret; |
| 1945 | |
| 1946 | cds_ssr_protect(__func__); |
| 1947 | ret = __hdd_open(dev); |
| 1948 | cds_ssr_unprotect(__func__); |
| 1949 | |
| 1950 | return ret; |
| 1951 | } |
| 1952 | |
| 1953 | /** |
| 1954 | * __hdd_stop() - HDD stop function |
| 1955 | * @dev: Pointer to net_device structure |
| 1956 | * |
| 1957 | * This is called in response to ifconfig down |
| 1958 | * |
| 1959 | * Return: 0 for success; non-zero for failure |
| 1960 | */ |
| 1961 | static int __hdd_stop(struct net_device *dev) |
| 1962 | { |
| 1963 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1964 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1965 | hdd_adapter_list_node_t *adapternode = NULL, *next = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1966 | int ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1967 | bool close_modules = true; |
| 1968 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1969 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 1970 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1971 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1972 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1973 | adapter->sessionId, adapter->device_mode)); |
| 1974 | |
| 1975 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 1976 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1977 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1978 | |
| 1979 | /* Nothing to be done if the interface is not opened */ |
| 1980 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 1981 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1982 | return -ENODEV; |
| 1983 | } |
| 1984 | |
| 1985 | /* Make sure the interface is marked as closed */ |
| 1986 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 1987 | hdd_notice("Disabling OS Tx queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1988 | |
| 1989 | /* |
| 1990 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 1991 | * be called on that interface |
| 1992 | */ |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 1993 | hdd_notice("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1994 | wlan_hdd_netif_queue_control(adapter, WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 1995 | WLAN_CONTROL_PATH); |
| 1996 | |
| 1997 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 1998 | * NAN data interface is different in some sense. The traffic on NDI is |
| 1999 | * bursty in nature and depends on the need to transfer. The service |
| 2000 | * layer may down the interface after the usage and up again when |
| 2001 | * required. In some sense, the NDI is expected to be available |
| 2002 | * (like SAP) iface until NDI delete request is issued by the service |
| 2003 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 2004 | * interface (NDI). |
| 2005 | */ |
| 2006 | if (WLAN_HDD_IS_NDI(adapter)) |
| 2007 | return 0; |
| 2008 | |
| 2009 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2010 | * The interface is marked as down for outside world (aka kernel) |
| 2011 | * But the driver is pretty much alive inside. The driver needs to |
| 2012 | * tear down the existing connection on the netdev (session) |
| 2013 | * cleanup the data pipes and wait until the control plane is stabilized |
| 2014 | * for this interface. The call also needs to wait until the above |
| 2015 | * mentioned actions are completed before returning to the caller. |
| 2016 | * Notice that the hdd_stop_adapter is requested not to close the session |
| 2017 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 2018 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2019 | hdd_stop_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2020 | |
| 2021 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 2022 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 2023 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2024 | |
| 2025 | /* |
| 2026 | * Find if any iface is up. If any iface is up then can't put device to |
| 2027 | * sleep/power save mode |
| 2028 | */ |
| 2029 | status = hdd_get_front_adapter(hdd_ctx, &adapternode); |
| 2030 | while ((NULL != adapternode) && (QDF_STATUS_SUCCESS == status)) { |
| 2031 | if (test_bit(DEVICE_IFACE_OPENED, |
| 2032 | &adapternode->pAdapter->event_flags)) { |
| 2033 | hdd_info("Still other ifaces are up cannot close modules"); |
| 2034 | close_modules = false; |
| 2035 | break; |
| 2036 | } |
| 2037 | status = hdd_get_next_adapter(hdd_ctx, adapternode, &next); |
| 2038 | adapternode = next; |
| 2039 | |
| 2040 | } |
| 2041 | |
| 2042 | if (close_modules) { |
| 2043 | hdd_info("Closing all modules from the hdd_stop"); |
| 2044 | qdf_mc_timer_start(&hdd_ctx->iface_change_timer, |
| 2045 | hdd_ctx->config->iface_change_wait_time |
| 2046 | * 50000); |
| 2047 | } |
| 2048 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2049 | EXIT(); |
| 2050 | return 0; |
| 2051 | } |
| 2052 | |
| 2053 | /** |
| 2054 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 2055 | * @dev: pointer to net_device structure |
| 2056 | * |
| 2057 | * This is called in response to ifconfig down |
| 2058 | * |
| 2059 | * Return: 0 for success and error number for failure |
| 2060 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2061 | static int hdd_stop(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2062 | { |
| 2063 | int ret; |
| 2064 | |
| 2065 | cds_ssr_protect(__func__); |
| 2066 | ret = __hdd_stop(dev); |
| 2067 | cds_ssr_unprotect(__func__); |
| 2068 | |
| 2069 | return ret; |
| 2070 | } |
| 2071 | |
| 2072 | /** |
| 2073 | * __hdd_uninit() - HDD uninit function |
| 2074 | * @dev: Pointer to net_device structure |
| 2075 | * |
| 2076 | * This is called during the netdev unregister to uninitialize all data |
| 2077 | * associated with the device |
| 2078 | * |
| 2079 | * Return: None |
| 2080 | */ |
| 2081 | static void __hdd_uninit(struct net_device *dev) |
| 2082 | { |
| 2083 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2084 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2085 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2086 | |
| 2087 | do { |
| 2088 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2089 | hdd_alert("Invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2090 | break; |
| 2091 | } |
| 2092 | |
| 2093 | if (NULL == adapter->pHddCtx) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2094 | hdd_alert("NULL hdd_ctx"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2095 | break; |
| 2096 | } |
| 2097 | |
| 2098 | if (dev != adapter->dev) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2099 | hdd_alert("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2100 | /* |
| 2101 | * we haven't validated all cases so let this go for |
| 2102 | * now |
| 2103 | */ |
| 2104 | } |
| 2105 | |
| 2106 | hdd_deinit_adapter(adapter->pHddCtx, adapter, true); |
| 2107 | |
| 2108 | /* after uninit our adapter structure will no longer be valid */ |
| 2109 | adapter->dev = NULL; |
| 2110 | adapter->magic = 0; |
| 2111 | } while (0); |
| 2112 | |
| 2113 | EXIT(); |
| 2114 | } |
| 2115 | |
| 2116 | /** |
| 2117 | * hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 2118 | * @dev: pointer to net_device structure |
| 2119 | * |
| 2120 | * This is called during the netdev unregister to uninitialize all data |
| 2121 | * associated with the device |
| 2122 | * |
| 2123 | * Return: none |
| 2124 | */ |
| 2125 | static void hdd_uninit(struct net_device *dev) |
| 2126 | { |
| 2127 | cds_ssr_protect(__func__); |
| 2128 | __hdd_uninit(dev); |
| 2129 | cds_ssr_unprotect(__func__); |
| 2130 | } |
| 2131 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2132 | static int hdd_open_cesium_nl_sock(void) |
| 2133 | { |
| 2134 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 2135 | struct netlink_kernel_cfg cfg = { |
| 2136 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 2137 | .input = NULL |
| 2138 | }; |
| 2139 | #endif |
| 2140 | int ret = 0; |
| 2141 | |
| 2142 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 2143 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 2144 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 2145 | THIS_MODULE, |
| 2146 | #endif |
| 2147 | &cfg); |
| 2148 | #else |
| 2149 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 2150 | WLAN_NLINK_MCAST_GRP_ID, |
| 2151 | NULL, NULL, THIS_MODULE); |
| 2152 | #endif |
| 2153 | |
| 2154 | if (cesium_nl_srv_sock == NULL) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2155 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2156 | ret = -ECONNREFUSED; |
| 2157 | } |
| 2158 | |
| 2159 | return ret; |
| 2160 | } |
| 2161 | |
| 2162 | static void hdd_close_cesium_nl_sock(void) |
| 2163 | { |
| 2164 | if (NULL != cesium_nl_srv_sock) { |
| 2165 | netlink_kernel_release(cesium_nl_srv_sock); |
| 2166 | cesium_nl_srv_sock = NULL; |
| 2167 | } |
| 2168 | } |
| 2169 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2170 | /** |
| 2171 | * __hdd_set_mac_address() - set the user specified mac address |
| 2172 | * @dev: Pointer to the net device. |
| 2173 | * @addr: Pointer to the sockaddr. |
| 2174 | * |
| 2175 | * This function sets the user specified mac address using |
| 2176 | * the command ifconfig wlanX hw ether <mac adress>. |
| 2177 | * |
| 2178 | * Return: 0 for success, non zero for failure |
| 2179 | */ |
| 2180 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 2181 | { |
| 2182 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2183 | hdd_context_t *hdd_ctx; |
| 2184 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2185 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2186 | int ret; |
| 2187 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2188 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2189 | |
| 2190 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2191 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2192 | if (0 != ret) |
| 2193 | return ret; |
| 2194 | |
| 2195 | memcpy(&adapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN); |
| 2196 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 2197 | |
| 2198 | EXIT(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2199 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2200 | } |
| 2201 | |
| 2202 | /** |
| 2203 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
| 2204 | * function from SSR |
| 2205 | * @dev: pointer to net_device structure |
| 2206 | * @addr: Pointer to the sockaddr |
| 2207 | * |
| 2208 | * This function sets the user specified mac address using |
| 2209 | * the command ifconfig wlanX hw ether <mac adress>. |
| 2210 | * |
| 2211 | * Return: 0 for success. |
| 2212 | */ |
| 2213 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 2214 | { |
| 2215 | int ret; |
| 2216 | |
| 2217 | cds_ssr_protect(__func__); |
| 2218 | ret = __hdd_set_mac_address(dev, addr); |
| 2219 | cds_ssr_unprotect(__func__); |
| 2220 | |
| 2221 | return ret; |
| 2222 | } |
| 2223 | |
| 2224 | uint8_t *wlan_hdd_get_intf_addr(hdd_context_t *hdd_ctx) |
| 2225 | { |
| 2226 | int i; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2227 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2228 | if (0 == ((hdd_ctx->config->intfAddrMask) & (1 << i))) |
| 2229 | break; |
| 2230 | } |
| 2231 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2232 | if (QDF_MAX_CONCURRENCY_PERSONA == i) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2233 | return NULL; |
| 2234 | |
| 2235 | hdd_ctx->config->intfAddrMask |= (1 << i); |
| 2236 | return &hdd_ctx->config->intfMacAddr[i].bytes[0]; |
| 2237 | } |
| 2238 | |
| 2239 | void wlan_hdd_release_intf_addr(hdd_context_t *hdd_ctx, uint8_t *releaseAddr) |
| 2240 | { |
| 2241 | int i; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2242 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2243 | if (!memcmp(releaseAddr, |
| 2244 | &hdd_ctx->config->intfMacAddr[i].bytes[0], |
| 2245 | 6)) { |
| 2246 | hdd_ctx->config->intfAddrMask &= ~(1 << i); |
| 2247 | break; |
| 2248 | } |
| 2249 | } |
| 2250 | return; |
| 2251 | } |
| 2252 | |
| 2253 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 2254 | /** |
| 2255 | * __hdd_set_multicast_list() - set the multicast address list |
| 2256 | * @dev: Pointer to the WLAN device. |
| 2257 | * @skb: Pointer to OS packet (sk_buff). |
| 2258 | * |
| 2259 | * This funciton sets the multicast address list. |
| 2260 | * |
| 2261 | * Return: None |
| 2262 | */ |
| 2263 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 2264 | { |
| 2265 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2266 | int mc_count; |
| 2267 | int i = 0, status; |
| 2268 | struct netdev_hw_addr *ha; |
| 2269 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2270 | static const uint8_t ipv6_router_solicitation[] |
| 2271 | = {0x33, 0x33, 0x00, 0x00, 0x00, 0x02}; |
| 2272 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2273 | ENTER_DEV(dev); |
| 2274 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2275 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 2276 | return; |
| 2277 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2278 | status = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 2279 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2280 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2281 | |
| 2282 | if (dev->flags & IFF_ALLMULTI) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2283 | hdd_notice("allow all multicast frames"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2284 | adapter->mc_addr_list.mc_cnt = 0; |
| 2285 | } else { |
| 2286 | mc_count = netdev_mc_count(dev); |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 2287 | hdd_notice("mc_count : %u", mc_count); |
| 2288 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2289 | if (mc_count > WLAN_HDD_MAX_MC_ADDR_LIST) { |
Dustin Brown | 6126946 | 2016-09-19 13:25:45 -0700 | [diff] [blame] | 2290 | hdd_notice("Exceeded max MC filter addresses (%d). Allowing all MC frames by disabling MC address filtering", |
| 2291 | WLAN_HDD_MAX_MC_ADDR_LIST); |
| 2292 | wlan_hdd_set_mc_addr_list(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2293 | adapter->mc_addr_list.mc_cnt = 0; |
| 2294 | return; |
| 2295 | } |
| 2296 | |
| 2297 | adapter->mc_addr_list.mc_cnt = mc_count; |
| 2298 | |
| 2299 | netdev_for_each_mc_addr(ha, dev) { |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 2300 | hdd_notice("ha_addr[%d] "MAC_ADDRESS_STR, |
| 2301 | i, MAC_ADDR_ARRAY(ha->addr)); |
| 2302 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2303 | if (i == mc_count) |
| 2304 | break; |
| 2305 | /* |
| 2306 | * Skip following addresses: |
| 2307 | * 1)IPv6 router solicitation address |
| 2308 | * 2)Any other address pattern if its set during |
| 2309 | * RXFILTER REMOVE driver command based on |
| 2310 | * addr_filter_pattern |
| 2311 | */ |
| 2312 | if ((!memcmp(ha->addr, ipv6_router_solicitation, |
| 2313 | ETH_ALEN)) || |
| 2314 | (adapter->addr_filter_pattern && (!memcmp(ha->addr, |
| 2315 | &adapter->addr_filter_pattern, 1)))) { |
Srinivas Girigowda | f2599dd | 2015-11-16 18:20:46 -0800 | [diff] [blame] | 2316 | hdd_info("MC/BC filtering Skip addr ="MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2317 | MAC_ADDR_ARRAY(ha->addr)); |
| 2318 | adapter->mc_addr_list.mc_cnt--; |
| 2319 | continue; |
| 2320 | } |
| 2321 | |
| 2322 | memset(&(adapter->mc_addr_list.addr[i][0]), 0, |
| 2323 | ETH_ALEN); |
| 2324 | memcpy(&(adapter->mc_addr_list.addr[i][0]), ha->addr, |
| 2325 | ETH_ALEN); |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2326 | hdd_notice("mlist[%d] = " MAC_ADDRESS_STR, i, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2327 | MAC_ADDR_ARRAY(adapter->mc_addr_list.addr[i])); |
| 2328 | i++; |
| 2329 | } |
| 2330 | } |
| 2331 | if (hdd_ctx->config->active_mode_offload) { |
| 2332 | hdd_info("enable mc filtering"); |
| 2333 | wlan_hdd_set_mc_addr_list(adapter, true); |
| 2334 | } else { |
| 2335 | hdd_info("skip mc filtering enable it during cfg80211 suspend"); |
| 2336 | } |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 2337 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2338 | return; |
| 2339 | } |
| 2340 | |
| 2341 | /** |
| 2342 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
| 2343 | * @dev: pointer to net_device |
| 2344 | * |
| 2345 | * Return: none |
| 2346 | */ |
| 2347 | static void hdd_set_multicast_list(struct net_device *dev) |
| 2348 | { |
| 2349 | cds_ssr_protect(__func__); |
| 2350 | __hdd_set_multicast_list(dev); |
| 2351 | cds_ssr_unprotect(__func__); |
| 2352 | } |
| 2353 | #endif |
| 2354 | |
| 2355 | /** |
| 2356 | * hdd_select_queue() - used by Linux OS to decide which queue to use first |
| 2357 | * @dev: Pointer to the WLAN device. |
| 2358 | * @skb: Pointer to OS packet (sk_buff). |
| 2359 | * |
| 2360 | * This function is registered with the Linux OS for network |
| 2361 | * core to decide which queue to use first. |
| 2362 | * |
| 2363 | * Return: ac, Queue Index/access category corresponding to UP in IP header |
| 2364 | */ |
| 2365 | static uint16_t hdd_select_queue(struct net_device *dev, struct sk_buff *skb |
| 2366 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) |
| 2367 | , void *accel_priv |
| 2368 | #endif |
| 2369 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 2370 | , select_queue_fallback_t fallback |
| 2371 | #endif |
| 2372 | ) |
| 2373 | { |
| 2374 | return hdd_wmm_select_queue(dev, skb); |
| 2375 | } |
| 2376 | |
| 2377 | static struct net_device_ops wlan_drv_ops = { |
| 2378 | .ndo_open = hdd_open, |
| 2379 | .ndo_stop = hdd_stop, |
| 2380 | .ndo_uninit = hdd_uninit, |
| 2381 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 2382 | .ndo_tx_timeout = hdd_tx_timeout, |
| 2383 | .ndo_get_stats = hdd_get_stats, |
| 2384 | .ndo_do_ioctl = hdd_ioctl, |
| 2385 | .ndo_set_mac_address = hdd_set_mac_address, |
| 2386 | .ndo_select_queue = hdd_select_queue, |
| 2387 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2388 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2389 | #endif |
| 2390 | }; |
| 2391 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2392 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
| 2393 | static struct net_device_ops wlan_mon_drv_ops = { |
| 2394 | .ndo_open = hdd_mon_open, |
| 2395 | .ndo_stop = hdd_stop, |
| 2396 | .ndo_get_stats = hdd_get_stats, |
| 2397 | }; |
| 2398 | |
| 2399 | /** |
| 2400 | * hdd_set_station_ops() - update net_device ops for monitor mode |
| 2401 | * @pWlanDev: Handle to struct net_device to be updated. |
| 2402 | * Return: None |
| 2403 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2404 | void hdd_set_station_ops(struct net_device *pWlanDev) |
| 2405 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2406 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
| 2407 | pWlanDev->netdev_ops = &wlan_mon_drv_ops; |
| 2408 | else |
| 2409 | pWlanDev->netdev_ops = &wlan_drv_ops; |
| 2410 | } |
| 2411 | |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 2412 | #ifdef FEATURE_RUNTIME_PM |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 2413 | /** |
| 2414 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 2415 | * @hdd_ctx: HDD context |
| 2416 | * |
| 2417 | * Return: None |
| 2418 | */ |
| 2419 | static void hdd_runtime_suspend_context_init(hdd_context_t *hdd_ctx) |
| 2420 | { |
| 2421 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 2422 | |
| 2423 | ctx->scan = qdf_runtime_lock_init("scan"); |
Komal Seelam | aa75f26 | 2016-09-29 12:32:13 +0530 | [diff] [blame] | 2424 | ctx->roc = qdf_runtime_lock_init("roc"); |
Komal Seelam | 81cb166 | 2016-09-29 12:39:08 +0530 | [diff] [blame] | 2425 | ctx->dfs = qdf_runtime_lock_init("dfs"); |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 2426 | } |
| 2427 | |
| 2428 | /** |
| 2429 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 2430 | * @hdd_ctx: HDD Context |
| 2431 | * |
| 2432 | * Return: None |
| 2433 | */ |
| 2434 | static void hdd_runtime_suspend_context_deinit(hdd_context_t *hdd_ctx) |
| 2435 | { |
| 2436 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 2437 | |
| 2438 | qdf_runtime_lock_deinit(ctx->scan); |
| 2439 | ctx->scan = NULL; |
Komal Seelam | aa75f26 | 2016-09-29 12:32:13 +0530 | [diff] [blame] | 2440 | qdf_runtime_lock_deinit(ctx->roc); |
| 2441 | ctx->roc = NULL; |
Komal Seelam | 81cb166 | 2016-09-29 12:39:08 +0530 | [diff] [blame] | 2442 | qdf_runtime_lock_deinit(ctx->dfs); |
| 2443 | ctx->dfs = NULL; |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 2444 | } |
| 2445 | |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 2446 | static void hdd_adapter_runtime_suspend_init(hdd_adapter_t *adapter) |
| 2447 | { |
| 2448 | struct hdd_connect_pm_context *ctx = &adapter->connect_rpm_ctx; |
| 2449 | |
| 2450 | ctx->connect = qdf_runtime_lock_init("connect"); |
| 2451 | } |
| 2452 | |
| 2453 | static void hdd_adapter_runtime_suspend_denit(hdd_adapter_t *adapter) |
| 2454 | { |
| 2455 | struct hdd_connect_pm_context *ctx = &adapter->connect_rpm_ctx; |
| 2456 | |
| 2457 | qdf_runtime_lock_deinit(ctx->connect); |
| 2458 | ctx->connect = NULL; |
| 2459 | } |
| 2460 | #else /* FEATURE_RUNTIME_PM */ |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 2461 | static void hdd_runtime_suspend_context_init(hdd_context_t *hdd_ctx) {} |
| 2462 | static void hdd_runtime_suspend_context_deinit(hdd_context_t *hdd_ctx) {} |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 2463 | static inline void hdd_adapter_runtime_suspend_init(hdd_adapter_t *adapter) {} |
| 2464 | static inline void hdd_adapter_runtime_suspend_denit(hdd_adapter_t *adapter) {} |
| 2465 | #endif /* FEATURE_RUNTIME_PM */ |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2466 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 2467 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 2468 | * @hdd_ctx: global hdd context |
| 2469 | * @macAddr: mac address to assign to the interface |
| 2470 | * @name: User-visible name of the interface |
| 2471 | * |
| 2472 | * hdd adapter pointer would point to the netdev->priv space, this function |
| 2473 | * would retrive the pointer, and setup the hdd adapter configuration. |
| 2474 | * |
| 2475 | * Return: the pointer to hdd adapter, otherwise NULL |
| 2476 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2477 | static hdd_adapter_t *hdd_alloc_station_adapter(hdd_context_t *hdd_ctx, |
| 2478 | tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 2479 | unsigned char name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2480 | const char *name) |
| 2481 | { |
| 2482 | struct net_device *pWlanDev = NULL; |
| 2483 | hdd_adapter_t *adapter = NULL; |
| 2484 | /* |
| 2485 | * cfg80211 initialization and registration.... |
| 2486 | */ |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 2487 | pWlanDev = alloc_netdev_mq(sizeof(hdd_adapter_t), name, |
| 2488 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
| 2489 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2490 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2491 | (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam() ? |
| 2492 | hdd_mon_mode_ether_setup : ether_setup), |
| 2493 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2494 | |
| 2495 | if (pWlanDev != NULL) { |
| 2496 | |
| 2497 | /* Save the pointer to the net_device in the HDD adapter */ |
| 2498 | adapter = (hdd_adapter_t *) netdev_priv(pWlanDev); |
| 2499 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2500 | qdf_mem_zero(adapter, sizeof(hdd_adapter_t)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2501 | |
| 2502 | adapter->dev = pWlanDev; |
| 2503 | adapter->pHddCtx = hdd_ctx; |
| 2504 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Arun Khandavalli | 9ad88f0 | 2016-09-01 19:03:37 +0530 | [diff] [blame] | 2505 | adapter->sessionId = HDD_SESSION_ID_INVALID; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2506 | |
| 2507 | init_completion(&adapter->session_open_comp_var); |
| 2508 | init_completion(&adapter->session_close_comp_var); |
| 2509 | init_completion(&adapter->disconnect_comp_var); |
| 2510 | init_completion(&adapter->linkup_event_var); |
| 2511 | init_completion(&adapter->cancel_rem_on_chan_var); |
| 2512 | init_completion(&adapter->rem_on_chan_ready_event); |
| 2513 | init_completion(&adapter->sta_authorized_event); |
| 2514 | init_completion(&adapter->offchannel_tx_event); |
| 2515 | init_completion(&adapter->tx_action_cnf_event); |
| 2516 | #ifdef FEATURE_WLAN_TDLS |
| 2517 | init_completion(&adapter->tdls_add_station_comp); |
| 2518 | init_completion(&adapter->tdls_del_station_comp); |
| 2519 | init_completion(&adapter->tdls_mgmt_comp); |
| 2520 | init_completion(&adapter->tdls_link_establish_req_comp); |
| 2521 | #endif |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2522 | init_completion(&adapter->ibss_peer_info_comp); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2523 | init_completion(&adapter->change_country_code); |
| 2524 | |
| 2525 | |
| 2526 | init_completion(&adapter->scan_info.abortscan_event_var); |
| 2527 | |
| 2528 | adapter->offloads_configured = false; |
| 2529 | adapter->isLinkUpSvcNeeded = false; |
| 2530 | adapter->higherDtimTransition = true; |
| 2531 | /* Init the net_device structure */ |
| 2532 | strlcpy(pWlanDev->name, name, IFNAMSIZ); |
| 2533 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2534 | qdf_mem_copy(pWlanDev->dev_addr, (void *)macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2535 | sizeof(tSirMacAddr)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2536 | qdf_mem_copy(adapter->macAddressCurrent.bytes, macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2537 | sizeof(tSirMacAddr)); |
| 2538 | pWlanDev->watchdog_timeo = HDD_TX_TIMEOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2539 | |
| 2540 | if (hdd_ctx->config->enable_ip_tcp_udp_checksum_offload) |
| 2541 | pWlanDev->features |= |
| 2542 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
| 2543 | pWlanDev->features |= NETIF_F_RXCSUM; |
| 2544 | |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 2545 | hdd_set_tso_flags(hdd_ctx, pWlanDev); |
| 2546 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2547 | hdd_set_station_ops(adapter->dev); |
| 2548 | |
| 2549 | pWlanDev->destructor = free_netdev; |
| 2550 | pWlanDev->ieee80211_ptr = &adapter->wdev; |
Mohit Khanna | ee9e80f | 2015-11-10 11:32:49 -0800 | [diff] [blame] | 2551 | pWlanDev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2552 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
| 2553 | adapter->wdev.netdev = pWlanDev; |
| 2554 | /* set pWlanDev's parent to underlying device */ |
| 2555 | SET_NETDEV_DEV(pWlanDev, hdd_ctx->parent_dev); |
| 2556 | hdd_wmm_init(adapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 2557 | hdd_adapter_runtime_suspend_init(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2558 | spin_lock_init(&adapter->pause_map_lock); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 2559 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2560 | } |
| 2561 | |
| 2562 | return adapter; |
| 2563 | } |
| 2564 | |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2565 | static QDF_STATUS hdd_register_interface(hdd_adapter_t *adapter, |
| 2566 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2567 | { |
| 2568 | struct net_device *pWlanDev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2569 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 2570 | if (rtnl_held) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2571 | if (strnchr(pWlanDev->name, strlen(pWlanDev->name), '%')) { |
| 2572 | if (dev_alloc_name(pWlanDev, pWlanDev->name) < 0) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2573 | hdd_err("Failed:dev_alloc_name"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2574 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2575 | } |
| 2576 | } |
| 2577 | if (register_netdevice(pWlanDev)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2578 | hdd_err("Failed:register_netdev"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2579 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2580 | } |
| 2581 | } else { |
| 2582 | if (register_netdev(pWlanDev)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2583 | hdd_err("Failed:register_netdev"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2584 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2585 | } |
| 2586 | } |
| 2587 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 2588 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2589 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2590 | } |
| 2591 | |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 2592 | QDF_STATUS hdd_sme_close_session_callback(void *pContext) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2593 | { |
| 2594 | hdd_adapter_t *adapter = pContext; |
| 2595 | |
| 2596 | if (NULL == adapter) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2597 | hdd_alert("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2598 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2599 | } |
| 2600 | |
| 2601 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2602 | hdd_alert("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2603 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2604 | } |
| 2605 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 2606 | /* |
| 2607 | * For NAN Data interface, the close session results in the final |
| 2608 | * indication to the userspace |
| 2609 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 2610 | if (adapter->device_mode == QDF_NDI_MODE) |
| 2611 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 2612 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2613 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 2614 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2615 | /* |
| 2616 | * We can be blocked while waiting for scheduled work to be |
| 2617 | * flushed, and the adapter structure can potentially be freed, in |
| 2618 | * which case the magic will have been reset. So make sure the |
| 2619 | * magic is still good, and hence the adapter structure is still |
| 2620 | * valid, before signaling completion |
| 2621 | */ |
| 2622 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
| 2623 | complete(&adapter->session_close_comp_var); |
| 2624 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2625 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2626 | } |
| 2627 | |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 2628 | /** |
| 2629 | * hdd_check_and_init_tdls() - check and init TDLS operation for desired mode |
| 2630 | * @adapter: pointer to device adapter |
| 2631 | * @type: type of interface |
| 2632 | * |
| 2633 | * This routine will check the mode of adapter and if it is required then it |
| 2634 | * will initialize the TDLS operations |
| 2635 | * |
| 2636 | * Return: QDF_STATUS |
| 2637 | */ |
| 2638 | #ifdef FEATURE_WLAN_TDLS |
| 2639 | static QDF_STATUS hdd_check_and_init_tdls(hdd_adapter_t *adapter, uint32_t type) |
| 2640 | { |
| 2641 | if (QDF_IBSS_MODE != type) { |
| 2642 | if (0 != wlan_hdd_tdls_init(adapter)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2643 | hdd_err("wlan_hdd_tdls_init failed"); |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 2644 | return QDF_STATUS_E_FAILURE; |
| 2645 | } |
| 2646 | set_bit(TDLS_INIT_DONE, &adapter->event_flags); |
| 2647 | } |
| 2648 | return QDF_STATUS_SUCCESS; |
| 2649 | } |
| 2650 | #else |
| 2651 | static QDF_STATUS hdd_check_and_init_tdls(hdd_adapter_t *adapter, uint32_t type) |
| 2652 | { |
| 2653 | return QDF_STATUS_SUCCESS; |
| 2654 | } |
| 2655 | #endif |
| 2656 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2657 | QDF_STATUS hdd_init_station_mode(hdd_adapter_t *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2658 | { |
| 2659 | struct net_device *pWlanDev = adapter->dev; |
| 2660 | hdd_station_ctx_t *pHddStaCtx = &adapter->sessionCtx.station; |
| 2661 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2662 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2663 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2664 | uint32_t type, subType; |
| 2665 | unsigned long rc; |
| 2666 | int ret_val; |
| 2667 | |
| 2668 | INIT_COMPLETION(adapter->session_open_comp_var); |
| 2669 | sme_set_curr_device_mode(hdd_ctx->hHal, adapter->device_mode); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 2670 | 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] | 2671 | status = cds_get_vdev_types(adapter->device_mode, &type, &subType); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2672 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2673 | hdd_err("failed to get vdev type"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2674 | goto error_sme_open; |
| 2675 | } |
| 2676 | /* Open a SME session for future operation */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2677 | qdf_ret_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2678 | sme_open_session(hdd_ctx->hHal, hdd_sme_roam_callback, adapter, |
| 2679 | (uint8_t *) &adapter->macAddressCurrent, |
| 2680 | &adapter->sessionId, type, subType); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2681 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2682 | hdd_alert("sme_open_session() failed, status code %08d [x%08x]", |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2683 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2684 | status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2685 | goto error_sme_open; |
| 2686 | } |
| 2687 | /* Block on a completion variable. Can't wait forever though. */ |
| 2688 | rc = wait_for_completion_timeout( |
| 2689 | &adapter->session_open_comp_var, |
| 2690 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
| 2691 | if (!rc) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2692 | hdd_alert("Session is not opened within timeout period code %ld", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2693 | rc); |
Sandeep Puligilla | e806599 | 2016-11-14 00:23:43 -0800 | [diff] [blame] | 2694 | adapter->sessionId = HDD_SESSION_ID_INVALID; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2695 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2696 | } |
| 2697 | |
Rajeev Kumar | deabf3e | 2017-01-13 15:55:05 -0800 | [diff] [blame] | 2698 | ret_val = hdd_create_and_store_vdev(hdd_ctx->hdd_pdev, adapter); |
| 2699 | if (ret_val) |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2700 | goto error_vdev_create; |
| 2701 | |
Naveen Rawat | a410c5a | 2016-09-19 14:22:33 -0700 | [diff] [blame] | 2702 | sme_set_vdev_ies_per_band(hdd_ctx->hHal, adapter->sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2703 | /* Register wireless extensions */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2704 | qdf_ret_status = hdd_register_wext(pWlanDev); |
| 2705 | if (QDF_STATUS_SUCCESS != qdf_ret_status) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2706 | hdd_alert("hdd_register_wext() failed, status code %08d [x%08x]", |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2707 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2708 | status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2709 | goto error_register_wext; |
| 2710 | } |
| 2711 | /* Set the Connection State to Not Connected */ |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2712 | hdd_notice("Set HDD connState to eConnectionState_NotConnected"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2713 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 2714 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 2715 | /* set fast roaming capability in sme session */ |
| 2716 | status = sme_config_fast_roaming(hdd_ctx->hHal, adapter->sessionId, |
| 2717 | adapter->fast_roaming_allowed); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2718 | /* Set the default operation channel */ |
| 2719 | pHddStaCtx->conn_info.operationChannel = |
| 2720 | hdd_ctx->config->OperatingChannel; |
| 2721 | |
| 2722 | /* Make the default Auth Type as OPEN */ |
| 2723 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 2724 | |
| 2725 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2726 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2727 | hdd_alert("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2728 | status, status); |
| 2729 | goto error_init_txrx; |
| 2730 | } |
| 2731 | |
| 2732 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 2733 | |
| 2734 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2735 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2736 | hdd_alert("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2737 | status, status); |
| 2738 | goto error_wmm_init; |
| 2739 | } |
| 2740 | |
| 2741 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 2742 | |
| 2743 | ret_val = wma_cli_set_command(adapter->sessionId, |
| 2744 | WMI_PDEV_PARAM_BURST_ENABLE, |
| 2745 | hdd_ctx->config->enableSifsBurst, |
| 2746 | PDEV_CMD); |
| 2747 | |
| 2748 | if (0 != ret_val) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2749 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2750 | ret_val); |
| 2751 | } |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 2752 | status = hdd_check_and_init_tdls(adapter, type); |
| 2753 | if (status != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2754 | goto error_tdls_init; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2755 | |
Himanshu Agarwal | 3d95b90 | 2016-08-24 16:27:03 +0530 | [diff] [blame] | 2756 | status = hdd_lro_enable(hdd_ctx, adapter); |
| 2757 | if (status != QDF_STATUS_SUCCESS) |
| 2758 | goto error_lro_enable; |
| 2759 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2760 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2761 | |
Himanshu Agarwal | 3d95b90 | 2016-08-24 16:27:03 +0530 | [diff] [blame] | 2762 | error_lro_enable: |
| 2763 | wlan_hdd_tdls_exit(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2764 | error_tdls_init: |
| 2765 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 2766 | hdd_wmm_adapter_close(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2767 | error_wmm_init: |
| 2768 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 2769 | hdd_deinit_tx_rx(adapter); |
| 2770 | error_init_txrx: |
| 2771 | hdd_unregister_wext(pWlanDev); |
| 2772 | error_register_wext: |
Rajeev Kumar | 9591d2b | 2017-01-13 16:05:06 -0800 | [diff] [blame] | 2773 | ret_val = hdd_release_and_destroy_vdev(adapter); |
| 2774 | if (ret_val) |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2775 | hdd_err("vdev delete failed"); |
| 2776 | error_vdev_create: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2777 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2778 | INIT_COMPLETION(adapter->session_close_comp_var); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2779 | if (QDF_STATUS_SUCCESS == sme_close_session(hdd_ctx->hHal, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2780 | adapter->sessionId, |
| 2781 | hdd_sme_close_session_callback, |
| 2782 | adapter)) { |
| 2783 | unsigned long rc; |
| 2784 | |
| 2785 | /* |
| 2786 | * Block on a completion variable. |
| 2787 | * Can't wait forever though. |
| 2788 | */ |
| 2789 | rc = wait_for_completion_timeout( |
| 2790 | &adapter->session_close_comp_var, |
| 2791 | msecs_to_jiffies |
| 2792 | (WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
| 2793 | if (rc <= 0) |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2794 | hdd_err("Session is not opened within timeout period code %ld", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2795 | rc); |
| 2796 | } |
| 2797 | } |
| 2798 | error_sme_open: |
| 2799 | return status; |
| 2800 | } |
| 2801 | |
| 2802 | void hdd_cleanup_actionframe(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter) |
| 2803 | { |
| 2804 | hdd_cfg80211_state_t *cfgState; |
| 2805 | |
| 2806 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR(adapter); |
| 2807 | |
| 2808 | if (NULL != cfgState->buf) { |
| 2809 | unsigned long rc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2810 | rc = wait_for_completion_timeout( |
| 2811 | &adapter->tx_action_cnf_event, |
| 2812 | msecs_to_jiffies(ACTION_FRAME_TX_TIMEOUT)); |
| 2813 | if (!rc) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 2814 | hdd_err("HDD Wait for Action Confirmation Failed!!"); |
Masti, Narayanraddi | f8f6e7e | 2015-08-25 10:22:46 +0530 | [diff] [blame] | 2815 | /* |
| 2816 | * Inform tx status as FAILURE to upper layer and free |
| 2817 | * cfgState->buf |
| 2818 | */ |
| 2819 | hdd_send_action_cnf(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2820 | } |
| 2821 | } |
| 2822 | return; |
| 2823 | } |
| 2824 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2825 | /** |
| 2826 | * hdd_station_adapter_deinit() - De-initialize the station adapter |
| 2827 | * @hdd_ctx: global hdd context |
| 2828 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2829 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 2830 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2831 | * |
| 2832 | * This function De-initializes the STA/P2P/OCB adapter. |
| 2833 | * |
| 2834 | * Return: None. |
| 2835 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2836 | static void hdd_station_adapter_deinit(hdd_context_t *hdd_ctx, |
| 2837 | hdd_adapter_t *adapter, |
| 2838 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2839 | { |
| 2840 | ENTER_DEV(adapter->dev); |
| 2841 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 2842 | if (adapter->dev) { |
| 2843 | if (rtnl_held) |
| 2844 | adapter->dev->wireless_handlers = NULL; |
| 2845 | else { |
| 2846 | rtnl_lock(); |
| 2847 | adapter->dev->wireless_handlers = NULL; |
| 2848 | rtnl_unlock(); |
| 2849 | } |
| 2850 | } |
| 2851 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2852 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 2853 | hdd_deinit_tx_rx(adapter); |
| 2854 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 2855 | } |
| 2856 | |
| 2857 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 2858 | hdd_wmm_adapter_close(adapter); |
| 2859 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 2860 | } |
| 2861 | |
| 2862 | hdd_cleanup_actionframe(hdd_ctx, adapter); |
| 2863 | wlan_hdd_tdls_exit(adapter); |
| 2864 | |
| 2865 | EXIT(); |
| 2866 | } |
| 2867 | |
| 2868 | /** |
| 2869 | * hdd_ap_adapter_deinit() - De-initialize the ap adapter |
| 2870 | * @hdd_ctx: global hdd context |
| 2871 | * @adapter: HDD adapter |
| 2872 | * @rtnl_held: the rtnl lock hold flag |
| 2873 | * This function De-initializes the AP/P2PGo adapter. |
| 2874 | * |
| 2875 | * Return: None. |
| 2876 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2877 | static void hdd_ap_adapter_deinit(hdd_context_t *hdd_ctx, |
| 2878 | hdd_adapter_t *adapter, |
| 2879 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2880 | { |
| 2881 | ENTER_DEV(adapter->dev); |
| 2882 | |
| 2883 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 2884 | hdd_wmm_adapter_close(adapter); |
| 2885 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 2886 | } |
Liangwei Dong | 8baf7c8 | 2016-10-11 01:26:59 -0400 | [diff] [blame] | 2887 | wlan_hdd_undo_acs(adapter); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2888 | |
| 2889 | hdd_cleanup_actionframe(hdd_ctx, adapter); |
| 2890 | |
| 2891 | hdd_unregister_hostapd(adapter, rtnl_held); |
| 2892 | |
| 2893 | EXIT(); |
| 2894 | } |
| 2895 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2896 | void hdd_deinit_adapter(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, |
| 2897 | bool rtnl_held) |
| 2898 | { |
| 2899 | ENTER(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2900 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2901 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 2902 | case QDF_STA_MODE: |
| 2903 | case QDF_P2P_CLIENT_MODE: |
| 2904 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2905 | { |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 2906 | hdd_station_adapter_deinit(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2907 | break; |
| 2908 | } |
| 2909 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 2910 | case QDF_SAP_MODE: |
| 2911 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2912 | { |
| 2913 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2914 | hdd_ap_adapter_deinit(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2915 | break; |
| 2916 | } |
| 2917 | |
| 2918 | default: |
| 2919 | break; |
| 2920 | } |
| 2921 | |
| 2922 | EXIT(); |
| 2923 | } |
| 2924 | |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2925 | static void hdd_cleanup_adapter(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, |
| 2926 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2927 | { |
Rajeev Kumar | 9591d2b | 2017-01-13 16:05:06 -0800 | [diff] [blame] | 2928 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2929 | struct net_device *pWlanDev = NULL; |
| 2930 | |
| 2931 | if (adapter) |
| 2932 | pWlanDev = adapter->dev; |
| 2933 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 2934 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2935 | return; |
| 2936 | } |
| 2937 | |
Rajeev Kumar | 9591d2b | 2017-01-13 16:05:06 -0800 | [diff] [blame] | 2938 | ret = hdd_release_and_destroy_vdev(adapter); |
| 2939 | if (ret) |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2940 | hdd_err("vdev delete failed"); |
| 2941 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 2942 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 2943 | |
| 2944 | if (adapter->scan_info.default_scan_ies) { |
| 2945 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 2946 | adapter->scan_info.default_scan_ies = NULL; |
| 2947 | } |
| 2948 | |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 2949 | hdd_adapter_runtime_suspend_denit(adapter); |
| 2950 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2951 | /* |
| 2952 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 2953 | * the driver is almost closed and cannot handle either control |
| 2954 | * messages or data. However, unregister_netdevice() call above will |
| 2955 | * eventually invoke hdd_stop (ndo_close) driver callback, which attempts |
| 2956 | * to close the active connections (basically excites control path) which |
| 2957 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 2958 | * the interface is closed and restricts any operations on that |
| 2959 | */ |
| 2960 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2961 | |
| 2962 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
| 2963 | if (rtnl_held) { |
| 2964 | unregister_netdevice(pWlanDev); |
| 2965 | } else { |
| 2966 | unregister_netdev(pWlanDev); |
| 2967 | } |
| 2968 | /* |
| 2969 | * Note that the adapter is no longer valid at this point |
| 2970 | * since the memory has been reclaimed |
| 2971 | */ |
| 2972 | } |
| 2973 | } |
| 2974 | |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2975 | static QDF_STATUS hdd_check_for_existing_macaddr(hdd_context_t *hdd_ctx, |
| 2976 | tSirMacAddr macAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2977 | { |
| 2978 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 2979 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2980 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2981 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2982 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2983 | adapter = adapterNode->pAdapter; |
| 2984 | if (adapter |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2985 | && !qdf_mem_cmp(adapter->macAddressCurrent.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2986 | macAddr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2987 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2988 | } |
| 2989 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 2990 | adapterNode = pNext; |
| 2991 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2992 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2993 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 2994 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 2995 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 2996 | /** |
| 2997 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 2998 | * @hdd_ctx: HDD Context |
| 2999 | * @adapter: HDD Adapter |
| 3000 | * |
| 3001 | * This function set the FW Debug log level based on the INI. |
| 3002 | * |
| 3003 | * Return: None |
| 3004 | */ |
| 3005 | static void hdd_set_fw_log_params(hdd_context_t *hdd_ctx, |
| 3006 | hdd_adapter_t *adapter) |
| 3007 | { |
| 3008 | uint8_t count = 0, numentries = 0, |
| 3009 | moduleloglevel[FW_MODULE_LOG_LEVEL_STRING_LENGTH]; |
| 3010 | uint32_t value = 0; |
| 3011 | int ret; |
| 3012 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3013 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 3014 | (!hdd_ctx->config->enable_fw_log)) { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3015 | hdd_info("enable_fw_log not enabled in INI or in FTM mode return"); |
| 3016 | return; |
| 3017 | } |
| 3018 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3019 | /* Enable FW logs based on INI configuration */ |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3020 | hdd_ctx->fw_log_settings.dl_type = |
| 3021 | hdd_ctx->config->enableFwLogType; |
| 3022 | ret = wma_cli_set_command(adapter->sessionId, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3023 | WMI_DBGLOG_TYPE, |
| 3024 | hdd_ctx->config->enableFwLogType, |
| 3025 | DBG_CMD); |
| 3026 | if (ret != 0) |
| 3027 | hdd_err("Failed to enable FW log type ret %d", |
| 3028 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3029 | |
| 3030 | hdd_ctx->fw_log_settings.dl_loglevel = |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3031 | hdd_ctx->config->enableFwLogLevel; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3032 | ret = wma_cli_set_command(adapter->sessionId, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3033 | WMI_DBGLOG_LOG_LEVEL, |
| 3034 | hdd_ctx->config->enableFwLogLevel, |
| 3035 | DBG_CMD); |
| 3036 | if (ret != 0) |
| 3037 | hdd_err("Failed to enable FW log level ret %d", |
| 3038 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3039 | |
| 3040 | hdd_string_to_u8_array( |
| 3041 | hdd_ctx->config->enableFwModuleLogLevel, |
| 3042 | moduleloglevel, |
| 3043 | &numentries, |
| 3044 | FW_MODULE_LOG_LEVEL_STRING_LENGTH); |
| 3045 | |
| 3046 | while (count < numentries) { |
| 3047 | /* |
| 3048 | * FW module log level input string looks like |
| 3049 | * below: |
| 3050 | * gFwDebugModuleLoglevel=<FW Module ID>, |
| 3051 | * <Log Level>,... |
| 3052 | * For example: |
| 3053 | * gFwDebugModuleLoglevel= |
| 3054 | * 1,0,2,1,3,2,4,3,5,4,6,5,7,6 |
| 3055 | * Above input string means : |
| 3056 | * For FW module ID 1 enable log level 0 |
| 3057 | * For FW module ID 2 enable log level 1 |
| 3058 | * For FW module ID 3 enable log level 2 |
| 3059 | * For FW module ID 4 enable log level 3 |
| 3060 | * For FW module ID 5 enable log level 4 |
| 3061 | * For FW module ID 6 enable log level 5 |
| 3062 | * For FW module ID 7 enable log level 6 |
| 3063 | */ |
| 3064 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3065 | /* FW expects WMI command value = |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3066 | * Module ID * 10 + Module Log level |
| 3067 | */ |
| 3068 | value = ((moduleloglevel[count] * 10) + |
| 3069 | moduleloglevel[count + 1]); |
| 3070 | ret = wma_cli_set_command(adapter->sessionId, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3071 | WMI_DBGLOG_MOD_LOG_LEVEL, |
| 3072 | value, DBG_CMD); |
| 3073 | if (ret != 0) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3074 | hdd_err("Failed to enable FW module log level %d ret %d", |
| 3075 | value, ret); |
| 3076 | |
| 3077 | count += 2; |
| 3078 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3079 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3080 | } |
| 3081 | #else |
| 3082 | static void hdd_set_fw_log_params(hdd_context_t *hdd_ctx, |
| 3083 | hdd_adapter_t *adapter) |
| 3084 | { |
| 3085 | } |
| 3086 | |
| 3087 | #endif |
| 3088 | |
| 3089 | /** |
| 3090 | * hdd_set_fw_params() - Set parameters to firmware |
| 3091 | * @adapter: HDD adapter |
| 3092 | * |
| 3093 | * This function Sets various parameters to fw once the |
| 3094 | * adapter is started. |
| 3095 | * |
| 3096 | * Return: 0 on success or errno on failure |
| 3097 | */ |
| 3098 | int hdd_set_fw_params(hdd_adapter_t *adapter) |
| 3099 | { |
| 3100 | int ret; |
| 3101 | hdd_context_t *hdd_ctx; |
| 3102 | |
| 3103 | ENTER_DEV(adapter->dev); |
| 3104 | |
| 3105 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3106 | if (!hdd_ctx) |
| 3107 | return -EINVAL; |
| 3108 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3109 | if ((cds_get_conparam() != QDF_GLOBAL_FTM_MODE) && |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3110 | (!hdd_ctx->config->enable2x2)) { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3111 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 3112 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3113 | /* |
| 3114 | * Disable DTIM 1 chain Rx when in 1x1, |
| 3115 | * we are passing two value |
| 3116 | * as param_id << 29 | param_value. |
| 3117 | * Below param_value = 0(disable) |
| 3118 | */ |
| 3119 | ret = wma_cli_set_command(adapter->sessionId, |
| 3120 | WMI_STA_SMPS_PARAM_CMDID, |
| 3121 | HDD_DTIM_1CHAIN_RX_ID << |
| 3122 | HDD_SMPS_PARAM_VALUE_S, |
| 3123 | VDEV_CMD); |
| 3124 | if (ret) { |
| 3125 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 3126 | goto error; |
| 3127 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3128 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3129 | ret = wma_cli_set_command(adapter->sessionId, |
| 3130 | WMI_PDEV_PARAM_TX_CHAIN_MASK, |
| 3131 | hdd_ctx->config->txchainmask1x1, |
| 3132 | PDEV_CMD); |
| 3133 | if (ret) { |
| 3134 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK set failed %d", |
| 3135 | ret); |
| 3136 | goto error; |
| 3137 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3138 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3139 | ret = wma_cli_set_command(adapter->sessionId, |
| 3140 | WMI_PDEV_PARAM_RX_CHAIN_MASK, |
| 3141 | hdd_ctx->config->rxchainmask1x1, |
| 3142 | PDEV_CMD); |
| 3143 | if (ret) { |
| 3144 | hdd_err("WMI_PDEV_PARAM_RX_CHAIN_MASK set failed %d", |
| 3145 | ret); |
| 3146 | goto error; |
| 3147 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3148 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 3149 | #undef HDD_SMPS_PARAM_VALUE_S |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3150 | } else { |
| 3151 | hdd_info("FTM Mode or 2x2 mode - Do not set 1x1 params"); |
| 3152 | } |
| 3153 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3154 | if (QDF_GLOBAL_FTM_MODE != cds_get_conparam()) { |
| 3155 | ret = wma_cli_set_command(adapter->sessionId, |
| 3156 | WMI_PDEV_PARAM_HYST_EN, |
| 3157 | hdd_ctx->config->enableMemDeepSleep, |
| 3158 | PDEV_CMD); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3159 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3160 | if (ret) { |
| 3161 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", |
| 3162 | ret); |
| 3163 | goto error; |
| 3164 | } |
Rajeev Kumar Sirasanagandla | 2dab3ec | 2016-10-18 16:10:15 +0530 | [diff] [blame] | 3165 | |
| 3166 | ret = wma_cli_set_command(adapter->sessionId, |
| 3167 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
| 3168 | hdd_ctx->config->rts_profile, |
| 3169 | VDEV_CMD); |
| 3170 | if (ret) { |
| 3171 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 3172 | goto error; |
| 3173 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3174 | } |
| 3175 | |
| 3176 | hdd_set_fw_log_params(hdd_ctx, adapter); |
| 3177 | |
| 3178 | EXIT(); |
| 3179 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3180 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3181 | error: |
| 3182 | return -EINVAL; |
| 3183 | } |
| 3184 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3185 | /** |
| 3186 | * hdd_open_adapter() - open and setup the hdd adatper |
| 3187 | * @hdd_ctx: global hdd context |
| 3188 | * @session_type: type of the interface to be created |
| 3189 | * @iface_name: User-visible name of the interface |
| 3190 | * @macAddr: MAC address to assign to the interface |
| 3191 | * @name_assign_type: the name of assign type of the netdev |
| 3192 | * @rtnl_held: the rtnl lock hold flag |
| 3193 | * |
| 3194 | * This function open and setup the hdd adpater according to the device |
| 3195 | * type request, assign the name, the mac address assigned, and then prepared |
| 3196 | * the hdd related parameters, queue, lock and ready to start. |
| 3197 | * |
| 3198 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 3199 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3200 | hdd_adapter_t *hdd_open_adapter(hdd_context_t *hdd_ctx, uint8_t session_type, |
| 3201 | const char *iface_name, tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3202 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3203 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3204 | { |
| 3205 | hdd_adapter_t *adapter = NULL; |
| 3206 | hdd_adapter_list_node_t *pHddAdapterNode = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3207 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3208 | hdd_cfg80211_state_t *cfgState; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3209 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3210 | hdd_info("iface(%s) type(%d)", iface_name, session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3211 | |
| 3212 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 3213 | /* |
| 3214 | * Max limit reached on the number of vdevs configured by the |
| 3215 | * host. Return error |
| 3216 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3217 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 3218 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3219 | return NULL; |
| 3220 | } |
| 3221 | |
| 3222 | if (macAddr == NULL) { |
| 3223 | /* Not received valid macAddr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3224 | 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] | 3225 | return NULL; |
| 3226 | } |
| 3227 | status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3228 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3229 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 3230 | " already exists", |
| 3231 | MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3232 | return NULL; |
| 3233 | } |
| 3234 | |
| 3235 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3236 | case QDF_STA_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3237 | /* Reset locally administered bit if the device mode is STA */ |
| 3238 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr); |
| 3239 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3240 | case QDF_P2P_CLIENT_MODE: |
| 3241 | case QDF_P2P_DEVICE_MODE: |
| 3242 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 3243 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3244 | case QDF_MONITOR_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3245 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 3246 | name_assign_type, |
| 3247 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3248 | |
| 3249 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3250 | hdd_err("failed to allocate adapter for session %d", |
| 3251 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3252 | return NULL; |
| 3253 | } |
| 3254 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3255 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3256 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3257 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3258 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3259 | else if (QDF_MONITOR_MODE == session_type) |
| 3260 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3261 | else |
| 3262 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 3263 | |
| 3264 | adapter->device_mode = session_type; |
| 3265 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3266 | if (QDF_NDI_MODE == session_type) { |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 3267 | status = hdd_init_nan_data_mode(adapter); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3268 | if (QDF_STATUS_SUCCESS != status) |
| 3269 | goto err_free_netdev; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3270 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3271 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3272 | /* |
| 3273 | * Workqueue which gets scheduled in IPv4 notification |
| 3274 | * callback |
| 3275 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3276 | INIT_WORK(&adapter->ipv4NotifierWorkQueue, |
| 3277 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3278 | |
| 3279 | #ifdef WLAN_NS_OFFLOAD |
| 3280 | /* |
| 3281 | * Workqueue which gets scheduled in IPv6 |
| 3282 | * notification callback. |
| 3283 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3284 | INIT_WORK(&adapter->ipv6NotifierWorkQueue, |
| 3285 | hdd_ipv6_notifier_work_queue); |
| 3286 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3287 | status = hdd_register_interface(adapter, rtnl_held); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3288 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3289 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 3290 | goto err_free_netdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3291 | } |
| 3292 | |
| 3293 | /* Stop the Interface TX queue. */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3294 | hdd_info("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3295 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3296 | WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 3297 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3298 | break; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3299 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3300 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3301 | case QDF_P2P_GO_MODE: |
| 3302 | case QDF_SAP_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3303 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr, |
| 3304 | name_assign_type, |
| 3305 | (uint8_t *) iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3306 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3307 | hdd_alert("failed to allocate adapter for session %d", |
| 3308 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3309 | return NULL; |
| 3310 | } |
| 3311 | |
| 3312 | adapter->wdev.iftype = |
| 3313 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3314 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3315 | NL80211_IFTYPE_P2P_GO; |
| 3316 | adapter->device_mode = session_type; |
| 3317 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3318 | status = hdd_register_hostapd(adapter, rtnl_held); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3319 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3320 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
| 3321 | goto err_free_netdev; |
| 3322 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3323 | hdd_info("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3324 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3325 | WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 3326 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3327 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3328 | case QDF_FTM_MODE: |
| 3329 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 3330 | name_assign_type, |
| 3331 | "wlan0"); |
| 3332 | if (NULL == adapter) { |
| 3333 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 3334 | return NULL; |
| 3335 | } |
| 3336 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 3337 | adapter->device_mode = session_type; |
| 3338 | status = hdd_register_interface(adapter, rtnl_held); |
| 3339 | if (QDF_STATUS_SUCCESS != status) { |
| 3340 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
| 3341 | goto err_free_netdev; |
| 3342 | } |
| 3343 | /* Stop the Interface TX queue. */ |
| 3344 | hdd_info("Disabling queues"); |
| 3345 | wlan_hdd_netif_queue_control(adapter, |
| 3346 | WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 3347 | WLAN_CONTROL_PATH); |
| 3348 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3349 | default: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3350 | hdd_alert("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3351 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3352 | return NULL; |
| 3353 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3354 | |
| 3355 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR(adapter); |
| 3356 | mutex_init(&cfgState->remain_on_chan_ctx_lock); |
| 3357 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3358 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3359 | /* Add it to the hdd's session list. */ |
| 3360 | pHddAdapterNode = |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3361 | qdf_mem_malloc(sizeof(hdd_adapter_list_node_t)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3362 | if (NULL == pHddAdapterNode) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3363 | status = QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3364 | } else { |
| 3365 | pHddAdapterNode->pAdapter = adapter; |
| 3366 | status = hdd_add_adapter_back(hdd_ctx, pHddAdapterNode); |
| 3367 | } |
| 3368 | } |
| 3369 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3370 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3371 | if (NULL != adapter) { |
| 3372 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 3373 | adapter = NULL; |
| 3374 | } |
| 3375 | if (NULL != pHddAdapterNode) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3376 | qdf_mem_free(pHddAdapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3377 | } |
| 3378 | return NULL; |
| 3379 | } |
| 3380 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3381 | if (QDF_STATUS_SUCCESS == status) { |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 3382 | cds_set_concurrency_mode(session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3383 | |
| 3384 | /* Initialize the WoWL service */ |
| 3385 | if (!hdd_init_wowl(adapter)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3386 | hdd_alert("hdd_init_wowl failed"); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 3387 | goto err_close_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3388 | } |
| 3389 | |
| 3390 | /* Adapter successfully added. Increment the vdev count */ |
| 3391 | hdd_ctx->current_intf_count++; |
| 3392 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3393 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3394 | hdd_ctx->current_intf_count); |
| 3395 | |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 3396 | cds_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3397 | } |
| 3398 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 3399 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
| 3400 | hdd_err("Interface %s wow debug_fs init failed", iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3401 | |
| 3402 | return adapter; |
| 3403 | |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 3404 | err_close_adapter: |
| 3405 | hdd_close_adapter(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3406 | err_free_netdev: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3407 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->macAddressCurrent.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 3408 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3409 | |
| 3410 | return NULL; |
| 3411 | } |
| 3412 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3413 | 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] | 3414 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3415 | { |
| 3416 | hdd_adapter_list_node_t *adapterNode, *pCurrent, *pNext; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3417 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3418 | |
| 3419 | status = hdd_get_front_adapter(hdd_ctx, &pCurrent); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3420 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3421 | hdd_warn("adapter list empty %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3422 | status); |
| 3423 | return status; |
| 3424 | } |
| 3425 | |
| 3426 | while (pCurrent->pAdapter != adapter) { |
| 3427 | status = hdd_get_next_adapter(hdd_ctx, pCurrent, &pNext); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3428 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3429 | break; |
| 3430 | |
| 3431 | pCurrent = pNext; |
| 3432 | } |
| 3433 | adapterNode = pCurrent; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3434 | if (QDF_STATUS_SUCCESS == status) { |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 3435 | hdd_info("wait for bus bw work to flush"); |
| 3436 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 3437 | cds_clear_concurrency_mode(adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3438 | hdd_cleanup_adapter(hdd_ctx, adapterNode->pAdapter, rtnl_held); |
| 3439 | |
| 3440 | hdd_remove_adapter(hdd_ctx, adapterNode); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3441 | qdf_mem_free(adapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3442 | adapterNode = NULL; |
| 3443 | |
| 3444 | /* Adapter removed. Decrement vdev count */ |
| 3445 | if (hdd_ctx->current_intf_count != 0) |
| 3446 | hdd_ctx->current_intf_count--; |
| 3447 | |
| 3448 | /* Fw will take care incase of concurrency */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3449 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3450 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3451 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3452 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3453 | } |
| 3454 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3455 | /** |
| 3456 | * hdd_close_all_adapters - Close all open adapters |
| 3457 | * @hdd_ctx: Hdd context |
| 3458 | * rtnl_held: True if RTNL lock held |
| 3459 | * |
| 3460 | * Close all open adapters. |
| 3461 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3462 | * Return: QDF status code |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3463 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3464 | 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] | 3465 | { |
| 3466 | hdd_adapter_list_node_t *pHddAdapterNode; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3467 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3468 | |
| 3469 | ENTER(); |
| 3470 | |
| 3471 | do { |
| 3472 | status = hdd_remove_front_adapter(hdd_ctx, &pHddAdapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3473 | if (pHddAdapterNode && QDF_STATUS_SUCCESS == status) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3474 | wlan_hdd_release_intf_addr(hdd_ctx, |
| 3475 | pHddAdapterNode->pAdapter->macAddressCurrent.bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3476 | hdd_cleanup_adapter(hdd_ctx, pHddAdapterNode->pAdapter, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3477 | rtnl_held); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3478 | qdf_mem_free(pHddAdapterNode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3479 | /* Adapter removed. Decrement vdev count */ |
| 3480 | if (hdd_ctx->current_intf_count != 0) |
| 3481 | hdd_ctx->current_intf_count--; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3482 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3483 | } while (NULL != pHddAdapterNode && QDF_STATUS_E_EMPTY != status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3484 | |
| 3485 | EXIT(); |
| 3486 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3487 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3488 | } |
| 3489 | |
| 3490 | void wlan_hdd_reset_prob_rspies(hdd_adapter_t *pHostapdAdapter) |
| 3491 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3492 | struct qdf_mac_addr *bssid = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3493 | tSirUpdateIE updateIE; |
| 3494 | switch (pHostapdAdapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3495 | case QDF_STA_MODE: |
| 3496 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3497 | { |
| 3498 | hdd_station_ctx_t *pHddStaCtx = |
| 3499 | WLAN_HDD_GET_STATION_CTX_PTR(pHostapdAdapter); |
Srinivas Girigowda | 8b98396 | 2015-11-18 22:14:34 -0800 | [diff] [blame] | 3500 | bssid = &pHddStaCtx->conn_info.bssId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3501 | break; |
| 3502 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3503 | case QDF_SAP_MODE: |
| 3504 | case QDF_P2P_GO_MODE: |
| 3505 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3506 | { |
Srinivas Girigowda | 8b98396 | 2015-11-18 22:14:34 -0800 | [diff] [blame] | 3507 | bssid = &pHostapdAdapter->macAddressCurrent; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3508 | break; |
| 3509 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3510 | case QDF_FTM_MODE: |
| 3511 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3512 | default: |
| 3513 | /* |
| 3514 | * wlan_hdd_reset_prob_rspies should not have been called |
| 3515 | * for these kind of devices |
| 3516 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3517 | hdd_err("Unexpected request for the current device type %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3518 | pHostapdAdapter->device_mode); |
| 3519 | return; |
| 3520 | } |
| 3521 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 3522 | qdf_copy_macaddr(&updateIE.bssid, bssid); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3523 | updateIE.smeSessionId = pHostapdAdapter->sessionId; |
| 3524 | updateIE.ieBufferlength = 0; |
| 3525 | updateIE.pAdditionIEBuffer = NULL; |
| 3526 | updateIE.append = true; |
| 3527 | updateIE.notify = false; |
| 3528 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(pHostapdAdapter), |
| 3529 | &updateIE, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3530 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3531 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3532 | } |
| 3533 | } |
| 3534 | |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 3535 | /** |
| 3536 | * hdd_wait_for_sme_close_sesion() - Close and wait for SME session close |
| 3537 | * @hdd_ctx: HDD context which is already NULL validated |
| 3538 | * @adapter: HDD adapter which is already NULL validated |
| 3539 | * |
| 3540 | * Close the SME session and wait for its completion, if needed. |
| 3541 | * |
| 3542 | * Return: None |
| 3543 | */ |
| 3544 | static void hdd_wait_for_sme_close_sesion(hdd_context_t *hdd_ctx, |
| 3545 | hdd_adapter_t *adapter) |
| 3546 | { |
Rajeev Kumar | 9591d2b | 2017-01-13 16:05:06 -0800 | [diff] [blame] | 3547 | int ret; |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 3548 | unsigned long rc; |
| 3549 | |
| 3550 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 3551 | hdd_err("session is not opened:%d", adapter->sessionId); |
| 3552 | return; |
| 3553 | } |
| 3554 | |
| 3555 | INIT_COMPLETION(adapter->session_close_comp_var); |
| 3556 | if (QDF_STATUS_SUCCESS == |
| 3557 | sme_close_session(hdd_ctx->hHal, adapter->sessionId, |
| 3558 | hdd_sme_close_session_callback, |
| 3559 | adapter)) { |
| 3560 | /* |
| 3561 | * Block on a completion variable. Can't wait |
| 3562 | * forever though. |
| 3563 | */ |
| 3564 | rc = wait_for_completion_timeout( |
| 3565 | &adapter->session_close_comp_var, |
| 3566 | msecs_to_jiffies |
| 3567 | (WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
Sandeep Puligilla | ada7292 | 2016-09-29 19:31:21 -0700 | [diff] [blame] | 3568 | if (!rc) { |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 3569 | hdd_err("failure waiting for session_close_comp_var"); |
Sandeep Puligilla | ada7292 | 2016-09-29 19:31:21 -0700 | [diff] [blame] | 3570 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3571 | hdd_ndp_session_end_handler(adapter); |
| 3572 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Hanumanth Reddy Pothula | 3370212 | 2016-10-07 17:27:04 +0530 | [diff] [blame] | 3573 | return; |
Sandeep Puligilla | ada7292 | 2016-09-29 19:31:21 -0700 | [diff] [blame] | 3574 | } |
Rajeev Kumar | 9591d2b | 2017-01-13 16:05:06 -0800 | [diff] [blame] | 3575 | ret = hdd_release_and_destroy_vdev(adapter); |
| 3576 | if (ret) |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 3577 | hdd_err("vdev delete failed"); |
| 3578 | |
Hanumanth Reddy Pothula | 3370212 | 2016-10-07 17:27:04 +0530 | [diff] [blame] | 3579 | adapter->sessionId = HDD_SESSION_ID_INVALID; |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 3580 | } |
| 3581 | } |
| 3582 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3583 | 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] | 3584 | const bool bCloseSession) |
| 3585 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3586 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3587 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(adapter); |
| 3588 | union iwreq_data wrqu; |
| 3589 | tSirUpdateIE updateIE; |
| 3590 | unsigned long rc; |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 3591 | hdd_scaninfo_t *scan_info = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3592 | |
| 3593 | ENTER(); |
| 3594 | |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 3595 | scan_info = &adapter->scan_info; |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3596 | hdd_notice("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3597 | wlan_hdd_netif_queue_control(adapter, WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 3598 | WLAN_CONTROL_PATH); |
| 3599 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3600 | case QDF_STA_MODE: |
| 3601 | case QDF_P2P_CLIENT_MODE: |
| 3602 | case QDF_IBSS_MODE: |
| 3603 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3604 | case QDF_NDI_MODE: |
| 3605 | if ((QDF_NDI_MODE == adapter->device_mode) || |
| 3606 | hdd_conn_is_connected( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3607 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)) || |
| 3608 | hdd_is_connecting( |
| 3609 | WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3610 | INIT_COMPLETION(adapter->disconnect_comp_var); |
| 3611 | /* |
| 3612 | * For NDI do not use pWextState from sta_ctx, if needed |
| 3613 | * extract from ndi_ctx. |
| 3614 | */ |
| 3615 | if (QDF_NDI_MODE == adapter->device_mode) |
| 3616 | qdf_ret_status = sme_roam_disconnect( |
| 3617 | hdd_ctx->hHal, |
| 3618 | adapter->sessionId, |
| 3619 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
| 3620 | else if (pWextState->roamProfile.BSSType == |
| 3621 | eCSR_BSS_TYPE_START_IBSS) |
| 3622 | qdf_ret_status = sme_roam_disconnect( |
| 3623 | hdd_ctx->hHal, |
| 3624 | adapter->sessionId, |
| 3625 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3626 | else |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3627 | qdf_ret_status = sme_roam_disconnect( |
| 3628 | hdd_ctx->hHal, |
| 3629 | adapter->sessionId, |
| 3630 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3631 | /* success implies disconnect command got queued up successfully */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3632 | if (qdf_ret_status == QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3633 | rc = wait_for_completion_timeout( |
| 3634 | &adapter->disconnect_comp_var, |
| 3635 | msecs_to_jiffies |
| 3636 | (WLAN_WAIT_TIME_DISCONNECT)); |
| 3637 | if (!rc) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3638 | hdd_err("wait on disconnect_comp_var failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3639 | } |
| 3640 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3641 | hdd_err("failed to post disconnect event to SME"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3642 | } |
| 3643 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 3644 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 3645 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 3646 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 3647 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 3648 | } |
| 3649 | if (scan_info != NULL && scan_info->mScanPending) { |
Mahesh A Saptasagar | ebb47fa | 2016-07-21 18:11:38 +0530 | [diff] [blame] | 3650 | wlan_hdd_scan_abort(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3651 | } |
Himanshu Agarwal | 3d95b90 | 2016-08-24 16:27:03 +0530 | [diff] [blame] | 3652 | hdd_lro_disable(hdd_ctx, adapter); |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 3653 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3654 | |
| 3655 | #ifdef WLAN_OPEN_SOURCE |
| 3656 | cancel_work_sync(&adapter->ipv4NotifierWorkQueue); |
| 3657 | #endif |
| 3658 | |
| 3659 | hdd_deregister_tx_flow_control(adapter); |
| 3660 | |
| 3661 | #ifdef WLAN_NS_OFFLOAD |
| 3662 | #ifdef WLAN_OPEN_SOURCE |
| 3663 | cancel_work_sync(&adapter->ipv6NotifierWorkQueue); |
| 3664 | #endif |
| 3665 | #endif |
| 3666 | |
| 3667 | /* |
| 3668 | * It is possible that the caller of this function does not |
| 3669 | * wish to close the session |
| 3670 | */ |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 3671 | if (true == bCloseSession) |
| 3672 | hdd_wait_for_sme_close_sesion(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3673 | break; |
| 3674 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3675 | case QDF_SAP_MODE: |
| 3676 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3677 | if (hdd_ctx->config->conc_custom_rule1 && |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3678 | (QDF_SAP_MODE == adapter->device_mode)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3679 | /* |
| 3680 | * Before stopping the sap adapter, lets make sure there |
| 3681 | * is no sap restart work pending. |
| 3682 | */ |
| 3683 | cds_flush_work(&hdd_ctx->sap_start_work); |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3684 | hdd_info("Canceled the pending SAP restart work"); |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 3685 | cds_change_sap_restart_required_status(false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3686 | } |
| 3687 | /* Any softap specific cleanup here... */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3688 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3689 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 3690 | |
| 3691 | hdd_deregister_tx_flow_control(adapter); |
| 3692 | |
| 3693 | mutex_lock(&hdd_ctx->sap_lock); |
| 3694 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3695 | QDF_STATUS status; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 3696 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3697 | |
| 3698 | /* Stop Bss. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3699 | status = wlansap_stop_bss( |
| 3700 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3701 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3702 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3703 | hdd_hostapd_state_t *hostapd_state = |
| 3704 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 3705 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3706 | qdf_stop_bss_event); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 3707 | qdf_status = |
| 3708 | qdf_wait_single_event(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 3709 | qdf_stop_bss_event, |
| 3710 | SME_CMD_TIMEOUT_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3711 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 3712 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3713 | hdd_err("failure waiting for wlansap_stop_bss %d", |
| 3714 | qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3715 | } |
| 3716 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3717 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3718 | } |
| 3719 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 3720 | cds_decr_session_set_pcl( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3721 | adapter->device_mode, |
| 3722 | adapter->sessionId); |
| 3723 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 3724 | qdf_copy_macaddr(&updateIE.bssid, |
Srinivas Girigowda | 8b98396 | 2015-11-18 22:14:34 -0800 | [diff] [blame] | 3725 | &adapter->macAddressCurrent); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3726 | updateIE.smeSessionId = adapter->sessionId; |
| 3727 | updateIE.ieBufferlength = 0; |
| 3728 | updateIE.pAdditionIEBuffer = NULL; |
| 3729 | updateIE.append = false; |
| 3730 | updateIE.notify = false; |
| 3731 | /* Probe bcn reset */ |
| 3732 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 3733 | &updateIE, eUPDATE_IE_PROBE_BCN) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3734 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3735 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3736 | } |
| 3737 | /* Assoc resp reset */ |
| 3738 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 3739 | &updateIE, |
| 3740 | eUPDATE_IE_ASSOC_RESP) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3741 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3742 | hdd_err("Could not pass on ASSOC_RSP data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3743 | } |
| 3744 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 3745 | wlan_hdd_reset_prob_rspies(adapter); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 3746 | qdf_mem_free(adapter->sessionCtx.ap.beacon); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3747 | adapter->sessionCtx.ap.beacon = NULL; |
| 3748 | } |
| 3749 | mutex_unlock(&hdd_ctx->sap_lock); |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 3750 | if (true == bCloseSession) |
| 3751 | hdd_wait_for_sme_close_sesion(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3752 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3753 | case QDF_OCB_MODE: |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 3754 | cdp_peer_clear(cds_get_context(QDF_MODULE_ID_SOC), |
| 3755 | cds_get_context(QDF_MODULE_ID_TXRX), |
| 3756 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.staId[0]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3757 | break; |
| 3758 | default: |
| 3759 | break; |
| 3760 | } |
| 3761 | |
| 3762 | EXIT(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3763 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3764 | } |
| 3765 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 3766 | /** |
| 3767 | * hdd_deinit_all_adapters - deinit all adapters |
| 3768 | * @hdd_ctx: HDD context |
| 3769 | * @rtnl_held: True if RTNL lock held |
| 3770 | * |
| 3771 | */ |
| 3772 | void hdd_deinit_all_adapters(hdd_context_t *hdd_ctx, bool rtnl_held) |
| 3773 | { |
| 3774 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 3775 | QDF_STATUS status; |
| 3776 | hdd_adapter_t *adapter; |
| 3777 | |
| 3778 | ENTER(); |
| 3779 | |
| 3780 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 3781 | |
| 3782 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 3783 | adapter = adapter_node->pAdapter; |
| 3784 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
| 3785 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 3786 | adapter_node = next; |
| 3787 | } |
| 3788 | |
| 3789 | EXIT(); |
| 3790 | } |
| 3791 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3792 | QDF_STATUS hdd_stop_all_adapters(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3793 | { |
| 3794 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3795 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3796 | hdd_adapter_t *adapter; |
| 3797 | |
| 3798 | ENTER(); |
| 3799 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 3800 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 3801 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3802 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 3803 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3804 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3805 | adapter = adapterNode->pAdapter; |
| 3806 | hdd_stop_adapter(hdd_ctx, adapter, true); |
| 3807 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 3808 | adapterNode = pNext; |
| 3809 | } |
| 3810 | |
| 3811 | EXIT(); |
| 3812 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3813 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3814 | } |
| 3815 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3816 | QDF_STATUS hdd_reset_all_adapters(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3817 | { |
| 3818 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3819 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3820 | hdd_adapter_t *adapter; |
| 3821 | |
| 3822 | ENTER(); |
| 3823 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 3824 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 3825 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3826 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 3827 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3828 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3829 | adapter = adapterNode->pAdapter; |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3830 | hdd_notice("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3831 | wlan_hdd_netif_queue_control(adapter, |
| 3832 | WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 3833 | WLAN_CONTROL_PATH); |
| 3834 | |
| 3835 | adapter->sessionCtx.station.hdd_ReassocScenario = false; |
| 3836 | |
| 3837 | hdd_deinit_tx_rx(adapter); |
Tushnim Bhattacharyya | 4adb368 | 2016-01-07 15:07:12 -0800 | [diff] [blame] | 3838 | cds_decr_session_set_pcl(adapter->device_mode, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3839 | adapter->sessionId); |
| 3840 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 3841 | hdd_wmm_adapter_close(adapter); |
| 3842 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3843 | } |
| 3844 | |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 3845 | /* |
| 3846 | * If adapter is SAP, set session ID to invalid since SAP |
| 3847 | * session will be cleanup during SSR. |
| 3848 | */ |
| 3849 | if (adapter->device_mode == QDF_SAP_MODE) |
| 3850 | wlansap_set_invalid_session( |
| 3851 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 3852 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3853 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 3854 | adapterNode = pNext; |
| 3855 | } |
| 3856 | |
| 3857 | EXIT(); |
| 3858 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3859 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3860 | } |
| 3861 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3862 | /** |
| 3863 | * hdd_is_interface_up()- Checkfor interface up before ssr |
| 3864 | * @hdd_ctx: HDD context |
| 3865 | * |
| 3866 | * check if there are any wlan interfaces before SSR accordingly start |
| 3867 | * the interface. |
| 3868 | * |
| 3869 | * Return: 0 if interface was opened else false |
| 3870 | */ |
| 3871 | static bool hdd_is_interface_up(hdd_adapter_t *adapter) |
| 3872 | { |
| 3873 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 3874 | return true; |
| 3875 | else |
| 3876 | return false; |
| 3877 | } |
| 3878 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3879 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
Abhishek Singh | b5e38ef | 2017-01-02 12:09:34 +0530 | [diff] [blame] | 3880 | && !defined(WITH_BACKPORTS) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3881 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 3882 | struct ieee80211_channel *channel, |
| 3883 | const u8 *bssid, const u8 *ssid, |
| 3884 | size_t ssid_len) |
| 3885 | { |
| 3886 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 3887 | ssid, ssid_len, |
| 3888 | WLAN_CAPABILITY_ESS, |
| 3889 | WLAN_CAPABILITY_ESS); |
| 3890 | } |
| 3891 | #else |
| 3892 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 3893 | struct ieee80211_channel *channel, |
| 3894 | const u8 *bssid, const u8 *ssid, |
| 3895 | size_t ssid_len) |
| 3896 | { |
| 3897 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 3898 | ssid, ssid_len, |
| 3899 | IEEE80211_BSS_TYPE_ESS, |
| 3900 | IEEE80211_PRIVACY_ANY); |
| 3901 | } |
| 3902 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3903 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 3904 | #if defined CFG80211_CONNECT_BSS |
| 3905 | /** |
| 3906 | * hdd_connect_bss() - API to send connection status to supplicant |
| 3907 | * @dev: network device |
| 3908 | * @bssid: bssid to which we want to associate |
| 3909 | * @req_ie: Request Information Element |
| 3910 | * @req_ie_len: len of the req IE |
| 3911 | * @resp_ie: Response IE |
| 3912 | * @resp_ie_len: len of ht response IE |
| 3913 | * @status: status |
| 3914 | * @gfp: Kernel Flag |
| 3915 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 3916 | * |
| 3917 | * The API is a wrapper to send connection status to supplicant |
| 3918 | * |
| 3919 | * Return: Void |
| 3920 | */ |
| 3921 | #if defined CFG80211_CONNECT_TIMEOUT |
| 3922 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 3923 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 3924 | size_t req_ie_len, const u8 *resp_ie, |
| 3925 | size_t resp_ie_len, int status, gfp_t gfp, |
| 3926 | bool connect_timeout) |
| 3927 | { |
| 3928 | if (connect_timeout) |
| 3929 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 3930 | else |
| 3931 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 3932 | resp_ie, resp_ie_len, status, gfp); |
| 3933 | } |
| 3934 | #else |
| 3935 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 3936 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 3937 | size_t req_ie_len, const u8 *resp_ie, |
| 3938 | size_t resp_ie_len, int status, gfp_t gfp, |
| 3939 | bool connect_timeout) |
| 3940 | { |
| 3941 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 3942 | resp_ie, resp_ie_len, status, gfp); |
| 3943 | } |
| 3944 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3945 | |
| 3946 | /** |
| 3947 | * hdd_connect_result() - API to send connection status to supplicant |
| 3948 | * @dev: network device |
| 3949 | * @bssid: bssid to which we want to associate |
| 3950 | * @roam_info: information about connected bss |
| 3951 | * @req_ie: Request Information Element |
| 3952 | * @req_ie_len: len of the req IE |
| 3953 | * @resp_ie: Response IE |
| 3954 | * @resp_ie_len: len of ht response IE |
| 3955 | * @status: status |
| 3956 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 3957 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3958 | * |
| 3959 | * The API is a wrapper to send connection status to supplicant |
| 3960 | * and allow runtime suspend |
| 3961 | * |
| 3962 | * Return: Void |
| 3963 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3964 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
| 3965 | tCsrRoamInfo *roam_info, const u8 *req_ie, |
| 3966 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 3967 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 3968 | bool connect_timeout) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3969 | { |
| 3970 | hdd_adapter_t *padapter = (hdd_adapter_t *) netdev_priv(dev); |
| 3971 | struct cfg80211_bss *bss = NULL; |
| 3972 | |
| 3973 | if (WLAN_STATUS_SUCCESS == status) { |
| 3974 | struct ieee80211_channel *chan; |
| 3975 | int freq; |
| 3976 | int chan_no = roam_info->pBssDesc->channelId; |
| 3977 | |
| 3978 | if (chan_no <= 14) |
| 3979 | freq = ieee80211_channel_to_frequency(chan_no, |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 3980 | NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3981 | else |
| 3982 | freq = ieee80211_channel_to_frequency(chan_no, |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 3983 | NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3984 | |
| 3985 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
| 3986 | bss = hdd_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
| 3987 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 3988 | roam_info->u.pConnectedProfile->SSID.length); |
| 3989 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3990 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 3991 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 3992 | req_ie_len, resp_ie, resp_ie_len, |
| 3993 | status, gfp, connect_timeout); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3994 | |
| 3995 | qdf_runtime_pm_allow_suspend(padapter->connect_rpm_ctx.connect); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3996 | } |
| 3997 | #else |
| 3998 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
| 3999 | tCsrRoamInfo *roam_info, const u8 *req_ie, |
| 4000 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4001 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 4002 | bool connect_timeout) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4003 | { |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 4004 | hdd_adapter_t *padapter = (hdd_adapter_t *) netdev_priv(dev); |
| 4005 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4006 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 4007 | resp_ie, resp_ie_len, status, gfp); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 4008 | qdf_runtime_pm_allow_suspend(padapter->connect_rpm_ctx.connect); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4009 | } |
| 4010 | #endif |
| 4011 | |
| 4012 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4013 | QDF_STATUS hdd_start_all_adapters(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4014 | { |
| 4015 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4016 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4017 | hdd_adapter_t *adapter; |
| 4018 | #ifndef MSM_PLATFORM |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4019 | struct qdf_mac_addr bcastMac = QDF_MAC_ADDR_BROADCAST_INITIALIZER; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4020 | #endif |
| 4021 | eConnectionState connState; |
| 4022 | |
| 4023 | ENTER(); |
| 4024 | |
| 4025 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4026 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4027 | adapter = adapterNode->pAdapter; |
| 4028 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4029 | if (!hdd_is_interface_up(adapter)) |
Hanumanth Reddy Pothula | c1c4d2b | 2016-09-22 15:45:16 +0530 | [diff] [blame] | 4030 | goto get_adapter; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4031 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4032 | hdd_wmm_init(adapter); |
| 4033 | |
| 4034 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4035 | case QDF_STA_MODE: |
| 4036 | case QDF_P2P_CLIENT_MODE: |
| 4037 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4038 | |
| 4039 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 4040 | ->conn_info.connState; |
| 4041 | |
| 4042 | hdd_init_station_mode(adapter); |
| 4043 | /* Open the gates for HDD to receive Wext commands */ |
| 4044 | adapter->isLinkUpSvcNeeded = false; |
| 4045 | adapter->scan_info.mScanPending = false; |
| 4046 | |
| 4047 | /* Indicate disconnect event to supplicant if associated previously */ |
| 4048 | if (eConnectionState_Associated == connState || |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 4049 | eConnectionState_IbssConnected == connState || |
| 4050 | eConnectionState_NotConnected == connState || |
| 4051 | eConnectionState_IbssDisconnected == connState || |
| 4052 | eConnectionState_Disconnecting == connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4053 | union iwreq_data wrqu; |
| 4054 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 4055 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 4056 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 4057 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 4058 | &wrqu, NULL); |
| 4059 | adapter->sessionCtx.station. |
| 4060 | hdd_ReassocScenario = false; |
| 4061 | |
| 4062 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 4063 | wlan_hdd_cfg80211_indicate_disconnect( |
| 4064 | adapter->dev, false, |
| 4065 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4066 | } else if (eConnectionState_Connecting == connState) { |
| 4067 | /* |
| 4068 | * Indicate connect failure to supplicant if we were in the |
| 4069 | * process of connecting |
| 4070 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4071 | hdd_connect_result(adapter->dev, NULL, NULL, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4072 | NULL, 0, NULL, 0, |
| 4073 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4074 | GFP_KERNEL, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4075 | } |
| 4076 | |
| 4077 | hdd_register_tx_flow_control(adapter, |
| 4078 | hdd_tx_resume_timer_expired_handler, |
| 4079 | hdd_tx_resume_cb); |
| 4080 | |
| 4081 | break; |
| 4082 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4083 | case QDF_SAP_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4084 | /* softAP can handle SSR */ |
| 4085 | break; |
| 4086 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4087 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4088 | #ifdef MSM_PLATFORM |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4089 | hdd_err("[SSR] send stop ap to supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4090 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 4091 | #else |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4092 | hdd_err("[SSR] send restart supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4093 | /* event supplicant to restart */ |
| 4094 | cfg80211_del_sta(adapter->dev, |
| 4095 | (const u8 *)&bcastMac.bytes[0], |
| 4096 | GFP_KERNEL); |
| 4097 | #endif |
| 4098 | break; |
| 4099 | |
| 4100 | default: |
| 4101 | break; |
| 4102 | } |
Hanumanth Reddy Pothula | c1c4d2b | 2016-09-22 15:45:16 +0530 | [diff] [blame] | 4103 | get_adapter: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4104 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4105 | adapterNode = pNext; |
| 4106 | } |
| 4107 | |
| 4108 | EXIT(); |
| 4109 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4110 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4111 | } |
| 4112 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4113 | QDF_STATUS hdd_get_front_adapter(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4114 | hdd_adapter_list_node_t **padapterNode) |
| 4115 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4116 | QDF_STATUS status; |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4117 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4118 | status = qdf_list_peek_front(&hdd_ctx->hddAdapters, |
| 4119 | (qdf_list_node_t **) padapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4120 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4121 | return status; |
| 4122 | } |
| 4123 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4124 | QDF_STATUS hdd_get_next_adapter(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4125 | hdd_adapter_list_node_t *adapterNode, |
| 4126 | hdd_adapter_list_node_t **pNextAdapterNode) |
| 4127 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4128 | QDF_STATUS status; |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4129 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4130 | status = qdf_list_peek_next(&hdd_ctx->hddAdapters, |
| 4131 | (qdf_list_node_t *) adapterNode, |
| 4132 | (qdf_list_node_t **) pNextAdapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4133 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4134 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4135 | return status; |
| 4136 | } |
| 4137 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4138 | QDF_STATUS hdd_remove_adapter(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4139 | hdd_adapter_list_node_t *adapterNode) |
| 4140 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4141 | QDF_STATUS status; |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4142 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4143 | status = qdf_list_remove_node(&hdd_ctx->hddAdapters, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4144 | &adapterNode->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4145 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4146 | return status; |
| 4147 | } |
| 4148 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4149 | QDF_STATUS hdd_remove_front_adapter(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4150 | hdd_adapter_list_node_t **padapterNode) |
| 4151 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4152 | QDF_STATUS status; |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4153 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4154 | status = qdf_list_remove_front(&hdd_ctx->hddAdapters, |
| 4155 | (qdf_list_node_t **) padapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4156 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4157 | return status; |
| 4158 | } |
| 4159 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4160 | QDF_STATUS hdd_add_adapter_back(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4161 | hdd_adapter_list_node_t *adapterNode) |
| 4162 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4163 | QDF_STATUS status; |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4164 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4165 | status = qdf_list_insert_back(&hdd_ctx->hddAdapters, |
| 4166 | (qdf_list_node_t *) adapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4167 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4168 | return status; |
| 4169 | } |
| 4170 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4171 | QDF_STATUS hdd_add_adapter_front(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4172 | hdd_adapter_list_node_t *adapterNode) |
| 4173 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4174 | QDF_STATUS status; |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4175 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4176 | status = qdf_list_insert_front(&hdd_ctx->hddAdapters, |
| 4177 | (qdf_list_node_t *) adapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4178 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4179 | return status; |
| 4180 | } |
| 4181 | |
| 4182 | hdd_adapter_t *hdd_get_adapter_by_macaddr(hdd_context_t *hdd_ctx, |
| 4183 | tSirMacAddr macAddr) |
| 4184 | { |
| 4185 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 4186 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4187 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4188 | |
| 4189 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4190 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4191 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4192 | adapter = adapterNode->pAdapter; |
| 4193 | |
| 4194 | if (adapter |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4195 | && !qdf_mem_cmp(adapter->macAddressCurrent.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4196 | macAddr, sizeof(tSirMacAddr))) { |
| 4197 | return adapter; |
| 4198 | } |
| 4199 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4200 | adapterNode = pNext; |
| 4201 | } |
| 4202 | |
| 4203 | return NULL; |
| 4204 | |
| 4205 | } |
| 4206 | |
| 4207 | hdd_adapter_t *hdd_get_adapter_by_vdev(hdd_context_t *hdd_ctx, |
| 4208 | uint32_t vdev_id) |
| 4209 | { |
| 4210 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 4211 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4212 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4213 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4214 | qdf_status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4215 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4216 | while ((NULL != adapterNode) && (QDF_STATUS_SUCCESS == qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4217 | adapter = adapterNode->pAdapter; |
| 4218 | |
| 4219 | if (adapter->sessionId == vdev_id) |
| 4220 | return adapter; |
| 4221 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4222 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4223 | hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4224 | adapterNode = pNext; |
| 4225 | } |
| 4226 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4227 | hdd_err("vdev_id %d does not exist with host", vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4228 | |
| 4229 | return NULL; |
| 4230 | } |
| 4231 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 4232 | /** |
| 4233 | * hdd_get_adapter_by_sme_session_id() - Return adapter with |
| 4234 | * the sessionid |
| 4235 | * @hdd_ctx: hdd context. |
| 4236 | * @sme_session_id: sme session is for the adapter to get. |
| 4237 | * |
| 4238 | * This function is used to get the adapter with provided session id |
| 4239 | * |
| 4240 | * Return: adapter pointer if found |
| 4241 | * |
| 4242 | */ |
| 4243 | hdd_adapter_t *hdd_get_adapter_by_sme_session_id(hdd_context_t *hdd_ctx, |
| 4244 | uint32_t sme_session_id) |
| 4245 | { |
| 4246 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 4247 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4248 | QDF_STATUS qdf_status; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 4249 | |
| 4250 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4251 | qdf_status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 4252 | |
| 4253 | while ((NULL != adapter_node) && |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4254 | (QDF_STATUS_SUCCESS == qdf_status)) { |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 4255 | adapter = adapter_node->pAdapter; |
| 4256 | |
| 4257 | if (adapter && |
| 4258 | adapter->sessionId == sme_session_id) |
| 4259 | return adapter; |
| 4260 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4261 | qdf_status = |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 4262 | hdd_get_next_adapter(hdd_ctx, |
| 4263 | adapter_node, &next); |
| 4264 | adapter_node = next; |
| 4265 | } |
| 4266 | return NULL; |
| 4267 | } |
| 4268 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4269 | /** |
| 4270 | * hdd_get_adapter() - to get adapter matching the mode |
| 4271 | * @hdd_ctx: hdd context |
| 4272 | * @mode: adapter mode |
| 4273 | * |
| 4274 | * This routine will return the pointer to adapter matching |
| 4275 | * with the passed mode. |
| 4276 | * |
| 4277 | * Return: pointer to adapter or null |
| 4278 | */ |
| 4279 | hdd_adapter_t *hdd_get_adapter(hdd_context_t *hdd_ctx, |
| 4280 | enum tQDF_ADAPTER_MODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4281 | { |
| 4282 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 4283 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4284 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4285 | |
| 4286 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4287 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4288 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4289 | adapter = adapterNode->pAdapter; |
| 4290 | |
| 4291 | if (adapter && (mode == adapter->device_mode)) |
| 4292 | return adapter; |
| 4293 | |
| 4294 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4295 | adapterNode = pNext; |
| 4296 | } |
| 4297 | |
| 4298 | return NULL; |
| 4299 | |
| 4300 | } |
| 4301 | |
| 4302 | /** |
| 4303 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 4304 | * @hdd_ctx: Pointer to the HDD context. |
| 4305 | * @mode: Device mode for which operating channel is required. |
| 4306 | * Suported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4307 | * QDF_STA_MODE, |
| 4308 | * QDF_P2P_CLIENT_MODE, |
| 4309 | * QDF_SAP_MODE, |
| 4310 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4311 | * |
| 4312 | * This API returns the operating channel of the requested device mode |
| 4313 | * |
| 4314 | * Return: channel number. "0" id the requested device is not found OR it is |
| 4315 | * not connected. |
| 4316 | */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4317 | uint8_t hdd_get_operating_channel(hdd_context_t *hdd_ctx, |
| 4318 | enum tQDF_ADAPTER_MODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4319 | { |
| 4320 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4321 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4322 | hdd_adapter_t *adapter; |
| 4323 | uint8_t operatingChannel = 0; |
| 4324 | |
| 4325 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4326 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4327 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4328 | adapter = adapterNode->pAdapter; |
| 4329 | |
| 4330 | if (mode == adapter->device_mode) { |
| 4331 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4332 | case QDF_STA_MODE: |
| 4333 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4334 | if (hdd_conn_is_connected |
| 4335 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 4336 | (adapter))) { |
| 4337 | operatingChannel = |
| 4338 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 4339 | (adapter))->conn_info. |
| 4340 | operationChannel; |
| 4341 | } |
| 4342 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4343 | case QDF_SAP_MODE: |
| 4344 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4345 | /* softap connection info */ |
| 4346 | if (test_bit |
| 4347 | (SOFTAP_BSS_STARTED, |
| 4348 | &adapter->event_flags)) |
| 4349 | operatingChannel = |
| 4350 | (WLAN_HDD_GET_AP_CTX_PTR |
| 4351 | (adapter))->operatingChannel; |
| 4352 | break; |
| 4353 | default: |
| 4354 | break; |
| 4355 | } |
| 4356 | |
| 4357 | break; /* Found the device of interest. break the loop */ |
| 4358 | } |
| 4359 | |
| 4360 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4361 | adapterNode = pNext; |
| 4362 | } |
| 4363 | return operatingChannel; |
| 4364 | } |
| 4365 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4366 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(hdd_context_t * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4367 | hdd_ctx) |
| 4368 | { |
| 4369 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4370 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4371 | hdd_adapter_t *adapter; |
| 4372 | |
| 4373 | ENTER(); |
| 4374 | |
| 4375 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4376 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4377 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4378 | adapter = adapterNode->pAdapter; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4379 | if ((adapter->device_mode == QDF_STA_MODE) || |
| 4380 | (adapter->device_mode == QDF_P2P_CLIENT_MODE) || |
| 4381 | (adapter->device_mode == QDF_IBSS_MODE) || |
| 4382 | (adapter->device_mode == QDF_P2P_DEVICE_MODE) || |
| 4383 | (adapter->device_mode == QDF_SAP_MODE) || |
| 4384 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4385 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 4386 | hdd_unregister_wext(adapter->dev); |
| 4387 | } |
| 4388 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4389 | adapterNode = pNext; |
| 4390 | } |
| 4391 | |
| 4392 | EXIT(); |
| 4393 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4394 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4395 | } |
| 4396 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4397 | 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] | 4398 | { |
| 4399 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4400 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4401 | hdd_adapter_t *adapter; |
| 4402 | |
| 4403 | ENTER(); |
| 4404 | |
| 4405 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4406 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4407 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4408 | adapter = adapterNode->pAdapter; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4409 | if ((adapter->device_mode == QDF_STA_MODE) || |
| 4410 | (adapter->device_mode == QDF_P2P_CLIENT_MODE) || |
| 4411 | (adapter->device_mode == QDF_IBSS_MODE) || |
| 4412 | (adapter->device_mode == QDF_P2P_DEVICE_MODE) || |
| 4413 | (adapter->device_mode == QDF_SAP_MODE) || |
| 4414 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4415 | hdd_abort_mac_scan(hdd_ctx, adapter->sessionId, |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4416 | INVALID_SCAN_ID, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4417 | eCSR_SCAN_ABORT_DEFAULT); |
| 4418 | } |
| 4419 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4420 | adapterNode = pNext; |
| 4421 | } |
| 4422 | |
| 4423 | EXIT(); |
| 4424 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4425 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4426 | } |
| 4427 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 4428 | /** |
| 4429 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 4430 | * adapters |
| 4431 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 4432 | * |
| 4433 | * return: QDF_STATUS_SUCCESS |
| 4434 | */ |
| 4435 | static QDF_STATUS hdd_abort_sched_scan_all_adapters(hdd_context_t *hdd_ctx) |
| 4436 | { |
| 4437 | hdd_adapter_list_node_t *adapter_node = NULL, *next_node = NULL; |
| 4438 | QDF_STATUS status; |
| 4439 | hdd_adapter_t *adapter; |
| 4440 | int err; |
| 4441 | |
| 4442 | ENTER(); |
| 4443 | |
| 4444 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 4445 | |
| 4446 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 4447 | adapter = adapter_node->pAdapter; |
| 4448 | if ((adapter->device_mode == QDF_STA_MODE) || |
| 4449 | (adapter->device_mode == QDF_P2P_CLIENT_MODE) || |
| 4450 | (adapter->device_mode == QDF_IBSS_MODE) || |
| 4451 | (adapter->device_mode == QDF_P2P_DEVICE_MODE) || |
| 4452 | (adapter->device_mode == QDF_SAP_MODE) || |
| 4453 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
| 4454 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 4455 | if (err) |
| 4456 | hdd_err("Unable to stop scheduled scan"); |
| 4457 | } |
| 4458 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next_node); |
| 4459 | adapter_node = next_node; |
| 4460 | } |
| 4461 | |
| 4462 | EXIT(); |
| 4463 | |
| 4464 | return QDF_STATUS_SUCCESS; |
| 4465 | } |
| 4466 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4467 | #ifdef WLAN_NS_OFFLOAD |
| 4468 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4469 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4470 | * @hdd_ctx: Pointer to hdd context |
| 4471 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4472 | * Unregister for IPv6 address change notifications. |
| 4473 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4474 | * Return: None |
| 4475 | */ |
| 4476 | static void hdd_wlan_unregister_ip6_notifier(hdd_context_t *hdd_ctx) |
| 4477 | { |
| 4478 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
| 4479 | |
| 4480 | return; |
| 4481 | } |
| 4482 | |
| 4483 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4484 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4485 | * @hdd_ctx: Pointer to hdd context |
| 4486 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4487 | * Register for IPv6 address change notifications. |
| 4488 | * |
| 4489 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4490 | */ |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4491 | static int hdd_wlan_register_ip6_notifier(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4492 | { |
| 4493 | int ret; |
| 4494 | |
| 4495 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 4496 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4497 | if (ret) { |
| 4498 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 4499 | goto out; |
| 4500 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4501 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4502 | hdd_info("Registered IPv6 notifier"); |
| 4503 | out: |
| 4504 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4505 | } |
| 4506 | #else |
| 4507 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4508 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4509 | * @hdd_ctx: Pointer to hdd context |
| 4510 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4511 | * Unregister for IPv6 address change notifications. |
| 4512 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4513 | * Return: None |
| 4514 | */ |
| 4515 | static void hdd_wlan_unregister_ip6_notifier(hdd_context_t *hdd_ctx) |
| 4516 | { |
| 4517 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4518 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4519 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4520 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4521 | * @hdd_ctx: Pointer to hdd context |
| 4522 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4523 | * Register for IPv6 address change notifications. |
| 4524 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4525 | * Return: None |
| 4526 | */ |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4527 | static int hdd_wlan_register_ip6_notifier(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4528 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4529 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4530 | } |
| 4531 | #endif |
| 4532 | |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 4533 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 4534 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4535 | * hdd_logging_sock_activate_svc() - Activate logging |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 4536 | * @hdd_ctx: HDD context |
| 4537 | * |
| 4538 | * Activates the logging service |
| 4539 | * |
| 4540 | * Return: Zero in case of success, negative value otherwise |
| 4541 | */ |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4542 | static int hdd_logging_sock_activate_svc(hdd_context_t *hdd_ctx) |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 4543 | { |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4544 | int ret; |
| 4545 | struct hdd_config *config = hdd_ctx->config; |
| 4546 | |
| 4547 | if (!config->wlanLoggingEnable) |
| 4548 | return 0; |
| 4549 | |
| 4550 | ret = wlan_logging_sock_activate_svc(config->wlanLoggingFEToConsole, |
| 4551 | config->wlanLoggingNumBuf); |
| 4552 | if (ret) |
| 4553 | hdd_err("wlan_logging_sock_activate_svc failed: %d", ret); |
| 4554 | return ret; |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 4555 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4556 | |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 4557 | /** |
| 4558 | * wlan_hdd_logging_sock_deactivate_svc() - Deactivate logging |
| 4559 | * @hdd_ctx: HDD context |
| 4560 | * |
| 4561 | * Deactivates the logging service |
| 4562 | * |
| 4563 | * Return: 0 on deactivating the logging service |
| 4564 | */ |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4565 | static int hdd_logging_sock_deactivate_svc(hdd_context_t *hdd_ctx) |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 4566 | { |
| 4567 | if (hdd_ctx && hdd_ctx->config->wlanLoggingEnable) |
| 4568 | return wlan_logging_sock_deactivate_svc(); |
| 4569 | |
| 4570 | return 0; |
| 4571 | } |
| 4572 | #else |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4573 | 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] | 4574 | { |
| 4575 | return 0; |
| 4576 | } |
| 4577 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4578 | 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] | 4579 | { |
| 4580 | return 0; |
| 4581 | } |
| 4582 | #endif |
| 4583 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4584 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4585 | * hdd_register_notifiers - Register netdev notifiers. |
| 4586 | * @hdd_ctx: HDD context |
| 4587 | * |
| 4588 | * Register netdev notifiers like IPv4 and IPv6. |
| 4589 | * |
| 4590 | * Return: 0 on success and errno on failure |
| 4591 | */ |
| 4592 | static int hdd_register_notifiers(hdd_context_t *hdd_ctx) |
| 4593 | { |
| 4594 | int ret; |
| 4595 | |
| 4596 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 4597 | if (ret) { |
| 4598 | hdd_err("register_netdevice_notifier failed: %d", ret); |
| 4599 | goto out; |
| 4600 | } |
| 4601 | |
| 4602 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 4603 | if (ret) |
| 4604 | goto unregister_notifier; |
| 4605 | |
| 4606 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 4607 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 4608 | if (ret) { |
| 4609 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 4610 | goto unregister_ip6_notifier; |
| 4611 | } |
| 4612 | |
| 4613 | return 0; |
| 4614 | |
| 4615 | unregister_ip6_notifier: |
| 4616 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 4617 | unregister_notifier: |
| 4618 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 4619 | out: |
| 4620 | return ret; |
| 4621 | |
| 4622 | } |
| 4623 | |
| 4624 | /** |
| 4625 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 4626 | * @hdd_ctx: HDD context |
| 4627 | * |
| 4628 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 4629 | * |
| 4630 | * Return: None. |
| 4631 | */ |
| 4632 | static void hdd_unregister_notifiers(hdd_context_t *hdd_ctx) |
| 4633 | { |
| 4634 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 4635 | |
| 4636 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 4637 | |
| 4638 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 4639 | } |
| 4640 | |
| 4641 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4642 | * hdd_exit_netlink_services - Exit netlink services |
| 4643 | * @hdd_ctx: HDD context |
| 4644 | * |
| 4645 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 4646 | * nl service. |
| 4647 | * |
| 4648 | * Return: None. |
| 4649 | */ |
| 4650 | static void hdd_exit_netlink_services(hdd_context_t *hdd_ctx) |
| 4651 | { |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4652 | hdd_close_cesium_nl_sock(); |
| 4653 | |
| 4654 | ptt_sock_deactivate_svc(); |
| 4655 | |
| 4656 | nl_srv_exit(); |
| 4657 | } |
| 4658 | |
| 4659 | /** |
| 4660 | * hdd_init_netlink_services- Init netlink services |
| 4661 | * @hdd_ctx: HDD context |
| 4662 | * |
| 4663 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 4664 | * nl service. |
| 4665 | * |
| 4666 | * Return: 0 on success and errno on failure. |
| 4667 | */ |
| 4668 | static int hdd_init_netlink_services(hdd_context_t *hdd_ctx) |
| 4669 | { |
| 4670 | int ret; |
| 4671 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 4672 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4673 | if (ret) { |
| 4674 | hdd_alert("nl_srv_init failed: %d", ret); |
| 4675 | goto out; |
| 4676 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 4677 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4678 | |
| 4679 | ret = oem_activate_service(hdd_ctx); |
| 4680 | if (ret) { |
| 4681 | hdd_alert("oem_activate_service failed: %d", ret); |
| 4682 | goto err_nl_srv; |
| 4683 | } |
| 4684 | |
| 4685 | ret = ptt_sock_activate_svc(); |
| 4686 | if (ret) { |
| 4687 | hdd_alert("ptt_sock_activate_svc failed: %d", ret); |
| 4688 | goto err_nl_srv; |
| 4689 | } |
| 4690 | |
| 4691 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 4692 | if (ret) |
| 4693 | hdd_warn("hdd_open_cesium_nl_sock failed"); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4694 | |
| 4695 | ret = cnss_diag_activate_service(); |
| 4696 | if (ret) { |
| 4697 | hdd_alert("cnss_diag_activate_service failed: %d", ret); |
| 4698 | goto err_close_cesium; |
| 4699 | } |
| 4700 | |
| 4701 | return 0; |
| 4702 | |
| 4703 | err_close_cesium: |
| 4704 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4705 | ptt_sock_deactivate_svc(); |
| 4706 | err_nl_srv: |
| 4707 | nl_srv_exit(); |
| 4708 | out: |
| 4709 | return ret; |
| 4710 | } |
| 4711 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 4712 | /** |
| 4713 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 4714 | * @hdd_ctx: HDD context. |
| 4715 | * |
| 4716 | * Destroy RX wakelock. |
| 4717 | * |
| 4718 | * Return: None. |
| 4719 | */ |
| 4720 | static void hdd_rx_wake_lock_destroy(hdd_context_t *hdd_ctx) |
| 4721 | { |
| 4722 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 4723 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4724 | |
| 4725 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 4726 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 4727 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4728 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 4729 | * Create RX wakelock. |
| 4730 | * |
| 4731 | * Return: None. |
| 4732 | */ |
| 4733 | static void hdd_rx_wake_lock_create(hdd_context_t *hdd_ctx) |
| 4734 | { |
| 4735 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 4736 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 4737 | |
| 4738 | /** |
| 4739 | * hdd_roc_context_init() - Init ROC context |
| 4740 | * @hdd_ctx: HDD context. |
| 4741 | * |
| 4742 | * Initialize ROC context. |
| 4743 | * |
| 4744 | * Return: 0 on success and errno on failure. |
| 4745 | */ |
| 4746 | static int hdd_roc_context_init(hdd_context_t *hdd_ctx) |
| 4747 | { |
| 4748 | qdf_spinlock_create(&hdd_ctx->hdd_roc_req_q_lock); |
| 4749 | qdf_list_create(&hdd_ctx->hdd_roc_req_q, MAX_ROC_REQ_QUEUE_ENTRY); |
| 4750 | |
| 4751 | INIT_DELAYED_WORK(&hdd_ctx->roc_req_work, wlan_hdd_roc_request_dequeue); |
| 4752 | |
| 4753 | return 0; |
| 4754 | } |
| 4755 | |
| 4756 | /** |
| 4757 | * hdd_roc_context_destroy() - Destroy ROC context |
| 4758 | * @hdd_ctx: HDD context. |
| 4759 | * |
| 4760 | * Destroy roc list and flush the pending roc work. |
| 4761 | * |
| 4762 | * Return: None. |
| 4763 | */ |
| 4764 | static void hdd_roc_context_destroy(hdd_context_t *hdd_ctx) |
| 4765 | { |
| 4766 | flush_delayed_work(&hdd_ctx->roc_req_work); |
| 4767 | qdf_list_destroy(&hdd_ctx->hdd_roc_req_q); |
Houston Hoffman | 2eac7c4 | 2016-12-12 12:22:52 -0800 | [diff] [blame] | 4768 | qdf_spinlock_destroy(&hdd_ctx->hdd_roc_req_q_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 4769 | } |
| 4770 | |
| 4771 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 4772 | * hdd_context_deinit() - Deinitialize HDD context |
| 4773 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 4774 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 4775 | * Deinitialize HDD context along with all the feature specific contexts but |
| 4776 | * do not free hdd context itself. Caller of this API is supposed to free |
| 4777 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4778 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 4779 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4780 | */ |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 4781 | static int hdd_context_deinit(hdd_context_t *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4782 | { |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 4783 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4784 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 4785 | hdd_roc_context_destroy(hdd_ctx); |
| 4786 | |
| 4787 | hdd_sap_context_destroy(hdd_ctx); |
| 4788 | |
| 4789 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 4790 | |
| 4791 | hdd_tdls_context_destroy(hdd_ctx); |
| 4792 | |
| 4793 | hdd_scan_context_destroy(hdd_ctx); |
| 4794 | |
| 4795 | qdf_list_destroy(&hdd_ctx->hddAdapters); |
| 4796 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 4797 | return 0; |
| 4798 | } |
| 4799 | |
| 4800 | /** |
| 4801 | * hdd_context_destroy() - Destroy HDD context |
| 4802 | * @hdd_ctx: HDD context to be destroyed. |
| 4803 | * |
| 4804 | * Free config and HDD context as well as destroy all the resources. |
| 4805 | * |
| 4806 | * Return: None |
| 4807 | */ |
| 4808 | static void hdd_context_destroy(hdd_context_t *hdd_ctx) |
| 4809 | { |
| 4810 | if (QDF_GLOBAL_FTM_MODE != hdd_get_conparam()) |
| 4811 | hdd_logging_sock_deactivate_svc(hdd_ctx); |
| 4812 | |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 4813 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 4814 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 4815 | hdd_context_deinit(hdd_ctx); |
| 4816 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4817 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4818 | hdd_ctx->config = NULL; |
| 4819 | |
| 4820 | wiphy_free(hdd_ctx->wiphy); |
| 4821 | } |
| 4822 | |
| 4823 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4824 | * hdd_wlan_exit() - HDD WLAN exit function |
| 4825 | * @hdd_ctx: Pointer to the HDD Context |
| 4826 | * |
| 4827 | * This is the driver exit point (invoked during rmmod) |
| 4828 | * |
| 4829 | * Return: None |
| 4830 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4831 | static void hdd_wlan_exit(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4832 | { |
| 4833 | v_CONTEXT_t p_cds_context = hdd_ctx->pcds_context; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4834 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4835 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4836 | int driver_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4837 | |
| 4838 | ENTER(); |
| 4839 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4840 | if (QDF_TIMER_STATE_RUNNING == |
| 4841 | qdf_mc_timer_get_current_state(&hdd_ctx->iface_change_timer)) { |
| 4842 | hdd_info("Stpp interface change timer"); |
| 4843 | qdf_mc_timer_stop(&hdd_ctx->iface_change_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4844 | } |
| 4845 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4846 | if (!QDF_IS_STATUS_SUCCESS |
| 4847 | (qdf_mc_timer_destroy(&hdd_ctx->iface_change_timer))) |
| 4848 | hdd_err("Cannot delete interface change timer"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4849 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4850 | |
| 4851 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4852 | |
Nitesh Shah | 61c10d9 | 2016-10-19 19:29:15 +0530 | [diff] [blame] | 4853 | qdf_mc_timer_destroy(&hdd_ctx->tdls_source_timer); |
| 4854 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 4855 | hdd_bus_bandwidth_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4856 | |
| 4857 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 4858 | if (QDF_TIMER_STATE_RUNNING == |
| 4859 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 4860 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4861 | } |
| 4862 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4863 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 4864 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4865 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4866 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 4867 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 4868 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 4869 | hdd_ctx->last_acs_channel_list = NULL; |
| 4870 | hdd_ctx->num_of_channels = 0; |
| 4871 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4872 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4873 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4874 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 4875 | driver_status = hdd_ctx->driver_status; |
| 4876 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 4877 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4878 | /* |
| 4879 | * Powersave Offload Case |
| 4880 | * Disable Idle Power Save Mode |
| 4881 | */ |
| 4882 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 4883 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4884 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 4885 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 4886 | /* |
| 4887 | * Cancel any outstanding scan requests. We are about to close |
| 4888 | * all of our adapters, but an adapter structure is what SME |
| 4889 | * passes back to our callback function. Hence if there |
| 4890 | * are any outstanding scan requests then there is a |
| 4891 | * race condition between when the adapter is closed and |
| 4892 | * when the callback is invoked. We try to resolve that |
| 4893 | * race condition here by canceling any outstanding scans |
| 4894 | * before we close the adapters. |
| 4895 | * Note that the scans may be cancelled in an asynchronous |
| 4896 | * manner, so ideally there needs to be some kind of |
| 4897 | * synchronization. Rather than introduce a new |
| 4898 | * synchronization here, we will utilize the fact that we are |
| 4899 | * about to Request Full Power, and since that is synchronized, |
| 4900 | * the expectation is that by the time Request Full Power has |
| 4901 | * completed, all scans will be cancelled |
| 4902 | */ |
| 4903 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 4904 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4905 | hdd_stop_all_adapters(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4906 | } |
| 4907 | |
| 4908 | /* |
| 4909 | * Close the scheduler before calling cds_close to make sure no thread |
| 4910 | * is scheduled after the each module close is called i.e after all the |
| 4911 | * data structures are freed. |
| 4912 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4913 | qdf_status = cds_sched_close(p_cds_context); |
| 4914 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4915 | hdd_alert("Failed to close CDS Scheduler"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4916 | QDF_ASSERT(QDF_IS_STATUS_SUCCESS(qdf_status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4917 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4918 | |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 4919 | hdd_wlan_stop_modules(hdd_ctx); |
| 4920 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 4921 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
| 4922 | qdf_spinlock_destroy(&hdd_ctx->sta_update_info_lock); |
| 4923 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
| 4924 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4925 | /* |
| 4926 | * Close CDS |
| 4927 | * This frees pMac(HAL) context. There should not be any call |
| 4928 | * that requires pMac access after this. |
| 4929 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4930 | |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 4931 | hdd_green_ap_deinit(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4932 | |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 4933 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4934 | hdd_close_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4935 | |
| 4936 | hdd_ipa_cleanup(hdd_ctx); |
| 4937 | |
| 4938 | /* Free up RoC request queue and flush workqueue */ |
| 4939 | cds_flush_work(&hdd_ctx->roc_req_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4940 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 4941 | wlansap_global_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4942 | wiphy_unregister(wiphy); |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 4943 | wlan_hdd_cfg80211_deinit(wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4944 | |
Jeff Johnson | f7f66f0 | 2016-09-23 14:50:11 -0700 | [diff] [blame] | 4945 | hdd_lpass_notify_stop(hdd_ctx); |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 4946 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4947 | hdd_exit_netlink_services(hdd_ctx); |
| 4948 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 4949 | hdd_context_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4950 | } |
| 4951 | |
| 4952 | void __hdd_wlan_exit(void) |
| 4953 | { |
| 4954 | hdd_context_t *hdd_ctx; |
| 4955 | |
| 4956 | ENTER(); |
| 4957 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4958 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4959 | if (!hdd_ctx) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4960 | hdd_alert("Invalid HDD Context"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4961 | EXIT(); |
| 4962 | return; |
| 4963 | } |
| 4964 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 4965 | /* Check IPA HW Pipe shutdown */ |
| 4966 | hdd_ipa_uc_force_pipe_shutdown(hdd_ctx); |
| 4967 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 4968 | memdump_deinit(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 4969 | hdd_driver_memdump_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 4970 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4971 | /* Do all the cleanup before deregistering the driver */ |
| 4972 | hdd_wlan_exit(hdd_ctx); |
Mohit Khanna | ebf8a86 | 2016-04-28 17:53:59 -0700 | [diff] [blame] | 4973 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4974 | EXIT(); |
| 4975 | } |
| 4976 | |
| 4977 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 4978 | /** |
| 4979 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
| 4980 | * @data: pointer to hdd_context_t |
| 4981 | * |
| 4982 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 4983 | * Then new ACS request will do a fresh scan without reusing the cached |
| 4984 | * scan information. |
| 4985 | * |
| 4986 | * Return: void |
| 4987 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4988 | void hdd_skip_acs_scan_timer_handler(void *data) |
| 4989 | { |
| 4990 | hdd_context_t *hdd_ctx = (hdd_context_t *) data; |
| 4991 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 4992 | hdd_notice("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4993 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 4994 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 4995 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 4996 | hdd_ctx->last_acs_channel_list = NULL; |
| 4997 | hdd_ctx->num_of_channels = 0; |
| 4998 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4999 | |
| 5000 | if (!hdd_ctx->hHal) |
| 5001 | return; |
| 5002 | sme_scan_flush_result(hdd_ctx->hHal); |
| 5003 | } |
| 5004 | #endif |
| 5005 | |
| 5006 | #ifdef QCA_HT_2040_COEX |
| 5007 | /** |
| 5008 | * hdd_wlan_set_ht2040_mode() - notify FW with HT20/HT40 mode |
| 5009 | * @adapter: pointer to adapter |
| 5010 | * @staId: station id |
| 5011 | * @macAddrSTA: station MAC address |
| 5012 | * @channel_type: channel type |
| 5013 | * |
| 5014 | * This function notifies FW with HT20/HT40 mode |
| 5015 | * |
| 5016 | * Return: 0 if successful, error number otherwise |
| 5017 | */ |
| 5018 | 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] | 5019 | struct qdf_mac_addr macAddrSTA, int channel_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5020 | { |
| 5021 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5022 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5023 | hdd_context_t *hdd_ctx = NULL; |
| 5024 | |
| 5025 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 5026 | |
| 5027 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 5028 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5029 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 5030 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5031 | if (!hdd_ctx->hHal) |
| 5032 | return -EINVAL; |
| 5033 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5034 | qdf_status = sme_notify_ht2040_mode(hdd_ctx->hHal, staId, macAddrSTA, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5035 | adapter->sessionId, channel_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5036 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5037 | hdd_err("Fail to send notification with ht2040 mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5038 | return -EINVAL; |
| 5039 | } |
| 5040 | |
| 5041 | return 0; |
| 5042 | } |
| 5043 | #endif |
| 5044 | |
| 5045 | /** |
| 5046 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 5047 | * @state: state |
| 5048 | * |
| 5049 | * This function notifies FW with modem power status |
| 5050 | * |
| 5051 | * Return: 0 if successful, error number otherwise |
| 5052 | */ |
| 5053 | int hdd_wlan_notify_modem_power_state(int state) |
| 5054 | { |
| 5055 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5056 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5057 | hdd_context_t *hdd_ctx; |
| 5058 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5059 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5060 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 5061 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5062 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 5063 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5064 | if (!hdd_ctx->hHal) |
| 5065 | return -EINVAL; |
| 5066 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5067 | qdf_status = sme_notify_modem_power_state(hdd_ctx->hHal, state); |
| 5068 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5069 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5070 | state); |
| 5071 | return -EINVAL; |
| 5072 | } |
| 5073 | return 0; |
| 5074 | } |
| 5075 | |
| 5076 | /** |
| 5077 | * |
| 5078 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 5079 | * @adapter - Pointer to the HDD |
| 5080 | * |
| 5081 | * Return: None |
| 5082 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5083 | QDF_STATUS hdd_post_cds_enable_config(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5084 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5085 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5086 | |
| 5087 | /* |
| 5088 | * Send ready indication to the HDD. This will kick off the MAC |
| 5089 | * into a 'running' state and should kick off an initial scan. |
| 5090 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5091 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->hHal); |
| 5092 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5093 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 5094 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5095 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5096 | } |
| 5097 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5098 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5099 | } |
| 5100 | |
| 5101 | /* wake lock APIs for HDD */ |
| 5102 | void hdd_prevent_suspend(uint32_t reason) |
| 5103 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5104 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5105 | } |
| 5106 | |
| 5107 | void hdd_allow_suspend(uint32_t reason) |
| 5108 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5109 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5110 | } |
| 5111 | |
| 5112 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 5113 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 5114 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 5115 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5116 | } |
| 5117 | |
| 5118 | /** |
| 5119 | * hdd_exchange_version_and_caps() - exchange version and capability with target |
| 5120 | * @hdd_ctx: Pointer to HDD context |
| 5121 | * |
| 5122 | * This is the HDD function to exchange version and capability information |
| 5123 | * between Host and Target |
| 5124 | * |
| 5125 | * This function gets reported version of FW. |
| 5126 | * It also finds the version of target headers used to compile the host; |
| 5127 | * It compares the above two and prints a warning if they are different; |
| 5128 | * It gets the SW and HW version string; |
| 5129 | * Finally, it exchanges capabilities between host and target i.e. host |
| 5130 | * and target exchange a msg indicating the features they support through a |
| 5131 | * bitmap |
| 5132 | * |
| 5133 | * Return: None |
| 5134 | */ |
| 5135 | void hdd_exchange_version_and_caps(hdd_context_t *hdd_ctx) |
| 5136 | { |
| 5137 | |
| 5138 | tSirVersionType versionCompiled; |
| 5139 | tSirVersionType versionReported; |
| 5140 | tSirVersionString versionString; |
| 5141 | uint8_t fwFeatCapsMsgSupported = 0; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5142 | QDF_STATUS vstatus; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5143 | |
| 5144 | memset(&versionCompiled, 0, sizeof(versionCompiled)); |
| 5145 | memset(&versionReported, 0, sizeof(versionReported)); |
| 5146 | |
| 5147 | /* retrieve and display WCNSS version information */ |
| 5148 | do { |
| 5149 | |
| 5150 | vstatus = sme_get_wcnss_wlan_compiled_version(hdd_ctx->hHal, |
| 5151 | &versionCompiled); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5152 | if (!QDF_IS_STATUS_SUCCESS(vstatus)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5153 | hdd_alert("unable to retrieve WCNSS WLAN compiled version"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5154 | break; |
| 5155 | } |
| 5156 | |
| 5157 | vstatus = sme_get_wcnss_wlan_reported_version(hdd_ctx->hHal, |
| 5158 | &versionReported); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5159 | if (!QDF_IS_STATUS_SUCCESS(vstatus)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5160 | hdd_alert("unable to retrieve WCNSS WLAN reported version"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5161 | break; |
| 5162 | } |
| 5163 | |
| 5164 | if ((versionCompiled.major != versionReported.major) || |
| 5165 | (versionCompiled.minor != versionReported.minor) || |
| 5166 | (versionCompiled.version != versionReported.version) || |
| 5167 | (versionCompiled.revision != versionReported.revision)) { |
| 5168 | pr_err("%s: WCNSS WLAN Version %u.%u.%u.%u, " |
| 5169 | "Host expected %u.%u.%u.%u\n", |
| 5170 | WLAN_MODULE_NAME, |
| 5171 | (int)versionReported.major, |
| 5172 | (int)versionReported.minor, |
| 5173 | (int)versionReported.version, |
| 5174 | (int)versionReported.revision, |
| 5175 | (int)versionCompiled.major, |
| 5176 | (int)versionCompiled.minor, |
| 5177 | (int)versionCompiled.version, |
| 5178 | (int)versionCompiled.revision); |
| 5179 | } else { |
| 5180 | pr_info("%s: WCNSS WLAN version %u.%u.%u.%u\n", |
| 5181 | WLAN_MODULE_NAME, |
| 5182 | (int)versionReported.major, |
| 5183 | (int)versionReported.minor, |
| 5184 | (int)versionReported.version, |
| 5185 | (int)versionReported.revision); |
| 5186 | } |
| 5187 | |
| 5188 | vstatus = sme_get_wcnss_software_version(hdd_ctx->hHal, |
| 5189 | versionString, |
| 5190 | sizeof(versionString)); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5191 | if (!QDF_IS_STATUS_SUCCESS(vstatus)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5192 | hdd_alert("unable to retrieve WCNSS software version string"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5193 | break; |
| 5194 | } |
| 5195 | |
| 5196 | pr_info("%s: WCNSS software version %s\n", |
| 5197 | WLAN_MODULE_NAME, versionString); |
| 5198 | |
| 5199 | vstatus = sme_get_wcnss_hardware_version(hdd_ctx->hHal, |
| 5200 | versionString, |
| 5201 | sizeof(versionString)); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5202 | if (!QDF_IS_STATUS_SUCCESS(vstatus)) { |
Jeff Johnson | b7082ae | 2016-08-23 13:13:30 -0700 | [diff] [blame] | 5203 | hdd_alert("unable to retrieve WCNSS hardware version string"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5204 | break; |
| 5205 | } |
| 5206 | |
| 5207 | pr_info("%s: WCNSS hardware version %s\n", |
| 5208 | WLAN_MODULE_NAME, versionString); |
| 5209 | |
| 5210 | /* |
| 5211 | * 1.Check if FW version is greater than 0.1.1.0. Only then |
| 5212 | * send host-FW capability exchange message |
| 5213 | * 2.Host-FW capability exchange message is only present on |
| 5214 | * target 1.1 so send the message only if it the target is 1.1 |
| 5215 | * minor numbers for different target branches: |
| 5216 | * 0 -> (1.0)Mainline Build |
| 5217 | * 1 -> (1.1)Mainline Build |
| 5218 | * 2->(1.04) Stability Build |
| 5219 | */ |
| 5220 | if (((versionReported.major > 0) || (versionReported.minor > 1) |
| 5221 | || ((versionReported.minor >= 1) |
| 5222 | && (versionReported.version >= 1))) |
| 5223 | && ((versionReported.major == 1) |
| 5224 | && (versionReported.minor >= 1))) |
| 5225 | fwFeatCapsMsgSupported = 1; |
| 5226 | |
| 5227 | if (fwFeatCapsMsgSupported) { |
| 5228 | /* |
| 5229 | * Indicate if IBSS heartbeat monitoring needs to be |
| 5230 | * offloaded |
| 5231 | */ |
| 5232 | if (!hdd_ctx->config->enableIbssHeartBeatOffload) { |
| 5233 | sme_disable_feature_capablity |
| 5234 | (IBSS_HEARTBEAT_OFFLOAD); |
| 5235 | } |
| 5236 | |
| 5237 | sme_feature_caps_exchange(hdd_ctx->hHal); |
| 5238 | } |
| 5239 | |
| 5240 | } while (0); |
| 5241 | |
| 5242 | } |
| 5243 | |
| 5244 | /* Initialize channel list in sme based on the country code */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5245 | QDF_STATUS hdd_set_sme_chan_list(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5246 | { |
| 5247 | return sme_init_chan_list(hdd_ctx->hHal, hdd_ctx->reg.alpha2, |
| 5248 | hdd_ctx->reg.cc_src); |
| 5249 | } |
| 5250 | |
| 5251 | /** |
| 5252 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 5253 | * @hdd_ctx: Pointer to the hdd context |
| 5254 | * |
| 5255 | * HDD function to know if hardware supports 5GHz |
| 5256 | * |
| 5257 | * Return: true if hardware supports 5GHz |
| 5258 | */ |
| 5259 | bool hdd_is_5g_supported(hdd_context_t *hdd_ctx) |
| 5260 | { |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 5261 | if (!hdd_ctx || !hdd_ctx->config) |
| 5262 | return true; |
| 5263 | |
| 5264 | if (hdd_ctx->config->nBandCapability != eCSR_BAND_24) |
| 5265 | return true; |
| 5266 | else |
| 5267 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5268 | } |
| 5269 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 5270 | static int hdd_wiphy_init(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5271 | { |
| 5272 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 5273 | int ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5274 | |
| 5275 | wiphy = hdd_ctx->wiphy; |
| 5276 | |
| 5277 | /* |
| 5278 | * The channel information in |
| 5279 | * wiphy needs to be initialized before wiphy registration |
| 5280 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 5281 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 5282 | if (ret_val) { |
| 5283 | hdd_alert("regulatory init failed"); |
| 5284 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5285 | } |
| 5286 | |
| 5287 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 5288 | wiphy->wowlan = &wowlan_support_reg_init; |
| 5289 | #else |
| 5290 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 5291 | WIPHY_WOWLAN_MAGIC_PKT | |
| 5292 | WIPHY_WOWLAN_DISCONNECT | |
| 5293 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 5294 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 5295 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 5296 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 5297 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 5298 | |
| 5299 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 5300 | WOW_MAX_FILTERS_PER_LIST); |
| 5301 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 5302 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 5303 | #endif |
| 5304 | |
| 5305 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 5306 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
| 5307 | if (0 > ret_val) |
| 5308 | hdd_err("wiphy registration failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5309 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 5310 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5311 | } |
| 5312 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 5313 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5314 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 5315 | * @hdd_ctx - handle to hdd context |
| 5316 | * @tx_packets - transmit packet count |
| 5317 | * @rx_packets - receive packet count |
| 5318 | * |
| 5319 | * The function controls the bus bandwidth and dynamic control of |
| 5320 | * tcp delayed ack configuration |
| 5321 | * |
| 5322 | * Returns: None |
| 5323 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5324 | #ifdef MSM_PLATFORM |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 5325 | static void hdd_pld_request_bus_bandwidth(hdd_context_t *hdd_ctx, |
| 5326 | const uint64_t tx_packets, |
| 5327 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5328 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5329 | uint64_t total = tx_packets + rx_packets; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5330 | uint64_t temp_rx = 0; |
| 5331 | uint64_t temp_tx = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5332 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5333 | enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
| 5334 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 5335 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5336 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5337 | if (total > hdd_ctx->config->busBandwidthHighThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5338 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5339 | else if (total > hdd_ctx->config->busBandwidthMediumThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5340 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 5341 | else if (total > hdd_ctx->config->busBandwidthLowThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5342 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 5343 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5344 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5345 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5346 | hdd_ctx->hdd_txrx_hist[hdd_ctx->hdd_txrx_hist_idx].next_vote_level = |
| 5347 | next_vote_level; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5348 | |
| 5349 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 5350 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 5351 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5352 | hdd_ctx->cur_vote_level = next_vote_level; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5353 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 5354 | if (next_vote_level == PLD_BUS_WIDTH_LOW) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 5355 | if (hdd_ctx->hbw_requested) { |
| 5356 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 5357 | hdd_ctx->hbw_requested = false; |
| 5358 | } |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 5359 | if (cds_sched_handle_throughput_req(false)) |
Jeff Johnson | b7082ae | 2016-08-23 13:13:30 -0700 | [diff] [blame] | 5360 | hdd_err("low bandwidth set rx affinity fail"); |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 5361 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 5362 | if (!hdd_ctx->hbw_requested) { |
| 5363 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 5364 | hdd_ctx->hbw_requested = true; |
| 5365 | } |
| 5366 | |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 5367 | if (cds_sched_handle_throughput_req(true)) |
Jeff Johnson | b7082ae | 2016-08-23 13:13:30 -0700 | [diff] [blame] | 5368 | hdd_err("high bandwidth set rx affinity fail"); |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 5369 | } |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 5370 | hdd_napi_apply_throughput_policy(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5371 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5372 | |
| 5373 | /* fine-tuning parameters for RX Flows */ |
| 5374 | temp_rx = (rx_packets + hdd_ctx->prev_rx) / 2; |
| 5375 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5376 | hdd_ctx->prev_rx = rx_packets; |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 5377 | if (temp_rx > hdd_ctx->config->tcpDelackThresholdHigh) { |
| 5378 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 5379 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 5380 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 5381 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 5382 | } else { |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5383 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 5384 | hdd_ctx->rx_high_ind_cnt = 0; |
| 5385 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5386 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5387 | hdd_ctx->hdd_txrx_hist[hdd_ctx->hdd_txrx_hist_idx].next_rx_level = |
| 5388 | next_rx_level; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5389 | |
| 5390 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 5391 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5392 | next_rx_level, temp_rx); |
| 5393 | hdd_ctx->cur_rx_level = next_rx_level; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 5394 | /* Send throughput indication only if it is enabled. |
| 5395 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 5396 | * to default delayed ack. Note that this will disable the |
| 5397 | * dynamic delayed ack mechanism across the system |
| 5398 | */ |
| 5399 | if (hdd_ctx->config->enable_tcp_delack) |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 5400 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 5401 | WLAN_SVC_WLAN_TP_IND, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5402 | &next_rx_level, |
| 5403 | sizeof(next_rx_level)); |
| 5404 | } |
| 5405 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5406 | /* fine-tuning parameters for TX Flows */ |
| 5407 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 5408 | hdd_ctx->prev_tx = tx_packets; |
| 5409 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 5410 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 5411 | else |
| 5412 | next_tx_level = WLAN_SVC_TP_LOW; |
| 5413 | |
| 5414 | if (hdd_ctx->cur_tx_level != next_tx_level) { |
| 5415 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 5416 | next_tx_level, temp_tx); |
| 5417 | hdd_ctx->cur_tx_level = next_tx_level; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 5418 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 5419 | WLAN_SVC_WLAN_TP_TX_IND, |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5420 | &next_tx_level, |
| 5421 | sizeof(next_tx_level)); |
| 5422 | } |
| 5423 | |
| 5424 | hdd_ctx->hdd_txrx_hist[hdd_ctx->hdd_txrx_hist_idx].next_tx_level = |
| 5425 | next_tx_level; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5426 | hdd_ctx->hdd_txrx_hist_idx++; |
| 5427 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5428 | } |
| 5429 | |
| 5430 | #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] | 5431 | static void hdd_bus_bw_work_handler(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5432 | { |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 5433 | hdd_context_t *hdd_ctx = container_of(work, hdd_context_t, |
| 5434 | bus_bw_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5435 | hdd_adapter_t *adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 5436 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 5437 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 5438 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5439 | uint64_t total_tx = 0, total_rx = 0; |
| 5440 | hdd_adapter_list_node_t *adapterNode = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5441 | QDF_STATUS status = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 5442 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5443 | bool connected = false; |
| 5444 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 5445 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 5446 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 5447 | return; |
| 5448 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5449 | for (status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5450 | NULL != adapterNode && QDF_STATUS_SUCCESS == status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5451 | status = |
| 5452 | hdd_get_next_adapter(hdd_ctx, adapterNode, &adapterNode)) { |
| 5453 | |
| 5454 | if (adapterNode->pAdapter == NULL) |
| 5455 | continue; |
| 5456 | adapter = adapterNode->pAdapter; |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 5457 | /* |
| 5458 | * Validate magic so we don't end up accessing |
| 5459 | * an invalid adapter. |
| 5460 | */ |
| 5461 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 5462 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5463 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5464 | if ((adapter->device_mode == QDF_STA_MODE || |
| 5465 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5466 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.connState |
| 5467 | != eConnectionState_Associated) { |
| 5468 | |
| 5469 | continue; |
| 5470 | } |
| 5471 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5472 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 5473 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5474 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->bApActive == false) { |
| 5475 | |
| 5476 | continue; |
| 5477 | } |
| 5478 | |
| 5479 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 5480 | adapter->prev_tx_packets); |
| 5481 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 5482 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 5483 | |
| 5484 | if (adapter->device_mode == QDF_SAP_MODE || |
| 5485 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 5486 | adapter->device_mode == QDF_IBSS_MODE) { |
| 5487 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 5488 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 5489 | cds_get_context(QDF_MODULE_ID_SOC), |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 5490 | adapter->sessionId, |
| 5491 | &fwd_tx_packets, &fwd_rx_packets); |
| 5492 | if (ret == A_OK) { |
| 5493 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 5494 | fwd_tx_packets, |
| 5495 | adapter->prev_fwd_tx_packets); |
| 5496 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 5497 | fwd_tx_packets, |
| 5498 | adapter->prev_fwd_rx_packets); |
| 5499 | } |
| 5500 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5501 | |
| 5502 | total_rx += adapter->stats.rx_packets; |
| 5503 | total_tx += adapter->stats.tx_packets; |
| 5504 | |
| 5505 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 5506 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 5507 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 5508 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 5509 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5510 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 5511 | connected = true; |
| 5512 | } |
| 5513 | |
| 5514 | hdd_ctx->hdd_txrx_hist[hdd_ctx->hdd_txrx_hist_idx].total_rx = total_rx; |
| 5515 | hdd_ctx->hdd_txrx_hist[hdd_ctx->hdd_txrx_hist_idx].total_tx = total_tx; |
| 5516 | hdd_ctx->hdd_txrx_hist[hdd_ctx->hdd_txrx_hist_idx].interval_rx = |
| 5517 | rx_packets; |
| 5518 | hdd_ctx->hdd_txrx_hist[hdd_ctx->hdd_txrx_hist_idx].interval_tx = |
| 5519 | tx_packets; |
| 5520 | |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 5521 | /* add intra bss forwarded tx and rx packets */ |
| 5522 | tx_packets += fwd_tx_packets_diff; |
| 5523 | rx_packets += fwd_rx_packets_diff; |
| 5524 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5525 | hdd_ipa_uc_stat_query(hdd_ctx, &ipa_tx_packets, &ipa_rx_packets); |
| 5526 | tx_packets += (uint64_t)ipa_tx_packets; |
| 5527 | rx_packets += (uint64_t)ipa_rx_packets; |
| 5528 | |
| 5529 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5530 | hdd_err("bus bandwidth timer running in disconnected state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5531 | return; |
| 5532 | } |
| 5533 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5534 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5535 | |
| 5536 | hdd_ipa_set_perf_level(hdd_ctx, tx_packets, rx_packets); |
| 5537 | hdd_ipa_uc_stat_request(adapter, 2); |
| 5538 | |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 5539 | /* ensure periodic timer should still be running before restarting it */ |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 5540 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 5541 | if (hdd_ctx->bus_bw_timer_running) |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 5542 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
| 5543 | hdd_ctx->config->busBandwidthComputeInterval); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 5544 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5545 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 5546 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 5547 | /** |
| 5548 | * __hdd_bus_bw_cbk() - Bus bandwidth data structure callback. |
| 5549 | * @arg: Argument of timer function |
| 5550 | * |
| 5551 | * Schedule a workqueue in this function where all the processing is done. |
| 5552 | * |
| 5553 | * Return: None. |
| 5554 | */ |
| 5555 | static void __hdd_bus_bw_cbk(void *arg) |
| 5556 | { |
| 5557 | hdd_context_t *hdd_ctx = (hdd_context_t *) arg; |
| 5558 | |
| 5559 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 5560 | return; |
| 5561 | |
| 5562 | schedule_work(&hdd_ctx->bus_bw_work); |
| 5563 | } |
| 5564 | |
| 5565 | /** |
| 5566 | * hdd_bus_bw_cbk() - Wrapper for bus bw callback for SSR protection. |
| 5567 | * @arg: Argument of timer function |
| 5568 | * |
| 5569 | * Return: None. |
| 5570 | */ |
| 5571 | static void hdd_bus_bw_cbk(void *arg) |
| 5572 | { |
| 5573 | cds_ssr_protect(__func__); |
| 5574 | __hdd_bus_bw_cbk(arg); |
| 5575 | cds_ssr_unprotect(__func__); |
| 5576 | } |
| 5577 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 5578 | int hdd_bus_bandwidth_init(hdd_context_t *hdd_ctx) |
| 5579 | { |
| 5580 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 5581 | INIT_WORK(&hdd_ctx->bus_bw_work, |
| 5582 | hdd_bus_bw_work_handler); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 5583 | hdd_ctx->bus_bw_timer_running = false; |
| 5584 | qdf_spinlock_create(&hdd_ctx->bus_bw_timer_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 5585 | qdf_timer_init(NULL, |
| 5586 | &hdd_ctx->bus_bw_timer, |
| 5587 | hdd_bus_bw_cbk, (void *)hdd_ctx, |
| 5588 | QDF_TIMER_TYPE_SW); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 5589 | |
| 5590 | return 0; |
| 5591 | } |
| 5592 | |
| 5593 | void hdd_bus_bandwidth_destroy(hdd_context_t *hdd_ctx) |
| 5594 | { |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 5595 | if (hdd_ctx->bus_bw_timer_running) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 5596 | hdd_reset_tcp_delack(hdd_ctx); |
| 5597 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 5598 | hdd_info("wait for bus bw work to flush"); |
| 5599 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 5600 | qdf_timer_free(&hdd_ctx->bus_bw_timer); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 5601 | hdd_ctx->bus_bw_timer_running = false; |
| 5602 | qdf_spinlock_destroy(&hdd_ctx->bus_bw_timer_lock); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 5603 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5604 | #endif |
| 5605 | |
| 5606 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 5607 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 5608 | * @hdd_ctx: hdd context |
| 5609 | * |
| 5610 | * Return: 0 for success or error code |
| 5611 | */ |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 5612 | 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] | 5613 | { |
| 5614 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 5615 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
| 5616 | if (hdd_ctx->hdd_txrx_hist == NULL) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5617 | hdd_err("Failed malloc for hdd_txrx_hist"); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 5618 | return -ENOMEM; |
| 5619 | } |
| 5620 | return 0; |
| 5621 | } |
| 5622 | |
| 5623 | /** |
| 5624 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 5625 | * @hdd_ctx: hdd context |
| 5626 | * |
| 5627 | * Return: none |
| 5628 | */ |
| 5629 | void wlan_hdd_deinit_tx_rx_histogram(hdd_context_t *hdd_ctx) |
| 5630 | { |
| 5631 | if (hdd_ctx->hdd_txrx_hist) { |
| 5632 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 5633 | hdd_ctx->hdd_txrx_hist = NULL; |
| 5634 | } |
| 5635 | } |
| 5636 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5637 | static uint8_t *convert_level_to_string(uint32_t level) |
| 5638 | { |
| 5639 | switch (level) { |
| 5640 | /* initialize the wlan sub system */ |
| 5641 | case WLAN_SVC_TP_NONE: |
| 5642 | return "NONE"; |
| 5643 | case WLAN_SVC_TP_LOW: |
| 5644 | return "LOW"; |
| 5645 | case WLAN_SVC_TP_MEDIUM: |
| 5646 | return "MED"; |
| 5647 | case WLAN_SVC_TP_HIGH: |
| 5648 | return "HIGH"; |
| 5649 | default: |
| 5650 | return "INVAL"; |
| 5651 | } |
| 5652 | } |
| 5653 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 5654 | |
| 5655 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5656 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 5657 | * @hdd_ctx: hdd context |
| 5658 | * |
| 5659 | * Return: none |
| 5660 | */ |
| 5661 | void wlan_hdd_display_tx_rx_histogram(hdd_context_t *hdd_ctx) |
| 5662 | { |
| 5663 | int i; |
| 5664 | |
| 5665 | #ifdef MSM_PLATFORM |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5666 | hdd_err("BW compute Interval: %dms", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5667 | hdd_ctx->config->busBandwidthComputeInterval); |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5668 | 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] | 5669 | hdd_ctx->config->busBandwidthHighThreshold, |
| 5670 | hdd_ctx->config->busBandwidthMediumThreshold, |
| 5671 | hdd_ctx->config->busBandwidthLowThreshold); |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5672 | hdd_err("Enable TCP DEL ACK: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5673 | hdd_ctx->config->enable_tcp_delack); |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5674 | hdd_err("TCP DEL High TH: %d TCP DEL Low TH: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5675 | hdd_ctx->config->tcpDelackThresholdHigh, |
| 5676 | hdd_ctx->config->tcpDelackThresholdLow); |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5677 | 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] | 5678 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5679 | #endif |
| 5680 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5681 | hdd_err("Total entries: %d Current index: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5682 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
| 5683 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5684 | 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] | 5685 | |
| 5686 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5687 | hdd_err("%d: %llu, %llu, %llu, %llu, %s, %s, %s", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5688 | i, hdd_ctx->hdd_txrx_hist[i].total_rx, |
| 5689 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
| 5690 | hdd_ctx->hdd_txrx_hist[i].total_tx, |
| 5691 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5692 | convert_level_to_string( |
| 5693 | hdd_ctx->hdd_txrx_hist[i].next_vote_level), |
| 5694 | convert_level_to_string( |
| 5695 | hdd_ctx->hdd_txrx_hist[i].next_rx_level), |
| 5696 | convert_level_to_string( |
| 5697 | hdd_ctx->hdd_txrx_hist[i].next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5698 | } |
| 5699 | return; |
| 5700 | } |
| 5701 | |
| 5702 | /** |
| 5703 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 5704 | * @hdd_ctx: hdd context |
| 5705 | * |
| 5706 | * Return: none |
| 5707 | */ |
| 5708 | void wlan_hdd_clear_tx_rx_histogram(hdd_context_t *hdd_ctx) |
| 5709 | { |
| 5710 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 5711 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 5712 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5713 | } |
| 5714 | |
| 5715 | /** |
| 5716 | * wlan_hdd_display_netif_queue_history() - display netif queue operation history |
| 5717 | * @pHddCtx: hdd context |
| 5718 | * |
| 5719 | * Return: none |
| 5720 | */ |
| 5721 | void wlan_hdd_display_netif_queue_history(hdd_context_t *hdd_ctx) |
| 5722 | { |
| 5723 | |
| 5724 | hdd_adapter_t *adapter = NULL; |
| 5725 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5726 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5727 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5728 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5729 | |
| 5730 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5731 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5732 | adapter = adapter_node->pAdapter; |
| 5733 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5734 | hdd_err("\nNetif queue operation statistics:"); |
| 5735 | hdd_err("Session_id %d device mode %d", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 5736 | adapter->sessionId, adapter->device_mode); |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5737 | hdd_err("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 5738 | curr_time = qdf_system_ticks(); |
| 5739 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5740 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 5741 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5742 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 5743 | unpause = adapter->total_unpause_time; |
| 5744 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5745 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 5746 | pause = adapter->total_pause_time; |
| 5747 | } |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5748 | hdd_err("Total: %ums Pause: %ums Unpause: %ums", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 5749 | qdf_system_ticks_to_msecs(total), |
| 5750 | qdf_system_ticks_to_msecs(pause), |
| 5751 | qdf_system_ticks_to_msecs(unpause)); |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5752 | hdd_err("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5753 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5754 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 5755 | qdf_time_t pause_delta = 0; |
| 5756 | |
| 5757 | if (adapter->pause_map & (1 << i)) |
| 5758 | pause_delta = delta; |
| 5759 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5760 | hdd_err("%s: %d: %d: %ums", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5761 | hdd_reason_type_to_string(i), |
| 5762 | adapter->queue_oper_stats[i].pause_count, |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5763 | adapter->queue_oper_stats[i].unpause_count, |
| 5764 | qdf_system_ticks_to_msecs( |
| 5765 | adapter->queue_oper_stats[i].total_pause_time + |
| 5766 | pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5767 | } |
| 5768 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5769 | hdd_err("\nNetif queue operation history:"); |
| 5770 | hdd_err("Total entries: %d current index %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5771 | WLAN_HDD_MAX_HISTORY_ENTRY, adapter->history_index); |
| 5772 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5773 | hdd_err("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5774 | |
| 5775 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5776 | hdd_err("%d: %u: %s: %s: %x", |
Anurag Chouhan | 50220ce | 2016-02-18 20:11:33 +0530 | [diff] [blame] | 5777 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5778 | adapter->queue_oper_history[i].time), |
| 5779 | hdd_action_type_to_string( |
| 5780 | adapter->queue_oper_history[i].netif_action), |
| 5781 | hdd_reason_type_to_string( |
| 5782 | adapter->queue_oper_history[i].netif_reason), |
| 5783 | adapter->queue_oper_history[i].pause_map); |
| 5784 | } |
| 5785 | |
| 5786 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 5787 | adapter_node = next; |
| 5788 | } |
| 5789 | |
| 5790 | |
| 5791 | } |
| 5792 | |
| 5793 | /** |
| 5794 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 5795 | * @hdd_ctx: hdd context |
| 5796 | * |
| 5797 | * Return: none |
| 5798 | */ |
| 5799 | void wlan_hdd_clear_netif_queue_history(hdd_context_t *hdd_ctx) |
| 5800 | { |
| 5801 | hdd_adapter_t *adapter = NULL; |
| 5802 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5803 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5804 | |
| 5805 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5806 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5807 | adapter = adapter_node->pAdapter; |
| 5808 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5809 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5810 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5811 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5812 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 5813 | adapter->history_index = 0; |
| 5814 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 5815 | adapter->total_pause_time = 0; |
| 5816 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5817 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 5818 | adapter_node = next; |
| 5819 | } |
| 5820 | } |
| 5821 | |
| 5822 | /** |
| 5823 | * hdd_11d_scan_done() - callback for 11d scan completion of flushing results |
| 5824 | * @halHandle: Hal handle |
| 5825 | * @pContext: Pointer to the context |
| 5826 | * @sessionId: Session ID |
| 5827 | * @scanId: Scan ID |
| 5828 | * @status: Status |
| 5829 | * |
| 5830 | * This is the callback to be executed when 11d scan is completed to flush out |
| 5831 | * the scan results |
| 5832 | * |
| 5833 | * 11d scan is done during driver load and is a passive scan on all |
| 5834 | * channels supported by the device, 11d scans may find some APs on |
| 5835 | * frequencies which are forbidden to be used in the regulatory domain |
| 5836 | * the device is operating in. If these APs are notified to the supplicant |
| 5837 | * it may try to connect to these APs, thus flush out all the scan results |
| 5838 | * which are present in SME after 11d scan is done. |
| 5839 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5840 | * Return: QDF_STATUS_SUCCESS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5841 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5842 | static QDF_STATUS hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5843 | uint8_t sessionId, uint32_t scanId, |
| 5844 | eCsrScanStatus status) |
| 5845 | { |
| 5846 | ENTER(); |
| 5847 | |
| 5848 | sme_scan_flush_result(halHandle); |
| 5849 | |
| 5850 | EXIT(); |
| 5851 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5852 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5853 | } |
| 5854 | |
| 5855 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 5856 | /** |
| 5857 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 5858 | * @hdd_ctx: hdd global context |
| 5859 | * |
| 5860 | * Return: none |
| 5861 | */ |
| 5862 | static void hdd_init_offloaded_packets_ctx(hdd_context_t *hdd_ctx) |
| 5863 | { |
| 5864 | uint8_t i; |
| 5865 | |
| 5866 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 5867 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 5868 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 5869 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 5870 | } |
| 5871 | } |
| 5872 | #else |
| 5873 | static void hdd_init_offloaded_packets_ctx(hdd_context_t *hdd_ctx) |
| 5874 | { |
| 5875 | } |
| 5876 | #endif |
| 5877 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 5878 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 5879 | /** |
| 5880 | * wlan_hdd_set_wow_pulse() - call SME to send wmi cmd of wow pulse |
| 5881 | * @phddctx: hdd_context_t structure pointer |
| 5882 | * @enable: enable or disable this behaviour |
| 5883 | * |
| 5884 | * Return: int |
| 5885 | */ |
| 5886 | static int wlan_hdd_set_wow_pulse(hdd_context_t *phddctx, bool enable) |
| 5887 | { |
| 5888 | struct hdd_config *pcfg_ini = phddctx->config; |
| 5889 | struct wow_pulse_mode wow_pulse_set_info; |
| 5890 | QDF_STATUS status; |
| 5891 | |
| 5892 | hdd_notice("wow pulse enable flag is %d", enable); |
| 5893 | |
| 5894 | if (false == phddctx->config->wow_pulse_support) |
| 5895 | return 0; |
| 5896 | |
| 5897 | /* prepare the request to send to SME */ |
| 5898 | if (enable == true) { |
| 5899 | wow_pulse_set_info.wow_pulse_enable = true; |
| 5900 | wow_pulse_set_info.wow_pulse_pin = |
| 5901 | pcfg_ini->wow_pulse_pin; |
| 5902 | wow_pulse_set_info.wow_pulse_interval_low = |
| 5903 | pcfg_ini->wow_pulse_interval_low; |
| 5904 | wow_pulse_set_info.wow_pulse_interval_high = |
| 5905 | pcfg_ini->wow_pulse_interval_high; |
| 5906 | } else { |
| 5907 | wow_pulse_set_info.wow_pulse_enable = false; |
| 5908 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 5909 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 5910 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 5911 | } |
| 5912 | hdd_notice("enable %d pin %d low %d high %d", |
| 5913 | wow_pulse_set_info.wow_pulse_enable, |
| 5914 | wow_pulse_set_info.wow_pulse_pin, |
| 5915 | wow_pulse_set_info.wow_pulse_interval_low, |
| 5916 | wow_pulse_set_info.wow_pulse_interval_high); |
| 5917 | |
| 5918 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 5919 | if (QDF_STATUS_E_FAILURE == status) { |
| 5920 | hdd_notice("sme_set_wow_pulse failure!"); |
| 5921 | return -EIO; |
| 5922 | } |
| 5923 | hdd_notice("sme_set_wow_pulse success!"); |
| 5924 | return 0; |
| 5925 | } |
| 5926 | #else |
| 5927 | static inline int wlan_hdd_set_wow_pulse(hdd_context_t *phddctx, bool enable) |
| 5928 | { |
| 5929 | return 0; |
| 5930 | } |
| 5931 | #endif |
| 5932 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5933 | #ifdef WLAN_FEATURE_FASTPATH |
| 5934 | /** |
| 5935 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 5936 | * @hdd_cfg: hdd config |
| 5937 | * @context: lower layer context |
| 5938 | * |
| 5939 | * Return: none |
| 5940 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5941 | void hdd_enable_fastpath(struct hdd_config *hdd_cfg, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5942 | void *context) |
| 5943 | { |
| 5944 | if (hdd_cfg->fastpath_enable) |
| 5945 | hif_enable_fastpath(context); |
| 5946 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5947 | #endif |
| 5948 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5949 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5950 | /** |
| 5951 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 5952 | * @context: hdd context pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5953 | * @level: thermal level |
| 5954 | * |
| 5955 | * Change IPA data path to SW path when the thermal throttle level greater |
| 5956 | * than 0, and restore the original data path when throttle level is 0 |
| 5957 | * |
| 5958 | * Return: none |
| 5959 | */ |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 5960 | 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] | 5961 | { |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 5962 | hdd_context_t *hdd_ctx = context; |
| 5963 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5964 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 5965 | if (level > THROTTLE_LEVEL_0) |
| 5966 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, true); |
| 5967 | else |
| 5968 | /* restore original concurrency mode */ |
| 5969 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, hdd_ctx->mcc_mode); |
| 5970 | } |
| 5971 | |
| 5972 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 5973 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 5974 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 5975 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5976 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 5977 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 5978 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 5979 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5980 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 5981 | * Return: Channel number to restart SAP in case of success. In case of any |
| 5982 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5983 | */ |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 5984 | static uint8_t hdd_get_safe_channel_from_pcl_and_acs_range( |
| 5985 | hdd_adapter_t *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5986 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 5987 | struct sir_pcl_list pcl; |
| 5988 | QDF_STATUS status; |
| 5989 | uint32_t i, j; |
| 5990 | tHalHandle *hal_handle; |
| 5991 | hdd_context_t *hdd_ctx; |
| 5992 | bool found = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5993 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 5994 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 5995 | if (!hdd_ctx) { |
| 5996 | hdd_err("invalid HDD context"); |
| 5997 | return INVALID_CHANNEL_ID; |
| 5998 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5999 | |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 6000 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 6001 | if (!hal_handle) { |
| 6002 | hdd_err("invalid HAL handle"); |
| 6003 | return INVALID_CHANNEL_ID; |
| 6004 | } |
| 6005 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6006 | status = cds_get_pcl_for_existing_conn(CDS_SAP_MODE, |
| 6007 | pcl.pcl_list, &pcl.pcl_len, |
| 6008 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list)); |
| 6009 | if (QDF_IS_STATUS_ERROR(status)) { |
| 6010 | hdd_err("Get PCL failed"); |
| 6011 | return INVALID_CHANNEL_ID; |
| 6012 | } |
| 6013 | |
| 6014 | if (!pcl.pcl_len) { |
| 6015 | hdd_alert("pcl length is zero. this is not expected"); |
| 6016 | return INVALID_CHANNEL_ID; |
| 6017 | } |
| 6018 | |
| 6019 | hdd_info("start:%d end:%d", |
| 6020 | adapter->sessionCtx.ap.sapConfig.acs_cfg.start_ch, |
| 6021 | adapter->sessionCtx.ap.sapConfig.acs_cfg.end_ch); |
| 6022 | |
| 6023 | /* PCL already takes unsafe channel into account */ |
| 6024 | for (i = 0; i < pcl.pcl_len; i++) { |
| 6025 | hdd_info("chan[%d]:%d", i, pcl.pcl_list[i]); |
| 6026 | if ((pcl.pcl_list[i] >= |
| 6027 | adapter->sessionCtx.ap.sapConfig.acs_cfg.start_ch) && |
| 6028 | (pcl.pcl_list[i] <= |
| 6029 | adapter->sessionCtx.ap.sapConfig.acs_cfg.end_ch)) { |
| 6030 | hdd_info("found PCL safe chan:%d", pcl.pcl_list[i]); |
| 6031 | return pcl.pcl_list[i]; |
| 6032 | } |
| 6033 | } |
| 6034 | |
| 6035 | hdd_info("no safe channel from PCL found in ACS range"); |
| 6036 | |
| 6037 | /* Try for safe channel from all valid channel */ |
| 6038 | pcl.pcl_len = MAX_NUM_CHAN; |
| 6039 | status = sme_get_cfg_valid_channels(hal_handle, pcl.pcl_list, |
| 6040 | &pcl.pcl_len); |
| 6041 | if (QDF_IS_STATUS_ERROR(status)) { |
| 6042 | hdd_err("error in getting valid channel list"); |
| 6043 | return INVALID_CHANNEL_ID; |
| 6044 | } |
| 6045 | |
| 6046 | for (i = 0; i < pcl.pcl_len; i++) { |
| 6047 | hdd_info("chan[%d]:%d", i, pcl.pcl_list[i]); |
| 6048 | found = false; |
| 6049 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 6050 | if (pcl.pcl_list[i] == |
| 6051 | hdd_ctx->unsafe_channel_list[j]) { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6052 | hdd_info("unsafe chan:%d", pcl.pcl_list[i]); |
| 6053 | found = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6054 | break; |
| 6055 | } |
| 6056 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6057 | |
| 6058 | if (found) |
| 6059 | continue; |
| 6060 | |
| 6061 | if ((pcl.pcl_list[i] >= |
| 6062 | adapter->sessionCtx.ap.sapConfig.acs_cfg.start_ch) && |
| 6063 | (pcl.pcl_list[i] <= |
| 6064 | adapter->sessionCtx.ap.sapConfig.acs_cfg.end_ch)) { |
| 6065 | hdd_info("found safe chan:%d", pcl.pcl_list[i]); |
| 6066 | return pcl.pcl_list[i]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6067 | } |
| 6068 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6069 | |
| 6070 | return INVALID_CHANNEL_ID; |
| 6071 | } |
| 6072 | |
| 6073 | /** |
| 6074 | * hdd_restart_sap() - Restarts SAP on the given channel |
| 6075 | * @adapter: AP adapter |
| 6076 | * @channel: Channel |
| 6077 | * |
| 6078 | * Restarts the SAP interface by invoking the function which executes the |
| 6079 | * callback to perform channel switch using (E)CSA. |
| 6080 | * |
| 6081 | * Return: None |
| 6082 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 6083 | static void hdd_restart_sap(hdd_adapter_t *adapter, uint8_t channel) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6084 | { |
| 6085 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 6086 | tHalHandle *hal_handle; |
| 6087 | |
| 6088 | if (!adapter) { |
| 6089 | hdd_err("invalid adapter"); |
| 6090 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6091 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6092 | |
| 6093 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 6094 | |
| 6095 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 6096 | if (!hal_handle) { |
| 6097 | hdd_err("invalid HAL handle"); |
| 6098 | return; |
| 6099 | } |
| 6100 | |
| 6101 | hdd_ap_ctx->sapConfig.channel = channel; |
| 6102 | hdd_ap_ctx->sapConfig.ch_params.ch_width = |
| 6103 | hdd_ap_ctx->sapConfig.ch_width_orig; |
| 6104 | |
| 6105 | hdd_info("chan:%d width:%d", |
| 6106 | channel, hdd_ap_ctx->sapConfig.ch_width_orig); |
| 6107 | |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 6108 | cds_set_channel_params(hdd_ap_ctx->sapConfig.channel, |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6109 | hdd_ap_ctx->sapConfig.sec_ch, |
| 6110 | &hdd_ap_ctx->sapConfig.ch_params); |
| 6111 | |
| 6112 | cds_change_sap_channel_with_csa(adapter, hdd_ap_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6113 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6114 | /** |
| 6115 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 6116 | * @hdd_ctx: hdd context pointer |
| 6117 | * |
| 6118 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 6119 | * and if ACS is enabled, driver will ask userspace to restart the |
| 6120 | * sap. User space on LTE coex indication restart driver. |
| 6121 | * |
| 6122 | * Return - none |
| 6123 | */ |
| 6124 | void hdd_unsafe_channel_restart_sap(hdd_context_t *hdd_ctxt) |
| 6125 | { |
| 6126 | QDF_STATUS status; |
| 6127 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 6128 | hdd_adapter_t *adapter_temp; |
| 6129 | uint32_t i; |
| 6130 | bool found = false; |
| 6131 | uint8_t restart_chan; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6132 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6133 | status = hdd_get_front_adapter(hdd_ctxt, &adapter_node); |
| 6134 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 6135 | adapter_temp = adapter_node->pAdapter; |
| 6136 | |
| 6137 | if (!adapter_temp) { |
| 6138 | hdd_err("adapter is NULL, moving to next one"); |
| 6139 | goto next_adapater; |
| 6140 | } |
| 6141 | |
| 6142 | if (!((adapter_temp->device_mode == QDF_SAP_MODE) && |
| 6143 | (adapter_temp->sessionCtx.ap.sapConfig.acs_cfg.acs_mode))) { |
| 6144 | hdd_info("skip device mode:%d acs:%d", |
| 6145 | adapter_temp->device_mode, |
| 6146 | adapter_temp->sessionCtx.ap.sapConfig. |
| 6147 | acs_cfg.acs_mode); |
| 6148 | goto next_adapater; |
| 6149 | } |
| 6150 | |
| 6151 | found = false; |
| 6152 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 6153 | if (adapter_temp->sessionCtx.ap.operatingChannel == |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6154 | hdd_ctxt->unsafe_channel_list[i]) { |
| 6155 | found = true; |
| 6156 | hdd_info("operating ch:%d is unsafe", |
| 6157 | adapter_temp->sessionCtx.ap.operatingChannel); |
| 6158 | break; |
| 6159 | } |
| 6160 | } |
| 6161 | |
| 6162 | if (!found) { |
| 6163 | hdd_info("ch:%d is safe. no need to change channel", |
| 6164 | adapter_temp->sessionCtx.ap.operatingChannel); |
| 6165 | goto next_adapater; |
| 6166 | } |
| 6167 | |
| 6168 | restart_chan = |
| 6169 | hdd_get_safe_channel_from_pcl_and_acs_range( |
| 6170 | adapter_temp); |
| 6171 | if (!restart_chan) { |
| 6172 | hdd_alert("fail to restart SAP"); |
| 6173 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 6174 | /* |
| 6175 | * SAP restart due to unsafe channel. While |
| 6176 | * restarting the SAP, make sure to clear |
| 6177 | * acs_channel, channel to reset to |
| 6178 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 6179 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 6180 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 6181 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
| 6182 | adapter_temp->sessionCtx.ap.sapConfig.channel = |
| 6183 | AUTO_CHANNEL_SELECT; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6184 | hdd_info("sending coex indication"); |
| 6185 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 6186 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
| 6187 | hdd_restart_sap(adapter_temp, restart_chan); |
| 6188 | } |
| 6189 | |
| 6190 | next_adapater: |
| 6191 | status = hdd_get_next_adapter(hdd_ctxt, adapter_node, &next); |
| 6192 | adapter_node = next; |
| 6193 | } |
| 6194 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6195 | /** |
| 6196 | * hdd_ch_avoid_cb() - Avoid notified channels from FW handler |
| 6197 | * @adapter: HDD adapter pointer |
| 6198 | * @indParam: Channel avoid notification parameter |
| 6199 | * |
| 6200 | * Avoid channel notification from FW handler. |
| 6201 | * FW will send un-safe channel list to avoid over wrapping. |
| 6202 | * hostapd should not use notified channel |
| 6203 | * |
| 6204 | * Return: None |
| 6205 | */ |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6206 | void hdd_ch_avoid_cb(void *hdd_context, void *indi_param) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6207 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6208 | hdd_context_t *hdd_ctxt; |
| 6209 | tSirChAvoidIndType *ch_avoid_indi; |
| 6210 | uint8_t range_loop; |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6211 | enum channel_enum channel_loop, start_channel_idx = INVALID_CHANNEL, |
| 6212 | end_channel_idx = INVALID_CHANNEL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6213 | uint16_t start_channel; |
| 6214 | uint16_t end_channel; |
| 6215 | v_CONTEXT_t cds_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6216 | tHddAvoidFreqList hdd_avoid_freq_list; |
| 6217 | uint32_t i; |
| 6218 | |
| 6219 | /* Basic sanity */ |
| 6220 | if (!hdd_context || !indi_param) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6221 | hdd_err("Invalid arguments"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6222 | return; |
| 6223 | } |
| 6224 | |
| 6225 | hdd_ctxt = (hdd_context_t *) hdd_context; |
| 6226 | ch_avoid_indi = (tSirChAvoidIndType *) indi_param; |
| 6227 | cds_context = hdd_ctxt->pcds_context; |
| 6228 | |
| 6229 | /* Make unsafe channel list */ |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6230 | hdd_notice("band count %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6231 | ch_avoid_indi->avoid_range_count); |
| 6232 | |
| 6233 | /* generate vendor specific event */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6234 | qdf_mem_zero((void *)&hdd_avoid_freq_list, sizeof(tHddAvoidFreqList)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6235 | for (i = 0; i < ch_avoid_indi->avoid_range_count; i++) { |
| 6236 | hdd_avoid_freq_list.avoidFreqRange[i].startFreq = |
| 6237 | ch_avoid_indi->avoid_freq_range[i].start_freq; |
| 6238 | hdd_avoid_freq_list.avoidFreqRange[i].endFreq = |
| 6239 | ch_avoid_indi->avoid_freq_range[i].end_freq; |
| 6240 | } |
| 6241 | hdd_avoid_freq_list.avoidFreqRangeCount = |
| 6242 | ch_avoid_indi->avoid_range_count; |
| 6243 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6244 | /* clear existing unsafe channel cache */ |
| 6245 | hdd_ctxt->unsafe_channel_count = 0; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6246 | qdf_mem_zero(hdd_ctxt->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6247 | sizeof(hdd_ctxt->unsafe_channel_list)); |
| 6248 | |
| 6249 | for (range_loop = 0; range_loop < ch_avoid_indi->avoid_range_count; |
| 6250 | range_loop++) { |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6251 | if (hdd_ctxt->unsafe_channel_count >= NUM_CHANNELS) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6252 | hdd_warn("LTE Coex unsafe channel list full"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6253 | break; |
| 6254 | } |
| 6255 | |
| 6256 | start_channel = ieee80211_frequency_to_channel( |
| 6257 | ch_avoid_indi->avoid_freq_range[range_loop].start_freq); |
| 6258 | end_channel = ieee80211_frequency_to_channel( |
| 6259 | ch_avoid_indi->avoid_freq_range[range_loop].end_freq); |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6260 | hdd_notice("start %d : %d, end %d : %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6261 | ch_avoid_indi->avoid_freq_range[range_loop].start_freq, |
| 6262 | start_channel, |
| 6263 | ch_avoid_indi->avoid_freq_range[range_loop].end_freq, |
| 6264 | end_channel); |
| 6265 | |
| 6266 | /* do not process frequency bands that are not mapped to |
| 6267 | * predefined channels |
| 6268 | */ |
| 6269 | if (start_channel == 0 || end_channel == 0) |
| 6270 | continue; |
| 6271 | |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6272 | for (channel_loop = CHAN_ENUM_1; channel_loop <= |
| 6273 | CHAN_ENUM_184; channel_loop++) { |
Amar Singhal | 7a1726a | 2015-10-14 16:28:11 -0700 | [diff] [blame] | 6274 | if (CDS_CHANNEL_FREQ(channel_loop) >= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6275 | ch_avoid_indi->avoid_freq_range[ |
| 6276 | range_loop].start_freq) { |
| 6277 | start_channel_idx = channel_loop; |
| 6278 | break; |
| 6279 | } |
| 6280 | } |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6281 | for (channel_loop = CHAN_ENUM_1; channel_loop <= |
| 6282 | CHAN_ENUM_184; channel_loop++) { |
Amar Singhal | 7a1726a | 2015-10-14 16:28:11 -0700 | [diff] [blame] | 6283 | if (CDS_CHANNEL_FREQ(channel_loop) >= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6284 | ch_avoid_indi->avoid_freq_range[ |
| 6285 | range_loop].end_freq) { |
| 6286 | end_channel_idx = channel_loop; |
Amar Singhal | 7a1726a | 2015-10-14 16:28:11 -0700 | [diff] [blame] | 6287 | if (CDS_CHANNEL_FREQ(channel_loop) > |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6288 | ch_avoid_indi->avoid_freq_range[ |
| 6289 | range_loop].end_freq) |
| 6290 | end_channel_idx--; |
| 6291 | break; |
| 6292 | } |
| 6293 | } |
| 6294 | |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6295 | if (start_channel_idx == INVALID_CHANNEL || |
| 6296 | end_channel_idx == INVALID_CHANNEL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6297 | continue; |
| 6298 | |
| 6299 | for (channel_loop = start_channel_idx; channel_loop <= |
| 6300 | end_channel_idx; channel_loop++) { |
| 6301 | hdd_ctxt->unsafe_channel_list[ |
Amar Singhal | 7a1726a | 2015-10-14 16:28:11 -0700 | [diff] [blame] | 6302 | hdd_ctxt->unsafe_channel_count++] = |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 6303 | CDS_CHANNEL_NUM(channel_loop); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6304 | if (hdd_ctxt->unsafe_channel_count >= |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6305 | NUM_CHANNELS) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6306 | hdd_warn("LTECoex unsafe ch list full"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6307 | break; |
| 6308 | } |
| 6309 | } |
| 6310 | } |
| 6311 | |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6312 | hdd_notice("number of unsafe channels is %d ", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6313 | hdd_ctxt->unsafe_channel_count); |
| 6314 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6315 | if (pld_set_wlan_unsafe_channel(hdd_ctxt->parent_dev, |
| 6316 | hdd_ctxt->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6317 | hdd_ctxt->unsafe_channel_count)) { |
| 6318 | hdd_err("Failed to set unsafe channel"); |
| 6319 | |
| 6320 | /* clear existing unsafe channel cache */ |
| 6321 | hdd_ctxt->unsafe_channel_count = 0; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6322 | qdf_mem_zero(hdd_ctxt->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6323 | sizeof(hdd_ctxt->unsafe_channel_list)); |
| 6324 | |
| 6325 | return; |
| 6326 | } |
| 6327 | |
| 6328 | for (channel_loop = 0; |
| 6329 | channel_loop < hdd_ctxt->unsafe_channel_count; channel_loop++) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6330 | hdd_notice("channel %d is not safe ", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6331 | hdd_ctxt->unsafe_channel_list[channel_loop]); |
| 6332 | } |
| 6333 | |
Kondabattini, Ganesh | cf7b60f | 2016-08-10 16:31:55 +0530 | [diff] [blame] | 6334 | /* |
| 6335 | * first update the unsafe channel list to the platform driver and |
| 6336 | * send the avoid freq event to the application |
| 6337 | */ |
| 6338 | wlan_hdd_send_avoid_freq_event(hdd_ctxt, &hdd_avoid_freq_list); |
| 6339 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6340 | if (!hdd_ctxt->unsafe_channel_count) { |
| 6341 | hdd_info("no unsafe channels - not restarting SAP"); |
| 6342 | return; |
| 6343 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6344 | hdd_unsafe_channel_restart_sap(hdd_ctxt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6345 | return; |
| 6346 | } |
| 6347 | |
| 6348 | /** |
| 6349 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 6350 | * @hdd_ctx: HDD global context |
| 6351 | * |
| 6352 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6353 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6354 | * down to the lower layers. Then subscribe to subsequent channel |
| 6355 | * avoidance events. |
| 6356 | * |
| 6357 | * Return: None |
| 6358 | */ |
| 6359 | static void hdd_init_channel_avoidance(hdd_context_t *hdd_ctx) |
| 6360 | { |
| 6361 | uint16_t unsafe_channel_count; |
| 6362 | int index; |
| 6363 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6364 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 6365 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6366 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6367 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6368 | |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6369 | hdd_notice("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6370 | hdd_ctx->unsafe_channel_count); |
| 6371 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6372 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6373 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6374 | |
| 6375 | for (index = 0; index < unsafe_channel_count; index++) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6376 | hdd_notice("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6377 | hdd_ctx->unsafe_channel_list[index]); |
| 6378 | |
| 6379 | } |
| 6380 | |
| 6381 | /* Plug in avoid channel notification callback */ |
| 6382 | sme_add_ch_avoid_callback(hdd_ctx->hHal, hdd_ch_avoid_cb); |
| 6383 | } |
| 6384 | #else |
| 6385 | static void hdd_init_channel_avoidance(hdd_context_t *hdd_ctx) |
| 6386 | { |
| 6387 | } |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 6388 | 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] | 6389 | { |
| 6390 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6391 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6392 | |
| 6393 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 6394 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 6395 | * user space |
| 6396 | * @frame_ind: Management frame data to be informed. |
| 6397 | * |
| 6398 | * This function is used to indicate management frame to |
| 6399 | * user space |
| 6400 | * |
| 6401 | * Return: None |
| 6402 | * |
| 6403 | */ |
| 6404 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 6405 | { |
| 6406 | hdd_context_t *hdd_ctx = NULL; |
| 6407 | hdd_adapter_t *adapter = NULL; |
| 6408 | void *cds_context = NULL; |
| 6409 | int i; |
| 6410 | |
| 6411 | /* Get the global VOSS context.*/ |
| 6412 | cds_context = cds_get_global_context(); |
| 6413 | if (!cds_context) { |
| 6414 | hdd_err("Global CDS context is Null"); |
| 6415 | return; |
| 6416 | } |
| 6417 | /* Get the HDD context.*/ |
| 6418 | hdd_ctx = (hdd_context_t *)cds_get_context(QDF_MODULE_ID_HDD); |
| 6419 | |
| 6420 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 6421 | return; |
| 6422 | |
| 6423 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
| 6424 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 6425 | adapter = |
| 6426 | hdd_get_adapter_by_sme_session_id(hdd_ctx, i); |
| 6427 | if (adapter) |
| 6428 | break; |
| 6429 | } |
| 6430 | } else { |
| 6431 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 6432 | frame_ind->sessionId); |
| 6433 | } |
| 6434 | |
| 6435 | if ((NULL != adapter) && |
| 6436 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 6437 | __hdd_indicate_mgmt_frame(adapter, |
| 6438 | frame_ind->frame_len, |
| 6439 | frame_ind->frameBuf, |
| 6440 | frame_ind->frameType, |
| 6441 | frame_ind->rxChan, |
| 6442 | frame_ind->rxRssi); |
| 6443 | return; |
| 6444 | } |
| 6445 | |
| 6446 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6447 | * wlan_hdd_disable_all_dual_mac_features() - Disable dual mac features |
| 6448 | * @hdd_ctx: HDD context |
| 6449 | * |
| 6450 | * Disables all the dual mac features like DBS, Agile DFS etc. |
| 6451 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6452 | * Return: QDF_STATUS_SUCCESS on success |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6453 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6454 | 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] | 6455 | { |
| 6456 | struct sir_dual_mac_config cfg; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6457 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6458 | |
| 6459 | if (!hdd_ctx) { |
| 6460 | hdd_err("HDD context is NULL"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6461 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6462 | } |
| 6463 | |
| 6464 | cfg.scan_config = 0; |
| 6465 | cfg.fw_mode_config = 0; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 6466 | cfg.set_dual_mac_cb = cds_soc_set_dual_mac_cfg_cb; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6467 | |
| 6468 | hdd_debug("Disabling all dual mac features..."); |
| 6469 | |
| 6470 | status = sme_soc_set_dual_mac_config(hdd_ctx->hHal, cfg); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6471 | if (status != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6472 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 6473 | return status; |
| 6474 | } |
| 6475 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6476 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6477 | } |
| 6478 | |
| 6479 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6480 | * hdd_override_ini_config - Override INI config |
| 6481 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6482 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6483 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6484 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6485 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6486 | */ |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6487 | static void hdd_override_ini_config(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6488 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6489 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6490 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
| 6491 | hdd_ctx->config->enableDFSChnlScan = enable_dfs_chan_scan; |
| 6492 | hdd_notice("Module enable_dfs_chan_scan set to %d", |
| 6493 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6494 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6495 | if (0 == enable_11d || 1 == enable_11d) { |
| 6496 | hdd_ctx->config->Is11dSupportEnabled = enable_11d; |
| 6497 | hdd_notice("Module enable_11d set to %d", enable_11d); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6498 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 6499 | |
| 6500 | if (!hdd_ipa_is_present(hdd_ctx)) |
| 6501 | hdd_ctx->config->IpaConfig = 0; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6502 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6503 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6504 | /** |
| 6505 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 6506 | * @hdd_ctx - HDD context |
| 6507 | * |
| 6508 | * Set trace level for each module based on INI config. |
| 6509 | * |
| 6510 | * Return: None |
| 6511 | */ |
| 6512 | static void hdd_set_trace_level_for_each(hdd_context_t *hdd_ctx) |
| 6513 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6514 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMI, |
| 6515 | hdd_ctx->config->qdf_trace_enable_wdi); |
| 6516 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD, |
| 6517 | hdd_ctx->config->qdf_trace_enable_hdd); |
| 6518 | hdd_qdf_trace_enable(QDF_MODULE_ID_SME, |
| 6519 | hdd_ctx->config->qdf_trace_enable_sme); |
| 6520 | hdd_qdf_trace_enable(QDF_MODULE_ID_PE, |
| 6521 | hdd_ctx->config->qdf_trace_enable_pe); |
| 6522 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMA, |
| 6523 | hdd_ctx->config->qdf_trace_enable_wma); |
| 6524 | hdd_qdf_trace_enable(QDF_MODULE_ID_SYS, |
| 6525 | hdd_ctx->config->qdf_trace_enable_sys); |
| 6526 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF, |
| 6527 | hdd_ctx->config->qdf_trace_enable_qdf); |
| 6528 | hdd_qdf_trace_enable(QDF_MODULE_ID_SAP, |
| 6529 | hdd_ctx->config->qdf_trace_enable_sap); |
| 6530 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SOFTAP, |
| 6531 | hdd_ctx->config->qdf_trace_enable_hdd_sap); |
| 6532 | hdd_qdf_trace_enable(QDF_MODULE_ID_BMI, |
| 6533 | hdd_ctx->config->qdf_trace_enable_bmi); |
| 6534 | hdd_qdf_trace_enable(QDF_MODULE_ID_CFG, |
| 6535 | hdd_ctx->config->qdf_trace_enable_cfg); |
| 6536 | hdd_qdf_trace_enable(QDF_MODULE_ID_EPPING, |
| 6537 | hdd_ctx->config->qdf_trace_enable_epping); |
| 6538 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF_DEVICE, |
| 6539 | hdd_ctx->config->qdf_trace_enable_qdf_devices); |
| 6540 | hdd_qdf_trace_enable(QDF_MODULE_ID_TXRX, |
Bhargav Shah | 480a90f | 2015-06-24 15:10:14 +0530 | [diff] [blame] | 6541 | hdd_ctx->config->cfd_trace_enable_txrx); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6542 | hdd_qdf_trace_enable(QDF_MODULE_ID_HTC, |
| 6543 | hdd_ctx->config->qdf_trace_enable_htc); |
| 6544 | hdd_qdf_trace_enable(QDF_MODULE_ID_HIF, |
| 6545 | hdd_ctx->config->qdf_trace_enable_hif); |
| 6546 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SAP_DATA, |
| 6547 | hdd_ctx->config->qdf_trace_enable_hdd_sap_data); |
| 6548 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_DATA, |
| 6549 | hdd_ctx->config->qdf_trace_enable_hdd_data); |
Bhargav Shah | 480a90f | 2015-06-24 15:10:14 +0530 | [diff] [blame] | 6550 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6551 | hdd_cfg_print(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6552 | } |
| 6553 | |
| 6554 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6555 | * hdd_context_init() - Initialize HDD context |
| 6556 | * @hdd_ctx: HDD context. |
| 6557 | * |
| 6558 | * Initialize HDD context along with all the feature specific contexts. |
| 6559 | * |
| 6560 | * return: 0 on success and errno on failure. |
| 6561 | */ |
| 6562 | static int hdd_context_init(hdd_context_t *hdd_ctx) |
| 6563 | { |
| 6564 | int ret; |
| 6565 | |
| 6566 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 6567 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 6568 | |
| 6569 | hdd_init_ll_stats_ctx(); |
| 6570 | |
| 6571 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 6572 | init_completion(&hdd_ctx->ready_to_suspend); |
| 6573 | |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6574 | hdd_init_bpf_completion(); |
| 6575 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6576 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 6577 | qdf_spinlock_create(&hdd_ctx->sta_update_info_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6578 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 6579 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6580 | qdf_list_create(&hdd_ctx->hddAdapters, MAX_NUMBER_OF_ADAPTERS); |
| 6581 | |
| 6582 | init_completion(&hdd_ctx->set_antenna_mode_cmpl); |
| 6583 | |
| 6584 | ret = hdd_scan_context_init(hdd_ctx); |
| 6585 | if (ret) |
| 6586 | goto list_destroy; |
| 6587 | |
Nitesh Shah | d1266d7 | 2017-01-25 22:07:07 +0530 | [diff] [blame] | 6588 | hdd_tdls_context_init(hdd_ctx, false); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6589 | |
| 6590 | hdd_rx_wake_lock_create(hdd_ctx); |
| 6591 | |
| 6592 | ret = hdd_sap_context_init(hdd_ctx); |
| 6593 | if (ret) |
| 6594 | goto scan_destroy; |
| 6595 | |
| 6596 | ret = hdd_roc_context_init(hdd_ctx); |
| 6597 | if (ret) |
| 6598 | goto sap_destroy; |
| 6599 | |
| 6600 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 6601 | |
| 6602 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 6603 | |
| 6604 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 6605 | hdd_ctx->config); |
| 6606 | if (ret) |
| 6607 | goto roc_destroy; |
| 6608 | |
| 6609 | return 0; |
| 6610 | |
| 6611 | roc_destroy: |
| 6612 | hdd_roc_context_destroy(hdd_ctx); |
| 6613 | |
| 6614 | sap_destroy: |
| 6615 | hdd_sap_context_destroy(hdd_ctx); |
| 6616 | |
| 6617 | scan_destroy: |
| 6618 | hdd_scan_context_destroy(hdd_ctx); |
| 6619 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 6620 | hdd_tdls_context_destroy(hdd_ctx); |
| 6621 | |
| 6622 | list_destroy: |
| 6623 | qdf_list_destroy(&hdd_ctx->hddAdapters); |
| 6624 | return ret; |
| 6625 | } |
| 6626 | |
| 6627 | /** |
| 6628 | * hdd_context_create() - Allocate and inialize HDD context. |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6629 | * @dev: Device Pointer to the underlying device |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6630 | * |
| 6631 | * Allocate and initialize HDD context. HDD context is allocated as part of |
| 6632 | * wiphy allocation and then context is initialized. |
| 6633 | * |
| 6634 | * Return: HDD context on success and ERR_PTR on failure |
| 6635 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 6636 | static hdd_context_t *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6637 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6638 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6639 | int ret = 0; |
| 6640 | hdd_context_t *hdd_ctx; |
| 6641 | v_CONTEXT_t p_cds_context; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 6642 | int qdf_print_idx = -1; |
| 6643 | |
| 6644 | struct category_info cinfo[MAX_SUPPORTED_CATEGORY] = { |
| 6645 | [QDF_MODULE_ID_TLSHIM] = {QDF_TRACE_LEVEL_ALL}, |
| 6646 | [QDF_MODULE_ID_WMI] = {QDF_TRACE_LEVEL_ALL}, |
| 6647 | [QDF_MODULE_ID_HTT] = {QDF_TRACE_LEVEL_ALL}, |
| 6648 | [QDF_MODULE_ID_HDD] = {QDF_TRACE_LEVEL_ALL}, |
| 6649 | [QDF_MODULE_ID_SME] = {QDF_TRACE_LEVEL_ALL}, |
| 6650 | [QDF_MODULE_ID_PE] = {QDF_TRACE_LEVEL_ALL}, |
| 6651 | [QDF_MODULE_ID_WMA] = {QDF_TRACE_LEVEL_ALL}, |
| 6652 | [QDF_MODULE_ID_SYS] = {QDF_TRACE_LEVEL_ALL}, |
| 6653 | [QDF_MODULE_ID_QDF] = {QDF_TRACE_LEVEL_ALL}, |
| 6654 | [QDF_MODULE_ID_SAP] = {QDF_TRACE_LEVEL_ALL}, |
| 6655 | [QDF_MODULE_ID_HDD_SOFTAP] = {QDF_TRACE_LEVEL_ALL}, |
| 6656 | [QDF_MODULE_ID_HDD_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 6657 | [QDF_MODULE_ID_HDD_SAP_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 6658 | [QDF_MODULE_ID_HIF] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 6659 | [QDF_MODULE_ID_HTC] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 6660 | [QDF_MODULE_ID_TXRX] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 6661 | [QDF_MODULE_ID_QDF_DEVICE] = {QDF_TRACE_LEVEL_ALL}, |
| 6662 | [QDF_MODULE_ID_CFG] = {QDF_TRACE_LEVEL_ALL}, |
| 6663 | [QDF_MODULE_ID_BMI] = {QDF_TRACE_LEVEL_ALL}, |
| 6664 | [QDF_MODULE_ID_EPPING] = {QDF_TRACE_LEVEL_ALL}, |
| 6665 | [QDF_MODULE_ID_QVIT] = {QDF_TRACE_LEVEL_ALL} |
| 6666 | }; |
| 6667 | |
| 6668 | status = qdf_print_setup(); |
| 6669 | if (status != QDF_STATUS_SUCCESS) { |
| 6670 | pr_err("QDF print control object setup failed\n"); |
| 6671 | ret = -EINVAL; |
| 6672 | goto err_out; |
| 6673 | } |
| 6674 | /* Register the module here with QDF */ |
| 6675 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, |
| 6676 | "MCL_WLAN"); |
| 6677 | |
| 6678 | /* if qdf_print_idx is negative */ |
| 6679 | if (qdf_print_idx < 0) { |
| 6680 | pr_err("QDF print control can not be registered %d\n", |
| 6681 | qdf_print_idx); |
| 6682 | ret = -EINVAL; |
| 6683 | goto err_out; |
| 6684 | } |
| 6685 | |
| 6686 | /* Store the qdf_pidx information into qdf module */ |
| 6687 | qdf_set_pidx(qdf_print_idx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6688 | |
| 6689 | ENTER(); |
| 6690 | |
| 6691 | p_cds_context = cds_get_global_context(); |
| 6692 | if (p_cds_context == NULL) { |
| 6693 | hdd_alert("Failed to get CDS global context"); |
| 6694 | ret = -EINVAL; |
| 6695 | goto err_out; |
| 6696 | } |
| 6697 | |
| 6698 | hdd_ctx = hdd_cfg80211_wiphy_alloc(sizeof(hdd_context_t)); |
| 6699 | |
| 6700 | if (hdd_ctx == NULL) { |
| 6701 | ret = -ENOMEM; |
| 6702 | goto err_out; |
| 6703 | } |
| 6704 | |
| 6705 | hdd_ctx->pcds_context = p_cds_context; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6706 | hdd_ctx->parent_dev = dev; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6707 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6708 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6709 | if (hdd_ctx->config == NULL) { |
| 6710 | hdd_alert("Failed to alloc memory for HDD config!"); |
| 6711 | ret = -ENOMEM; |
| 6712 | goto err_free_hdd_context; |
| 6713 | } |
| 6714 | |
| 6715 | /* Read and parse the qcom_cfg.ini file */ |
| 6716 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6717 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6718 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6719 | WLAN_INI_FILE); |
| 6720 | ret = -EINVAL; |
| 6721 | goto err_free_config; |
| 6722 | } |
| 6723 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6724 | hdd_ctx->configuredMcastBcastFilter = |
| 6725 | hdd_ctx->config->mcastBcastFilterSetting; |
| 6726 | |
| 6727 | hdd_notice("Setting configuredMcastBcastFilter: %d", |
| 6728 | hdd_ctx->config->mcastBcastFilterSetting); |
| 6729 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 6730 | if (hdd_ctx->config->fhostNSOffload) |
| 6731 | hdd_ctx->ns_offload_enable = true; |
| 6732 | |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 6733 | cds_set_fatal_event(hdd_ctx->config->enable_fatal_event); |
| 6734 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6735 | hdd_override_ini_config(hdd_ctx); |
| 6736 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6737 | ((cds_context_type *) (p_cds_context))->pHDDContext = (void *)hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6738 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6739 | ret = hdd_context_init(hdd_ctx); |
| 6740 | |
| 6741 | if (ret) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6742 | goto err_free_config; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6743 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6744 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6745 | pld_set_fw_debug_mode(hdd_ctx->parent_dev, |
| 6746 | hdd_ctx->config->enable_fw_log); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6747 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6748 | |
| 6749 | /* Uses to enabled logging after SSR */ |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 6750 | hdd_ctx->fw_log_settings.enable = hdd_ctx->config->enable_fw_log; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6751 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6752 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6753 | goto skip_multicast_logging; |
| 6754 | |
| 6755 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 6756 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 6757 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 6758 | if (ret) |
| 6759 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6760 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6761 | ret = hdd_logging_sock_activate_svc(hdd_ctx); |
| 6762 | if (ret) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6763 | goto err_free_histogram; |
| 6764 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6765 | skip_multicast_logging: |
| 6766 | hdd_set_trace_level_for_each(hdd_ctx); |
| 6767 | |
| 6768 | return hdd_ctx; |
| 6769 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6770 | err_free_histogram: |
| 6771 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 6772 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 6773 | err_deinit_hdd_context: |
| 6774 | hdd_context_deinit(hdd_ctx); |
| 6775 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6776 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6777 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6778 | |
| 6779 | err_free_hdd_context: |
| 6780 | wiphy_free(hdd_ctx->wiphy); |
| 6781 | |
| 6782 | err_out: |
| 6783 | return ERR_PTR(ret); |
| 6784 | } |
| 6785 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6786 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 6787 | /** |
| 6788 | * hdd_open_p2p_interface - Open P2P interface |
| 6789 | * @hdd_ctx: HDD context |
| 6790 | * @rtnl_held: True if RTNL lock held |
| 6791 | * |
| 6792 | * Open P2P interface during probe. This function called to open the P2P |
| 6793 | * interface at probe along with STA interface. |
| 6794 | * |
| 6795 | * Return: 0 on success and errno on failure |
| 6796 | */ |
| 6797 | static int hdd_open_p2p_interface(hdd_context_t *hdd_ctx, bool rtnl_held) |
| 6798 | { |
| 6799 | hdd_adapter_t *adapter; |
| 6800 | uint8_t *p2p_dev_addr; |
| 6801 | |
| 6802 | if (hdd_ctx->config->isP2pDeviceAddrAdministrated && |
| 6803 | !(hdd_ctx->config->intfMacAddr[0].bytes[0] & 0x02)) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6804 | qdf_mem_copy(hdd_ctx->p2pDeviceAddress.bytes, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6805 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 6806 | sizeof(tSirMacAddr)); |
| 6807 | |
| 6808 | /* |
| 6809 | * Generate the P2P Device Address. This consists of |
| 6810 | * the device's primary MAC address with the locally |
| 6811 | * administered bit set. |
| 6812 | */ |
| 6813 | hdd_ctx->p2pDeviceAddress.bytes[0] |= 0x02; |
| 6814 | } else { |
| 6815 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx); |
| 6816 | if (p2p_dev_addr == NULL) { |
| 6817 | hdd_alert("Failed to allocate mac_address for p2p_device"); |
| 6818 | return -ENOSPC; |
| 6819 | } |
| 6820 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6821 | qdf_mem_copy(&hdd_ctx->p2pDeviceAddress.bytes[0], p2p_dev_addr, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6822 | QDF_MAC_ADDR_SIZE); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6823 | } |
| 6824 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6825 | adapter = hdd_open_adapter(hdd_ctx, QDF_P2P_DEVICE_MODE, "p2p%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6826 | &hdd_ctx->p2pDeviceAddress.bytes[0], |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 6827 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6828 | |
| 6829 | if (NULL == adapter) { |
| 6830 | hdd_alert("Failed to do hdd_open_adapter for P2P Device Interface"); |
| 6831 | return -ENOSPC; |
| 6832 | } |
| 6833 | |
| 6834 | return 0; |
| 6835 | } |
| 6836 | #else |
Manishekar Chandrasekaran | c81ba24 | 2016-07-18 17:44:44 +0530 | [diff] [blame] | 6837 | static inline int hdd_open_p2p_interface(hdd_context_t *hdd_ctx, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6838 | bool rtnl_held) |
| 6839 | { |
| 6840 | return 0; |
| 6841 | } |
| 6842 | #endif |
| 6843 | |
| 6844 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 6845 | * hdd_start_station_adapter()- Start the Station Adapter |
| 6846 | * @adapter: HDD adapter |
| 6847 | * |
| 6848 | * This function initializes the adapter for the station mode. |
| 6849 | * |
| 6850 | * Return: 0 on success or errno on failure. |
| 6851 | */ |
| 6852 | int hdd_start_station_adapter(hdd_adapter_t *adapter) |
| 6853 | { |
| 6854 | QDF_STATUS status; |
| 6855 | |
| 6856 | ENTER_DEV(adapter->dev); |
| 6857 | |
| 6858 | status = hdd_init_station_mode(adapter); |
| 6859 | |
| 6860 | if (QDF_STATUS_SUCCESS != status) { |
| 6861 | hdd_err("Error Initializing station mode: %d", status); |
| 6862 | return qdf_status_to_os_return(status); |
| 6863 | } |
| 6864 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6865 | hdd_register_tx_flow_control(adapter, |
| 6866 | hdd_tx_resume_timer_expired_handler, |
| 6867 | hdd_tx_resume_cb); |
| 6868 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 6869 | EXIT(); |
| 6870 | return 0; |
| 6871 | } |
| 6872 | |
| 6873 | /** |
| 6874 | * hdd_start_ap_adapter()- Start AP Adapter |
| 6875 | * @adapter: HDD adapter |
| 6876 | * |
| 6877 | * This function initializes the adapter for the AP mode. |
| 6878 | * |
| 6879 | * Return: 0 on success errno on failure. |
| 6880 | */ |
| 6881 | int hdd_start_ap_adapter(hdd_adapter_t *adapter) |
| 6882 | { |
| 6883 | QDF_STATUS status; |
| 6884 | |
| 6885 | ENTER(); |
| 6886 | |
| 6887 | status = hdd_init_ap_mode(adapter); |
| 6888 | |
| 6889 | if (QDF_STATUS_SUCCESS != status) { |
| 6890 | hdd_err("Error Initializing the AP mode: %d", status); |
| 6891 | return qdf_status_to_os_return(status); |
| 6892 | } |
| 6893 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6894 | hdd_register_tx_flow_control(adapter, |
| 6895 | hdd_softap_tx_resume_timer_expired_handler, |
| 6896 | hdd_softap_tx_resume_cb); |
| 6897 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 6898 | EXIT(); |
| 6899 | return 0; |
| 6900 | } |
| 6901 | |
| 6902 | /** |
| 6903 | * hdd_start_ftm_adapter()- Start FTM adapter |
| 6904 | * @adapter: HDD adapter |
| 6905 | * |
| 6906 | * This function initializes the adapter for the FTM mode. |
| 6907 | * |
| 6908 | * Return: 0 on success or errno on failure. |
| 6909 | */ |
| 6910 | int hdd_start_ftm_adapter(hdd_adapter_t *adapter) |
| 6911 | { |
| 6912 | QDF_STATUS qdf_status; |
| 6913 | |
| 6914 | ENTER_DEV(adapter->dev); |
| 6915 | |
| 6916 | qdf_status = hdd_init_tx_rx(adapter); |
| 6917 | |
| 6918 | if (QDF_STATUS_SUCCESS != qdf_status) { |
| 6919 | hdd_err("Failed to start FTM adapter: %d", qdf_status); |
| 6920 | return qdf_status_to_os_return(qdf_status); |
| 6921 | } |
| 6922 | |
| 6923 | return 0; |
| 6924 | EXIT(); |
| 6925 | } |
| 6926 | |
| 6927 | /** |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6928 | * hdd_open_interfaces - Open all required interfaces |
| 6929 | * hdd_ctx: HDD context |
| 6930 | * rtnl_held: True if RTNL lock is held |
| 6931 | * |
| 6932 | * Open all the interfaces like STA, P2P and OCB based on the configuration. |
| 6933 | * |
| 6934 | * Return: Primary adapter on success and PTR_ERR on failure |
| 6935 | */ |
| 6936 | static hdd_adapter_t *hdd_open_interfaces(hdd_context_t *hdd_ctx, |
| 6937 | bool rtnl_held) |
| 6938 | { |
| 6939 | hdd_adapter_t *adapter = NULL; |
| 6940 | hdd_adapter_t *adapter_11p = NULL; |
| 6941 | int ret; |
| 6942 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6943 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_STANDALONE) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6944 | /* Create only 802.11p interface */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6945 | adapter = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, "wlanocb%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6946 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 6947 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6948 | |
| 6949 | if (adapter == NULL) |
| 6950 | return ERR_PTR(-ENOSPC); |
| 6951 | |
| 6952 | return adapter; |
| 6953 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6954 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, "wlan%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6955 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 6956 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6957 | |
| 6958 | if (adapter == NULL) |
| 6959 | return ERR_PTR(-ENOSPC); |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 6960 | /* fast roaming is allowed only on first STA, i.e. wlan adapter */ |
| 6961 | adapter->fast_roaming_allowed = true; |
| 6962 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6963 | ret = hdd_open_p2p_interface(hdd_ctx, rtnl_held); |
| 6964 | if (ret) |
| 6965 | goto err_close_adapter; |
| 6966 | |
| 6967 | /* Open 802.11p Interface */ |
| 6968 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_CONCURRENT) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6969 | adapter_11p = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6970 | "wlanocb%d", |
| 6971 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 6972 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6973 | if (adapter_11p == NULL) { |
| 6974 | hdd_err("Failed to open 802.11p interface"); |
| 6975 | goto err_close_adapter; |
| 6976 | } |
| 6977 | } |
| 6978 | |
| 6979 | return adapter; |
| 6980 | |
| 6981 | err_close_adapter: |
| 6982 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
| 6983 | return ERR_PTR(ret); |
| 6984 | } |
| 6985 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 6986 | /** |
| 6987 | * hdd_update_country_code - Update country code |
| 6988 | * @hdd_ctx: HDD context |
| 6989 | * @adapter: Primary adapter context |
| 6990 | * |
| 6991 | * Update country code based on module parameter country_code at SME and wait |
| 6992 | * for the settings to take effect. |
| 6993 | * |
| 6994 | * Return: 0 on success and errno on failure |
| 6995 | */ |
| 6996 | static int hdd_update_country_code(hdd_context_t *hdd_ctx, |
| 6997 | hdd_adapter_t *adapter) |
| 6998 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6999 | QDF_STATUS status; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7000 | int ret = 0; |
| 7001 | unsigned long rc; |
| 7002 | |
| 7003 | if (country_code == NULL) |
| 7004 | return 0; |
| 7005 | |
| 7006 | INIT_COMPLETION(adapter->change_country_code); |
| 7007 | |
| 7008 | status = sme_change_country_code(hdd_ctx->hHal, |
| 7009 | wlan_hdd_change_country_code_callback, |
| 7010 | country_code, adapter, |
| 7011 | hdd_ctx->pcds_context, eSIR_TRUE, |
| 7012 | eSIR_TRUE); |
| 7013 | |
| 7014 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7015 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7016 | hdd_err("SME Change Country code from module param fail ret=%d", |
| 7017 | ret); |
| 7018 | return -EINVAL; |
| 7019 | } |
| 7020 | |
| 7021 | rc = wait_for_completion_timeout(&adapter->change_country_code, |
| 7022 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 7023 | if (!rc) { |
| 7024 | hdd_err("SME while setting country code timed out"); |
| 7025 | ret = -ETIMEDOUT; |
| 7026 | } |
| 7027 | |
| 7028 | return ret; |
| 7029 | } |
| 7030 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7031 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 7032 | /** |
| 7033 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 7034 | * @cds_cfg: CDS Configuration |
| 7035 | * @hdd_ctx: Pointer to hdd context |
| 7036 | * |
| 7037 | * Return: none |
| 7038 | */ |
| 7039 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 7040 | *cds_cfg, |
| 7041 | hdd_context_t *hdd_ctx) |
| 7042 | { |
| 7043 | cds_cfg->tx_flow_stop_queue_th = |
| 7044 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 7045 | cds_cfg->tx_flow_start_queue_offset = |
| 7046 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 7047 | } |
| 7048 | #else |
| 7049 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 7050 | *cds_cfg, |
| 7051 | hdd_context_t *hdd_ctx) |
| 7052 | { |
| 7053 | } |
| 7054 | #endif |
| 7055 | |
| 7056 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 7057 | /** |
| 7058 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 7059 | * @cds_cfg: CDS Configuration |
| 7060 | * @hdd_ctx: Pointer to hdd context |
| 7061 | * |
| 7062 | * Return: none |
| 7063 | */ |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 7064 | 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] | 7065 | hdd_context_t *hdd_ctx) |
| 7066 | { |
| 7067 | cds_cfg->ra_ratelimit_interval = |
| 7068 | hdd_ctx->config->RArateLimitInterval; |
| 7069 | cds_cfg->is_ra_ratelimit_enabled = |
| 7070 | hdd_ctx->config->IsRArateLimitEnabled; |
| 7071 | } |
| 7072 | #else |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 7073 | 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] | 7074 | hdd_context_t *hdd_ctx) |
| 7075 | { |
| 7076 | } |
| 7077 | #endif |
| 7078 | |
| 7079 | /** |
| 7080 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 7081 | * @hdd_ctx: HDD Context |
| 7082 | * |
| 7083 | * Return: 0 for Success, errno on failure |
| 7084 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 7085 | static int hdd_update_cds_config(hdd_context_t *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7086 | { |
| 7087 | struct cds_config_info *cds_cfg; |
| 7088 | |
| 7089 | cds_cfg = (struct cds_config_info *)qdf_mem_malloc(sizeof(*cds_cfg)); |
| 7090 | if (!cds_cfg) { |
| 7091 | hdd_err("failed to allocate cds config"); |
| 7092 | return -ENOMEM; |
| 7093 | } |
| 7094 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7095 | cds_cfg->driver_type = DRIVER_TYPE_PRODUCTION; |
| 7096 | cds_cfg->powersave_offload_enabled = |
| 7097 | hdd_ctx->config->enablePowersaveOffload; |
| 7098 | cds_cfg->sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 7099 | cds_cfg->sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 7100 | cds_cfg->sta_maxlimod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 7101 | cds_cfg->wow_enable = hdd_ctx->config->wowEnable; |
| 7102 | cds_cfg->max_wow_filters = hdd_ctx->config->maxWoWFilters; |
| 7103 | |
| 7104 | /* Here ol_ini_info is used to store ini status of arp offload |
| 7105 | * ns offload and others. Currently 1st bit is used for arp |
| 7106 | * off load and 2nd bit for ns offload currently, rest bits are unused |
| 7107 | */ |
| 7108 | if (hdd_ctx->config->fhostArpOffload) |
| 7109 | cds_cfg->ol_ini_info = cds_cfg->ol_ini_info | 0x1; |
| 7110 | if (hdd_ctx->config->fhostNSOffload) |
| 7111 | cds_cfg->ol_ini_info = cds_cfg->ol_ini_info | 0x2; |
| 7112 | |
| 7113 | /* |
| 7114 | * Copy the DFS Phyerr Filtering Offload status. |
| 7115 | * This parameter reflects the value of the |
| 7116 | * dfs_phyerr_filter_offload flag as set in the ini. |
| 7117 | */ |
| 7118 | cds_cfg->dfs_phyerr_filter_offload = |
| 7119 | hdd_ctx->config->fDfsPhyerrFilterOffload; |
| 7120 | if (hdd_ctx->config->ssdp) |
| 7121 | cds_cfg->ssdp = hdd_ctx->config->ssdp; |
| 7122 | |
| 7123 | cds_cfg->enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 7124 | cds_cfg->ap_maxoffload_peers = hdd_ctx->config->apMaxOffloadPeers; |
| 7125 | |
| 7126 | cds_cfg->ap_maxoffload_reorderbuffs = |
| 7127 | hdd_ctx->config->apMaxOffloadReorderBuffs; |
| 7128 | |
| 7129 | cds_cfg->ap_disable_intrabss_fwd = |
| 7130 | hdd_ctx->config->apDisableIntraBssFwd; |
| 7131 | |
| 7132 | cds_cfg->dfs_pri_multiplier = |
| 7133 | hdd_ctx->config->dfsRadarPriMultiplier; |
| 7134 | cds_cfg->reorder_offload = |
| 7135 | hdd_ctx->config->reorderOffloadSupport; |
| 7136 | |
| 7137 | /* IPA micro controller data path offload resource config item */ |
| 7138 | cds_cfg->uc_offload_enabled = hdd_ipa_uc_is_enabled(hdd_ctx); |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 7139 | if (!is_power_of_2(hdd_ctx->config->IpaUcTxBufCount)) { |
| 7140 | /* IpaUcTxBufCount should be power of 2 */ |
| 7141 | hdd_err("Round down IpaUcTxBufCount %d to nearest power of 2", |
| 7142 | hdd_ctx->config->IpaUcTxBufCount); |
| 7143 | hdd_ctx->config->IpaUcTxBufCount = |
| 7144 | rounddown_pow_of_two( |
| 7145 | hdd_ctx->config->IpaUcTxBufCount); |
| 7146 | if (!hdd_ctx->config->IpaUcTxBufCount) { |
| 7147 | hdd_err("Failed to round down IpaUcTxBufCount"); |
| 7148 | return -EINVAL; |
| 7149 | } |
| 7150 | hdd_err("IpaUcTxBufCount rounded down to %d", |
| 7151 | hdd_ctx->config->IpaUcTxBufCount); |
| 7152 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7153 | cds_cfg->uc_txbuf_count = hdd_ctx->config->IpaUcTxBufCount; |
| 7154 | cds_cfg->uc_txbuf_size = hdd_ctx->config->IpaUcTxBufSize; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 7155 | if (!is_power_of_2(hdd_ctx->config->IpaUcRxIndRingCount)) { |
| 7156 | /* IpaUcRxIndRingCount should be power of 2 */ |
| 7157 | hdd_err("Round down IpaUcRxIndRingCount %d to nearest power of 2", |
| 7158 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 7159 | hdd_ctx->config->IpaUcRxIndRingCount = |
| 7160 | rounddown_pow_of_two( |
| 7161 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 7162 | if (!hdd_ctx->config->IpaUcRxIndRingCount) { |
| 7163 | hdd_err("Failed to round down IpaUcRxIndRingCount"); |
| 7164 | return -EINVAL; |
| 7165 | } |
| 7166 | hdd_err("IpaUcRxIndRingCount rounded down to %d", |
| 7167 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 7168 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7169 | cds_cfg->uc_rxind_ringcount = |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 7170 | hdd_ctx->config->IpaUcRxIndRingCount; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7171 | cds_cfg->uc_tx_partition_base = |
| 7172 | hdd_ctx->config->IpaUcTxPartitionBase; |
| 7173 | cds_cfg->max_scan = hdd_ctx->config->max_scan_count; |
| 7174 | |
| 7175 | cds_cfg->ip_tcp_udp_checksum_offload = |
| 7176 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 7177 | cds_cfg->enable_rxthread = hdd_ctx->enableRxThread; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7178 | cds_cfg->ce_classify_enabled = |
| 7179 | hdd_ctx->config->ce_classify_enabled; |
Dustin Brown | d3fc9ee | 2016-09-14 13:57:27 -0700 | [diff] [blame] | 7180 | cds_cfg->bpf_packet_filter_enable = |
| 7181 | hdd_ctx->config->bpf_packet_filter_enable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7182 | cds_cfg->tx_chain_mask_cck = hdd_ctx->config->tx_chain_mask_cck; |
| 7183 | cds_cfg->self_gen_frm_pwr = hdd_ctx->config->self_gen_frm_pwr; |
| 7184 | cds_cfg->max_station = hdd_ctx->config->maxNumberOfPeers; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 7185 | cds_cfg->sub_20_channel_width = WLAN_SUB_20_CH_WIDTH_NONE; |
Manjunathappa Prakash | fff753c | 2016-09-01 19:34:56 -0700 | [diff] [blame] | 7186 | cds_cfg->flow_steering_enabled = hdd_ctx->config->flow_steering_enable; |
Naveen Rawat | 91df30a | 2016-10-12 21:26:18 -0700 | [diff] [blame] | 7187 | cds_cfg->self_recovery_enabled = hdd_ctx->config->enableSelfRecovery; |
Sandeep Puligilla | afa5289 | 2016-10-26 19:03:16 -0700 | [diff] [blame] | 7188 | cds_cfg->fw_timeout_crash = hdd_ctx->config->fw_timeout_crash; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7189 | |
| 7190 | hdd_ra_populate_cds_config(cds_cfg, hdd_ctx); |
| 7191 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
| 7192 | hdd_nan_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 7193 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7194 | cds_init_ini_config(cds_cfg); |
| 7195 | return 0; |
| 7196 | } |
| 7197 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7198 | /** |
| 7199 | * hdd_init_thermal_info - Initialize thermal level |
| 7200 | * @hdd_ctx: HDD context |
| 7201 | * |
| 7202 | * Initialize thermal level at SME layer and set the thermal level callback |
| 7203 | * which would be called when a configured thermal threshold is hit. |
| 7204 | * |
| 7205 | * Return: 0 on success and errno on failure |
| 7206 | */ |
| 7207 | static int hdd_init_thermal_info(hdd_context_t *hdd_ctx) |
| 7208 | { |
| 7209 | tSmeThermalParams thermal_param; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7210 | QDF_STATUS status; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7211 | |
| 7212 | thermal_param.smeThermalMgmtEnabled = |
| 7213 | hdd_ctx->config->thermalMitigationEnable; |
| 7214 | thermal_param.smeThrottlePeriod = hdd_ctx->config->throttlePeriod; |
| 7215 | |
Poddar, Siddarth | 8390502 | 2016-04-16 17:56:08 -0700 | [diff] [blame] | 7216 | thermal_param.sme_throttle_duty_cycle_tbl[0] = |
| 7217 | hdd_ctx->config->throttle_dutycycle_level0; |
| 7218 | thermal_param.sme_throttle_duty_cycle_tbl[1] = |
| 7219 | hdd_ctx->config->throttle_dutycycle_level1; |
| 7220 | thermal_param.sme_throttle_duty_cycle_tbl[2] = |
| 7221 | hdd_ctx->config->throttle_dutycycle_level2; |
| 7222 | thermal_param.sme_throttle_duty_cycle_tbl[3] = |
| 7223 | hdd_ctx->config->throttle_dutycycle_level3; |
| 7224 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7225 | thermal_param.smeThermalLevels[0].smeMinTempThreshold = |
| 7226 | hdd_ctx->config->thermalTempMinLevel0; |
| 7227 | thermal_param.smeThermalLevels[0].smeMaxTempThreshold = |
| 7228 | hdd_ctx->config->thermalTempMaxLevel0; |
| 7229 | thermal_param.smeThermalLevels[1].smeMinTempThreshold = |
| 7230 | hdd_ctx->config->thermalTempMinLevel1; |
| 7231 | thermal_param.smeThermalLevels[1].smeMaxTempThreshold = |
| 7232 | hdd_ctx->config->thermalTempMaxLevel1; |
| 7233 | thermal_param.smeThermalLevels[2].smeMinTempThreshold = |
| 7234 | hdd_ctx->config->thermalTempMinLevel2; |
| 7235 | thermal_param.smeThermalLevels[2].smeMaxTempThreshold = |
| 7236 | hdd_ctx->config->thermalTempMaxLevel2; |
| 7237 | thermal_param.smeThermalLevels[3].smeMinTempThreshold = |
| 7238 | hdd_ctx->config->thermalTempMinLevel3; |
| 7239 | thermal_param.smeThermalLevels[3].smeMaxTempThreshold = |
| 7240 | hdd_ctx->config->thermalTempMaxLevel3; |
| 7241 | |
| 7242 | status = sme_init_thermal_info(hdd_ctx->hHal, thermal_param); |
| 7243 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7244 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 7245 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7246 | |
| 7247 | sme_add_set_thermal_level_callback(hdd_ctx->hHal, |
| 7248 | hdd_set_thermal_level_cb); |
| 7249 | |
| 7250 | return 0; |
| 7251 | |
| 7252 | } |
| 7253 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7254 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 7255 | /** |
| 7256 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 7257 | * |
| 7258 | * Hold RTNL lock |
| 7259 | * |
| 7260 | * Return: True if held and false otherwise |
| 7261 | */ |
| 7262 | static inline bool hdd_hold_rtnl_lock(void) |
| 7263 | { |
| 7264 | rtnl_lock(); |
| 7265 | return true; |
| 7266 | } |
| 7267 | |
| 7268 | /** |
| 7269 | * hdd_release_rtnl_lock - Release RTNL lock |
| 7270 | * |
| 7271 | * Release RTNL lock |
| 7272 | * |
| 7273 | * Return: None |
| 7274 | */ |
| 7275 | static inline void hdd_release_rtnl_lock(void) |
| 7276 | { |
| 7277 | rtnl_unlock(); |
| 7278 | } |
| 7279 | #else |
| 7280 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 7281 | static inline void hdd_release_rtnl_lock(void) { } |
| 7282 | #endif |
| 7283 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 7284 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7285 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7286 | /* MAX iwpriv command support */ |
| 7287 | #define PKTLOG_SET_BUFF_SIZE 3 |
| 7288 | #define MAX_PKTLOG_SIZE 16 |
| 7289 | |
| 7290 | /** |
| 7291 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 7292 | * @hdd_ctx: hdd context |
| 7293 | * @set_value2: pktlog buffer size value |
| 7294 | * |
| 7295 | * |
| 7296 | * Return: 0 for success or error. |
| 7297 | */ |
| 7298 | static int hdd_pktlog_set_buff_size(hdd_context_t *hdd_ctx, int set_value2) |
| 7299 | { |
| 7300 | struct sir_wifi_start_log start_log = { 0 }; |
| 7301 | QDF_STATUS status; |
| 7302 | |
| 7303 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 7304 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 7305 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 7306 | start_log.user_triggered = 1; |
| 7307 | start_log.size = set_value2; |
| 7308 | |
| 7309 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 7310 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 7311 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 7312 | EXIT(); |
| 7313 | return -EINVAL; |
| 7314 | } |
| 7315 | |
| 7316 | return 0; |
| 7317 | } |
| 7318 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7319 | /** |
| 7320 | * hdd_process_pktlog_command() - process pktlog command |
| 7321 | * @hdd_ctx: hdd context |
| 7322 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7323 | * @set_value2: pktlog buffer size value |
| 7324 | * |
| 7325 | * This function process pktlog command. |
| 7326 | * set_value2 only matters when set_value is 3 (set buff size) |
| 7327 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7328 | * |
| 7329 | * Return: 0 for success or error. |
| 7330 | */ |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7331 | int hdd_process_pktlog_command(hdd_context_t *hdd_ctx, uint32_t set_value, |
| 7332 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7333 | { |
| 7334 | int ret; |
| 7335 | bool enable; |
| 7336 | uint8_t user_triggered = 0; |
| 7337 | |
| 7338 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 7339 | if (0 != ret) |
| 7340 | return ret; |
| 7341 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7342 | hdd_info("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7343 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7344 | if (set_value > PKTLOG_SET_BUFF_SIZE) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7345 | hdd_err("invalid pktlog value %d", set_value); |
| 7346 | return -EINVAL; |
| 7347 | } |
| 7348 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7349 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 7350 | if (set_value2 <= 0) { |
| 7351 | hdd_err("invalid pktlog size %d", set_value2); |
| 7352 | return -EINVAL; |
| 7353 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
| 7354 | hdd_err("Pktlog buff size is too large. max value is 16MB.\n"); |
| 7355 | return -EINVAL; |
| 7356 | } |
| 7357 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
| 7358 | } |
| 7359 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7360 | /* |
| 7361 | * set_value = 0 then disable packetlog |
| 7362 | * set_value = 1 enable packetlog forcefully |
| 7363 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 7364 | * enable packetlog with AUTO type. |
| 7365 | */ |
| 7366 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 7367 | true : false; |
| 7368 | |
| 7369 | if (1 == set_value) { |
| 7370 | enable = true; |
| 7371 | user_triggered = 1; |
| 7372 | } |
| 7373 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7374 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7375 | } |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 7376 | /** |
| 7377 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 7378 | * @hdd_ctx: HDD context |
| 7379 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7380 | * @user_triggered: triggered through iwpriv |
| 7381 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 7382 | * |
| 7383 | * Return: 0 on success; error number otherwise |
| 7384 | */ |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7385 | int hdd_pktlog_enable_disable(hdd_context_t *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7386 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 7387 | { |
| 7388 | struct sir_wifi_start_log start_log; |
| 7389 | QDF_STATUS status; |
| 7390 | |
| 7391 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 7392 | start_log.verbose_level = |
| 7393 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7394 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 7395 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7396 | start_log.size = size; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 7397 | /* |
| 7398 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 7399 | * commands. Host uses this flag to decide whether to send pktlog |
| 7400 | * disable command to fw without sending pktlog enable command |
| 7401 | * previously. For eg, If vendor sends pktlog disable command without |
| 7402 | * sending pktlog enable command, then host discards the packet |
| 7403 | * but for iwpriv command, host will send it to fw. |
| 7404 | */ |
| 7405 | start_log.is_iwpriv_command = 1; |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 7406 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 7407 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 7408 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 7409 | EXIT(); |
| 7410 | return -EINVAL; |
| 7411 | } |
| 7412 | |
| 7413 | return 0; |
| 7414 | } |
| 7415 | #endif /* REMOVE_PKT_LOG */ |
| 7416 | |
| 7417 | |
Chandrasekaran Manishekar | cde33d7 | 2016-04-14 19:03:39 +0530 | [diff] [blame] | 7418 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 7419 | /** |
| 7420 | * hdd_register_for_sap_restart_with_channel_switch() - Register for SAP channel |
| 7421 | * switch without restart |
| 7422 | * |
| 7423 | * Registers callback function to change the operating channel of SAP by using |
| 7424 | * channel switch announcements instead of restarting SAP. |
| 7425 | * |
| 7426 | * Return: QDF_STATUS |
| 7427 | */ |
| 7428 | QDF_STATUS hdd_register_for_sap_restart_with_channel_switch(void) |
| 7429 | { |
| 7430 | QDF_STATUS status; |
| 7431 | |
| 7432 | status = cds_register_sap_restart_channel_switch_cb( |
| 7433 | (void *)hdd_sap_restart_with_channel_switch); |
| 7434 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 7435 | hdd_err("restart cb registration failed"); |
| 7436 | |
| 7437 | return status; |
| 7438 | } |
| 7439 | #endif |
| 7440 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7441 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7442 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 7443 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7444 | * @dev: Device Pointer |
| 7445 | * @num: Number of Valid Mac address |
| 7446 | * |
| 7447 | * Return: Pointer to MAC address buffer |
| 7448 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7449 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 7450 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7451 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7452 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7453 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7454 | |
| 7455 | /** |
| 7456 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 7457 | * @hdd_ctx: HDD Context |
| 7458 | * @num: Number of random mac addresses needed |
| 7459 | * |
| 7460 | * Generate random addresses using bit manipulation on the base mac address |
| 7461 | * |
| 7462 | * Return: None |
| 7463 | */ |
| 7464 | static void hdd_populate_random_mac_addr(hdd_context_t *hdd_ctx, uint32_t num) |
| 7465 | { |
| 7466 | uint32_t start_idx = QDF_MAX_CONCURRENCY_PERSONA - num; |
| 7467 | uint32_t iter; |
| 7468 | struct hdd_config *ini = hdd_ctx->config; |
| 7469 | uint8_t *buf = NULL; |
| 7470 | uint8_t macaddr_b3, tmp_br3; |
| 7471 | uint8_t *src = ini->intfMacAddr[0].bytes; |
| 7472 | |
| 7473 | for (iter = start_idx; iter < QDF_MAX_CONCURRENCY_PERSONA; ++iter) { |
| 7474 | buf = ini->intfMacAddr[iter].bytes; |
| 7475 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 7476 | macaddr_b3 = buf[3]; |
| 7477 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + iter) & |
| 7478 | INTF_MACADDR_MASK; |
| 7479 | macaddr_b3 += tmp_br3; |
| 7480 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 7481 | buf[0] |= 0x02; |
| 7482 | buf[3] = macaddr_b3; |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 7483 | hdd_info(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7484 | } |
| 7485 | } |
| 7486 | |
| 7487 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7488 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7489 | * @hdd_ctx: HDD Context |
| 7490 | * |
| 7491 | * API to get mac addresses from platform driver and update the driver |
| 7492 | * structures and configure FW with the base mac address. |
| 7493 | * Return: int |
| 7494 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7495 | static int hdd_platform_wlan_mac(hdd_context_t *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7496 | { |
| 7497 | uint32_t no_of_mac_addr, iter; |
| 7498 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 7499 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 7500 | uint8_t *addr, *buf; |
| 7501 | struct device *dev = hdd_ctx->parent_dev; |
| 7502 | struct hdd_config *ini = hdd_ctx->config; |
| 7503 | tSirMacAddr mac_addr; |
| 7504 | QDF_STATUS status; |
| 7505 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7506 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7507 | |
| 7508 | if (no_of_mac_addr == 0 || !addr) { |
| 7509 | hdd_warn("Platform Driver Doesn't have wlan mac addresses"); |
| 7510 | return -EINVAL; |
| 7511 | } |
| 7512 | |
| 7513 | if (no_of_mac_addr > max_mac_addr) |
| 7514 | no_of_mac_addr = max_mac_addr; |
| 7515 | |
| 7516 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 7517 | |
| 7518 | for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { |
| 7519 | buf = ini->intfMacAddr[iter].bytes; |
| 7520 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 7521 | hdd_info(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7522 | } |
| 7523 | |
| 7524 | status = sme_set_custom_mac_addr(mac_addr); |
| 7525 | |
| 7526 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 7527 | return -EAGAIN; |
| 7528 | if (no_of_mac_addr < max_mac_addr) |
| 7529 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 7530 | no_of_mac_addr); |
| 7531 | return 0; |
| 7532 | } |
| 7533 | |
| 7534 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 7535 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 7536 | * @hdd_ctx: HDD Context |
| 7537 | * |
| 7538 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 7539 | * will generate its own MAC and update it to FW. |
| 7540 | * |
| 7541 | * Return: 0 for success |
| 7542 | * Non-zero error code for failure |
| 7543 | */ |
| 7544 | static int hdd_update_mac_addr_to_fw(hdd_context_t *hdd_ctx) |
| 7545 | { |
| 7546 | tSirMacAddr customMacAddr; |
| 7547 | QDF_STATUS status; |
| 7548 | |
| 7549 | qdf_mem_copy(&customMacAddr, |
| 7550 | &hdd_ctx->config->intfMacAddr[0].bytes[0], |
| 7551 | sizeof(tSirMacAddr)); |
| 7552 | status = sme_set_custom_mac_addr(customMacAddr); |
| 7553 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 7554 | return -EAGAIN; |
| 7555 | return 0; |
| 7556 | } |
| 7557 | |
| 7558 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7559 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 7560 | * @hdd_ctx: HDD Context |
| 7561 | * |
| 7562 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 7563 | * is provisioned with mac addresses, driver uses it, else it will use |
| 7564 | * wlan_mac.bin to update HW MAC addresses. |
| 7565 | * |
| 7566 | * Return: None |
| 7567 | */ |
| 7568 | static void hdd_initialize_mac_address(hdd_context_t *hdd_ctx) |
| 7569 | { |
| 7570 | QDF_STATUS status; |
| 7571 | int ret; |
| 7572 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7573 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7574 | if (ret == 0) |
| 7575 | return; |
| 7576 | |
| 7577 | hdd_warn("Can't update mac config via platform driver ret:%d", ret); |
| 7578 | |
| 7579 | status = hdd_update_mac_config(hdd_ctx); |
| 7580 | |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 7581 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 7582 | return; |
| 7583 | |
| 7584 | hdd_warn("can't update mac config via wlan_mac.bin, using MAC from ini file or auto-gen"); |
| 7585 | |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 7586 | if (hdd_ctx->update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 7587 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 7588 | if (ret != 0) { |
| 7589 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
| 7590 | QDF_ASSERT(ret); |
| 7591 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 7592 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7593 | } |
| 7594 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7595 | /** |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 7596 | * hdd_tsf_init() - Initialize the TSF synchronization interface |
| 7597 | * @hdd_ctx: HDD global context |
| 7598 | * |
| 7599 | * When TSF synchronization via GPIO is supported by the driver and |
| 7600 | * has been enabled in the configuration file, this function plumbs |
| 7601 | * the GPIO value down to firmware via SME. |
| 7602 | * |
| 7603 | * Return: None |
| 7604 | */ |
| 7605 | #ifdef WLAN_FEATURE_TSF |
| 7606 | static void hdd_tsf_init(hdd_context_t *hdd_ctx) |
| 7607 | { |
| 7608 | QDF_STATUS status; |
| 7609 | |
| 7610 | if (hdd_ctx->config->tsf_gpio_pin == TSF_GPIO_PIN_INVALID) |
| 7611 | return; |
| 7612 | |
| 7613 | status = sme_set_tsf_gpio(hdd_ctx->hHal, |
| 7614 | hdd_ctx->config->tsf_gpio_pin); |
| 7615 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 7616 | hdd_err("Set tsf GPIO failed, status: %d", status); |
| 7617 | } |
| 7618 | #else |
| 7619 | static void hdd_tsf_init(hdd_context_t *hdd_ctx) |
| 7620 | { |
| 7621 | } |
| 7622 | #endif |
| 7623 | |
| 7624 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 7625 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 7626 | * @hdd_ctx: HDD context |
| 7627 | * |
| 7628 | * Pre configurations to be done at lower layer before calling cds enable. |
| 7629 | * |
| 7630 | * Return: 0 on success and errno on failure. |
| 7631 | */ |
| 7632 | static int hdd_pre_enable_configure(hdd_context_t *hdd_ctx) |
| 7633 | { |
| 7634 | int ret; |
| 7635 | QDF_STATUS status; |
| 7636 | tSirRetStatus hal_status; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 7637 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 7638 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 7639 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 7640 | /* |
| 7641 | * Set 802.11p config |
| 7642 | * TODO-OCB: This has been temporarily added here to ensure this |
| 7643 | * parameter is set in CSR when we init the channel list. This should |
| 7644 | * be removed once the 5.9 GHz channels are added to the regulatory |
| 7645 | * domain. |
| 7646 | */ |
| 7647 | hdd_set_dot11p_config(hdd_ctx); |
| 7648 | |
| 7649 | /* |
| 7650 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 7651 | * The cfg download must occur before we update the SME config |
| 7652 | * since the SME config operation must access the cfg database |
| 7653 | */ |
| 7654 | status = hdd_set_sme_config(hdd_ctx); |
| 7655 | |
| 7656 | if (QDF_STATUS_SUCCESS != status) { |
| 7657 | hdd_alert("Failed hdd_set_sme_config: %d", status); |
| 7658 | ret = qdf_status_to_os_return(status); |
| 7659 | goto out; |
| 7660 | } |
| 7661 | |
| 7662 | ret = wma_cli_set_command(0, WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS, |
| 7663 | hdd_ctx->config->tx_chain_mask_1ss, |
| 7664 | PDEV_CMD); |
| 7665 | if (0 != ret) { |
| 7666 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 7667 | goto out; |
| 7668 | } |
| 7669 | |
| 7670 | hdd_program_country_code(hdd_ctx); |
| 7671 | |
| 7672 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 7673 | if (status != QDF_STATUS_SUCCESS) { |
| 7674 | hdd_alert("Failed to init channel list: %d", status); |
| 7675 | ret = qdf_status_to_os_return(status); |
| 7676 | goto out; |
| 7677 | } |
| 7678 | |
| 7679 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 7680 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 7681 | hdd_alert("config update failed"); |
| 7682 | ret = -EINVAL; |
| 7683 | goto out; |
| 7684 | } |
| 7685 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 7686 | /* |
| 7687 | * Set the MAC Address Currently this is used by HAL to add self sta. |
| 7688 | * Remove this once self sta is added as part of session open. |
| 7689 | */ |
| 7690 | hal_status = cfg_set_str(hdd_ctx->hHal, WNI_CFG_STA_ID, |
| 7691 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 7692 | sizeof(hdd_ctx->config->intfMacAddr[0])); |
| 7693 | |
| 7694 | if (!IS_SIR_STATUS_SUCCESS(hal_status)) { |
| 7695 | hdd_err("Failed to set MAC Address. HALStatus is %08d [x%08x]", |
| 7696 | hal_status, hal_status); |
| 7697 | ret = -EINVAL; |
| 7698 | goto out; |
| 7699 | } |
| 7700 | |
| 7701 | hdd_init_channel_avoidance(hdd_ctx); |
| 7702 | |
| 7703 | out: |
| 7704 | return ret; |
| 7705 | } |
| 7706 | |
| 7707 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 7708 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
| 7709 | * @context_ptr - hdd context pointer |
| 7710 | * @event_ptr - event structure pointer |
| 7711 | * |
| 7712 | * This is the p2p listen offload stop event handler, it sends vendor |
| 7713 | * event back to supplicant to notify the stop reason. |
| 7714 | * |
| 7715 | * Return: None |
| 7716 | */ |
| 7717 | static void wlan_hdd_p2p_lo_event_callback(void *context_ptr, |
| 7718 | void *event_ptr) |
| 7719 | { |
| 7720 | hdd_context_t *hdd_ctx = (hdd_context_t *)context_ptr; |
| 7721 | struct sir_p2p_lo_event *evt = event_ptr; |
| 7722 | struct sk_buff *vendor_event; |
| 7723 | |
| 7724 | ENTER(); |
| 7725 | |
| 7726 | if (hdd_ctx == NULL) { |
| 7727 | hdd_err("Invalid HDD context pointer"); |
| 7728 | return; |
| 7729 | } |
| 7730 | |
| 7731 | vendor_event = |
| 7732 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
| 7733 | NULL, sizeof(uint32_t) + NLMSG_HDRLEN, |
| 7734 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 7735 | GFP_KERNEL); |
| 7736 | |
| 7737 | if (!vendor_event) { |
| 7738 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 7739 | return; |
| 7740 | } |
| 7741 | |
| 7742 | if (nla_put_u32(vendor_event, |
| 7743 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 7744 | evt->reason_code)) { |
| 7745 | hdd_err("nla put failed"); |
| 7746 | kfree_skb(vendor_event); |
| 7747 | return; |
| 7748 | } |
| 7749 | |
| 7750 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 7751 | } |
| 7752 | |
| 7753 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 7754 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 7755 | * @hdd_ctx: HDD context |
| 7756 | * |
| 7757 | * This function sends the adaptive dwell time config configuration to the |
| 7758 | * firmware via WMA |
| 7759 | * |
| 7760 | * Return: 0 - success, < 0 - failure |
| 7761 | */ |
| 7762 | static int hdd_adaptive_dwelltime_init(hdd_context_t *hdd_ctx) |
| 7763 | { |
| 7764 | QDF_STATUS status; |
| 7765 | struct adaptive_dwelltime_params dwelltime_params; |
| 7766 | |
| 7767 | dwelltime_params.is_enabled = |
| 7768 | hdd_ctx->config->adaptive_dwell_mode_enabled; |
| 7769 | dwelltime_params.dwelltime_mode = |
| 7770 | hdd_ctx->config->global_adapt_dwelltime_mode; |
| 7771 | dwelltime_params.lpf_weight = |
| 7772 | hdd_ctx->config->adapt_dwell_lpf_weight; |
| 7773 | dwelltime_params.passive_mon_intval = |
| 7774 | hdd_ctx->config->adapt_dwell_passive_mon_intval; |
| 7775 | dwelltime_params.wifi_act_threshold = |
| 7776 | hdd_ctx->config->adapt_dwell_wifi_act_threshold; |
| 7777 | |
| 7778 | status = sme_set_adaptive_dwelltime_config(hdd_ctx->hHal, |
| 7779 | &dwelltime_params); |
| 7780 | |
| 7781 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 7782 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 7783 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 7784 | return -EAGAIN; |
| 7785 | } |
| 7786 | return 0; |
| 7787 | } |
| 7788 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 7789 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 7790 | /** |
| 7791 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 7792 | * @hdd_ctx: HDD context |
| 7793 | * |
| 7794 | * Set auto shutdown callback to get indications from firmware to indicate |
| 7795 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 7796 | * |
| 7797 | * Return: 0 on success and errno on failure. |
| 7798 | */ |
| 7799 | static int hdd_set_auto_shutdown_cb(hdd_context_t *hdd_ctx) |
| 7800 | { |
| 7801 | QDF_STATUS status; |
| 7802 | |
| 7803 | if (!hdd_ctx->config->WlanAutoShutdown) |
| 7804 | return 0; |
| 7805 | |
| 7806 | status = sme_set_auto_shutdown_cb(hdd_ctx->hHal, |
| 7807 | wlan_hdd_auto_shutdown_cb); |
| 7808 | if (status != QDF_STATUS_SUCCESS) |
| 7809 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 7810 | status); |
| 7811 | |
| 7812 | return qdf_status_to_os_return(status); |
| 7813 | } |
| 7814 | #else |
| 7815 | static int hdd_set_auto_shutdown_cb(hdd_context_t *hdd_ctx) |
| 7816 | { |
| 7817 | return 0; |
| 7818 | } |
| 7819 | #endif |
| 7820 | |
| 7821 | /** |
| 7822 | * hdd_features_init() - Init features |
| 7823 | * @hdd_ctx: HDD context |
| 7824 | * @adapter: Primary adapter context |
| 7825 | * |
| 7826 | * Initialize features and their feature context after WLAN firmware is up. |
| 7827 | * |
| 7828 | * Return: 0 on success and errno on failure. |
| 7829 | */ |
| 7830 | static int hdd_features_init(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter) |
| 7831 | { |
| 7832 | tSirTxPowerLimit hddtxlimit; |
| 7833 | QDF_STATUS status; |
| 7834 | int ret; |
| 7835 | |
| 7836 | ENTER(); |
| 7837 | |
| 7838 | ret = hdd_update_country_code(hdd_ctx, adapter); |
| 7839 | if (ret) { |
| 7840 | hdd_err("Failed to update country code: %d", ret); |
| 7841 | goto out; |
| 7842 | } |
| 7843 | |
| 7844 | /* FW capabilities received, Set the Dot11 mode */ |
| 7845 | sme_setdef_dot11mode(hdd_ctx->hHal); |
Kiran Kumar Lokere | 1aa9c9a | 2016-10-05 18:50:59 -0700 | [diff] [blame] | 7846 | sme_set_prefer_80MHz_over_160MHz(hdd_ctx->hHal, |
| 7847 | hdd_ctx->config->sta_prefer_80MHz_over_160MHz); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 7848 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 7849 | |
| 7850 | if (hdd_ctx->config->fIsImpsEnabled) |
| 7851 | hdd_set_idle_ps_config(hdd_ctx, true); |
| 7852 | else |
| 7853 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 7854 | |
| 7855 | if (hdd_lro_init(hdd_ctx)) |
| 7856 | hdd_err("Unable to initialize LRO in fw"); |
| 7857 | |
| 7858 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 7859 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 7860 | |
| 7861 | ret = hdd_init_thermal_info(hdd_ctx); |
| 7862 | if (ret) { |
| 7863 | hdd_err("Error while initializing thermal information"); |
| 7864 | goto deregister_frames; |
| 7865 | } |
| 7866 | |
| 7867 | hddtxlimit.txPower2g = hdd_ctx->config->TxPower2g; |
| 7868 | hddtxlimit.txPower5g = hdd_ctx->config->TxPower5g; |
| 7869 | status = sme_txpower_limit(hdd_ctx->hHal, &hddtxlimit); |
| 7870 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 7871 | hdd_err("Error setting txlimit in sme: %d", status); |
| 7872 | |
| 7873 | hdd_tsf_init(hdd_ctx); |
Padma, Santhosh Kumar | 1472fab | 2016-10-07 13:29:27 +0530 | [diff] [blame] | 7874 | hdd_encrypt_decrypt_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 7875 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 7876 | ret = hdd_register_cb(hdd_ctx); |
| 7877 | if (ret) { |
| 7878 | hdd_err("Failed to register HDD callbacks!"); |
| 7879 | goto deregister_frames; |
| 7880 | } |
| 7881 | |
| 7882 | if (hdd_ctx->config->dual_mac_feature_disable) { |
| 7883 | status = wlan_hdd_disable_all_dual_mac_features(hdd_ctx); |
| 7884 | if (status != QDF_STATUS_SUCCESS) { |
| 7885 | hdd_err("Failed to disable dual mac features"); |
| 7886 | goto deregister_cb; |
| 7887 | } |
| 7888 | } |
| 7889 | |
| 7890 | /* register P2P Listen Offload event callback */ |
| 7891 | if (wma_is_p2p_lo_capable()) |
| 7892 | sme_register_p2p_lo_event(hdd_ctx->hHal, hdd_ctx, |
| 7893 | wlan_hdd_p2p_lo_event_callback); |
| 7894 | |
| 7895 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 7896 | |
| 7897 | if (ret) |
| 7898 | goto deregister_cb; |
| 7899 | |
| 7900 | EXIT(); |
| 7901 | return 0; |
| 7902 | |
| 7903 | deregister_cb: |
| 7904 | hdd_deregister_cb(hdd_ctx); |
| 7905 | deregister_frames: |
| 7906 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 7907 | out: |
| 7908 | return -EINVAL; |
| 7909 | |
| 7910 | } |
| 7911 | |
| 7912 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 7913 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7914 | * hdd_configure_cds() - Configure cds modules |
| 7915 | * @hdd_ctx: HDD context |
| 7916 | * @adapter: Primary adapter context |
| 7917 | * |
| 7918 | * Enable Cds modules after WLAN firmware is up. |
| 7919 | * |
| 7920 | * Return: 0 on success and errno on failure. |
| 7921 | */ |
| 7922 | int hdd_configure_cds(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter) |
| 7923 | { |
| 7924 | int ret; |
| 7925 | QDF_STATUS status; |
| 7926 | /* structure of function pointers to be used by CDS */ |
| 7927 | struct cds_sme_cbacks sme_cbacks; |
| 7928 | |
| 7929 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 7930 | if (ret) { |
| 7931 | hdd_err("Failed to pre-configure cds"); |
| 7932 | goto out; |
| 7933 | } |
| 7934 | |
| 7935 | /* |
| 7936 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 7937 | * else |
| 7938 | */ |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 7939 | status = cds_enable(hdd_ctx->hdd_psoc, hdd_ctx->pcds_context); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7940 | |
| 7941 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 7942 | hdd_alert("cds_enable failed"); |
| 7943 | goto out; |
| 7944 | } |
| 7945 | |
| 7946 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 7947 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 7948 | hdd_alert("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 7949 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7950 | } |
| 7951 | |
| 7952 | ret = hdd_features_init(hdd_ctx, adapter); |
| 7953 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 7954 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7955 | |
| 7956 | sme_cbacks.sme_get_valid_channels = sme_get_cfg_valid_channels; |
| 7957 | sme_cbacks.sme_get_nss_for_vdev = sme_get_vdev_type_nss; |
| 7958 | status = cds_init_policy_mgr(&sme_cbacks); |
| 7959 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 7960 | hdd_err("Policy manager initialization failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 7961 | goto hdd_features_deinit; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7962 | } |
| 7963 | |
| 7964 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 7965 | |
| 7966 | hdd_features_deinit: |
| 7967 | hdd_deregister_cb(hdd_ctx); |
| 7968 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 7969 | cds_disable: |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 7970 | cds_disable(hdd_ctx->hdd_psoc, hdd_ctx->pcds_context); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 7971 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7972 | out: |
| 7973 | return -EINVAL; |
| 7974 | } |
| 7975 | |
| 7976 | /** |
| 7977 | * hdd_deconfigure_cds() -De-Configure cds |
| 7978 | * @hdd_ctx: HDD context |
| 7979 | * |
| 7980 | * Deconfigure Cds modules before WLAN firmware is down. |
| 7981 | * |
| 7982 | * Return: 0 on success and errno on failure. |
| 7983 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 7984 | static int hdd_deconfigure_cds(hdd_context_t *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7985 | { |
| 7986 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 7987 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7988 | |
| 7989 | ENTER(); |
| 7990 | /* De-register the SME callbacks */ |
| 7991 | hdd_deregister_cb(hdd_ctx); |
Padma, Santhosh Kumar | 1472fab | 2016-10-07 13:29:27 +0530 | [diff] [blame] | 7992 | hdd_encrypt_decrypt_deinit(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7993 | |
| 7994 | /* De-init Policy Manager */ |
| 7995 | if (!QDF_IS_STATUS_SUCCESS(cds_deinit_policy_mgr())) { |
| 7996 | hdd_err("Failed to deinit policy manager"); |
| 7997 | /* Proceed and complete the clean up */ |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 7998 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7999 | } |
| 8000 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 8001 | qdf_status = cds_disable(hdd_ctx->hdd_psoc, hdd_ctx->pcds_context); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8002 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 8003 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 8004 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 8005 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8006 | } |
| 8007 | |
| 8008 | EXIT(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 8009 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8010 | } |
| 8011 | |
| 8012 | |
| 8013 | /** |
| 8014 | * hdd_wlan_stop_modules - Single driver state machine for stoping modules |
| 8015 | * @hdd_ctx: HDD context |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8016 | * |
| 8017 | * This function maintains the driver state machine it will be invoked from |
| 8018 | * exit, shutdown and con_mode change handler. Depending on the driver state |
| 8019 | * shall perform the stopping/closing of the modules. |
| 8020 | * |
| 8021 | * Return: 0 for success; non-zero for failure |
| 8022 | */ |
Prashanth Bhatta | 2ac92bd | 2016-10-11 16:08:00 -0700 | [diff] [blame] | 8023 | int hdd_wlan_stop_modules(hdd_context_t *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8024 | { |
| 8025 | void *hif_ctx; |
| 8026 | qdf_device_t qdf_ctx; |
| 8027 | QDF_STATUS qdf_status; |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8028 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8029 | p_cds_sched_context cds_sched_context = NULL; |
| 8030 | |
| 8031 | ENTER(); |
| 8032 | |
| 8033 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 8034 | if (!qdf_ctx) { |
| 8035 | hdd_err("QDF device context NULL"); |
| 8036 | return -EINVAL; |
| 8037 | } |
| 8038 | |
| 8039 | cds_sched_context = get_cds_sched_ctxt(); |
| 8040 | if (!cds_sched_context) { |
| 8041 | hdd_err("cds scheduler context NULL"); |
| 8042 | return -EINVAL; |
| 8043 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8044 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 8045 | hdd_ctx->stop_modules_in_progress = true; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8046 | |
| 8047 | hdd_info("Present Driver Status: %d", hdd_ctx->driver_status); |
| 8048 | |
| 8049 | switch (hdd_ctx->driver_status) { |
| 8050 | case DRIVER_MODULES_UNINITIALIZED: |
| 8051 | hdd_info("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8052 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8053 | case DRIVER_MODULES_CLOSED: |
| 8054 | hdd_info("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8055 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8056 | case DRIVER_MODULES_ENABLED: |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 8057 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8058 | if (hdd_deconfigure_cds(hdd_ctx)) { |
| 8059 | hdd_alert("Failed to de-configure CDS"); |
| 8060 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8061 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8062 | } |
| 8063 | hdd_info("successfully Disabled the CDS modules!"); |
| 8064 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
| 8065 | break; |
| 8066 | case DRIVER_MODULES_OPENED: |
| 8067 | hdd_info("Closing CDS modules!"); |
| 8068 | break; |
| 8069 | default: |
| 8070 | hdd_err("Trying to stop wlan in a wrong state: %d", |
| 8071 | hdd_ctx->driver_status); |
| 8072 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8073 | ret = -EINVAL; |
| 8074 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8075 | } |
| 8076 | |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 8077 | qdf_status = cds_post_disable(hdd_ctx->pcds_context); |
| 8078 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 8079 | hdd_err("Failed to process post CDS disable Modules! :%d", |
| 8080 | qdf_status); |
| 8081 | ret = -EINVAL; |
| 8082 | QDF_ASSERT(0); |
| 8083 | } |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 8084 | qdf_status = cds_close(hdd_ctx->hdd_psoc, hdd_ctx->pcds_context); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8085 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 8086 | hdd_warn("Failed to stop CDS:%d", qdf_status); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 8087 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8088 | QDF_ASSERT(0); |
| 8089 | } |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 8090 | |
Rajeev Kumar | ecf87ff | 2017-01-13 15:46:07 -0800 | [diff] [blame] | 8091 | ret = hdd_release_and_destroy_pdev(hdd_ctx); |
| 8092 | if (ret) |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 8093 | hdd_err("Pdev delete failed"); |
| 8094 | |
Rajeev Kumar | 99e4cf6 | 2017-01-13 15:31:19 -0800 | [diff] [blame] | 8095 | ret = hdd_release_and_destroy_psoc(hdd_ctx); |
| 8096 | if (ret) |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 8097 | hdd_err("Psoc delete failed"); |
| 8098 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8099 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 8100 | if (!hif_ctx) { |
| 8101 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8102 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8103 | } |
| 8104 | |
| 8105 | hdd_hif_close(hif_ctx); |
| 8106 | |
| 8107 | ol_cds_free(); |
| 8108 | |
Arunk Khandavalli | 649c009 | 2016-11-22 21:20:43 +0530 | [diff] [blame] | 8109 | if (!cds_is_driver_recovering() && !cds_is_driver_unloading()) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8110 | ret = pld_power_off(qdf_ctx->dev); |
| 8111 | if (ret) |
| 8112 | hdd_err("CNSS power down failed put device into Low power mode:%d", |
| 8113 | ret); |
| 8114 | } |
| 8115 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
| 8116 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8117 | done: |
| 8118 | hdd_ctx->stop_modules_in_progress = false; |
| 8119 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8120 | EXIT(); |
| 8121 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8122 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8123 | |
| 8124 | } |
| 8125 | |
| 8126 | /** |
| 8127 | * hdd_iface_change_callback() - Function invoked when stop modules expires |
| 8128 | * @priv: pointer to hdd context |
| 8129 | * |
| 8130 | * This function is invoked when the timer waiting for the interface change |
| 8131 | * expires, it shall cut-down the power to wlan and stop all the modules. |
| 8132 | * |
| 8133 | * Return: void |
| 8134 | */ |
| 8135 | static void hdd_iface_change_callback(void *priv) |
| 8136 | { |
| 8137 | hdd_context_t *hdd_ctx = (hdd_context_t *) priv; |
| 8138 | int ret; |
| 8139 | int status = wlan_hdd_validate_context(hdd_ctx); |
| 8140 | |
| 8141 | if (status) |
| 8142 | return; |
| 8143 | |
| 8144 | ENTER(); |
| 8145 | hdd_info("Interface change timer expired close the modules!"); |
Prashanth Bhatta | 2ac92bd | 2016-10-11 16:08:00 -0700 | [diff] [blame] | 8146 | ret = hdd_wlan_stop_modules(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8147 | if (ret) |
| 8148 | hdd_alert("Failed to stop modules"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8149 | EXIT(); |
| 8150 | } |
| 8151 | |
| 8152 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 8153 | * hdd_state_info_dump() - prints state information of hdd layer |
| 8154 | * @buf: buffer pointer |
| 8155 | * @size: size of buffer to be filled |
| 8156 | * |
| 8157 | * This function is used to dump state information of hdd layer |
| 8158 | * |
| 8159 | * Return: None |
| 8160 | */ |
| 8161 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 8162 | { |
| 8163 | hdd_context_t *hdd_ctx; |
| 8164 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 8165 | QDF_STATUS status; |
| 8166 | hdd_station_ctx_t *hdd_sta_ctx; |
| 8167 | hdd_adapter_t *adapter; |
| 8168 | uint16_t len = 0; |
| 8169 | char *buf = *buf_ptr; |
| 8170 | |
| 8171 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 8172 | if (!hdd_ctx) { |
| 8173 | hdd_err("Failed to get hdd context "); |
| 8174 | return; |
| 8175 | } |
| 8176 | |
| 8177 | hdd_notice("size of buffer: %d", *size); |
| 8178 | |
| 8179 | len += scnprintf(buf + len, *size - len, |
| 8180 | "\n isWiphySuspended %d", hdd_ctx->isWiphySuspended); |
| 8181 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 8182 | "\n is_scheduler_suspended %d", |
| 8183 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 8184 | |
| 8185 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 8186 | |
| 8187 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 8188 | adapter = adapter_node->pAdapter; |
| 8189 | if (adapter->dev) |
| 8190 | len += scnprintf(buf + len, *size - len, |
| 8191 | "\n device name: %s", adapter->dev->name); |
| 8192 | len += scnprintf(buf + len, *size - len, |
| 8193 | "\n device_mode: %d", adapter->device_mode); |
| 8194 | switch (adapter->device_mode) { |
| 8195 | case QDF_STA_MODE: |
| 8196 | case QDF_P2P_CLIENT_MODE: |
| 8197 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 8198 | len += scnprintf(buf + len, *size - len, |
| 8199 | "\n connState: %d", |
| 8200 | hdd_sta_ctx->conn_info.connState); |
| 8201 | break; |
| 8202 | |
| 8203 | default: |
| 8204 | break; |
| 8205 | } |
| 8206 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 8207 | adapter_node = next; |
| 8208 | } |
| 8209 | |
| 8210 | *size -= len; |
| 8211 | *buf_ptr += len; |
| 8212 | } |
| 8213 | |
| 8214 | /** |
| 8215 | * hdd_register_debug_callback() - registration function for hdd layer |
| 8216 | * to print hdd state information |
| 8217 | * |
| 8218 | * Return: None |
| 8219 | */ |
| 8220 | static void hdd_register_debug_callback(void) |
| 8221 | { |
| 8222 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 8223 | } |
| 8224 | |
| 8225 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8226 | * hdd_wlan_startup() - HDD init function |
| 8227 | * @dev: Pointer to the underlying device |
| 8228 | * |
| 8229 | * This is the driver startup code executed once a WLAN device has been detected |
| 8230 | * |
| 8231 | * Return: 0 for success, < 0 for failure |
| 8232 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8233 | int hdd_wlan_startup(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8234 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8235 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8236 | hdd_adapter_t *adapter = NULL; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8237 | hdd_context_t *hdd_ctx = NULL; |
| 8238 | int ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8239 | void *hif_sc; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8240 | bool rtnl_held; |
Manjeet Singh | e7ecb7c | 2016-09-03 12:34:53 +0530 | [diff] [blame] | 8241 | int set_value; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8242 | |
| 8243 | ENTER(); |
| 8244 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8245 | hdd_ctx = hdd_context_create(dev); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8246 | |
| 8247 | if (IS_ERR(hdd_ctx)) |
| 8248 | return PTR_ERR(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8249 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8250 | qdf_mc_timer_init(&hdd_ctx->iface_change_timer, QDF_TIMER_TYPE_SW, |
| 8251 | hdd_iface_change_callback, (void *)hdd_ctx); |
| 8252 | |
| 8253 | mutex_init(&hdd_ctx->iface_change_lock); |
| 8254 | |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 8255 | ret = hdd_init_netlink_services(hdd_ctx); |
| 8256 | if (ret) |
| 8257 | goto err_hdd_free_context; |
| 8258 | |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 8259 | hdd_green_ap_init(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8260 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8261 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 8262 | if (ret) { |
| 8263 | hdd_alert("Failed to start modules: %d", ret); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 8264 | goto err_exit_nl_srv; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8265 | } |
| 8266 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 8267 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8268 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8269 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 8270 | hdd_notice("Failed to set wow pulse"); |
| 8271 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8272 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8273 | |
| 8274 | if (NULL == hdd_ctx->hHal) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8275 | hdd_alert("HAL context is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8276 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8277 | } |
| 8278 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8279 | ret = hdd_wiphy_init(hdd_ctx); |
| 8280 | if (ret) { |
| 8281 | hdd_alert("Failed to initialize wiphy: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8282 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8283 | } |
| 8284 | |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 8285 | if (hdd_ctx->config->enable_dp_trace) |
| 8286 | qdf_dp_trace_init(); |
| 8287 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8288 | if (hdd_ipa_init(hdd_ctx) == QDF_STATUS_E_FAILURE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8289 | goto err_wiphy_unregister; |
| 8290 | |
Yuanyuan Liu | c98370e | 2016-10-13 11:22:13 -0700 | [diff] [blame] | 8291 | hdd_initialize_mac_address(hdd_ctx); |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 8292 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8293 | rtnl_held = hdd_hold_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8294 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8295 | adapter = hdd_open_interfaces(hdd_ctx, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8296 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8297 | if (IS_ERR(adapter)) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8298 | hdd_alert("Failed to open interface, adapter is NULL"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8299 | ret = PTR_ERR(adapter); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8300 | goto err_ipa_cleanup; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8301 | } |
| 8302 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8303 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
Anurag Chouhan | ce6a405 | 2016-09-14 18:20:42 +0530 | [diff] [blame] | 8304 | if (!hif_sc) { |
| 8305 | hdd_err("HIF context is NULL"); |
| 8306 | goto err_close_adapter; |
| 8307 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8308 | /* |
| 8309 | * target hw version/revision would only be retrieved after firmware |
| 8310 | * donwload |
| 8311 | */ |
| 8312 | hif_get_hw_info(hif_sc, &hdd_ctx->target_hw_version, |
| 8313 | &hdd_ctx->target_hw_revision, |
| 8314 | &hdd_ctx->target_hw_name); |
| 8315 | |
| 8316 | /* Get the wlan hw/fw version */ |
Arun Khandavalli | a96c2c0 | 2016-05-17 19:15:34 +0530 | [diff] [blame] | 8317 | hdd_wlan_get_version(hdd_ctx, NULL, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8318 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8319 | hdd_release_rtnl_lock(); |
| 8320 | rtnl_held = false; |
| 8321 | |
Agrawal Ashish | b2d1a45 | 2016-05-05 12:23:58 +0530 | [diff] [blame] | 8322 | if (hdd_ctx->config->enable_go_cts2self_for_sta) |
| 8323 | sme_set_cts2self_for_p2p_go(hdd_ctx->hHal); |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 8324 | |
| 8325 | wlan_hdd_update_11n_mode(hdd_ctx->config); |
| 8326 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8327 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 8328 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8329 | QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8330 | hdd_skip_acs_scan_timer_handler, |
| 8331 | (void *)hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8332 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8333 | hdd_err("Failed to init ACS Skip timer"); |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 8334 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8335 | #endif |
| 8336 | |
Nitesh Shah | 61c10d9 | 2016-10-19 19:29:15 +0530 | [diff] [blame] | 8337 | qdf_mc_timer_init(&hdd_ctx->tdls_source_timer, |
| 8338 | QDF_TIMER_TYPE_SW, |
| 8339 | wlan_hdd_change_tdls_mode, |
| 8340 | hdd_ctx); |
| 8341 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8342 | hdd_bus_bandwidth_init(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8343 | |
Jeff Johnson | 9afc501 | 2016-09-23 13:56:27 -0700 | [diff] [blame] | 8344 | hdd_lpass_notify_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8345 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 8346 | if (hdd_ctx->rps) |
| 8347 | hdd_set_rps_cpu_mask(hdd_ctx); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 8348 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8349 | |
| 8350 | if (cds_is_packet_log_enabled()) |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8351 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8352 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 8353 | ret = hdd_register_notifiers(hdd_ctx); |
| 8354 | if (ret) |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 8355 | goto err_debugfs_exit; |
| 8356 | |
| 8357 | status = wlansap_global_init(); |
| 8358 | if (QDF_IS_STATUS_ERROR(status)) |
| 8359 | goto err_debugfs_exit; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 8360 | |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 8361 | hdd_runtime_suspend_context_init(hdd_ctx); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 8362 | memdump_init(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 8363 | hdd_driver_memdump_init(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 8364 | |
bings | 612b9c4 | 2016-11-07 10:52:03 +0800 | [diff] [blame] | 8365 | if (hdd_enable_egap(hdd_ctx)) |
| 8366 | hdd_err("enhance green ap is not enabled"); |
| 8367 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8368 | if (hdd_ctx->config->fIsImpsEnabled) |
| 8369 | hdd_set_idle_ps_config(hdd_ctx, true); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 8370 | |
Manjeet Singh | e7ecb7c | 2016-09-03 12:34:53 +0530 | [diff] [blame] | 8371 | if (hdd_ctx->config->sifs_burst_duration) { |
| 8372 | set_value = (SIFS_BURST_DUR_MULTIPLIER) * |
| 8373 | hdd_ctx->config->sifs_burst_duration; |
| 8374 | |
| 8375 | if ((set_value > 0) && (set_value <= SIFS_BURST_DUR_MAX)) |
| 8376 | wma_cli_set_command(0, (int)WMI_PDEV_PARAM_BURST_DUR, |
| 8377 | set_value, PDEV_CMD); |
| 8378 | } |
| 8379 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8380 | qdf_mc_timer_start(&hdd_ctx->iface_change_timer, |
| 8381 | hdd_ctx->config->iface_change_wait_time * 5000); |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 8382 | |
| 8383 | if (hdd_ctx->config->goptimize_chan_avoid_event) { |
| 8384 | status = sme_enable_disable_chanavoidind_event( |
| 8385 | hdd_ctx->hHal, 0); |
| 8386 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8387 | hdd_err("Failed to disable Chan Avoidance Indication"); |
| 8388 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8389 | goto success; |
| 8390 | |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 8391 | err_debugfs_exit: |
| 8392 | hdd_debugfs_exit(adapter); |
Anurag Chouhan | ce6a405 | 2016-09-14 18:20:42 +0530 | [diff] [blame] | 8393 | |
| 8394 | err_close_adapter: |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8395 | hdd_close_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8396 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 8397 | if (rtnl_held) |
| 8398 | hdd_release_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8399 | |
Anurag Chouhan | ce6a405 | 2016-09-14 18:20:42 +0530 | [diff] [blame] | 8400 | err_ipa_cleanup: |
| 8401 | hdd_ipa_cleanup(hdd_ctx); |
Yun Park | 6a46ad8 | 2016-01-04 16:48:19 -0800 | [diff] [blame] | 8402 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8403 | err_wiphy_unregister: |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8404 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8405 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8406 | err_stop_modules: |
Prashanth Bhatta | 2ac92bd | 2016-10-11 16:08:00 -0700 | [diff] [blame] | 8407 | hdd_wlan_stop_modules(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8408 | |
| 8409 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8410 | status = cds_sched_close(hdd_ctx->pcds_context); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8411 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8412 | hdd_alert("Failed to close CDS Scheduler"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 8413 | QDF_ASSERT(QDF_IS_STATUS_SUCCESS(status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8414 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8415 | |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 8416 | err_exit_nl_srv: |
Houston Hoffman | 47a4a05 | 2016-11-14 23:22:44 -0800 | [diff] [blame] | 8417 | hdd_green_ap_deinit(hdd_ctx); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 8418 | hdd_exit_netlink_services(hdd_ctx); |
| 8419 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8420 | cds_deinit_ini_config(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8421 | err_hdd_free_context: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8422 | qdf_mc_timer_destroy(&hdd_ctx->iface_change_timer); |
| 8423 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8424 | hdd_context_destroy(hdd_ctx); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 8425 | QDF_BUG(1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8426 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8427 | return -EIO; |
| 8428 | |
| 8429 | success: |
| 8430 | EXIT(); |
| 8431 | return 0; |
| 8432 | } |
| 8433 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8434 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8435 | * hdd_wlan_update_target_info() - update target type info |
| 8436 | * @hdd_ctx: HDD context |
| 8437 | * @context: hif context |
| 8438 | * |
| 8439 | * Update target info received from firmware in hdd context |
| 8440 | * Return:None |
| 8441 | */ |
| 8442 | |
| 8443 | void hdd_wlan_update_target_info(hdd_context_t *hdd_ctx, void *context) |
| 8444 | { |
| 8445 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 8446 | |
| 8447 | if (!tgt_info) { |
| 8448 | hdd_err("Target info is Null"); |
| 8449 | return; |
| 8450 | } |
| 8451 | |
| 8452 | hdd_ctx->target_type = tgt_info->target_type; |
| 8453 | } |
| 8454 | |
| 8455 | /** |
| 8456 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 8457 | * @hdd_ctx: HDD context |
| 8458 | * |
| 8459 | * Register the HDD callbacks to CDS/SME. |
| 8460 | * |
| 8461 | * Return: 0 for success or Error code for failure |
| 8462 | */ |
| 8463 | int hdd_register_cb(hdd_context_t *hdd_ctx) |
| 8464 | { |
| 8465 | QDF_STATUS status; |
| 8466 | int ret = 0; |
| 8467 | |
| 8468 | ENTER(); |
| 8469 | |
| 8470 | sme_register11d_scan_done_callback(hdd_ctx->hHal, hdd_11d_scan_done); |
| 8471 | |
| 8472 | sme_register_oem_data_rsp_callback(hdd_ctx->hHal, |
| 8473 | hdd_send_oem_data_rsp_msg); |
| 8474 | |
| 8475 | status = sme_fw_mem_dump_register_cb(hdd_ctx->hHal, |
| 8476 | wlan_hdd_cfg80211_fw_mem_dump_cb); |
| 8477 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8478 | hdd_err("Failed to register memdump callback"); |
| 8479 | ret = -EINVAL; |
| 8480 | return ret; |
| 8481 | } |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 8482 | sme_register_mgmt_frame_ind_callback(hdd_ctx->hHal, |
| 8483 | hdd_indicate_mgmt_frame); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 8484 | sme_set_tsfcb(hdd_ctx->hHal, hdd_get_tsf_cb, hdd_ctx); |
| 8485 | sme_nan_register_callback(hdd_ctx->hHal, |
| 8486 | wlan_hdd_cfg80211_nan_callback); |
| 8487 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 8488 | wlan_hdd_cfg80211_stats_ext_callback); |
| 8489 | |
| 8490 | sme_ext_scan_register_callback(hdd_ctx->hHal, |
| 8491 | wlan_hdd_cfg80211_extscan_callback); |
| 8492 | |
| 8493 | status = cds_register_sap_restart_channel_switch_cb( |
| 8494 | (void *)hdd_sap_restart_with_channel_switch); |
| 8495 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8496 | hdd_err("restart cb registration failed"); |
| 8497 | ret = -EINVAL; |
| 8498 | return ret; |
| 8499 | } |
| 8500 | |
| 8501 | sme_set_rssi_threshold_breached_cb(hdd_ctx->hHal, |
| 8502 | hdd_rssi_threshold_breached); |
| 8503 | |
| 8504 | status = sme_bpf_offload_register_callback(hdd_ctx->hHal, |
| 8505 | hdd_get_bpf_offload_cb); |
| 8506 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8507 | hdd_err("set bpf offload callback failed"); |
| 8508 | ret = -EINVAL; |
| 8509 | return ret; |
| 8510 | } |
| 8511 | |
| 8512 | sme_set_link_layer_stats_ind_cb(hdd_ctx->hHal, |
| 8513 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 8514 | |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 8515 | status = sme_set_lost_link_info_cb(hdd_ctx->hHal, |
| 8516 | hdd_lost_link_info_cb); |
| 8517 | /* print error and not block the startup process */ |
| 8518 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8519 | hdd_err("set lost link info callback failed"); |
| 8520 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 8521 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 8522 | |
| 8523 | EXIT(); |
| 8524 | |
| 8525 | return ret; |
| 8526 | } |
| 8527 | |
| 8528 | /** |
| 8529 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 8530 | * @hdd_ctx: HDD context |
| 8531 | * |
| 8532 | * De-Register the HDD callbacks to CDS/SME. |
| 8533 | * |
| 8534 | * Return: void |
| 8535 | */ |
| 8536 | void hdd_deregister_cb(hdd_context_t *hdd_ctx) |
| 8537 | { |
| 8538 | QDF_STATUS status; |
| 8539 | |
| 8540 | ENTER(); |
| 8541 | |
| 8542 | status = sme_deregister_for_dcc_stats_event(hdd_ctx->hHal); |
| 8543 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8544 | hdd_err("De-register of dcc stats callback failed: %d", |
| 8545 | status); |
| 8546 | |
| 8547 | sme_reset_link_layer_stats_ind_cb(hdd_ctx->hHal); |
| 8548 | status = sme_bpf_offload_deregister_callback(hdd_ctx->hHal); |
| 8549 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8550 | hdd_err("De-register bpf offload callback failed: %d", |
| 8551 | status); |
| 8552 | sme_reset_rssi_threshold_breached_cb(hdd_ctx->hHal); |
| 8553 | |
| 8554 | status = cds_deregister_sap_restart_channel_switch_cb(); |
| 8555 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8556 | hdd_err("De-register restart cb registration failed: %d", |
| 8557 | status); |
| 8558 | |
| 8559 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 8560 | wlan_hdd_cfg80211_stats_ext_callback); |
| 8561 | |
| 8562 | sme_nan_deregister_callback(hdd_ctx->hHal); |
| 8563 | status = sme_reset_tsfcb(hdd_ctx->hHal); |
| 8564 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8565 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 8566 | status); |
| 8567 | status = sme_fw_mem_dump_unregister_cb(hdd_ctx->hHal); |
| 8568 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8569 | hdd_err("Failed to de-register the fw mem dump callback: %d", |
| 8570 | status); |
| 8571 | |
| 8572 | sme_deregister_oem_data_rsp_callback(hdd_ctx->hHal); |
| 8573 | sme_deregister11d_scan_done_callback(hdd_ctx->hHal); |
| 8574 | |
| 8575 | EXIT(); |
| 8576 | } |
| 8577 | |
| 8578 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8579 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
| 8580 | * @adapter: Pointer to the HDD |
| 8581 | * @enable: bool value |
| 8582 | * |
| 8583 | * This to take counter measure to handle deauth req from HDD |
| 8584 | * |
| 8585 | * Return: None |
| 8586 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8587 | QDF_STATUS hdd_softap_sta_deauth(hdd_adapter_t *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8588 | struct tagCsrDelStaParams *pDelStaParams) |
| 8589 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8590 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8591 | |
| 8592 | ENTER(); |
| 8593 | |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8594 | hdd_notice("hdd_softap_sta_deauth:(%p, false)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8595 | (WLAN_HDD_GET_CTX(adapter))->pcds_context); |
| 8596 | |
| 8597 | /* Ignore request to deauth bcmc station */ |
| 8598 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8599 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8600 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8601 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8602 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 8603 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8604 | |
| 8605 | EXIT(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8606 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8607 | } |
| 8608 | |
| 8609 | /** |
| 8610 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
| 8611 | * @adapter: Pointer to the HDD |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 8612 | * @p_del_sta_params: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8613 | * |
| 8614 | * This to take counter measure to handle deauth req from HDD |
| 8615 | * |
| 8616 | * Return: None |
| 8617 | */ |
| 8618 | void hdd_softap_sta_disassoc(hdd_adapter_t *adapter, |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 8619 | struct tagCsrDelStaParams *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8620 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8621 | ENTER(); |
| 8622 | |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8623 | hdd_err("hdd_softap_sta_disassoc:(%p, false)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8624 | (WLAN_HDD_GET_CTX(adapter))->pcds_context); |
| 8625 | |
| 8626 | /* Ignore request to disassoc bcmc station */ |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 8627 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8628 | return; |
| 8629 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8630 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 8631 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8632 | } |
| 8633 | |
| 8634 | void hdd_softap_tkip_mic_fail_counter_measure(hdd_adapter_t *adapter, |
| 8635 | bool enable) |
| 8636 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8637 | ENTER(); |
| 8638 | |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8639 | hdd_err("hdd_softap_tkip_mic_fail_counter_measure:(%p, false)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8640 | (WLAN_HDD_GET_CTX(adapter))->pcds_context); |
| 8641 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8642 | wlansap_set_counter_measure(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 8643 | (bool) enable); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8644 | } |
| 8645 | |
| 8646 | /** |
| 8647 | * hdd_issta_p2p_clientconnected() - check if sta or p2p client is connected |
| 8648 | * @hdd_ctx: HDD Context |
| 8649 | * |
| 8650 | * API to find if there is any STA or P2P-Client is connected |
| 8651 | * |
| 8652 | * Return: true if connected; false otherwise |
| 8653 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8654 | QDF_STATUS hdd_issta_p2p_clientconnected(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8655 | { |
| 8656 | return sme_is_sta_p2p_client_connected(hdd_ctx->hHal); |
| 8657 | } |
| 8658 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8659 | /** |
| 8660 | * wlan_hdd_disable_roaming() - disable roaming on all STAs except the input one |
| 8661 | * @adapter: HDD adapter pointer |
| 8662 | * |
| 8663 | * This function loop through each adapter and disable roaming on each STA |
| 8664 | * device mode except the input adapter. |
| 8665 | * |
| 8666 | * Note: On the input adapter roaming is not enabled yet hence no need to |
| 8667 | * disable. |
| 8668 | * |
| 8669 | * Return: None |
| 8670 | */ |
| 8671 | void wlan_hdd_disable_roaming(hdd_adapter_t *adapter) |
| 8672 | { |
| 8673 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8674 | hdd_adapter_t *adapterIdx = NULL; |
| 8675 | hdd_adapter_list_node_t *adapterNode = NULL; |
| 8676 | hdd_adapter_list_node_t *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8677 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8678 | |
| 8679 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
| 8680 | hdd_ctx->config->isRoamOffloadScanEnabled && |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8681 | QDF_STA_MODE == adapter->device_mode && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8682 | cds_is_sta_active_connection_exists()) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8683 | hdd_notice("Connect received on STA sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8684 | adapter->sessionId); |
| 8685 | /* |
| 8686 | * Loop through adapter and disable roaming for each STA device |
| 8687 | * mode except the input adapter. |
| 8688 | */ |
| 8689 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 8690 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8691 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8692 | adapterIdx = adapterNode->pAdapter; |
| 8693 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8694 | if (QDF_STA_MODE == adapterIdx->device_mode |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8695 | && adapter->sessionId != adapterIdx->sessionId) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8696 | hdd_notice("Disable Roaming on sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8697 | adapterIdx->sessionId); |
| 8698 | sme_stop_roaming(WLAN_HDD_GET_HAL_CTX |
| 8699 | (adapterIdx), |
| 8700 | adapterIdx->sessionId, 0); |
| 8701 | } |
| 8702 | |
| 8703 | status = hdd_get_next_adapter(hdd_ctx, |
| 8704 | adapterNode, |
| 8705 | &pNext); |
| 8706 | adapterNode = pNext; |
| 8707 | } |
| 8708 | } |
| 8709 | } |
| 8710 | |
| 8711 | /** |
| 8712 | * wlan_hdd_enable_roaming() - enable roaming on all STAs except the input one |
| 8713 | * @adapter: HDD adapter pointer |
| 8714 | * |
| 8715 | * This function loop through each adapter and enable roaming on each STA |
| 8716 | * device mode except the input adapter. |
| 8717 | * Note: On the input adapter no need to enable roaming because link got |
| 8718 | * disconnected on this. |
| 8719 | * |
| 8720 | * Return: None |
| 8721 | */ |
| 8722 | void wlan_hdd_enable_roaming(hdd_adapter_t *adapter) |
| 8723 | { |
| 8724 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8725 | hdd_adapter_t *adapterIdx = NULL; |
| 8726 | hdd_adapter_list_node_t *adapterNode = NULL; |
| 8727 | hdd_adapter_list_node_t *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8728 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8729 | |
| 8730 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
| 8731 | hdd_ctx->config->isRoamOffloadScanEnabled && |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8732 | QDF_STA_MODE == adapter->device_mode && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8733 | cds_is_sta_active_connection_exists()) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8734 | hdd_notice("Disconnect received on STA sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8735 | adapter->sessionId); |
| 8736 | /* |
| 8737 | * Loop through adapter and enable roaming for each STA device |
| 8738 | * mode except the input adapter. |
| 8739 | */ |
| 8740 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 8741 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8742 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8743 | adapterIdx = adapterNode->pAdapter; |
| 8744 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8745 | if (QDF_STA_MODE == adapterIdx->device_mode |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8746 | && adapter->sessionId != adapterIdx->sessionId) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8747 | hdd_notice("Enabling Roaming on sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8748 | adapterIdx->sessionId); |
| 8749 | sme_start_roaming(WLAN_HDD_GET_HAL_CTX |
| 8750 | (adapterIdx), |
| 8751 | adapterIdx->sessionId, |
| 8752 | REASON_CONNECT); |
| 8753 | } |
| 8754 | |
| 8755 | status = hdd_get_next_adapter(hdd_ctx, |
| 8756 | adapterNode, |
| 8757 | &pNext); |
| 8758 | adapterNode = pNext; |
| 8759 | } |
| 8760 | } |
| 8761 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8762 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 8763 | 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] | 8764 | { |
| 8765 | struct sk_buff *skb; |
| 8766 | struct nlmsghdr *nlh; |
| 8767 | tAniMsgHdr *ani_hdr; |
| 8768 | void *nl_data = NULL; |
| 8769 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 8770 | struct radio_index_tlv *radio_info; |
| 8771 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8772 | |
| 8773 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 8774 | flags = GFP_ATOMIC; |
| 8775 | |
| 8776 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 8777 | |
| 8778 | if (skb == NULL) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8779 | hdd_err("alloc_skb failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8780 | return; |
| 8781 | } |
| 8782 | |
| 8783 | nlh = (struct nlmsghdr *)skb->data; |
| 8784 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 8785 | nlh->nlmsg_flags = 0; |
| 8786 | nlh->nlmsg_seq = 0; |
| 8787 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 8788 | |
| 8789 | ani_hdr = NLMSG_DATA(nlh); |
| 8790 | ani_hdr->type = type; |
| 8791 | |
| 8792 | switch (type) { |
| 8793 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 8794 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8795 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8796 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 8797 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8798 | ani_hdr->length = 0; |
| 8799 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8800 | break; |
| 8801 | case WLAN_SVC_WLAN_STATUS_IND: |
| 8802 | case WLAN_SVC_WLAN_VERSION_IND: |
| 8803 | case WLAN_SVC_DFS_CAC_START_IND: |
| 8804 | case WLAN_SVC_DFS_CAC_END_IND: |
| 8805 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 8806 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 8807 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 8808 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 8809 | case WLAN_SVC_RPS_ENABLE_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8810 | ani_hdr->length = len; |
| 8811 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 8812 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 8813 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8814 | break; |
| 8815 | |
| 8816 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8817 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8818 | type); |
| 8819 | kfree_skb(skb); |
| 8820 | return; |
| 8821 | } |
| 8822 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 8823 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8824 | * Add radio index at the end of the svc event in TLV format |
| 8825 | * to maintain the backward compatibility with userspace |
| 8826 | * applications. |
| 8827 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 8828 | |
| 8829 | tlv_len = 0; |
| 8830 | |
| 8831 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 8832 | < WLAN_NL_MAX_PAYLOAD) { |
| 8833 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 8834 | sizeof(*ani_hdr) + len); |
| 8835 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 8836 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 8837 | radio_info->radio = radio; |
| 8838 | tlv_len = sizeof(*radio_info); |
| 8839 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO, |
| 8840 | "Added radio index tlv - radio index %d", |
| 8841 | radio_info->radio); |
| 8842 | } |
| 8843 | |
| 8844 | nlh->nlmsg_len += tlv_len; |
| 8845 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 8846 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8847 | nl_srv_bcast(skb); |
| 8848 | |
| 8849 | return; |
| 8850 | } |
| 8851 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8852 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 8853 | void wlan_hdd_auto_shutdown_cb(void) |
| 8854 | { |
Mahesh Kumar Kalikot Veetil | d214d55 | 2016-09-14 15:15:49 -0700 | [diff] [blame] | 8855 | hdd_context_t *hdd_ctx = cds_get_global_context(); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 8856 | |
| 8857 | if (!hdd_ctx) |
| 8858 | return; |
| 8859 | |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 8860 | hdd_err("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 8861 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 8862 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8863 | } |
| 8864 | |
| 8865 | void wlan_hdd_auto_shutdown_enable(hdd_context_t *hdd_ctx, bool enable) |
| 8866 | { |
| 8867 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8868 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8869 | hdd_adapter_t *adapter; |
| 8870 | bool ap_connected = false, sta_connected = false; |
| 8871 | tHalHandle hal_handle; |
| 8872 | |
| 8873 | hal_handle = hdd_ctx->hHal; |
| 8874 | if (hal_handle == NULL) |
| 8875 | return; |
| 8876 | |
| 8877 | if (hdd_ctx->config->WlanAutoShutdown == 0) |
| 8878 | return; |
| 8879 | |
| 8880 | if (enable == false) { |
| 8881 | if (sme_set_auto_shutdown_timer(hal_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8882 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 8883 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8884 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 8885 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 8886 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8887 | return; |
| 8888 | } |
| 8889 | |
| 8890 | /* To enable shutdown timer check conncurrency */ |
| 8891 | if (cds_concurrent_open_sessions_running()) { |
| 8892 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 8893 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8894 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8895 | adapter = adapterNode->pAdapter; |
| 8896 | if (adapter |
| 8897 | && adapter->device_mode == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8898 | QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8899 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 8900 | conn_info.connState == |
| 8901 | eConnectionState_Associated) { |
| 8902 | sta_connected = true; |
| 8903 | break; |
| 8904 | } |
| 8905 | } |
| 8906 | if (adapter |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8907 | && adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8908 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
| 8909 | bApActive == true) { |
| 8910 | ap_connected = true; |
| 8911 | break; |
| 8912 | } |
| 8913 | } |
| 8914 | status = hdd_get_next_adapter(hdd_ctx, |
| 8915 | adapterNode, |
| 8916 | &pNext); |
| 8917 | adapterNode = pNext; |
| 8918 | } |
| 8919 | } |
| 8920 | |
| 8921 | if (ap_connected == true || sta_connected == true) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 8922 | hdd_notice("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8923 | return; |
| 8924 | } else { |
| 8925 | if (sme_set_auto_shutdown_timer(hal_handle, |
| 8926 | hdd_ctx->config-> |
| 8927 | WlanAutoShutdown) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8928 | != QDF_STATUS_SUCCESS) |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 8929 | hdd_err("Failed to start wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8930 | else |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 8931 | hdd_notice("Auto Shutdown timer for %d seconds enabled", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8932 | hdd_ctx->config->WlanAutoShutdown); |
| 8933 | |
| 8934 | } |
| 8935 | } |
| 8936 | #endif |
| 8937 | |
| 8938 | hdd_adapter_t *hdd_get_con_sap_adapter(hdd_adapter_t *this_sap_adapter, |
| 8939 | bool check_start_bss) |
| 8940 | { |
| 8941 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
| 8942 | hdd_adapter_t *adapter, *con_sap_adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8943 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8944 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 8945 | |
| 8946 | con_sap_adapter = NULL; |
| 8947 | |
| 8948 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8949 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8950 | adapter = adapterNode->pAdapter; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8951 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 8952 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8953 | adapter != this_sap_adapter) { |
| 8954 | if (check_start_bss) { |
| 8955 | if (test_bit(SOFTAP_BSS_STARTED, |
| 8956 | &adapter->event_flags)) { |
| 8957 | con_sap_adapter = adapter; |
| 8958 | break; |
| 8959 | } |
| 8960 | } else { |
| 8961 | con_sap_adapter = adapter; |
| 8962 | break; |
| 8963 | } |
| 8964 | } |
| 8965 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 8966 | adapterNode = pNext; |
| 8967 | } |
| 8968 | |
| 8969 | return con_sap_adapter; |
| 8970 | } |
| 8971 | |
| 8972 | #ifdef MSM_PLATFORM |
| 8973 | void hdd_start_bus_bw_compute_timer(hdd_adapter_t *adapter) |
| 8974 | { |
| 8975 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8976 | |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 8977 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 8978 | if (!hdd_ctx->bus_bw_timer_running) { |
| 8979 | hdd_ctx->bus_bw_timer_running = true; |
| 8980 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
| 8981 | hdd_ctx->config->busBandwidthComputeInterval); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8982 | |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 8983 | } |
| 8984 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 8985 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8986 | } |
| 8987 | |
| 8988 | void hdd_stop_bus_bw_compute_timer(hdd_adapter_t *adapter) |
| 8989 | { |
| 8990 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8991 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8992 | bool can_stop = true; |
| 8993 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8994 | |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 8995 | if (!hdd_ctx->bus_bw_timer_running) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8996 | /* trying to stop timer, when not running is not good */ |
Srinivas Girigowda | 0ee9644 | 2016-08-17 19:10:56 -0700 | [diff] [blame] | 8997 | hdd_info("bus band width compute timer is not running"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8998 | return; |
| 8999 | } |
| 9000 | |
| 9001 | if (cds_concurrent_open_sessions_running()) { |
| 9002 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 9003 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9004 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9005 | adapter = adapterNode->pAdapter; |
| 9006 | if (adapter |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9007 | && (adapter->device_mode == QDF_STA_MODE |
| 9008 | || adapter->device_mode == QDF_P2P_CLIENT_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9009 | && WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 9010 | conn_info.connState == |
| 9011 | eConnectionState_Associated) { |
| 9012 | can_stop = false; |
| 9013 | break; |
| 9014 | } |
| 9015 | if (adapter |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9016 | && (adapter->device_mode == QDF_SAP_MODE |
| 9017 | || adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9018 | && WLAN_HDD_GET_AP_CTX_PTR(adapter)->bApActive == |
| 9019 | true) { |
| 9020 | can_stop = false; |
| 9021 | break; |
| 9022 | } |
| 9023 | status = hdd_get_next_adapter(hdd_ctx, |
| 9024 | adapterNode, |
| 9025 | &pNext); |
| 9026 | adapterNode = pNext; |
| 9027 | } |
| 9028 | } |
| 9029 | |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 9030 | if (can_stop == true) { |
Chris Guo | c0c95bf | 2016-11-10 14:28:25 +0800 | [diff] [blame] | 9031 | /* reset the ipa perf level */ |
| 9032 | hdd_ipa_set_perf_level(hdd_ctx, 0, 0); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 9033 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 9034 | qdf_timer_stop(&hdd_ctx->bus_bw_timer); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 9035 | hdd_ctx->bus_bw_timer_running = false; |
| 9036 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 9037 | hdd_reset_tcp_delack(hdd_ctx); |
| 9038 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9039 | } |
| 9040 | #endif |
| 9041 | |
| 9042 | /** |
| 9043 | * wlan_hdd_check_custom_con_channel_rules() - This function checks the sap's |
| 9044 | * and sta's operating channel. |
| 9045 | * @sta_adapter: Describe the first argument to foobar. |
| 9046 | * @ap_adapter: Describe the second argument to foobar. |
| 9047 | * @roam_profile: Roam profile of AP to which STA wants to connect. |
| 9048 | * @concurrent_chnl_same: If both SAP and STA channels are same then |
| 9049 | * set this flag to true else false. |
| 9050 | * |
| 9051 | * This function checks the sap's operating channel and sta's operating channel. |
| 9052 | * if both are same then it will return false else it will restart the sap in |
| 9053 | * sta's channel and return true. |
| 9054 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9055 | * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9056 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9057 | 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] | 9058 | hdd_adapter_t *ap_adapter, |
| 9059 | tCsrRoamProfile *roam_profile, |
| 9060 | tScanResultHandle *scan_cache, |
| 9061 | bool *concurrent_chnl_same) |
| 9062 | { |
| 9063 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 9064 | uint8_t channel_id; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9065 | QDF_STATUS status; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9066 | enum tQDF_ADAPTER_MODE device_mode = ap_adapter->device_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9067 | *concurrent_chnl_same = true; |
| 9068 | |
| 9069 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 9070 | status = |
| 9071 | sme_get_ap_channel_from_scan_cache(WLAN_HDD_GET_HAL_CTX(sta_adapter), |
| 9072 | roam_profile, |
| 9073 | scan_cache, |
| 9074 | &channel_id); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9075 | if ((QDF_STATUS_SUCCESS == status)) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9076 | if ((QDF_SAP_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9077 | (channel_id < SIR_11A_CHANNEL_BEGIN)) { |
| 9078 | if (hdd_ap_ctx->operatingChannel != channel_id) { |
| 9079 | *concurrent_chnl_same = false; |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9080 | hdd_info("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9081 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9082 | } else if ((QDF_P2P_GO_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9083 | (channel_id >= SIR_11A_CHANNEL_BEGIN)) { |
| 9084 | if (hdd_ap_ctx->operatingChannel != channel_id) { |
| 9085 | *concurrent_chnl_same = false; |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9086 | hdd_info("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9087 | } |
| 9088 | } |
| 9089 | } else { |
| 9090 | /* |
| 9091 | * Lets handle worst case scenario here, Scan cache lookup is |
| 9092 | * failed so we have to stop the SAP to avoid any channel |
| 9093 | * discrepancy between SAP's channel and STA's channel. |
| 9094 | * Return the status as failure so caller function could know |
| 9095 | * that scan look up is failed. |
| 9096 | */ |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9097 | hdd_err("Finding AP from scan cache failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9098 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9099 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9100 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9101 | } |
| 9102 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9103 | /** |
| 9104 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 9105 | * @ap_adapter: SAP adapter |
| 9106 | * |
| 9107 | * This function will process the stopping of sap adapter. |
| 9108 | * |
| 9109 | * Return: None |
| 9110 | */ |
| 9111 | void wlan_hdd_stop_sap(hdd_adapter_t *ap_adapter) |
| 9112 | { |
| 9113 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 9114 | hdd_hostapd_state_t *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 9115 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9116 | hdd_context_t *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9117 | |
| 9118 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9119 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9120 | return; |
| 9121 | } |
| 9122 | |
| 9123 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 9124 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 9125 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9126 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 9127 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9128 | mutex_lock(&hdd_ctx->sap_lock); |
| 9129 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 9130 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9131 | hdd_cleanup_actionframe(hdd_ctx, ap_adapter); |
| 9132 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9133 | hdd_info("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 9134 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9135 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9136 | sapContext)) { |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 9137 | qdf_status = qdf_wait_single_event(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 9138 | qdf_stop_bss_event, |
| 9139 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 9140 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9141 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9142 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9143 | return; |
| 9144 | } |
| 9145 | } |
| 9146 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | 4adb368 | 2016-01-07 15:07:12 -0800 | [diff] [blame] | 9147 | cds_decr_session_set_pcl(ap_adapter->device_mode, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9148 | ap_adapter->sessionId); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9149 | hdd_info("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9150 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9151 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9152 | } |
| 9153 | mutex_unlock(&hdd_ctx->sap_lock); |
| 9154 | return; |
| 9155 | } |
| 9156 | |
| 9157 | /** |
| 9158 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 9159 | * @ap_adapter: SAP adapter |
| 9160 | * |
| 9161 | * This function will process the starting of sap adapter. |
| 9162 | * |
| 9163 | * Return: None |
| 9164 | */ |
| 9165 | void wlan_hdd_start_sap(hdd_adapter_t *ap_adapter) |
| 9166 | { |
| 9167 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 9168 | hdd_hostapd_state_t *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 9169 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9170 | hdd_context_t *hdd_ctx; |
| 9171 | tsap_Config_t *sap_config; |
| 9172 | |
| 9173 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9174 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9175 | return; |
| 9176 | } |
| 9177 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9178 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 9179 | hdd_err("SoftAp role has not been enabled"); |
| 9180 | return; |
| 9181 | } |
| 9182 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9183 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 9184 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 9185 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 9186 | sap_config = &ap_adapter->sessionCtx.ap.sapConfig; |
| 9187 | |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 9188 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9189 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 9190 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9191 | mutex_lock(&hdd_ctx->sap_lock); |
| 9192 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 9193 | goto end; |
| 9194 | |
| 9195 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9196 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9197 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
| 9198 | goto end; |
| 9199 | } |
| 9200 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 9201 | qdf_event_reset(&hostapd_state->qdf_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9202 | if (wlansap_start_bss(hdd_ap_ctx->sapContext, hdd_hostapd_sap_event_cb, |
| 9203 | &hdd_ap_ctx->sapConfig, |
| 9204 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9205 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9206 | goto end; |
| 9207 | |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9208 | hdd_info("Waiting for SAP to start"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 9209 | qdf_status = qdf_wait_single_event(&hostapd_state->qdf_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 9210 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 9211 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9212 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9213 | goto end; |
| 9214 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9215 | hdd_info("SAP Start Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9216 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Krunal Soni | b37bb35 | 2016-12-20 14:12:21 -0800 | [diff] [blame] | 9217 | if (hostapd_state->bssState == BSS_START) |
| 9218 | cds_incr_active_session(ap_adapter->device_mode, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9219 | ap_adapter->sessionId); |
| 9220 | hostapd_state->bCommit = true; |
| 9221 | |
| 9222 | end: |
| 9223 | mutex_unlock(&hdd_ctx->sap_lock); |
| 9224 | return; |
| 9225 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9226 | |
| 9227 | /** |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 9228 | * wlan_hdd_soc_set_antenna_mode_cb() - Callback for set dual |
| 9229 | * mac scan config |
| 9230 | * @status: Status of set antenna mode |
| 9231 | * |
| 9232 | * Callback on setting the dual mac configuration |
| 9233 | * |
| 9234 | * Return: None |
| 9235 | */ |
| 9236 | void wlan_hdd_soc_set_antenna_mode_cb( |
| 9237 | enum set_antenna_mode_status status) |
| 9238 | { |
| 9239 | hdd_context_t *hdd_ctx; |
| 9240 | |
| 9241 | hdd_info("Status: %d", status); |
| 9242 | |
| 9243 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 9244 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 9245 | return; |
| 9246 | |
| 9247 | /* Signal the completion of set dual mac config */ |
| 9248 | complete(&hdd_ctx->set_antenna_mode_cmpl); |
| 9249 | } |
| 9250 | |
| 9251 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9252 | * hdd_get_fw_version() - Get FW version |
| 9253 | * @hdd_ctx: pointer to HDD context. |
| 9254 | * @major_spid: FW version - major spid. |
| 9255 | * @minor_spid: FW version - minor spid |
| 9256 | * @ssid: FW version - ssid |
| 9257 | * @crmid: FW version - crmid |
| 9258 | * |
| 9259 | * This function is called to get the firmware build version stored |
| 9260 | * as part of the HDD context |
| 9261 | * |
| 9262 | * Return: None |
| 9263 | */ |
| 9264 | void hdd_get_fw_version(hdd_context_t *hdd_ctx, |
| 9265 | uint32_t *major_spid, uint32_t *minor_spid, |
| 9266 | uint32_t *siid, uint32_t *crmid) |
| 9267 | { |
| 9268 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 9269 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 9270 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 9271 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 9272 | } |
| 9273 | |
| 9274 | #ifdef QCA_CONFIG_SMP |
| 9275 | /** |
| 9276 | * wlan_hdd_get_cpu() - get cpu_index |
| 9277 | * |
| 9278 | * Return: cpu_index |
| 9279 | */ |
| 9280 | int wlan_hdd_get_cpu(void) |
| 9281 | { |
| 9282 | int cpu_index = get_cpu(); |
| 9283 | put_cpu(); |
| 9284 | return cpu_index; |
| 9285 | } |
| 9286 | #endif |
| 9287 | |
| 9288 | /** |
| 9289 | * hdd_get_fwpath() - get framework path |
| 9290 | * |
| 9291 | * This function is used to get the string written by |
| 9292 | * userspace to start the wlan driver |
| 9293 | * |
| 9294 | * Return: string |
| 9295 | */ |
| 9296 | const char *hdd_get_fwpath(void) |
| 9297 | { |
| 9298 | return fwpath.string; |
| 9299 | } |
| 9300 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9301 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9302 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9303 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9304 | * This function initilizes CDS global context with the help of cds_init. This |
| 9305 | * has to be the first function called after probe to get a valid global |
| 9306 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9307 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9308 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9309 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9310 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9311 | { |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9312 | v_CONTEXT_t p_cds_context = NULL; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9313 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9314 | |
Houston Hoffman | 9e06e54 | 2016-12-12 12:06:26 -0800 | [diff] [blame] | 9315 | p_cds_context = cds_init(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9316 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9317 | wlan_logging_sock_init_svc(); |
| 9318 | #endif |
| 9319 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9320 | if (p_cds_context == NULL) { |
| 9321 | hdd_alert("Failed to allocate CDS context"); |
| 9322 | ret = -ENOMEM; |
| 9323 | goto err_out; |
| 9324 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9325 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9326 | hdd_trace_init(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 9327 | hdd_register_debug_callback(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9328 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9329 | err_out: |
| 9330 | return ret; |
| 9331 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9332 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9333 | /** |
| 9334 | * hdd_deinit() - Deinitialize Driver |
| 9335 | * |
| 9336 | * This function frees CDS global context with the help of cds_deinit. This |
| 9337 | * has to be the last function call in remove callback to free the global |
| 9338 | * context. |
| 9339 | */ |
| 9340 | void hdd_deinit(void) |
| 9341 | { |
| 9342 | cds_deinit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9343 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9344 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9345 | wlan_logging_sock_deinit_svc(); |
| 9346 | #endif |
| 9347 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9348 | |
| 9349 | #ifdef QCA_WIFI_3_0_ADRASTEA |
| 9350 | #define HDD_WLAN_START_WAIT_TIME (3600 * 1000) |
| 9351 | #else |
| 9352 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
| 9353 | #endif |
| 9354 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9355 | /** |
| 9356 | * __hdd_module_init - Module init helper |
| 9357 | * |
| 9358 | * Module init helper function used by both module and static driver. |
| 9359 | * |
| 9360 | * Return: 0 for success, errno on failure |
| 9361 | */ |
| 9362 | static int __hdd_module_init(void) |
| 9363 | { |
| 9364 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9365 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9366 | pr_err("%s: Loading driver v%s\n", WLAN_MODULE_NAME, |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9367 | QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9368 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 9369 | pld_init(); |
| 9370 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 9371 | ret = hdd_init(); |
| 9372 | if (ret) { |
| 9373 | pr_err("hdd_init failed %x\n", ret); |
| 9374 | goto err_hdd_init; |
| 9375 | } |
| 9376 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 9377 | dispatcher_init(); |
| 9378 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 9379 | qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9380 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9381 | hdd_set_conparam((uint32_t) con_mode); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9382 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9383 | ret = wlan_hdd_register_driver(); |
| 9384 | if (ret) { |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 9385 | pr_err("%s: driver load failure, err %d\n", WLAN_MODULE_NAME, |
| 9386 | ret); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9387 | goto out; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9388 | } |
| 9389 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 9390 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9391 | |
| 9392 | return 0; |
| 9393 | out: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 9394 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 9395 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 9396 | hdd_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 9397 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 9398 | err_hdd_init: |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 9399 | pld_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 9400 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9401 | return ret; |
| 9402 | } |
| 9403 | |
| 9404 | /** |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 9405 | * hdd_wait_for_recovery_completion() - Wait for cds recovery completion |
| 9406 | * |
| 9407 | * Block the unloading of the driver until the cds recovery is completed |
| 9408 | * |
| 9409 | * Return: None |
| 9410 | */ |
| 9411 | static void hdd_wait_for_recovery_completion(void) |
| 9412 | { |
| 9413 | int retry = 0; |
| 9414 | |
| 9415 | /* Wait for recovery to complete */ |
| 9416 | while (cds_is_driver_recovering()) { |
| 9417 | hdd_alert("Recovery in progress; wait here!!!"); |
| 9418 | msleep(1000); |
| 9419 | if (retry++ == HDD_MOD_EXIT_SSR_MAX_RETRIES) { |
| 9420 | hdd_alert("SSR never completed, fatal error"); |
| 9421 | QDF_BUG(0); |
| 9422 | } |
| 9423 | } |
| 9424 | } |
| 9425 | |
| 9426 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9427 | * __hdd_module_exit - Module exit helper |
| 9428 | * |
| 9429 | * Module exit helper function used by both module and static driver. |
| 9430 | */ |
| 9431 | static void __hdd_module_exit(void) |
| 9432 | { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 9433 | int qdf_print_idx = -1; |
| 9434 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9435 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 9436 | QWLAN_VERSIONSTR); |
| 9437 | |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 9438 | hdd_wait_for_recovery_completion(); |
| 9439 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9440 | wlan_hdd_unregister_driver(); |
| 9441 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 9442 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9443 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 9444 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 9445 | hdd_deinit(); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 9446 | pld_deinit(); |
| 9447 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 9448 | qdf_print_idx = qdf_get_pidx(); |
| 9449 | qdf_print_ctrl_cleanup(qdf_print_idx); |
| 9450 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9451 | return; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9452 | } |
| 9453 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9454 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9455 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9456 | * wlan_boot_cb() - Wlan boot callback |
| 9457 | * @kobj: object whose directory we're creating the link in. |
| 9458 | * @attr: attribute the user is interacting with |
| 9459 | * @buff: the buffer containing the user data |
| 9460 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9461 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9462 | * This callback is invoked when the fs is ready to start the |
| 9463 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9464 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9465 | * 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] | 9466 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9467 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 9468 | struct kobj_attribute *attr, |
| 9469 | const char *buf, |
| 9470 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9471 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9472 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9473 | if (wlan_loader->loaded_state) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 9474 | pr_err("%s: wlan driver already initialized\n", __func__); |
| 9475 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9476 | } |
| 9477 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9478 | if (__hdd_module_init()) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 9479 | pr_err("%s: wlan driver initialization failed\n", __func__); |
| 9480 | return -EIO; |
| 9481 | } |
| 9482 | |
| 9483 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9484 | |
| 9485 | return count; |
| 9486 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9487 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9488 | |
| 9489 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 9490 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 9491 | * |
| 9492 | * Return: None |
| 9493 | * |
| 9494 | */ |
| 9495 | static void hdd_sysfs_cleanup(void) |
| 9496 | { |
| 9497 | |
| 9498 | /* remove from group */ |
| 9499 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 9500 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 9501 | wlan_loader->attr_group); |
| 9502 | |
| 9503 | /* unlink the object from parent */ |
| 9504 | kobject_del(wlan_loader->boot_wlan_obj); |
| 9505 | |
| 9506 | /* free the object */ |
| 9507 | kobject_put(wlan_loader->boot_wlan_obj); |
| 9508 | |
| 9509 | kfree(wlan_loader->attr_group); |
| 9510 | kfree(wlan_loader); |
| 9511 | |
| 9512 | wlan_loader = NULL; |
| 9513 | } |
| 9514 | |
| 9515 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9516 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 9517 | * ready |
| 9518 | * |
| 9519 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 9520 | * when the filesystem is ready. |
| 9521 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 9522 | * QDF API cannot be used here since this function is called even before |
| 9523 | * initializing WLAN driver. |
| 9524 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 9525 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9526 | */ |
| 9527 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9528 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 9529 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9530 | |
| 9531 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
| 9532 | if (!wlan_loader) { |
| 9533 | pr_err("%s: memory alloc failed\n", __func__); |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 9534 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9535 | } |
| 9536 | |
| 9537 | wlan_loader->boot_wlan_obj = NULL; |
| 9538 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 9539 | GFP_KERNEL); |
| 9540 | if (!wlan_loader->attr_group) { |
| 9541 | pr_err("%s: malloc attr_group failed\n", __func__); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9542 | goto error_return; |
| 9543 | } |
| 9544 | |
| 9545 | wlan_loader->loaded_state = 0; |
| 9546 | wlan_loader->attr_group->attrs = attrs; |
| 9547 | |
| 9548 | wlan_loader->boot_wlan_obj = kobject_create_and_add("boot_wlan", |
| 9549 | kernel_kobj); |
| 9550 | if (!wlan_loader->boot_wlan_obj) { |
| 9551 | pr_err("%s: sysfs create and add failed\n", __func__); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9552 | goto error_return; |
| 9553 | } |
| 9554 | |
| 9555 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 9556 | wlan_loader->attr_group); |
| 9557 | if (ret) { |
| 9558 | pr_err("%s: sysfs create group failed %d\n", __func__, ret); |
| 9559 | goto error_return; |
| 9560 | } |
| 9561 | |
| 9562 | return 0; |
| 9563 | |
| 9564 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 9565 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9566 | |
| 9567 | return ret; |
| 9568 | } |
| 9569 | |
| 9570 | /** |
| 9571 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 9572 | * |
| 9573 | * Return: 0 on success or errno on failure |
| 9574 | */ |
| 9575 | static int wlan_deinit_sysfs(void) |
| 9576 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9577 | if (!wlan_loader) { |
| 9578 | hdd_alert("wlan loader context is Null!"); |
| 9579 | return -EINVAL; |
| 9580 | } |
| 9581 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 9582 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9583 | return 0; |
| 9584 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9585 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 9586 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9587 | |
| 9588 | #ifdef MODULE |
| 9589 | /** |
| 9590 | * __hdd_module_init - Module init helper |
| 9591 | * |
| 9592 | * Module init helper function used by both module and static driver. |
| 9593 | * |
| 9594 | * Return: 0 for success, errno on failure |
| 9595 | */ |
| 9596 | static int hdd_module_init(void) |
| 9597 | { |
| 9598 | int ret = 0; |
| 9599 | |
| 9600 | pr_err("%s: Loading driver v%s\n", WLAN_MODULE_NAME, |
| 9601 | QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
| 9602 | |
| 9603 | if (__hdd_module_init()) { |
| 9604 | pr_err("%s: Failed to register handler\n", __func__); |
| 9605 | ret = -EINVAL; |
| 9606 | } |
| 9607 | |
| 9608 | return ret; |
| 9609 | } |
| 9610 | #else |
| 9611 | static int __init hdd_module_init(void) |
| 9612 | { |
| 9613 | int ret = -EINVAL; |
| 9614 | |
| 9615 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 9616 | if (ret) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9617 | pr_err("Failed to create sysfs entry for loading wlan"); |
| 9618 | |
| 9619 | return ret; |
| 9620 | } |
| 9621 | #endif |
| 9622 | |
| 9623 | |
| 9624 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9625 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9626 | * hdd_module_exit() - Exit function |
| 9627 | * |
| 9628 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 9629 | * |
| 9630 | * Return: None |
| 9631 | */ |
| 9632 | static void __exit hdd_module_exit(void) |
| 9633 | { |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9634 | __hdd_module_exit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9635 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9636 | #else |
| 9637 | static void __exit hdd_module_exit(void) |
| 9638 | { |
| 9639 | __hdd_module_exit(); |
| 9640 | wlan_deinit_sysfs(); |
| 9641 | } |
| 9642 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9643 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9644 | static int fwpath_changed_handler(const char *kmessage, struct kernel_param *kp) |
| 9645 | { |
| 9646 | return param_set_copystring(kmessage, kp); |
| 9647 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9648 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9649 | /** |
| 9650 | * is_con_mode_valid() check con mode is valid or not |
| 9651 | * @mode: global con mode |
| 9652 | * |
| 9653 | * Return: TRUE on success FALSE on failure |
| 9654 | */ |
| 9655 | static bool is_con_mode_valid(enum tQDF_GLOBAL_CON_MODE mode) |
| 9656 | { |
| 9657 | switch (mode) { |
| 9658 | case QDF_GLOBAL_MONITOR_MODE: |
| 9659 | case QDF_GLOBAL_FTM_MODE: |
| 9660 | case QDF_GLOBAL_EPPING_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9661 | case QDF_GLOBAL_MISSION_MODE: |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9662 | return true; |
| 9663 | default: |
| 9664 | return false; |
| 9665 | } |
| 9666 | } |
| 9667 | |
| 9668 | /** |
| 9669 | * hdd_get_adpter_mode() - returns adapter mode based on global con mode |
| 9670 | * @mode: global con mode |
| 9671 | * |
| 9672 | * Return: adapter mode |
| 9673 | */ |
| 9674 | static enum tQDF_ADAPTER_MODE hdd_get_adpter_mode( |
| 9675 | enum tQDF_GLOBAL_CON_MODE mode) |
| 9676 | { |
| 9677 | |
| 9678 | switch (mode) { |
| 9679 | case QDF_GLOBAL_MISSION_MODE: |
| 9680 | return QDF_STA_MODE; |
| 9681 | case QDF_GLOBAL_MONITOR_MODE: |
| 9682 | return QDF_MONITOR_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9683 | case QDF_GLOBAL_EPPING_MODE: |
| 9684 | return QDF_EPPING_MODE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9685 | case QDF_GLOBAL_FTM_MODE: |
| 9686 | return QDF_FTM_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9687 | case QDF_GLOBAL_QVIT_MODE: |
| 9688 | return QDF_QVIT_MODE; |
| 9689 | default: |
| 9690 | return QDF_MAX_NO_OF_MODE; |
| 9691 | } |
| 9692 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9693 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9694 | static void hdd_cleanup_present_mode(hdd_context_t *hdd_ctx, |
| 9695 | enum tQDF_GLOBAL_CON_MODE curr_mode) |
| 9696 | { |
| 9697 | switch (curr_mode) { |
| 9698 | case QDF_GLOBAL_MISSION_MODE: |
| 9699 | case QDF_GLOBAL_MONITOR_MODE: |
| 9700 | case QDF_GLOBAL_FTM_MODE: |
| 9701 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
| 9702 | hdd_stop_all_adapters(hdd_ctx); |
| 9703 | hdd_deinit_all_adapters(hdd_ctx, false); |
| 9704 | hdd_close_all_adapters(hdd_ctx, false); |
| 9705 | break; |
| 9706 | case QDF_GLOBAL_EPPING_MODE: |
| 9707 | epping_disable(); |
| 9708 | epping_close(); |
| 9709 | break; |
| 9710 | default: |
| 9711 | return; |
| 9712 | } |
| 9713 | } |
| 9714 | |
| 9715 | static int hdd_register_req_mode(hdd_context_t *hdd_ctx, |
| 9716 | enum tQDF_GLOBAL_CON_MODE mode) |
| 9717 | { |
| 9718 | hdd_adapter_t *adapter; |
| 9719 | int ret = 0; |
| 9720 | bool rtnl_held; |
| 9721 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 9722 | QDF_STATUS status; |
| 9723 | |
| 9724 | if (!qdf_dev) { |
| 9725 | hdd_err("qdf device context is Null return!"); |
| 9726 | return -EINVAL; |
| 9727 | } |
| 9728 | |
| 9729 | rtnl_held = hdd_hold_rtnl_lock(); |
| 9730 | switch (mode) { |
| 9731 | case QDF_GLOBAL_MISSION_MODE: |
| 9732 | adapter = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 9733 | if (IS_ERR(adapter)) { |
| 9734 | hdd_alert("Failed to open interface, adapter is NULL"); |
| 9735 | ret = -EINVAL; |
| 9736 | } |
| 9737 | break; |
| 9738 | case QDF_GLOBAL_FTM_MODE: |
| 9739 | adapter = hdd_open_adapter(hdd_ctx, QDF_FTM_MODE, "wlan%d", |
| 9740 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 9741 | NET_NAME_UNKNOWN, rtnl_held); |
| 9742 | if (adapter == NULL) |
| 9743 | ret = -EINVAL; |
| 9744 | break; |
| 9745 | case QDF_GLOBAL_MONITOR_MODE: |
| 9746 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
| 9747 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 9748 | NET_NAME_UNKNOWN, rtnl_held); |
| 9749 | if (adapter == NULL) |
| 9750 | ret = -EINVAL; |
| 9751 | break; |
| 9752 | case QDF_GLOBAL_EPPING_MODE: |
| 9753 | status = epping_open(); |
| 9754 | if (status != QDF_STATUS_SUCCESS) { |
| 9755 | hdd_err("Failed to open in eeping mode: %d", status); |
| 9756 | ret = -EINVAL; |
| 9757 | break; |
| 9758 | } |
| 9759 | ret = epping_enable(qdf_dev->dev); |
| 9760 | if (ret) { |
| 9761 | hdd_err("Failed to enable in epping mode : %d", ret); |
| 9762 | epping_close(); |
| 9763 | } |
| 9764 | break; |
| 9765 | default: |
| 9766 | hdd_info("Mode not supported"); |
| 9767 | ret = -ENOTSUPP; |
| 9768 | break; |
| 9769 | } |
| 9770 | hdd_release_rtnl_lock(); |
| 9771 | rtnl_held = false; |
| 9772 | return ret; |
| 9773 | } |
| 9774 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9775 | /** |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 9776 | * __con_mode_handler() - Handles module param con_mode change |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9777 | * @kmessage: con mode name on which driver to be bring up |
| 9778 | * @kp: The associated kernel parameter |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 9779 | * @hdd_ctx: Pointer to the global HDD context |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9780 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9781 | * This function is invoked when user updates con mode using sys entry, |
| 9782 | * to initialize and bring-up driver in that specific mode. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9783 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9784 | * Return - 0 on success and failure code on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9785 | */ |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9786 | static int __con_mode_handler(const char *kmessage, struct kernel_param *kp, |
| 9787 | hdd_context_t *hdd_ctx) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9788 | { |
| 9789 | int ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9790 | hdd_adapter_t *adapter; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9791 | enum tQDF_GLOBAL_CON_MODE curr_mode; |
| 9792 | enum tQDF_ADAPTER_MODE adapter_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9793 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 9794 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9795 | if (ret) |
| 9796 | return ret; |
| 9797 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9798 | cds_set_load_in_progress(true); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9799 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9800 | hdd_info("con_mode handler: %s", kmessage); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9801 | ret = param_set_int(kmessage, kp); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9802 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9803 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9804 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9805 | if (!(is_con_mode_valid(con_mode))) { |
| 9806 | hdd_err("invlaid con_mode %d", con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9807 | ret = -EINVAL; |
| 9808 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9809 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9810 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9811 | curr_mode = hdd_get_conparam(); |
| 9812 | if (curr_mode == con_mode) { |
| 9813 | hdd_err("curr mode: %d is same as user triggered mode %d", |
| 9814 | curr_mode, con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9815 | ret = 0; |
| 9816 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9817 | } |
| 9818 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9819 | /* Cleanup present mode before switching to new mode */ |
| 9820 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 9821 | |
Prashanth Bhatta | 2ac92bd | 2016-10-11 16:08:00 -0700 | [diff] [blame] | 9822 | ret = hdd_wlan_stop_modules(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9823 | if (ret) { |
| 9824 | hdd_err("Stop wlan modules failed"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9825 | goto reset_flags; |
| 9826 | } |
| 9827 | |
| 9828 | hdd_set_conparam(con_mode); |
| 9829 | |
| 9830 | /* Register for new con_mode & then kick_start modules again */ |
| 9831 | ret = hdd_register_req_mode(hdd_ctx, con_mode); |
| 9832 | if (ret) { |
| 9833 | hdd_err("Failed to register for new mode"); |
| 9834 | goto reset_flags; |
| 9835 | } |
| 9836 | |
| 9837 | adapter_mode = hdd_get_adpter_mode(con_mode); |
| 9838 | if (adapter_mode == QDF_MAX_NO_OF_MODE) { |
| 9839 | hdd_err("invalid adapter"); |
| 9840 | ret = -EINVAL; |
| 9841 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9842 | } |
| 9843 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9844 | adapter = hdd_get_adapter(hdd_ctx, adapter_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9845 | if (!adapter) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9846 | hdd_err("Failed to get adapter:%d", adapter_mode); |
| 9847 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9848 | } |
| 9849 | |
| 9850 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 9851 | if (ret) { |
| 9852 | hdd_err("Start wlan modules failed: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9853 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9854 | } |
| 9855 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9856 | if (con_mode == QDF_GLOBAL_MONITOR_MODE || |
| 9857 | con_mode == QDF_GLOBAL_FTM_MODE) { |
| 9858 | if (hdd_start_adapter(adapter)) { |
| 9859 | hdd_err("Failed to start %s adapter", kmessage); |
| 9860 | ret = -EINVAL; |
| 9861 | goto reset_flags; |
| 9862 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9863 | } |
| 9864 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9865 | hdd_info("Mode successfully changed to %s", kmessage); |
| 9866 | ret = 0; |
| 9867 | |
| 9868 | reset_flags: |
| 9869 | cds_set_load_in_progress(false); |
| 9870 | return ret; |
| 9871 | } |
| 9872 | |
| 9873 | |
| 9874 | static int con_mode_handler(const char *kmessage, struct kernel_param *kp) |
| 9875 | { |
| 9876 | int ret; |
| 9877 | hdd_context_t *hdd_ctx; |
| 9878 | |
| 9879 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 9880 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9881 | if (ret) |
| 9882 | return ret; |
| 9883 | |
| 9884 | cds_ssr_protect(__func__); |
| 9885 | ret = __con_mode_handler(kmessage, kp, hdd_ctx); |
| 9886 | cds_ssr_unprotect(__func__); |
| 9887 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9888 | return ret; |
| 9889 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9890 | |
| 9891 | /** |
| 9892 | * hdd_get_conparam() - driver exit point |
| 9893 | * |
| 9894 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 9895 | * |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9896 | * Return: enum tQDF_GLOBAL_CON_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9897 | */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9898 | enum tQDF_GLOBAL_CON_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9899 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9900 | return (enum tQDF_GLOBAL_CON_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9901 | } |
| 9902 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 9903 | void hdd_set_conparam(uint32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9904 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 9905 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9906 | } |
| 9907 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 9908 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 9909 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 9910 | * @hdd_ctx: HDD context |
| 9911 | * |
| 9912 | * Cleans up the pre cac interface, if it exists |
| 9913 | * |
| 9914 | * Return: None |
| 9915 | */ |
| 9916 | void hdd_clean_up_pre_cac_interface(hdd_context_t *hdd_ctx) |
| 9917 | { |
| 9918 | uint8_t session_id; |
| 9919 | QDF_STATUS status; |
| 9920 | struct hdd_adapter_s *precac_adapter; |
| 9921 | |
| 9922 | status = wlan_sap_get_pre_cac_vdev_id(hdd_ctx->hHal, &session_id); |
| 9923 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9924 | hdd_err("failed to get pre cac vdev id"); |
| 9925 | return; |
| 9926 | } |
| 9927 | |
| 9928 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, session_id); |
| 9929 | if (!precac_adapter) { |
| 9930 | hdd_err("invalid pre cac adapater"); |
| 9931 | return; |
| 9932 | } |
| 9933 | |
| 9934 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 9935 | wlan_hdd_sap_pre_cac_failure, |
| 9936 | (void *)precac_adapter); |
| 9937 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 9938 | |
| 9939 | } |
| 9940 | |
| 9941 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9942 | * hdd_update_ol_config - API to update ol configuration parameters |
| 9943 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 9944 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 9945 | * Return: void |
| 9946 | */ |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9947 | static void hdd_update_ol_config(hdd_context_t *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 9948 | { |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9949 | struct ol_config_info cfg; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 9950 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 9951 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9952 | if (!ol_ctx) |
| 9953 | return; |
| 9954 | |
| 9955 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
| 9956 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 9957 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 9958 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 9959 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9960 | |
| 9961 | ol_init_ini_config(ol_ctx, &cfg); |
| 9962 | } |
| 9963 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 9964 | #ifdef FEATURE_RUNTIME_PM |
| 9965 | /** |
| 9966 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 9967 | * @hdd_ctx: hdd context |
| 9968 | * @cfg: pointer to the configuration memory being populated |
| 9969 | * |
| 9970 | * Return: void |
| 9971 | */ |
| 9972 | static void hdd_populate_runtime_cfg(hdd_context_t *hdd_ctx, |
| 9973 | struct hif_config_info *cfg) |
| 9974 | { |
| 9975 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
| 9976 | cfg->runtime_pm_delay = hdd_ctx->config->runtime_pm_delay; |
| 9977 | } |
| 9978 | #else |
| 9979 | static void hdd_populate_runtime_cfg(hdd_context_t *hdd_ctx, |
| 9980 | struct hif_config_info *cfg) |
| 9981 | { |
| 9982 | } |
| 9983 | #endif |
| 9984 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9985 | /** |
| 9986 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 9987 | * @hdd_ctx: HDD Context |
| 9988 | * |
| 9989 | * Return: void |
| 9990 | */ |
| 9991 | static void hdd_update_hif_config(hdd_context_t *hdd_ctx) |
| 9992 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 9993 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9994 | struct hif_config_info cfg; |
| 9995 | |
| 9996 | if (!scn) |
| 9997 | return; |
| 9998 | |
| 9999 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 10000 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 10001 | hif_init_ini_config(scn, &cfg); |
| 10002 | } |
| 10003 | |
| 10004 | /** |
| 10005 | * hdd_update_config() - Initialize driver per module ini parameters |
| 10006 | * @hdd_ctx: HDD Context |
| 10007 | * |
| 10008 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 10009 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 10010 | */ |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 10011 | int hdd_update_config(hdd_context_t *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 10012 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 10013 | int ret; |
| 10014 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 10015 | hdd_update_ol_config(hdd_ctx); |
| 10016 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 10017 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 10018 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 10019 | else |
| 10020 | ret = hdd_update_cds_config(hdd_ctx); |
| 10021 | |
| 10022 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 10023 | } |
| 10024 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 10025 | /** |
| 10026 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 10027 | * @mode : cfg80211 DFS mode |
| 10028 | * |
| 10029 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 10030 | */ |
| 10031 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 10032 | { |
| 10033 | switch (mode) { |
| 10034 | case DFS_MODE_ENABLE: |
| 10035 | return ACS_DFS_MODE_ENABLE; |
| 10036 | break; |
| 10037 | case DFS_MODE_DISABLE: |
| 10038 | return ACS_DFS_MODE_DISABLE; |
| 10039 | break; |
| 10040 | case DFS_MODE_DEPRIORITIZE: |
| 10041 | return ACS_DFS_MODE_DEPRIORITIZE; |
| 10042 | break; |
| 10043 | default: |
| 10044 | hdd_err("ACS dfs mode is NONE"); |
| 10045 | return ACS_DFS_MODE_NONE; |
| 10046 | } |
| 10047 | } |
| 10048 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 10049 | /** |
| 10050 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 10051 | * @hddctx: pointer to hdd context |
| 10052 | * @set_value: enable/disable |
| 10053 | * |
| 10054 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 10055 | * Host(even though it is duplicate). When Host send vendor command |
| 10056 | * disable,FW doesn't perform any action. Whenever any change in |
| 10057 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 10058 | * |
| 10059 | * return - 0 on success, appropriate error values on failure. |
| 10060 | */ |
| 10061 | int hdd_enable_disable_ca_event(hdd_context_t *hddctx, uint8_t set_value) |
| 10062 | { |
| 10063 | QDF_STATUS status; |
| 10064 | |
| 10065 | if (0 != wlan_hdd_validate_context(hddctx)) { |
| 10066 | return -EAGAIN; |
| 10067 | } |
| 10068 | |
| 10069 | if (!hddctx->config->goptimize_chan_avoid_event) { |
| 10070 | hdd_warn("goptimize_chan_avoid_event ini param disabled"); |
| 10071 | return -EINVAL; |
| 10072 | } |
| 10073 | |
| 10074 | status = sme_enable_disable_chanavoidind_event(hddctx->hHal, set_value); |
| 10075 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10076 | hdd_err("Failed to send chan avoid command to SME"); |
| 10077 | return -EINVAL; |
| 10078 | } |
| 10079 | return 0; |
| 10080 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 10081 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 10082 | /** |
| 10083 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 10084 | * @value: value to set |
| 10085 | * |
| 10086 | * This function will set the passed value to roaming in progress flag. |
| 10087 | * |
| 10088 | * Return: None |
| 10089 | */ |
| 10090 | void hdd_set_roaming_in_progress(bool value) |
| 10091 | { |
| 10092 | hdd_context_t *hdd_ctx; |
| 10093 | |
| 10094 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10095 | if (!hdd_ctx) { |
| 10096 | hdd_err("HDD context is NULL"); |
| 10097 | return; |
| 10098 | } |
| 10099 | |
| 10100 | hdd_ctx->roaming_in_progress = value; |
| 10101 | hdd_info("Roaming in Progress set to %d", value); |
| 10102 | } |
| 10103 | |
| 10104 | /** |
| 10105 | * hdd_is_roaming_in_progress() - check if roaming is in progress |
| 10106 | * @hdd_ctx - HDD context |
| 10107 | * |
| 10108 | * Return: true if roaming is in progress else false |
| 10109 | */ |
| 10110 | bool hdd_is_roaming_in_progress(void) |
| 10111 | { |
| 10112 | hdd_context_t *hdd_ctx; |
| 10113 | |
| 10114 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10115 | if (!hdd_ctx) { |
| 10116 | hdd_err("HDD context is NULL"); |
| 10117 | return false; |
| 10118 | } |
| 10119 | return hdd_ctx->roaming_in_progress; |
| 10120 | } |
| 10121 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10122 | /* Register the module init/exit functions */ |
| 10123 | module_init(hdd_module_init); |
| 10124 | module_exit(hdd_module_exit); |
| 10125 | |
| 10126 | MODULE_LICENSE("Dual BSD/GPL"); |
| 10127 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 10128 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 10129 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10130 | module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode, |
| 10131 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10132 | |
| 10133 | module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath, |
| 10134 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 10135 | |
| 10136 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 10137 | |
| 10138 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 10139 | |
| 10140 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |