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> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 60 | |
| 61 | #include <net/addrconf.h> |
| 62 | #include <linux/wireless.h> |
| 63 | #include <net/cfg80211.h> |
| 64 | #include <linux/inetdevice.h> |
| 65 | #include <net/addrconf.h> |
| 66 | #include "wlan_hdd_cfg80211.h" |
| 67 | #include "wlan_hdd_ext_scan.h" |
| 68 | #include "wlan_hdd_p2p.h" |
| 69 | #include <linux/rtnetlink.h> |
| 70 | #include "sap_api.h" |
| 71 | #include <linux/semaphore.h> |
| 72 | #include <linux/ctype.h> |
| 73 | #include <linux/compat.h> |
| 74 | #ifdef MSM_PLATFORM |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 75 | #include <soc/qcom/subsystem_restart.h> |
| 76 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 77 | #include <wlan_hdd_hostapd.h> |
| 78 | #include <wlan_hdd_softap_tx_rx.h> |
| 79 | #include "cfg_api.h" |
| 80 | #include "qwlan_version.h" |
| 81 | #include "wma_types.h" |
| 82 | #include "wlan_hdd_tdls.h" |
| 83 | #ifdef FEATURE_WLAN_CH_AVOID |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 84 | #include "cds_regdomain.h" |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 85 | #include "cdp_txrx_flow_ctrl_v2.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 86 | #endif /* FEATURE_WLAN_CH_AVOID */ |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 87 | #include "pld_common.h" |
Tushnim Bhattacharyya | 15596cf | 2016-02-12 11:57:02 -0800 | [diff] [blame] | 88 | #include "wlan_hdd_ocb.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 89 | #include "wlan_hdd_nan.h" |
| 90 | #include "wlan_hdd_debugfs.h" |
| 91 | #include "wlan_hdd_driver_ops.h" |
| 92 | #include "epping_main.h" |
| 93 | #include "wlan_hdd_memdump.h" |
| 94 | |
| 95 | #include <wlan_hdd_ipa.h> |
| 96 | #include "hif.h" |
| 97 | #include "wma.h" |
| 98 | #include "cds_concurrency.h" |
Manikandan Mohan | dcc21ba | 2016-03-15 14:31:56 -0700 | [diff] [blame] | 99 | #include "wlan_hdd_tsf.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 100 | #include "wlan_hdd_green_ap.h" |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 101 | #include "bmi.h" |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 102 | #include <wlan_hdd_regulatory.h> |
Himanshu Agarwal | 11c874a | 2016-05-06 18:35:29 +0530 | [diff] [blame] | 103 | #include "ol_rx_fwd.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" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 110 | |
| 111 | #ifdef MODULE |
| 112 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 113 | #else |
| 114 | #define WLAN_MODULE_NAME "wlan" |
| 115 | #endif |
| 116 | |
| 117 | #ifdef TIMER_MANAGER |
| 118 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 119 | #else |
| 120 | #define TIMER_MANAGER_STR "" |
| 121 | #endif |
| 122 | |
| 123 | #ifdef MEMORY_DEBUG |
| 124 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 125 | #else |
| 126 | #define MEMORY_DEBUG_STR "" |
| 127 | #endif |
| 128 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 129 | #ifndef MODULE |
| 130 | static struct gwlan_loader *wlan_loader; |
| 131 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 132 | struct kobj_attribute *attr, |
| 133 | const char *buf, size_t count); |
| 134 | struct gwlan_loader { |
| 135 | bool loaded_state; |
| 136 | struct kobject *boot_wlan_obj; |
| 137 | struct attribute_group *attr_group; |
| 138 | }; |
| 139 | |
| 140 | static struct kobj_attribute wlan_boot_attribute = |
| 141 | __ATTR(boot_wlan, 0220, NULL, wlan_boot_cb); |
| 142 | |
| 143 | static struct attribute *attrs[] = { |
| 144 | &wlan_boot_attribute.attr, |
| 145 | NULL, |
| 146 | }; |
| 147 | |
| 148 | #define MODULE_INITIALIZED 1 |
| 149 | #endif |
| 150 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 151 | /* the Android framework expects this param even though we don't use it */ |
| 152 | #define BUF_LEN 20 |
| 153 | static char fwpath_buffer[BUF_LEN]; |
| 154 | static struct kparam_string fwpath = { |
| 155 | .string = fwpath_buffer, |
| 156 | .maxlen = BUF_LEN, |
| 157 | }; |
| 158 | |
| 159 | static char *country_code; |
| 160 | static int enable_11d = -1; |
| 161 | static int enable_dfs_chan_scan = -1; |
| 162 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 163 | /* |
| 164 | * spinlock for synchronizing asynchronous request/response |
| 165 | * (full description of use in wlan_hdd_main.h) |
| 166 | */ |
| 167 | DEFINE_SPINLOCK(hdd_context_lock); |
| 168 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 169 | #define WLAN_NLINK_CESIUM 30 |
| 170 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 171 | static qdf_wake_lock_t wlan_wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 172 | |
| 173 | #define WOW_MAX_FILTER_LISTS 1 |
| 174 | #define WOW_MAX_FILTERS_PER_LIST 4 |
| 175 | #define WOW_MIN_PATTERN_SIZE 6 |
| 176 | #define WOW_MAX_PATTERN_SIZE 64 |
| 177 | |
| 178 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 179 | static const struct wiphy_wowlan_support wowlan_support_reg_init = { |
| 180 | .flags = WIPHY_WOWLAN_ANY | |
| 181 | WIPHY_WOWLAN_MAGIC_PKT | |
| 182 | WIPHY_WOWLAN_DISCONNECT | |
| 183 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 184 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 185 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 186 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 187 | WIPHY_WOWLAN_RFKILL_RELEASE, |
| 188 | .n_patterns = WOW_MAX_FILTER_LISTS * WOW_MAX_FILTERS_PER_LIST, |
| 189 | .pattern_min_len = WOW_MIN_PATTERN_SIZE, |
| 190 | .pattern_max_len = WOW_MAX_PATTERN_SIZE, |
| 191 | }; |
| 192 | #endif |
| 193 | |
| 194 | /* internal function declaration */ |
| 195 | |
| 196 | struct sock *cesium_nl_srv_sock; |
| 197 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 198 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 199 | void wlan_hdd_auto_shutdown_cb(void); |
| 200 | #endif |
| 201 | |
| 202 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 203 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
| 204 | * @hdd_ctx: pointer to hdd_context_t |
| 205 | * |
| 206 | * Return: none |
| 207 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 208 | static void hdd_set_rps_cpu_mask(hdd_context_t *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 209 | { |
| 210 | hdd_adapter_t *adapter; |
| 211 | hdd_adapter_list_node_t *adapter_node, *next; |
| 212 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 213 | |
| 214 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 215 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 216 | adapter = adapter_node->pAdapter; |
| 217 | if (NULL != adapter) |
| 218 | hdd_send_rps_ind(adapter); |
| 219 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 220 | adapter_node = next; |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 225 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 226 | * @vdev_id: vdev_id |
| 227 | * @action: action type |
| 228 | * @reason: reason type |
| 229 | * |
| 230 | * Return: none |
| 231 | */ |
| 232 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 233 | enum netif_action_type action, enum netif_reason_type reason) |
| 234 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 235 | hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 236 | hdd_adapter_t *adapter; |
| 237 | |
| 238 | if (!hdd_ctx) { |
| 239 | hdd_err("hdd ctx is NULL"); |
| 240 | return; |
| 241 | } |
| 242 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 243 | |
| 244 | wlan_hdd_netif_queue_control(adapter, action, reason); |
| 245 | return; |
| 246 | } |
| 247 | |
| 248 | /* |
| 249 | * Store WLAN driver version info in a global variable such that crash debugger |
| 250 | * can extract it from driver debug symbol and crashdump for post processing |
| 251 | */ |
| 252 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR; |
| 253 | |
| 254 | /** |
| 255 | * hdd_device_mode_to_string() - return string conversion of device mode |
| 256 | * @device_mode: device mode |
| 257 | * |
| 258 | * This utility function helps log string conversion of device mode. |
| 259 | * |
| 260 | * Return: string conversion of device mode, if match found; |
| 261 | * "Unknown" otherwise. |
| 262 | */ |
| 263 | const char *hdd_device_mode_to_string(uint8_t device_mode) |
| 264 | { |
| 265 | switch (device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 266 | CASE_RETURN_STRING(QDF_STA_MODE); |
| 267 | CASE_RETURN_STRING(QDF_SAP_MODE); |
| 268 | CASE_RETURN_STRING(QDF_P2P_CLIENT_MODE); |
| 269 | CASE_RETURN_STRING(QDF_P2P_GO_MODE); |
| 270 | CASE_RETURN_STRING(QDF_FTM_MODE); |
| 271 | CASE_RETURN_STRING(QDF_IBSS_MODE); |
| 272 | CASE_RETURN_STRING(QDF_P2P_DEVICE_MODE); |
| 273 | CASE_RETURN_STRING(QDF_OCB_MODE); |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 274 | CASE_RETURN_STRING(QDF_NDI_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 275 | default: |
| 276 | return "Unknown"; |
| 277 | } |
| 278 | } |
| 279 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 280 | /** |
| 281 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 282 | * @adapter: HDD adapter |
| 283 | * @chan_number: Channel number |
| 284 | * @chan_bw: Bandwidth |
| 285 | * |
| 286 | * Checks if the given bandwidth is valid for the given channel number. |
| 287 | * |
| 288 | * Return: 0 for success, non-zero for failure |
| 289 | */ |
| 290 | int hdd_validate_channel_and_bandwidth(hdd_adapter_t *adapter, |
| 291 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 292 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 293 | { |
| 294 | uint8_t chan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 295 | uint32_t len = WNI_CFG_VALID_CHANNEL_LIST_LEN, i; |
| 296 | bool found = false; |
| 297 | tHalHandle hal; |
| 298 | |
| 299 | hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 300 | if (!hal) { |
| 301 | hdd_err("Invalid HAL context"); |
| 302 | return -EINVAL; |
| 303 | } |
| 304 | |
| 305 | if (0 != sme_cfg_get_str(hal, WNI_CFG_VALID_CHANNEL_LIST, chan, &len)) { |
| 306 | hdd_err("No valid channel list"); |
| 307 | return -EOPNOTSUPP; |
| 308 | } |
| 309 | |
| 310 | for (i = 0; i < len; i++) { |
| 311 | if (chan[i] == chan_number) { |
| 312 | found = true; |
| 313 | break; |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | if (found == false) { |
| 318 | hdd_err("Channel not in driver's valid channel list"); |
| 319 | return -EOPNOTSUPP; |
| 320 | } |
| 321 | |
| 322 | if ((!CDS_IS_CHANNEL_24GHZ(chan_number)) && |
| 323 | (!CDS_IS_CHANNEL_5GHZ(chan_number))) { |
| 324 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 325 | return -EINVAL; |
| 326 | } |
| 327 | |
| 328 | if (CDS_IS_CHANNEL_24GHZ(chan_number)) { |
| 329 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 330 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 331 | return -EINVAL; |
| 332 | } |
| 333 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 334 | (chan_bw != CH_WIDTH_MAX)) { |
| 335 | hdd_err("Only BW20 possible on channel 14"); |
| 336 | return -EINVAL; |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | if (CDS_IS_CHANNEL_5GHZ(chan_number)) { |
| 341 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 342 | (chan_bw != CH_WIDTH_MAX)) { |
| 343 | hdd_err("Only BW20 possible on channel 165"); |
| 344 | return -EINVAL; |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | return 0; |
| 349 | } |
| 350 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 351 | static int __hdd_netdev_notifier_call(struct notifier_block *nb, |
| 352 | unsigned long state, void *data) |
| 353 | { |
| 354 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 355 | struct netdev_notifier_info *dev_notif_info = data; |
| 356 | struct net_device *dev = dev_notif_info->dev; |
| 357 | #else |
| 358 | struct net_device *dev = data; |
| 359 | #endif |
| 360 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 361 | hdd_context_t *hdd_ctx; |
| 362 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 363 | ENTER_DEV(dev); |
| 364 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 365 | /* Make sure that this callback corresponds to our device. */ |
| 366 | if ((strncmp(dev->name, "wlan", 4)) && (strncmp(dev->name, "p2p", 3))) |
| 367 | return NOTIFY_DONE; |
| 368 | |
Samuel Ahn | c9c48ca | 2016-09-19 15:46:36 +0530 | [diff] [blame] | 369 | if ((adapter->magic != WLAN_HDD_ADAPTER_MAGIC) || |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 370 | (adapter->dev != dev)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 371 | hdd_err("device adapter is not matching!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 372 | return NOTIFY_DONE; |
| 373 | } |
| 374 | |
| 375 | if (!dev->ieee80211_ptr) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 376 | hdd_err("ieee80211_ptr is NULL!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 377 | return NOTIFY_DONE; |
| 378 | } |
| 379 | |
| 380 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 381 | if (NULL == hdd_ctx) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 382 | hdd_alert("HDD Context Null Pointer"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 383 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 384 | return NOTIFY_DONE; |
| 385 | } |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 386 | if (cds_is_driver_recovering()) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 387 | return NOTIFY_DONE; |
| 388 | |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 389 | hdd_notice("%s New Net Device State = %lu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 390 | dev->name, state); |
| 391 | |
| 392 | switch (state) { |
| 393 | case NETDEV_REGISTER: |
| 394 | break; |
| 395 | |
| 396 | case NETDEV_UNREGISTER: |
| 397 | break; |
| 398 | |
| 399 | case NETDEV_UP: |
| 400 | sme_ch_avoid_update_req(hdd_ctx->hHal); |
| 401 | break; |
| 402 | |
| 403 | case NETDEV_DOWN: |
| 404 | break; |
| 405 | |
| 406 | case NETDEV_CHANGE: |
| 407 | if (true == adapter->isLinkUpSvcNeeded) |
| 408 | complete(&adapter->linkup_event_var); |
| 409 | break; |
| 410 | |
| 411 | case NETDEV_GOING_DOWN: |
| 412 | if (adapter->scan_info.mScanPending != false) { |
| 413 | unsigned long rc; |
| 414 | INIT_COMPLETION(adapter->scan_info. |
| 415 | abortscan_event_var); |
| 416 | hdd_abort_mac_scan(adapter->pHddCtx, |
| 417 | adapter->sessionId, |
| 418 | eCSR_SCAN_ABORT_DEFAULT); |
| 419 | rc = wait_for_completion_timeout( |
| 420 | &adapter->scan_info.abortscan_event_var, |
| 421 | msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN)); |
| 422 | if (!rc) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 423 | hdd_err("Timeout occurred while waiting for abortscan"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 424 | } |
| 425 | } else { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 426 | hdd_notice("Scan is not Pending from user"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 427 | } |
| 428 | break; |
| 429 | |
| 430 | default: |
| 431 | break; |
| 432 | } |
| 433 | |
| 434 | return NOTIFY_DONE; |
| 435 | } |
| 436 | |
| 437 | /** |
| 438 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 439 | * @nb: pointer to notifier block |
| 440 | * @state: state |
| 441 | * @ndev: ndev pointer |
| 442 | * |
| 443 | * Return: 0 on success, error number otherwise. |
| 444 | */ |
| 445 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 446 | unsigned long state, |
| 447 | void *ndev) |
| 448 | { |
| 449 | int ret; |
| 450 | |
| 451 | cds_ssr_protect(__func__); |
| 452 | ret = __hdd_netdev_notifier_call(nb, state, ndev); |
| 453 | cds_ssr_unprotect(__func__); |
| 454 | |
| 455 | return ret; |
| 456 | } |
| 457 | |
| 458 | struct notifier_block hdd_netdev_notifier = { |
| 459 | .notifier_call = hdd_netdev_notifier_call, |
| 460 | }; |
| 461 | |
| 462 | /* variable to hold the insmod parameters */ |
| 463 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 464 | |
| 465 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 466 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 467 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 468 | /** |
| 469 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 470 | * @ch_width: NL channel width |
| 471 | * |
| 472 | * Converts the NL channel width to the driver's internal representation |
| 473 | * |
| 474 | * Return: Converted channel width. In case of non matching NL channel width, |
| 475 | * CH_WIDTH_MAX will be returned. |
| 476 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 477 | 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] | 478 | { |
| 479 | switch (ch_width) { |
| 480 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 481 | case NL80211_CHAN_WIDTH_20: |
| 482 | return CH_WIDTH_20MHZ; |
| 483 | case NL80211_CHAN_WIDTH_40: |
| 484 | return CH_WIDTH_40MHZ; |
| 485 | break; |
| 486 | case NL80211_CHAN_WIDTH_80: |
| 487 | return CH_WIDTH_80MHZ; |
| 488 | case NL80211_CHAN_WIDTH_80P80: |
| 489 | return CH_WIDTH_80P80MHZ; |
| 490 | case NL80211_CHAN_WIDTH_160: |
| 491 | return CH_WIDTH_160MHZ; |
| 492 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 493 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 494 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 495 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 496 | default: |
| 497 | hdd_err("Invalid channel width %d, setting to default", |
| 498 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 499 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 500 | } |
| 501 | } |
| 502 | |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 503 | /* wlan_hdd_find_opclass() - Find operating class for a channel |
| 504 | * @hal: handler to HAL |
| 505 | * @channel: channel id |
| 506 | * @bw_offset: bandwidth offset |
| 507 | * |
| 508 | * Function invokes sme api to find the operating class |
| 509 | * |
| 510 | * Return: operating class |
| 511 | */ |
| 512 | uint8_t wlan_hdd_find_opclass(tHalHandle hal, uint8_t channel, |
| 513 | uint8_t bw_offset) |
| 514 | { |
| 515 | uint8_t opclass = 0; |
| 516 | |
| 517 | sme_get_opclass(hal, channel, bw_offset, &opclass); |
| 518 | return opclass; |
| 519 | } |
| 520 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 521 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 522 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 523 | * @moduleId: Module whose trace level is being configured |
| 524 | * @bitmask: Bitmask of log levels to be enabled |
| 525 | * |
| 526 | * Called immediately after the cfg.ini is read in order to configure |
| 527 | * the desired trace levels. |
| 528 | * |
| 529 | * Return: None |
| 530 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 531 | 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] | 532 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 533 | QDF_TRACE_LEVEL level; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 534 | |
| 535 | /* |
| 536 | * if the bitmask is the default value, then a bitmask was not |
| 537 | * specified in cfg.ini, so leave the logging level alone (it |
| 538 | * will remain at the "compiled in" default value) |
| 539 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 540 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 541 | return; |
| 542 | } |
| 543 | |
| 544 | /* a mask was specified. start by disabling all logging */ |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 545 | qdf_trace_set_value(moduleId, QDF_TRACE_LEVEL_NONE, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 546 | |
| 547 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 548 | level = QDF_TRACE_LEVEL_FATAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 549 | while (0 != bitmask) { |
| 550 | if (bitmask & 1) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 551 | qdf_trace_set_value(moduleId, level, 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 552 | } |
| 553 | level++; |
| 554 | bitmask >>= 1; |
| 555 | } |
| 556 | } |
| 557 | |
| 558 | /** |
| 559 | * wlan_hdd_validate_context() - check the HDD context |
| 560 | * @hdd_ctx: HDD context pointer |
| 561 | * |
| 562 | * Return: 0 if the context is valid. Error code otherwise |
| 563 | */ |
| 564 | int wlan_hdd_validate_context(hdd_context_t *hdd_ctx) |
| 565 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 566 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 567 | hdd_err("%pS HDD context is Null", (void *)_RET_IP_); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 568 | return -ENODEV; |
| 569 | } |
| 570 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 571 | if (cds_is_driver_recovering()) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 572 | hdd_err("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
| 573 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 574 | return -EAGAIN; |
| 575 | } |
| 576 | |
Rajeev Kumar | fec3dbe | 2016-01-19 15:23:52 -0800 | [diff] [blame] | 577 | if (cds_is_load_or_unload_in_progress()) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 578 | hdd_err("%pS Unloading/Loading in Progress. Ignore!!!: 0x%x", |
| 579 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 580 | return -EAGAIN; |
| 581 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 582 | |
| 583 | if (hdd_ctx->start_modules_in_progress || |
| 584 | hdd_ctx->stop_modules_in_progress) { |
| 585 | hdd_err("%pS Start/Stop Modules in progress. Ignore!!!", |
| 586 | (void *)_RET_IP_); |
| 587 | return -EAGAIN; |
| 588 | } |
| 589 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 590 | return 0; |
| 591 | } |
| 592 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 593 | /** |
| 594 | * hdd_set_ibss_power_save_params() - update IBSS Power Save params to WMA. |
| 595 | * @hdd_adapter_t Hdd adapter. |
| 596 | * |
| 597 | * This function sets the IBSS power save config parameters to WMA |
| 598 | * which will send it to firmware if FW supports IBSS power save |
| 599 | * before vdev start. |
| 600 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 601 | * 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] | 602 | * on failure. |
| 603 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 604 | QDF_STATUS hdd_set_ibss_power_save_params(hdd_adapter_t *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 605 | { |
| 606 | int ret; |
| 607 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 608 | |
| 609 | if (hdd_ctx == NULL) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 610 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 611 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 612 | } |
| 613 | |
| 614 | ret = wma_cli_set_command(adapter->sessionId, |
| 615 | WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE, |
| 616 | hdd_ctx->config->ibssATIMWinSize, |
| 617 | VDEV_CMD); |
| 618 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 619 | hdd_err("WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 620 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 621 | } |
| 622 | |
| 623 | ret = wma_cli_set_command(adapter->sessionId, |
| 624 | WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED, |
| 625 | hdd_ctx->config->isIbssPowerSaveAllowed, |
| 626 | VDEV_CMD); |
| 627 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 628 | hdd_err("WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED failed %d", |
| 629 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 630 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 631 | } |
| 632 | |
| 633 | ret = wma_cli_set_command(adapter->sessionId, |
| 634 | WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED, |
| 635 | hdd_ctx->config-> |
| 636 | isIbssPowerCollapseAllowed, VDEV_CMD); |
| 637 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 638 | hdd_err("WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED failed %d", |
| 639 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 640 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 641 | } |
| 642 | |
| 643 | ret = wma_cli_set_command(adapter->sessionId, |
| 644 | WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX, |
| 645 | hdd_ctx->config->isIbssAwakeOnTxRx, |
| 646 | VDEV_CMD); |
| 647 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 648 | 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] | 649 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 650 | } |
| 651 | |
| 652 | ret = wma_cli_set_command(adapter->sessionId, |
| 653 | WMA_VDEV_IBSS_SET_INACTIVITY_TIME, |
| 654 | hdd_ctx->config->ibssInactivityCount, |
| 655 | VDEV_CMD); |
| 656 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 657 | hdd_err("WMA_VDEV_IBSS_SET_INACTIVITY_TIME failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 658 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 659 | } |
| 660 | |
| 661 | ret = wma_cli_set_command(adapter->sessionId, |
| 662 | WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME, |
| 663 | hdd_ctx->config->ibssTxSpEndInactivityTime, |
| 664 | VDEV_CMD); |
| 665 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 666 | hdd_err("WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME failed %d", |
| 667 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 668 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 669 | } |
| 670 | |
| 671 | ret = wma_cli_set_command(adapter->sessionId, |
| 672 | WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS, |
| 673 | hdd_ctx->config->ibssPsWarmupTime, |
| 674 | VDEV_CMD); |
| 675 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 676 | hdd_err("WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS failed %d", |
| 677 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 678 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 679 | } |
| 680 | |
| 681 | ret = wma_cli_set_command(adapter->sessionId, |
| 682 | WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW, |
| 683 | hdd_ctx->config->ibssPs1RxChainInAtimEnable, |
| 684 | VDEV_CMD); |
| 685 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 686 | hdd_err("WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW failed %d", |
| 687 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 688 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 689 | } |
| 690 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 691 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 692 | } |
| 693 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 694 | #define INTF_MACADDR_MASK 0x7 |
| 695 | |
| 696 | /** |
| 697 | * hdd_update_macaddr() - update mac address |
| 698 | * @config: hdd configuration |
| 699 | * @hw_macaddr: mac address |
| 700 | * |
| 701 | * Mac address for multiple virtual interface is found as following |
| 702 | * i) The mac address of the first interface is just the actual hw mac address. |
| 703 | * ii) MSM 3 or 4 bits of byte5 of the actual mac address are used to |
| 704 | * define the mac address for the remaining interfaces and locally |
| 705 | * admistered bit is set. INTF_MACADDR_MASK is based on the number of |
| 706 | * supported virtual interfaces, right now this is 0x07 (meaning 8 |
| 707 | * interface). |
| 708 | * Byte[3] of second interface will be hw_macaddr[3](bit5..7) + 1, |
| 709 | * for third interface it will be hw_macaddr[3](bit5..7) + 2, etc. |
| 710 | * |
| 711 | * Return: None |
| 712 | */ |
| 713 | void hdd_update_macaddr(struct hdd_config *config, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 714 | struct qdf_mac_addr hw_macaddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 715 | { |
| 716 | int8_t i; |
| 717 | uint8_t macaddr_b3, tmp_br3; |
| 718 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 719 | qdf_mem_copy(config->intfMacAddr[0].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 720 | QDF_MAC_ADDR_SIZE); |
| 721 | for (i = 1; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 722 | qdf_mem_copy(config->intfMacAddr[i].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 723 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 724 | macaddr_b3 = config->intfMacAddr[i].bytes[3]; |
| 725 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 726 | INTF_MACADDR_MASK; |
| 727 | macaddr_b3 += tmp_br3; |
| 728 | |
| 729 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 730 | * mac address range before collision |
| 731 | */ |
| 732 | macaddr_b3 ^= (1 << 7); |
| 733 | |
| 734 | /* Set locally administered bit */ |
| 735 | config->intfMacAddr[i].bytes[0] |= 0x02; |
| 736 | config->intfMacAddr[i].bytes[3] = macaddr_b3; |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 737 | hdd_notice("config->intfMacAddr[%d]: " |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 738 | MAC_ADDRESS_STR, i, |
| 739 | MAC_ADDR_ARRAY(config->intfMacAddr[i].bytes)); |
| 740 | } |
| 741 | } |
| 742 | |
| 743 | static void hdd_update_tgt_services(hdd_context_t *hdd_ctx, |
| 744 | struct wma_tgt_services *cfg) |
| 745 | { |
| 746 | struct hdd_config *config = hdd_ctx->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 747 | |
| 748 | /* Set up UAPSD */ |
| 749 | config->apUapsdEnabled &= cfg->uapsd; |
| 750 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 751 | /* 11AC mode support */ |
| 752 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 753 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 754 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 755 | |
| 756 | /* ARP offload: override user setting if invalid */ |
| 757 | config->fhostArpOffload &= cfg->arp_offload; |
| 758 | |
| 759 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 760 | /* PNO offload */ |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 761 | hdd_info("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 762 | if (cfg->pno_offload) |
| 763 | config->PnoOffload = true; |
| 764 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 765 | #ifdef FEATURE_WLAN_TDLS |
| 766 | config->fEnableTDLSSupport &= cfg->en_tdls; |
Manjeet Singh | fdd2ac7 | 2016-09-02 18:11:43 +0530 | [diff] [blame] | 767 | config->fEnableTDLSOffChannel = config->fEnableTDLSOffChannel && |
| 768 | cfg->en_tdls_offchan; |
| 769 | config->fEnableTDLSBufferSta = config->fEnableTDLSBufferSta && |
| 770 | cfg->en_tdls_uapsd_buf_sta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 771 | if (config->fTDLSUapsdMask && cfg->en_tdls_uapsd_sleep_sta) { |
| 772 | config->fEnableTDLSSleepSta = true; |
| 773 | } else { |
| 774 | config->fEnableTDLSSleepSta = false; |
| 775 | } |
| 776 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 777 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 778 | config->isRoamOffloadEnabled &= cfg->en_roam_offload; |
| 779 | #endif |
Krishna Kumaar Natarajan | 052c6e6 | 2015-09-28 15:32:55 -0700 | [diff] [blame] | 780 | sme_update_tgt_services(hdd_ctx->hHal, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 781 | |
| 782 | } |
| 783 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 784 | /** |
| 785 | * hdd_update_vdev_nss() - sets the vdev nss |
| 786 | * @hdd_ctx: HDD context |
| 787 | * |
| 788 | * Sets the Nss per vdev type based on INI |
| 789 | * |
| 790 | * Return: None |
| 791 | */ |
| 792 | static void hdd_update_vdev_nss(hdd_context_t *hdd_ctx) |
| 793 | { |
| 794 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 795 | uint8_t max_supp_nss = 1; |
| 796 | |
| 797 | if (cfg_ini->enable2x2) |
| 798 | max_supp_nss = 2; |
| 799 | |
| 800 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
| 801 | cfg_ini->vdev_type_nss_2g, eCSR_BAND_24); |
| 802 | |
| 803 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
| 804 | cfg_ini->vdev_type_nss_5g, eCSR_BAND_5G); |
| 805 | } |
| 806 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 807 | static void hdd_update_tgt_ht_cap(hdd_context_t *hdd_ctx, |
| 808 | struct wma_tgt_ht_cap *cfg) |
| 809 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 810 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 811 | uint32_t value, val32; |
| 812 | uint16_t val16; |
| 813 | struct hdd_config *pconfig = hdd_ctx->config; |
| 814 | tSirMacHTCapabilityInfo *phtCapInfo; |
| 815 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
| 816 | uint8_t enable_tx_stbc; |
| 817 | |
| 818 | /* check and update RX STBC */ |
| 819 | if (pconfig->enableRxSTBC && !cfg->ht_rx_stbc) |
| 820 | pconfig->enableRxSTBC = cfg->ht_rx_stbc; |
| 821 | |
| 822 | /* get the MPDU density */ |
| 823 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, &value); |
| 824 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 825 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 826 | hdd_err("could not get MPDU DENSITY"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 827 | value = 0; |
| 828 | } |
| 829 | |
| 830 | /* |
| 831 | * MPDU density: |
| 832 | * override user's setting if value is larger |
| 833 | * than the one supported by target |
| 834 | */ |
| 835 | if (value > cfg->mpdu_density) { |
| 836 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, |
| 837 | cfg->mpdu_density); |
| 838 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 839 | if (status == QDF_STATUS_E_FAILURE) |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 840 | hdd_alert("could not set MPDU DENSITY to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 841 | } |
| 842 | |
| 843 | /* get the HT capability info */ |
| 844 | 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] | 845 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 846 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 847 | return; |
| 848 | } |
| 849 | val16 = (uint16_t) val32; |
| 850 | phtCapInfo = (tSirMacHTCapabilityInfo *) &val16; |
| 851 | |
| 852 | /* Set the LDPC capability */ |
| 853 | phtCapInfo->advCodingCap = cfg->ht_rx_ldpc; |
| 854 | |
| 855 | if (pconfig->ShortGI20MhzEnable && !cfg->ht_sgi_20) |
| 856 | pconfig->ShortGI20MhzEnable = cfg->ht_sgi_20; |
| 857 | |
| 858 | if (pconfig->ShortGI40MhzEnable && !cfg->ht_sgi_40) |
| 859 | pconfig->ShortGI40MhzEnable = cfg->ht_sgi_40; |
| 860 | |
| 861 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 862 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 863 | |
| 864 | enable_tx_stbc = pconfig->enableTxSTBC; |
| 865 | |
| 866 | if (pconfig->enable2x2 && (cfg->num_rf_chains == 2)) { |
| 867 | pconfig->enable2x2 = 1; |
| 868 | } else { |
| 869 | pconfig->enable2x2 = 0; |
| 870 | enable_tx_stbc = 0; |
| 871 | |
| 872 | /* 1x1 */ |
| 873 | /* Update Rx Highest Long GI data Rate */ |
| 874 | if (sme_cfg_set_int(hdd_ctx->hHal, |
| 875 | WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 876 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 877 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 878 | 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] | 879 | } |
| 880 | |
| 881 | /* Update Tx Highest Long GI data Rate */ |
| 882 | if (sme_cfg_set_int |
| 883 | (hdd_ctx->hHal, |
| 884 | WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 885 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 886 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 887 | hdd_err("VHT_TX_HIGHEST_SUPP_RATE_1_1 to CCM fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 888 | } |
| 889 | } |
| 890 | if (!(cfg->ht_tx_stbc && pconfig->enable2x2)) |
| 891 | enable_tx_stbc = 0; |
| 892 | phtCapInfo->txSTBC = enable_tx_stbc; |
| 893 | |
| 894 | val32 = val16; |
| 895 | 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] | 896 | if (status != QDF_STATUS_SUCCESS) |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 897 | hdd_alert("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 898 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
| 899 | value = SIZE_OF_SUPPORTED_MCS_SET; |
| 900 | 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] | 901 | &value) == QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 902 | hdd_notice("Read MCS rate set"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 903 | |
| 904 | if (pconfig->enable2x2) { |
| 905 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 906 | mcs_set[value] = |
| 907 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 908 | |
| 909 | status = |
| 910 | sme_cfg_set_str(hdd_ctx->hHal, |
| 911 | WNI_CFG_SUPPORTED_MCS_SET, |
| 912 | mcs_set, |
| 913 | SIZE_OF_SUPPORTED_MCS_SET); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 914 | if (status == QDF_STATUS_E_FAILURE) |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 915 | hdd_alert("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 916 | } |
| 917 | } |
| 918 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 919 | } |
| 920 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 921 | static void hdd_update_tgt_vht_cap(hdd_context_t *hdd_ctx, |
| 922 | struct wma_tgt_vht_cap *cfg) |
| 923 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 924 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 925 | uint32_t value = 0; |
| 926 | struct hdd_config *pconfig = hdd_ctx->config; |
| 927 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 928 | struct ieee80211_supported_band *band_5g = |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 929 | wiphy->bands[NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 930 | uint32_t temp = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 931 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 932 | if (!band_5g) { |
| 933 | hdd_info("5GHz band disabled, skipping capability population"); |
| 934 | return; |
| 935 | } |
| 936 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 937 | /* Get the current MPDU length */ |
| 938 | status = |
| 939 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 940 | &value); |
| 941 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 942 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 943 | hdd_err("could not get MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 944 | value = 0; |
| 945 | } |
| 946 | |
| 947 | /* |
| 948 | * VHT max MPDU length: |
| 949 | * override if user configured value is too high |
| 950 | * that the target cannot support |
| 951 | */ |
| 952 | if (value > cfg->vht_max_mpdu) { |
| 953 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 954 | WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 955 | cfg->vht_max_mpdu); |
| 956 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 957 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 958 | hdd_alert("could not set VHT MAX MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 959 | } |
| 960 | } |
| 961 | |
| 962 | /* Get the current supported chan width */ |
| 963 | status = sme_cfg_get_int(hdd_ctx->hHal, |
| 964 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 965 | &value); |
| 966 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 967 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 968 | hdd_err("could not get MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 969 | value = 0; |
| 970 | } |
| 971 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 972 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, &temp); |
| 973 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 974 | |
| 975 | if (pconfig->enable2x2) |
| 976 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 977 | |
| 978 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, temp) == |
| 979 | QDF_STATUS_E_FAILURE) { |
| 980 | hdd_err("Could not pass VHT_BASIC_MCS_SET to CCM"); |
| 981 | } |
| 982 | |
| 983 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, &temp); |
| 984 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 985 | if (pconfig->enable2x2) |
| 986 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 987 | |
| 988 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, temp) == |
| 989 | QDF_STATUS_E_FAILURE) { |
| 990 | hdd_err("Could not pass WNI_CFG_VHT_RX_MCS_MAP to CCM"); |
| 991 | } |
| 992 | |
| 993 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, &temp); |
| 994 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtTxMCS; |
| 995 | if (pconfig->enable2x2) |
| 996 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtTxMCS2x2 << 2); |
| 997 | |
| 998 | hdd_info("vhtRxMCS2x2 - %x temp - %u enable2x2 %d", |
| 999 | pconfig->vhtRxMCS2x2, temp, pconfig->enable2x2); |
| 1000 | |
| 1001 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, temp) == |
| 1002 | QDF_STATUS_E_FAILURE) { |
| 1003 | hdd_err("Could not pass WNI_CFG_VHT_TX_MCS_MAP to CCM"); |
| 1004 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1005 | /* Get the current RX LDPC setting */ |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1006 | 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] | 1007 | &value); |
| 1008 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1009 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1010 | hdd_err("could not get VHT LDPC CODING CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1011 | value = 0; |
| 1012 | } |
| 1013 | |
| 1014 | /* Set the LDPC capability */ |
| 1015 | if (value && !cfg->vht_rx_ldpc) { |
| 1016 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1017 | WNI_CFG_VHT_LDPC_CODING_CAP, |
| 1018 | cfg->vht_rx_ldpc); |
| 1019 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1020 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1021 | hdd_alert("could not set VHT LDPC CODING CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1022 | } |
| 1023 | } |
| 1024 | |
| 1025 | /* Get current GI 80 value */ |
| 1026 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1027 | &value); |
| 1028 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1029 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1030 | hdd_err("could not get SHORT GI 80MHZ"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1031 | value = 0; |
| 1032 | } |
| 1033 | |
| 1034 | /* set the Guard interval 80MHz */ |
| 1035 | if (value && !cfg->vht_short_gi_80) { |
| 1036 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1037 | WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1038 | cfg->vht_short_gi_80); |
| 1039 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1040 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1041 | hdd_alert("could not set SHORT GI 80MHZ to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1042 | } |
| 1043 | } |
| 1044 | |
| 1045 | /* Get current GI 160 value */ |
| 1046 | status = sme_cfg_get_int(hdd_ctx->hHal, |
| 1047 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
| 1048 | &value); |
| 1049 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1050 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1051 | hdd_err("could not get SHORT GI 80 & 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1052 | value = 0; |
| 1053 | } |
| 1054 | |
| 1055 | /* Get VHT TX STBC cap */ |
| 1056 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, &value); |
| 1057 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1058 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1059 | hdd_err("could not get VHT TX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1060 | value = 0; |
| 1061 | } |
| 1062 | |
| 1063 | /* VHT TX STBC cap */ |
| 1064 | if (value && !cfg->vht_tx_stbc) { |
| 1065 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, |
| 1066 | cfg->vht_tx_stbc); |
| 1067 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1068 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1069 | hdd_alert("could not set the VHT TX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1070 | } |
| 1071 | } |
| 1072 | |
| 1073 | /* Get VHT RX STBC cap */ |
| 1074 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, &value); |
| 1075 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1076 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1077 | hdd_err("could not get VHT RX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1078 | value = 0; |
| 1079 | } |
| 1080 | |
| 1081 | /* VHT RX STBC cap */ |
| 1082 | if (value && !cfg->vht_rx_stbc) { |
| 1083 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, |
| 1084 | cfg->vht_rx_stbc); |
| 1085 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1086 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1087 | hdd_alert("could not set the VHT RX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1088 | } |
| 1089 | } |
| 1090 | |
| 1091 | /* Get VHT SU Beamformer cap */ |
| 1092 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1093 | &value); |
| 1094 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1095 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1096 | hdd_err("could not get VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1097 | value = 0; |
| 1098 | } |
| 1099 | |
| 1100 | /* set VHT SU Beamformer cap */ |
| 1101 | if (value && !cfg->vht_su_bformer) { |
| 1102 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1103 | WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1104 | cfg->vht_su_bformer); |
| 1105 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1106 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1107 | hdd_alert("could not set VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1108 | } |
| 1109 | } |
| 1110 | |
| 1111 | /* check and update SU BEAMFORMEE capabality */ |
| 1112 | if (pconfig->enableTxBF && !cfg->vht_su_bformee) |
| 1113 | pconfig->enableTxBF = cfg->vht_su_bformee; |
| 1114 | |
| 1115 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1116 | WNI_CFG_VHT_SU_BEAMFORMEE_CAP, |
| 1117 | pconfig->enableTxBF); |
| 1118 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1119 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1120 | hdd_alert("could not set VHT SU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1121 | } |
| 1122 | |
| 1123 | /* Get VHT MU Beamformer cap */ |
| 1124 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1125 | &value); |
| 1126 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1127 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1128 | hdd_err("could not get VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1129 | value = 0; |
| 1130 | } |
| 1131 | |
| 1132 | /* set VHT MU Beamformer cap */ |
| 1133 | if (value && !cfg->vht_mu_bformer) { |
| 1134 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1135 | WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1136 | cfg->vht_mu_bformer); |
| 1137 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1138 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1139 | hdd_alert("could not set the VHT MU BEAMFORMER CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1140 | } |
| 1141 | } |
| 1142 | |
| 1143 | /* Get VHT MU Beamformee cap */ |
| 1144 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1145 | &value); |
| 1146 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1147 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1148 | hdd_err("could not get VHT MU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1149 | value = 0; |
| 1150 | } |
| 1151 | |
| 1152 | /* set VHT MU Beamformee cap */ |
| 1153 | if (value && !cfg->vht_mu_bformee) { |
| 1154 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1155 | WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1156 | cfg->vht_mu_bformee); |
| 1157 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1158 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1159 | hdd_alert("could not set VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1160 | } |
| 1161 | } |
| 1162 | |
| 1163 | /* Get VHT MAX AMPDU Len exp */ |
| 1164 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1165 | &value); |
| 1166 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1167 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1168 | hdd_err("could not get VHT AMPDU LEN"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1169 | value = 0; |
| 1170 | } |
| 1171 | |
| 1172 | /* |
| 1173 | * VHT max AMPDU len exp: |
| 1174 | * override if user configured value is too high |
| 1175 | * that the target cannot support. |
| 1176 | * Even though Rome publish ampdu_len=7, it can |
| 1177 | * only support 4 because of some h/w bug. |
| 1178 | */ |
| 1179 | |
| 1180 | if (value > cfg->vht_max_ampdu_len_exp) { |
| 1181 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1182 | WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1183 | cfg->vht_max_ampdu_len_exp); |
| 1184 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1185 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1186 | hdd_alert("could not set the VHT AMPDU LEN EXP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1187 | } |
| 1188 | } |
| 1189 | |
| 1190 | /* Get VHT TXOP PS CAP */ |
| 1191 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, &value); |
| 1192 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1193 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1194 | hdd_err("could not get VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1195 | value = 0; |
| 1196 | } |
| 1197 | |
| 1198 | /* set VHT TXOP PS cap */ |
| 1199 | if (value && !cfg->vht_txop_ps) { |
| 1200 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, |
| 1201 | cfg->vht_txop_ps); |
| 1202 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1203 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1204 | hdd_alert("could not set the VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1205 | } |
| 1206 | } |
| 1207 | |
| 1208 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1209 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1210 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1211 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1212 | else |
| 1213 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1214 | |
| 1215 | |
Amar Singhal | 90aaa6a | 2016-03-01 16:53:37 -0800 | [diff] [blame] | 1216 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1217 | band_5g->vht_cap.cap |= |
| 1218 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Amar Singhal | 90aaa6a | 2016-03-01 16:53:37 -0800 | [diff] [blame] | 1219 | else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1220 | band_5g->vht_cap.cap |= |
| 1221 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1222 | |
| 1223 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) |
| 1224 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1225 | |
| 1226 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1227 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1228 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1229 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1230 | |
| 1231 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1232 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1233 | |
| 1234 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1235 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1236 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1237 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1238 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1239 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1240 | |
| 1241 | band_5g->vht_cap.cap |= |
| 1242 | (cfg->vht_max_ampdu_len_exp << |
| 1243 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1244 | |
| 1245 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1246 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1247 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1248 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1249 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1250 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1251 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1252 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1253 | |
| 1254 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1255 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1256 | |
| 1257 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1258 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1259 | /** |
| 1260 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1261 | * @hdd_ctx: Pointer to the HDD context |
| 1262 | * |
| 1263 | * Auto-generate mac address using device serial number. |
| 1264 | * Keep the first 3 bytes of OUI as before and replace |
| 1265 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1266 | * |
| 1267 | * Return: 0 for success |
| 1268 | * Non zero failure code for errors |
| 1269 | */ |
| 1270 | static int hdd_generate_macaddr_auto(hdd_context_t *hdd_ctx) |
| 1271 | { |
| 1272 | unsigned int serialno = 0; |
| 1273 | struct qdf_mac_addr mac_addr = { |
| 1274 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1275 | }; |
| 1276 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1277 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1278 | if (serialno == 0) |
| 1279 | return -EINVAL; |
| 1280 | |
| 1281 | serialno &= 0x00ffffff; |
| 1282 | |
| 1283 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1284 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1285 | mac_addr.bytes[5] = serialno & 0xff; |
| 1286 | |
| 1287 | hdd_update_macaddr(hdd_ctx->config, mac_addr); |
| 1288 | return 0; |
| 1289 | } |
| 1290 | |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1291 | /** |
| 1292 | * hdd_update_ra_rate_limit() - Update RA rate limit from target |
| 1293 | * configuration to cfg_ini in HDD |
| 1294 | * @hdd_ctx: Pointer to hdd_ctx |
| 1295 | * @cfg: target configuration |
| 1296 | * |
| 1297 | * Return: None |
| 1298 | */ |
| 1299 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 1300 | static void hdd_update_ra_rate_limit(hdd_context_t *hdd_ctx, |
| 1301 | struct wma_tgt_cfg *cfg) |
| 1302 | { |
| 1303 | hdd_ctx->config->IsRArateLimitEnabled = cfg->is_ra_rate_limit_enabled; |
| 1304 | } |
| 1305 | #else |
| 1306 | static void hdd_update_ra_rate_limit(hdd_context_t *hdd_ctx, |
| 1307 | struct wma_tgt_cfg *cfg) |
| 1308 | { |
| 1309 | } |
| 1310 | #endif |
| 1311 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1312 | void hdd_update_tgt_cfg(void *context, void *param) |
| 1313 | { |
| 1314 | hdd_context_t *hdd_ctx = (hdd_context_t *) context; |
| 1315 | struct wma_tgt_cfg *cfg = param; |
| 1316 | uint8_t temp_band_cap; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1317 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1318 | QDF_STATUS qdf_status; |
| 1319 | |
| 1320 | qdf_status = hdd_create_and_store_pdev(hdd_ctx); |
| 1321 | if (QDF_IS_STATUS_ERROR(qdf_status)) { |
| 1322 | hdd_err("Pdev creation fails!"); |
| 1323 | QDF_BUG(0); |
| 1324 | } |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1325 | |
| 1326 | if (cds_cfg) { |
| 1327 | if (hdd_ctx->config->enable_sub_20_channel_width != |
| 1328 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
| 1329 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1330 | cds_cfg->sub_20_channel_width = |
| 1331 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1332 | } else { |
| 1333 | cds_cfg->sub_20_channel_width = |
| 1334 | hdd_ctx->config->enable_sub_20_channel_width; |
| 1335 | } |
| 1336 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1337 | |
| 1338 | /* first store the INI band capability */ |
| 1339 | temp_band_cap = hdd_ctx->config->nBandCapability; |
| 1340 | |
| 1341 | hdd_ctx->config->nBandCapability = cfg->band_cap; |
| 1342 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame^] | 1343 | /* |
| 1344 | * now overwrite the target band capability with INI |
| 1345 | * setting if INI setting is a subset |
| 1346 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1347 | |
| 1348 | if ((hdd_ctx->config->nBandCapability == eCSR_BAND_ALL) && |
| 1349 | (temp_band_cap != eCSR_BAND_ALL)) |
| 1350 | hdd_ctx->config->nBandCapability = temp_band_cap; |
| 1351 | else if ((hdd_ctx->config->nBandCapability != eCSR_BAND_ALL) && |
| 1352 | (temp_band_cap != eCSR_BAND_ALL) && |
| 1353 | (hdd_ctx->config->nBandCapability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1354 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1355 | } |
| 1356 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 1357 | if (!cds_is_driver_recovering()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1358 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 1359 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 1360 | } |
| 1361 | |
| 1362 | /* This can be extended to other configurations like ht, vht cap... */ |
| 1363 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 1364 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1365 | hdd_update_macaddr(hdd_ctx->config, cfg->hw_macaddr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1366 | hdd_ctx->update_mac_addr_to_fw = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1367 | } else { |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1368 | static struct qdf_mac_addr default_mac_addr = { |
| 1369 | {0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF} |
| 1370 | }; |
| 1371 | if (qdf_is_macaddr_equal(&hdd_ctx->config->intfMacAddr[0], |
| 1372 | &default_mac_addr)) { |
| 1373 | if (hdd_generate_macaddr_auto(hdd_ctx) != 0) |
| 1374 | hdd_err("Fail to auto-generate MAC, using MAC from ini file " |
| 1375 | MAC_ADDRESS_STR, |
| 1376 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1377 | intfMacAddr[0].bytes)); |
| 1378 | } else { |
| 1379 | hdd_err("Invalid MAC passed from target, using MAC from ini file " |
| 1380 | MAC_ADDRESS_STR, |
| 1381 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1382 | intfMacAddr[0].bytes)); |
| 1383 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1384 | hdd_ctx->update_mac_addr_to_fw = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1385 | } |
| 1386 | |
| 1387 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 1388 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1389 | |
| 1390 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 1391 | |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 1392 | hdd_lpass_target_config(hdd_ctx, cfg); |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 1393 | hdd_green_ap_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1394 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1395 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 1396 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 1397 | |
| 1398 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 1399 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1400 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1401 | |
| 1402 | hdd_update_vdev_nss(hdd_ctx); |
| 1403 | |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1404 | hdd_ctx->config->fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 1405 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1406 | hdd_info("fine_time_meas_cap: 0x%x", |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1407 | hdd_ctx->config->fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1408 | |
| 1409 | hdd_ctx->current_antenna_mode = |
| 1410 | (hdd_ctx->config->enable2x2 == 0x01) ? |
| 1411 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 1412 | hdd_info("Init current antenna mode: %d", |
| 1413 | hdd_ctx->current_antenna_mode); |
| 1414 | |
Rajeev Kumar | dd3bc60 | 2016-08-16 14:21:05 -0700 | [diff] [blame] | 1415 | hdd_info("Target BPF %d Host BPF %d", |
| 1416 | cfg->bpf_enabled, hdd_ctx->config->bpf_packet_filter_enable); |
| 1417 | hdd_ctx->bpf_enabled = (cfg->bpf_enabled && |
| 1418 | hdd_ctx->config->bpf_packet_filter_enable); |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1419 | hdd_update_ra_rate_limit(hdd_ctx, cfg); |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1420 | |
Arun Khandavalli | d454d42 | 2016-08-17 12:47:05 +0530 | [diff] [blame] | 1421 | /* |
| 1422 | * If BPF is enabled, maxWowFilters set to WMA_STA_WOW_DEFAULT_PTRN_MAX |
| 1423 | * because we need atleast WMA_STA_WOW_DEFAULT_PTRN_MAX free slots to |
| 1424 | * configure the STA mode wow pattern. |
| 1425 | */ |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1426 | if (hdd_ctx->bpf_enabled) |
Arun Khandavalli | d454d42 | 2016-08-17 12:47:05 +0530 | [diff] [blame] | 1427 | hdd_ctx->config->maxWoWFilters = WMA_STA_WOW_DEFAULT_PTRN_MAX; |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1428 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 1429 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 1430 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 1431 | /* Configure NAN datapath features */ |
| 1432 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1433 | } |
| 1434 | |
| 1435 | /** |
| 1436 | * hdd_dfs_indicate_radar() - handle radar detection on current SAP channel |
| 1437 | * @context: HDD context pointer |
| 1438 | * @param: HDD radar indication pointer |
| 1439 | * |
Sandeep Puligilla | a8d4eec | 2016-06-30 15:13:11 -0700 | [diff] [blame] | 1440 | * This function is invoked in atomic context when a radar |
| 1441 | * is found on the SAP current operating channel and Data Tx |
| 1442 | * from netif has to be stopped to honor the DFS regulations. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1443 | * Actions: Stop the netif Tx queues,Indicate Radar present |
| 1444 | * in HDD context for future usage. |
| 1445 | * |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1446 | * Return: true to allow radar indication to host else false |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1447 | */ |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1448 | bool hdd_dfs_indicate_radar(void *context, void *param) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1449 | { |
| 1450 | hdd_context_t *hdd_ctx = (hdd_context_t *) context; |
| 1451 | struct wma_dfs_radar_ind *hdd_radar_event = |
| 1452 | (struct wma_dfs_radar_ind *)param; |
| 1453 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 1454 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1455 | QDF_STATUS status; |
Manishekar Chandrasekaran | 11ecd55 | 2016-08-31 12:44:05 +0530 | [diff] [blame] | 1456 | hdd_ap_ctx_t *ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1457 | |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1458 | if (!hdd_ctx || !hdd_radar_event || |
| 1459 | hdd_ctx->config->disableDFSChSwitch) |
| 1460 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1461 | |
| 1462 | if (true == hdd_radar_event->dfs_radar_status) { |
Arif Hussain | 2a7c1f3 | 2016-07-18 14:24:36 -0700 | [diff] [blame] | 1463 | if (qdf_atomic_inc_return(&hdd_ctx->dfs_radar_found) > 1) { |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1464 | /* |
| 1465 | * Application already triggered channel switch |
| 1466 | * on current channel, so return here. |
| 1467 | */ |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1468 | return false; |
| 1469 | } |
| 1470 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1471 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1472 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1473 | adapter = adapterNode->pAdapter; |
Manishekar Chandrasekaran | 11ecd55 | 2016-08-31 12:44:05 +0530 | [diff] [blame] | 1474 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 1475 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 1476 | QDF_P2P_GO_MODE == adapter->device_mode) && |
| 1477 | (CHANNEL_STATE_DFS == |
| 1478 | cds_get_channel_state(ap_ctx->operatingChannel))) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1479 | WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
| 1480 | dfs_cac_block_tx = true; |
Manishekar Chandrasekaran | 11ecd55 | 2016-08-31 12:44:05 +0530 | [diff] [blame] | 1481 | hdd_info("tx blocked for session:%d", |
| 1482 | adapter->sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1483 | } |
| 1484 | |
| 1485 | status = hdd_get_next_adapter(hdd_ctx, |
| 1486 | adapterNode, |
| 1487 | &pNext); |
| 1488 | adapterNode = pNext; |
| 1489 | } |
| 1490 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1491 | |
| 1492 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1493 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1494 | |
| 1495 | /** |
| 1496 | * hdd_is_valid_mac_address() - validate MAC address |
| 1497 | * @pMacAddr: Pointer to the input MAC address |
| 1498 | * |
| 1499 | * This function validates whether the given MAC address is valid or not |
| 1500 | * Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 1501 | * where X is the hexa decimal digit character and separated by ':' |
| 1502 | * This algorithm works even if MAC address is not separated by ':' |
| 1503 | * |
| 1504 | * This code checks given input string mac contains exactly 12 hexadecimal |
| 1505 | * digits and a separator colon : appears in the input string only after |
| 1506 | * an even number of hex digits. |
| 1507 | * |
| 1508 | * Return: 1 for valid and 0 for invalid |
| 1509 | */ |
| 1510 | bool hdd_is_valid_mac_address(const uint8_t *pMacAddr) |
| 1511 | { |
| 1512 | int xdigit = 0; |
| 1513 | int separator = 0; |
| 1514 | while (*pMacAddr) { |
| 1515 | if (isxdigit(*pMacAddr)) { |
| 1516 | xdigit++; |
| 1517 | } else if (':' == *pMacAddr) { |
| 1518 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 1519 | break; |
| 1520 | |
| 1521 | ++separator; |
| 1522 | } else { |
| 1523 | /* Invalid MAC found */ |
| 1524 | return 0; |
| 1525 | } |
| 1526 | ++pMacAddr; |
| 1527 | } |
| 1528 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 1529 | } |
| 1530 | |
| 1531 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 1532 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 1533 | * @dev: Handle to struct net_device to be updated. |
| 1534 | * |
| 1535 | * Return: None |
| 1536 | */ |
| 1537 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 1538 | { |
| 1539 | dev->header_ops = NULL; |
| 1540 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 1541 | dev->hard_header_len = ETH_HLEN; |
| 1542 | dev->mtu = ETH_DATA_LEN; |
| 1543 | dev->addr_len = ETH_ALEN; |
| 1544 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 1545 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 1546 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 1547 | |
| 1548 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 1549 | } |
| 1550 | |
| 1551 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1552 | * __hdd__mon_open() - HDD Open function |
| 1553 | * @dev: Pointer to net_device structure |
| 1554 | * |
| 1555 | * This is called in response to ifconfig up |
| 1556 | * |
| 1557 | * Return: 0 for success; non-zero for failure |
| 1558 | */ |
| 1559 | static int __hdd_mon_open(struct net_device *dev) |
| 1560 | { |
| 1561 | int ret; |
| 1562 | |
| 1563 | ENTER_DEV(dev); |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 1564 | hdd_mon_mode_ether_setup(dev); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1565 | ret = hdd_set_mon_rx_cb(dev); |
| 1566 | return ret; |
| 1567 | } |
| 1568 | |
| 1569 | /** |
| 1570 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 1571 | * @dev: Pointer to net_device structure |
| 1572 | * |
| 1573 | * This is called in response to ifconfig up |
| 1574 | * |
| 1575 | * Return: 0 for success; non-zero for failure |
| 1576 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 1577 | static int hdd_mon_open(struct net_device *dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1578 | { |
| 1579 | int ret; |
| 1580 | |
| 1581 | cds_ssr_protect(__func__); |
| 1582 | ret = __hdd_mon_open(dev); |
| 1583 | cds_ssr_unprotect(__func__); |
| 1584 | |
| 1585 | return ret; |
| 1586 | } |
| 1587 | |
| 1588 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1589 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 1590 | * @adapter: pointer to HDD adapter |
| 1591 | * |
| 1592 | * This function is called to start the device specific adapter for |
| 1593 | * the mode passed in the adapter's device_mode. |
| 1594 | * |
| 1595 | * Return: 0 for success; non-zero for failure |
| 1596 | */ |
| 1597 | int hdd_start_adapter(hdd_adapter_t *adapter) |
| 1598 | { |
| 1599 | |
| 1600 | int ret; |
| 1601 | enum tQDF_ADAPTER_MODE device_mode = adapter->device_mode; |
| 1602 | |
| 1603 | ENTER_DEV(adapter->dev); |
| 1604 | hdd_info("Start_adapter for mode : %d", adapter->device_mode); |
| 1605 | |
| 1606 | switch (device_mode) { |
| 1607 | case QDF_P2P_CLIENT_MODE: |
| 1608 | case QDF_P2P_DEVICE_MODE: |
| 1609 | case QDF_OCB_MODE: |
| 1610 | case QDF_STA_MODE: |
| 1611 | case QDF_MONITOR_MODE: |
| 1612 | ret = hdd_start_station_adapter(adapter); |
| 1613 | if (ret) |
| 1614 | goto err_start_adapter; |
| 1615 | break; |
| 1616 | case QDF_P2P_GO_MODE: |
| 1617 | case QDF_SAP_MODE: |
| 1618 | ret = hdd_start_ap_adapter(adapter); |
| 1619 | if (ret) |
| 1620 | goto err_start_adapter; |
| 1621 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 1622 | case QDF_IBSS_MODE: |
| 1623 | /* |
| 1624 | * For IBSS interface is initialized as part of |
| 1625 | * hdd_init_station_mode() |
| 1626 | */ |
| 1627 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1628 | case QDF_FTM_MODE: |
| 1629 | ret = hdd_start_ftm_adapter(adapter); |
| 1630 | if (ret) |
| 1631 | goto err_start_adapter; |
| 1632 | break; |
| 1633 | default: |
| 1634 | hdd_err("Invalid session type %d", device_mode); |
| 1635 | QDF_ASSERT(0); |
| 1636 | goto err_start_adapter; |
| 1637 | } |
| 1638 | if (hdd_set_fw_params(adapter)) |
| 1639 | hdd_err("Failed to set the FW params for the adapter!"); |
| 1640 | |
| 1641 | /* |
| 1642 | * Action frame registered in one adapter which will |
| 1643 | * applicable to all interfaces |
| 1644 | */ |
| 1645 | wlan_hdd_cfg80211_register_frames(adapter); |
| 1646 | EXIT(); |
| 1647 | return 0; |
| 1648 | err_start_adapter: |
| 1649 | return -EINVAL; |
| 1650 | } |
| 1651 | |
| 1652 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 1653 | * hdd_enable_power_management() - API to Enable Power Management |
| 1654 | * |
| 1655 | * API invokes Bus Interface Layer power management functionality |
| 1656 | * |
| 1657 | * Return: None |
| 1658 | */ |
| 1659 | static void hdd_enable_power_management(void) |
| 1660 | { |
| 1661 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 1662 | |
| 1663 | if (!hif_ctx) { |
| 1664 | hdd_err("Bus Interface Context is Invalid"); |
| 1665 | return; |
| 1666 | } |
| 1667 | |
| 1668 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 1669 | } |
| 1670 | |
| 1671 | /** |
| 1672 | * hdd_disable_power_management() - API to disable Power Management |
| 1673 | * |
| 1674 | * API disable Bus Interface Layer Power management functionality |
| 1675 | * |
| 1676 | * Return: None |
| 1677 | */ |
| 1678 | static void hdd_disable_power_management(void) |
| 1679 | { |
| 1680 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 1681 | |
| 1682 | if (!hif_ctx) { |
| 1683 | hdd_err("Bus Interface Context is Invalid"); |
| 1684 | return; |
| 1685 | } |
| 1686 | |
| 1687 | hif_disable_power_management(hif_ctx); |
| 1688 | } |
| 1689 | |
| 1690 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1691 | * hdd_wlan_start_modules() - Single driver state machine for starting modules |
| 1692 | * @hdd_ctx: HDD context |
| 1693 | * @adapter: HDD adapter |
| 1694 | * @reinit: flag to indicate from SSR or normal path |
| 1695 | * |
| 1696 | * This function maintains the driver state machine it will be invoked from |
| 1697 | * startup, reinit and change interface. Depending on the driver state shall |
| 1698 | * perform the opening of the modules. |
| 1699 | * |
| 1700 | * Return: 0 for success; non-zero for failure |
| 1701 | */ |
| 1702 | int hdd_wlan_start_modules(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, |
| 1703 | bool reinit) |
| 1704 | { |
| 1705 | int ret; |
| 1706 | qdf_device_t qdf_dev; |
| 1707 | QDF_STATUS status; |
| 1708 | p_cds_contextType p_cds_context; |
| 1709 | bool unint = false; |
| 1710 | void *hif_ctx; |
| 1711 | |
| 1712 | ENTER(); |
| 1713 | |
| 1714 | p_cds_context = cds_get_global_context(); |
| 1715 | if (!p_cds_context) { |
| 1716 | hdd_err("Global Context is NULL"); |
| 1717 | QDF_ASSERT(0); |
| 1718 | return -EINVAL; |
| 1719 | } |
| 1720 | |
| 1721 | hdd_info("start modules called in state! :%d reinit: %d", |
| 1722 | hdd_ctx->driver_status, reinit); |
| 1723 | |
| 1724 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 1725 | if (!qdf_dev) { |
| 1726 | hdd_err("QDF Device Context is Invalid return"); |
| 1727 | return -EINVAL; |
| 1728 | } |
| 1729 | |
| 1730 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 1731 | hdd_ctx->start_modules_in_progress = true; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1732 | |
| 1733 | if (QDF_TIMER_STATE_RUNNING == |
| 1734 | qdf_mc_timer_get_current_state(&hdd_ctx->iface_change_timer)) { |
| 1735 | |
| 1736 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 1737 | hdd_info("Interface change Timer running Stop timer"); |
| 1738 | qdf_mc_timer_stop(&hdd_ctx->iface_change_timer); |
| 1739 | } |
| 1740 | |
| 1741 | switch (hdd_ctx->driver_status) { |
| 1742 | case DRIVER_MODULES_UNINITIALIZED: |
| 1743 | unint = true; |
| 1744 | /* Fall through dont add break here */ |
| 1745 | case DRIVER_MODULES_CLOSED: |
| 1746 | if (!reinit && !unint) { |
| 1747 | ret = pld_power_on(qdf_dev->dev); |
| 1748 | if (ret) { |
| 1749 | hdd_err("Failed to Powerup the device: %d", ret); |
| 1750 | goto release_lock; |
| 1751 | } |
| 1752 | } |
| 1753 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 1754 | qdf_dev->bus_type, |
| 1755 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 1756 | HIF_ENABLE_TYPE_PROBE); |
| 1757 | if (ret) { |
| 1758 | hdd_err("Failed to open hif: %d", ret); |
| 1759 | goto power_down; |
| 1760 | } |
| 1761 | |
| 1762 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 1763 | if (!hif_ctx) { |
| 1764 | hdd_err("hif context is null!!"); |
| 1765 | goto power_down; |
| 1766 | } |
| 1767 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1768 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 1769 | if (status != QDF_STATUS_SUCCESS) { |
| 1770 | hdd_err("No Memory to Create BMI Context :%d", status); |
| 1771 | goto hif_close; |
| 1772 | } |
| 1773 | |
Arun Khandavalli | f624663 | 2016-08-17 17:43:06 +0530 | [diff] [blame] | 1774 | ret = hdd_update_config(hdd_ctx); |
| 1775 | if (ret) { |
| 1776 | hdd_err("Failed to update configuration :%d", ret); |
| 1777 | goto ol_cds_free; |
| 1778 | } |
| 1779 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1780 | status = hdd_create_and_store_psoc(hdd_ctx, DEFAULT_PSOC_ID); |
| 1781 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1782 | hdd_err("Psoc creation fails!"); |
| 1783 | goto ol_cds_free; |
| 1784 | } |
| 1785 | |
| 1786 | status = cds_open(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1787 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 1788 | hdd_err("Failed to Open CDS: %d", status); |
| 1789 | goto ol_cds_free; |
| 1790 | } |
| 1791 | |
| 1792 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
| 1793 | |
| 1794 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
| 1795 | |
| 1796 | status = cds_pre_enable(hdd_ctx->pcds_context); |
| 1797 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 1798 | hdd_err("Failed to pre-enable CDS: %d", status); |
| 1799 | goto close; |
| 1800 | } |
| 1801 | |
| 1802 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 1803 | sme_register_ftm_msg_processor(hdd_ctx->hHal, |
| 1804 | hdd_ftm_mc_process_msg); |
| 1805 | break; |
| 1806 | } |
| 1807 | if (unint) { |
| 1808 | hdd_info("In phase-1 initialization don't enable modules"); |
| 1809 | break; |
| 1810 | } |
| 1811 | /* Fall through dont add break here */ |
| 1812 | case DRIVER_MODULES_OPENED: |
| 1813 | if (!adapter) { |
| 1814 | hdd_alert("adapter is Null"); |
| 1815 | goto close; |
| 1816 | } |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 1817 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 1818 | hdd_err("in ftm mode, no need to configure cds modules"); |
| 1819 | break; |
| 1820 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1821 | if (hdd_configure_cds(hdd_ctx, adapter)) { |
| 1822 | hdd_err("Failed to Enable cds modules"); |
| 1823 | goto close; |
| 1824 | } |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 1825 | hdd_enable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1826 | hdd_info("Driver Modules Successfully Enabled"); |
| 1827 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
| 1828 | break; |
| 1829 | case DRIVER_MODULES_ENABLED: |
| 1830 | hdd_info("Driver modules already Enabled"); |
| 1831 | break; |
| 1832 | default: |
| 1833 | hdd_err("WLAN start invoked in wrong state! :%d\n", |
| 1834 | hdd_ctx->driver_status); |
| 1835 | goto release_lock; |
| 1836 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 1837 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1838 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 1839 | EXIT(); |
| 1840 | return 0; |
| 1841 | |
| 1842 | close: |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1843 | cds_close(hdd_ctx->hdd_psoc, p_cds_context); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1844 | |
| 1845 | ol_cds_free: |
| 1846 | ol_cds_free(); |
| 1847 | |
| 1848 | hif_close: |
| 1849 | hdd_hif_close(p_cds_context->pHIFContext); |
| 1850 | power_down: |
| 1851 | if (!reinit && !unint) |
| 1852 | pld_power_off(qdf_dev->dev); |
| 1853 | release_lock: |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 1854 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1855 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 1856 | EXIT(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1857 | return -EINVAL; |
| 1858 | } |
| 1859 | |
| 1860 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1861 | * __hdd_open() - HDD Open function |
| 1862 | * @dev: Pointer to net_device structure |
| 1863 | * |
| 1864 | * This is called in response to ifconfig up |
| 1865 | * |
| 1866 | * Return: 0 for success; non-zero for failure |
| 1867 | */ |
| 1868 | static int __hdd_open(struct net_device *dev) |
| 1869 | { |
| 1870 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1871 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 1872 | int ret; |
| 1873 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 1874 | ENTER_DEV(dev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1875 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1876 | adapter->sessionId, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1877 | |
| 1878 | ret = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 1879 | if (ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1880 | return ret; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 1881 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1882 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1883 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 1884 | if (ret) { |
| 1885 | hdd_err("Failed to start WLAN modules return"); |
| 1886 | return -ret; |
| 1887 | } |
| 1888 | |
| 1889 | |
| 1890 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 1891 | ret = hdd_start_adapter(adapter); |
| 1892 | if (ret) { |
| 1893 | hdd_err("Failed to start adapter :%d", |
| 1894 | adapter->device_mode); |
| 1895 | return ret; |
| 1896 | } |
| 1897 | } |
| 1898 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1899 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 1900 | if (hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1901 | hdd_info("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1902 | /* Enable TX queues only when we are connected */ |
| 1903 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1904 | WLAN_START_ALL_NETIF_QUEUE, |
| 1905 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1906 | } |
| 1907 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 1908 | /* Enable carrier and transmit queues for NDI */ |
| 1909 | if (WLAN_HDD_IS_NDI(adapter)) { |
| 1910 | hdd_notice("Enabling Tx Queues"); |
| 1911 | wlan_hdd_netif_queue_control(adapter, |
| 1912 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 1913 | WLAN_CONTROL_PATH); |
| 1914 | } |
| 1915 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1916 | return ret; |
| 1917 | } |
| 1918 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1919 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1920 | /** |
| 1921 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 1922 | * @dev: Pointer to net_device structure |
| 1923 | * |
| 1924 | * This is called in response to ifconfig up |
| 1925 | * |
| 1926 | * Return: 0 for success; non-zero for failure |
| 1927 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 1928 | static int hdd_open(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1929 | { |
| 1930 | int ret; |
| 1931 | |
| 1932 | cds_ssr_protect(__func__); |
| 1933 | ret = __hdd_open(dev); |
| 1934 | cds_ssr_unprotect(__func__); |
| 1935 | |
| 1936 | return ret; |
| 1937 | } |
| 1938 | |
| 1939 | /** |
| 1940 | * __hdd_stop() - HDD stop function |
| 1941 | * @dev: Pointer to net_device structure |
| 1942 | * |
| 1943 | * This is called in response to ifconfig down |
| 1944 | * |
| 1945 | * Return: 0 for success; non-zero for failure |
| 1946 | */ |
| 1947 | static int __hdd_stop(struct net_device *dev) |
| 1948 | { |
| 1949 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1950 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1951 | hdd_adapter_list_node_t *adapternode = NULL, *next = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1952 | int ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1953 | bool close_modules = true; |
| 1954 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1955 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 1956 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1957 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1958 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1959 | adapter->sessionId, adapter->device_mode)); |
| 1960 | |
| 1961 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 1962 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1963 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1964 | |
| 1965 | /* Nothing to be done if the interface is not opened */ |
| 1966 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 1967 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1968 | return -ENODEV; |
| 1969 | } |
| 1970 | |
| 1971 | /* Make sure the interface is marked as closed */ |
| 1972 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 1973 | hdd_notice("Disabling OS Tx queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1974 | |
| 1975 | /* |
| 1976 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 1977 | * be called on that interface |
| 1978 | */ |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 1979 | hdd_notice("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1980 | wlan_hdd_netif_queue_control(adapter, WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 1981 | WLAN_CONTROL_PATH); |
| 1982 | |
| 1983 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 1984 | * NAN data interface is different in some sense. The traffic on NDI is |
| 1985 | * bursty in nature and depends on the need to transfer. The service |
| 1986 | * layer may down the interface after the usage and up again when |
| 1987 | * required. In some sense, the NDI is expected to be available |
| 1988 | * (like SAP) iface until NDI delete request is issued by the service |
| 1989 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 1990 | * interface (NDI). |
| 1991 | */ |
| 1992 | if (WLAN_HDD_IS_NDI(adapter)) |
| 1993 | return 0; |
| 1994 | |
| 1995 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1996 | * The interface is marked as down for outside world (aka kernel) |
| 1997 | * But the driver is pretty much alive inside. The driver needs to |
| 1998 | * tear down the existing connection on the netdev (session) |
| 1999 | * cleanup the data pipes and wait until the control plane is stabilized |
| 2000 | * for this interface. The call also needs to wait until the above |
| 2001 | * mentioned actions are completed before returning to the caller. |
| 2002 | * Notice that the hdd_stop_adapter is requested not to close the session |
| 2003 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 2004 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2005 | hdd_stop_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2006 | |
| 2007 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 2008 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 2009 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2010 | |
| 2011 | /* |
| 2012 | * Find if any iface is up. If any iface is up then can't put device to |
| 2013 | * sleep/power save mode |
| 2014 | */ |
| 2015 | status = hdd_get_front_adapter(hdd_ctx, &adapternode); |
| 2016 | while ((NULL != adapternode) && (QDF_STATUS_SUCCESS == status)) { |
| 2017 | if (test_bit(DEVICE_IFACE_OPENED, |
| 2018 | &adapternode->pAdapter->event_flags)) { |
| 2019 | hdd_info("Still other ifaces are up cannot close modules"); |
| 2020 | close_modules = false; |
| 2021 | break; |
| 2022 | } |
| 2023 | status = hdd_get_next_adapter(hdd_ctx, adapternode, &next); |
| 2024 | adapternode = next; |
| 2025 | |
| 2026 | } |
| 2027 | |
| 2028 | if (close_modules) { |
| 2029 | hdd_info("Closing all modules from the hdd_stop"); |
| 2030 | qdf_mc_timer_start(&hdd_ctx->iface_change_timer, |
| 2031 | hdd_ctx->config->iface_change_wait_time |
| 2032 | * 50000); |
| 2033 | } |
| 2034 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2035 | EXIT(); |
| 2036 | return 0; |
| 2037 | } |
| 2038 | |
| 2039 | /** |
| 2040 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 2041 | * @dev: pointer to net_device structure |
| 2042 | * |
| 2043 | * This is called in response to ifconfig down |
| 2044 | * |
| 2045 | * Return: 0 for success and error number for failure |
| 2046 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2047 | static int hdd_stop(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2048 | { |
| 2049 | int ret; |
| 2050 | |
| 2051 | cds_ssr_protect(__func__); |
| 2052 | ret = __hdd_stop(dev); |
| 2053 | cds_ssr_unprotect(__func__); |
| 2054 | |
| 2055 | return ret; |
| 2056 | } |
| 2057 | |
| 2058 | /** |
| 2059 | * __hdd_uninit() - HDD uninit function |
| 2060 | * @dev: Pointer to net_device structure |
| 2061 | * |
| 2062 | * This is called during the netdev unregister to uninitialize all data |
| 2063 | * associated with the device |
| 2064 | * |
| 2065 | * Return: None |
| 2066 | */ |
| 2067 | static void __hdd_uninit(struct net_device *dev) |
| 2068 | { |
| 2069 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2070 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2071 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2072 | |
| 2073 | do { |
| 2074 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2075 | hdd_alert("Invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2076 | break; |
| 2077 | } |
| 2078 | |
| 2079 | if (NULL == adapter->pHddCtx) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2080 | hdd_alert("NULL hdd_ctx"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2081 | break; |
| 2082 | } |
| 2083 | |
| 2084 | if (dev != adapter->dev) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2085 | hdd_alert("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2086 | /* |
| 2087 | * we haven't validated all cases so let this go for |
| 2088 | * now |
| 2089 | */ |
| 2090 | } |
| 2091 | |
| 2092 | hdd_deinit_adapter(adapter->pHddCtx, adapter, true); |
| 2093 | |
| 2094 | /* after uninit our adapter structure will no longer be valid */ |
| 2095 | adapter->dev = NULL; |
| 2096 | adapter->magic = 0; |
| 2097 | } while (0); |
| 2098 | |
| 2099 | EXIT(); |
| 2100 | } |
| 2101 | |
| 2102 | /** |
| 2103 | * hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 2104 | * @dev: pointer to net_device structure |
| 2105 | * |
| 2106 | * This is called during the netdev unregister to uninitialize all data |
| 2107 | * associated with the device |
| 2108 | * |
| 2109 | * Return: none |
| 2110 | */ |
| 2111 | static void hdd_uninit(struct net_device *dev) |
| 2112 | { |
| 2113 | cds_ssr_protect(__func__); |
| 2114 | __hdd_uninit(dev); |
| 2115 | cds_ssr_unprotect(__func__); |
| 2116 | } |
| 2117 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2118 | static int hdd_open_cesium_nl_sock(void) |
| 2119 | { |
| 2120 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 2121 | struct netlink_kernel_cfg cfg = { |
| 2122 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 2123 | .input = NULL |
| 2124 | }; |
| 2125 | #endif |
| 2126 | int ret = 0; |
| 2127 | |
| 2128 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 2129 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 2130 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 2131 | THIS_MODULE, |
| 2132 | #endif |
| 2133 | &cfg); |
| 2134 | #else |
| 2135 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 2136 | WLAN_NLINK_MCAST_GRP_ID, |
| 2137 | NULL, NULL, THIS_MODULE); |
| 2138 | #endif |
| 2139 | |
| 2140 | if (cesium_nl_srv_sock == NULL) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2141 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2142 | ret = -ECONNREFUSED; |
| 2143 | } |
| 2144 | |
| 2145 | return ret; |
| 2146 | } |
| 2147 | |
| 2148 | static void hdd_close_cesium_nl_sock(void) |
| 2149 | { |
| 2150 | if (NULL != cesium_nl_srv_sock) { |
| 2151 | netlink_kernel_release(cesium_nl_srv_sock); |
| 2152 | cesium_nl_srv_sock = NULL; |
| 2153 | } |
| 2154 | } |
| 2155 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2156 | /** |
| 2157 | * __hdd_set_mac_address() - set the user specified mac address |
| 2158 | * @dev: Pointer to the net device. |
| 2159 | * @addr: Pointer to the sockaddr. |
| 2160 | * |
| 2161 | * This function sets the user specified mac address using |
| 2162 | * the command ifconfig wlanX hw ether <mac adress>. |
| 2163 | * |
| 2164 | * Return: 0 for success, non zero for failure |
| 2165 | */ |
| 2166 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 2167 | { |
| 2168 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2169 | hdd_context_t *hdd_ctx; |
| 2170 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2171 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2172 | int ret; |
| 2173 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2174 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2175 | |
| 2176 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2177 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2178 | if (0 != ret) |
| 2179 | return ret; |
| 2180 | |
| 2181 | memcpy(&adapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN); |
| 2182 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 2183 | |
| 2184 | EXIT(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2185 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2186 | } |
| 2187 | |
| 2188 | /** |
| 2189 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
| 2190 | * function from SSR |
| 2191 | * @dev: pointer to net_device structure |
| 2192 | * @addr: Pointer to the sockaddr |
| 2193 | * |
| 2194 | * This function sets the user specified mac address using |
| 2195 | * the command ifconfig wlanX hw ether <mac adress>. |
| 2196 | * |
| 2197 | * Return: 0 for success. |
| 2198 | */ |
| 2199 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 2200 | { |
| 2201 | int ret; |
| 2202 | |
| 2203 | cds_ssr_protect(__func__); |
| 2204 | ret = __hdd_set_mac_address(dev, addr); |
| 2205 | cds_ssr_unprotect(__func__); |
| 2206 | |
| 2207 | return ret; |
| 2208 | } |
| 2209 | |
| 2210 | uint8_t *wlan_hdd_get_intf_addr(hdd_context_t *hdd_ctx) |
| 2211 | { |
| 2212 | int i; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2213 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2214 | if (0 == ((hdd_ctx->config->intfAddrMask) & (1 << i))) |
| 2215 | break; |
| 2216 | } |
| 2217 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2218 | if (QDF_MAX_CONCURRENCY_PERSONA == i) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2219 | return NULL; |
| 2220 | |
| 2221 | hdd_ctx->config->intfAddrMask |= (1 << i); |
| 2222 | return &hdd_ctx->config->intfMacAddr[i].bytes[0]; |
| 2223 | } |
| 2224 | |
| 2225 | void wlan_hdd_release_intf_addr(hdd_context_t *hdd_ctx, uint8_t *releaseAddr) |
| 2226 | { |
| 2227 | int i; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2228 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2229 | if (!memcmp(releaseAddr, |
| 2230 | &hdd_ctx->config->intfMacAddr[i].bytes[0], |
| 2231 | 6)) { |
| 2232 | hdd_ctx->config->intfAddrMask &= ~(1 << i); |
| 2233 | break; |
| 2234 | } |
| 2235 | } |
| 2236 | return; |
| 2237 | } |
| 2238 | |
| 2239 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 2240 | /** |
| 2241 | * __hdd_set_multicast_list() - set the multicast address list |
| 2242 | * @dev: Pointer to the WLAN device. |
| 2243 | * @skb: Pointer to OS packet (sk_buff). |
| 2244 | * |
| 2245 | * This funciton sets the multicast address list. |
| 2246 | * |
| 2247 | * Return: None |
| 2248 | */ |
| 2249 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 2250 | { |
| 2251 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2252 | int mc_count; |
| 2253 | int i = 0, status; |
| 2254 | struct netdev_hw_addr *ha; |
| 2255 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2256 | static const uint8_t ipv6_router_solicitation[] |
| 2257 | = {0x33, 0x33, 0x00, 0x00, 0x00, 0x02}; |
| 2258 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2259 | ENTER_DEV(dev); |
| 2260 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2261 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 2262 | return; |
| 2263 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2264 | status = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 2265 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2266 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2267 | |
| 2268 | if (dev->flags & IFF_ALLMULTI) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2269 | hdd_notice("allow all multicast frames"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2270 | adapter->mc_addr_list.mc_cnt = 0; |
| 2271 | } else { |
| 2272 | mc_count = netdev_mc_count(dev); |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 2273 | hdd_notice("mc_count : %u", mc_count); |
| 2274 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2275 | if (mc_count > WLAN_HDD_MAX_MC_ADDR_LIST) { |
Dustin Brown | 6126946 | 2016-09-19 13:25:45 -0700 | [diff] [blame] | 2276 | hdd_notice("Exceeded max MC filter addresses (%d). Allowing all MC frames by disabling MC address filtering", |
| 2277 | WLAN_HDD_MAX_MC_ADDR_LIST); |
| 2278 | wlan_hdd_set_mc_addr_list(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2279 | adapter->mc_addr_list.mc_cnt = 0; |
| 2280 | return; |
| 2281 | } |
| 2282 | |
| 2283 | adapter->mc_addr_list.mc_cnt = mc_count; |
| 2284 | |
| 2285 | netdev_for_each_mc_addr(ha, dev) { |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 2286 | hdd_notice("ha_addr[%d] "MAC_ADDRESS_STR, |
| 2287 | i, MAC_ADDR_ARRAY(ha->addr)); |
| 2288 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2289 | if (i == mc_count) |
| 2290 | break; |
| 2291 | /* |
| 2292 | * Skip following addresses: |
| 2293 | * 1)IPv6 router solicitation address |
| 2294 | * 2)Any other address pattern if its set during |
| 2295 | * RXFILTER REMOVE driver command based on |
| 2296 | * addr_filter_pattern |
| 2297 | */ |
| 2298 | if ((!memcmp(ha->addr, ipv6_router_solicitation, |
| 2299 | ETH_ALEN)) || |
| 2300 | (adapter->addr_filter_pattern && (!memcmp(ha->addr, |
| 2301 | &adapter->addr_filter_pattern, 1)))) { |
Srinivas Girigowda | f2599dd | 2015-11-16 18:20:46 -0800 | [diff] [blame] | 2302 | hdd_info("MC/BC filtering Skip addr ="MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2303 | MAC_ADDR_ARRAY(ha->addr)); |
| 2304 | adapter->mc_addr_list.mc_cnt--; |
| 2305 | continue; |
| 2306 | } |
| 2307 | |
| 2308 | memset(&(adapter->mc_addr_list.addr[i][0]), 0, |
| 2309 | ETH_ALEN); |
| 2310 | memcpy(&(adapter->mc_addr_list.addr[i][0]), ha->addr, |
| 2311 | ETH_ALEN); |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2312 | hdd_notice("mlist[%d] = " MAC_ADDRESS_STR, i, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2313 | MAC_ADDR_ARRAY(adapter->mc_addr_list.addr[i])); |
| 2314 | i++; |
| 2315 | } |
| 2316 | } |
| 2317 | if (hdd_ctx->config->active_mode_offload) { |
| 2318 | hdd_info("enable mc filtering"); |
| 2319 | wlan_hdd_set_mc_addr_list(adapter, true); |
| 2320 | } else { |
| 2321 | hdd_info("skip mc filtering enable it during cfg80211 suspend"); |
| 2322 | } |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 2323 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2324 | return; |
| 2325 | } |
| 2326 | |
| 2327 | /** |
| 2328 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
| 2329 | * @dev: pointer to net_device |
| 2330 | * |
| 2331 | * Return: none |
| 2332 | */ |
| 2333 | static void hdd_set_multicast_list(struct net_device *dev) |
| 2334 | { |
| 2335 | cds_ssr_protect(__func__); |
| 2336 | __hdd_set_multicast_list(dev); |
| 2337 | cds_ssr_unprotect(__func__); |
| 2338 | } |
| 2339 | #endif |
| 2340 | |
| 2341 | /** |
| 2342 | * hdd_select_queue() - used by Linux OS to decide which queue to use first |
| 2343 | * @dev: Pointer to the WLAN device. |
| 2344 | * @skb: Pointer to OS packet (sk_buff). |
| 2345 | * |
| 2346 | * This function is registered with the Linux OS for network |
| 2347 | * core to decide which queue to use first. |
| 2348 | * |
| 2349 | * Return: ac, Queue Index/access category corresponding to UP in IP header |
| 2350 | */ |
| 2351 | static uint16_t hdd_select_queue(struct net_device *dev, struct sk_buff *skb |
| 2352 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) |
| 2353 | , void *accel_priv |
| 2354 | #endif |
| 2355 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 2356 | , select_queue_fallback_t fallback |
| 2357 | #endif |
| 2358 | ) |
| 2359 | { |
| 2360 | return hdd_wmm_select_queue(dev, skb); |
| 2361 | } |
| 2362 | |
| 2363 | static struct net_device_ops wlan_drv_ops = { |
| 2364 | .ndo_open = hdd_open, |
| 2365 | .ndo_stop = hdd_stop, |
| 2366 | .ndo_uninit = hdd_uninit, |
| 2367 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 2368 | .ndo_tx_timeout = hdd_tx_timeout, |
| 2369 | .ndo_get_stats = hdd_get_stats, |
| 2370 | .ndo_do_ioctl = hdd_ioctl, |
| 2371 | .ndo_set_mac_address = hdd_set_mac_address, |
| 2372 | .ndo_select_queue = hdd_select_queue, |
| 2373 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2374 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2375 | #endif |
| 2376 | }; |
| 2377 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2378 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
| 2379 | static struct net_device_ops wlan_mon_drv_ops = { |
| 2380 | .ndo_open = hdd_mon_open, |
| 2381 | .ndo_stop = hdd_stop, |
| 2382 | .ndo_get_stats = hdd_get_stats, |
| 2383 | }; |
| 2384 | |
| 2385 | /** |
| 2386 | * hdd_set_station_ops() - update net_device ops for monitor mode |
| 2387 | * @pWlanDev: Handle to struct net_device to be updated. |
| 2388 | * Return: None |
| 2389 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2390 | void hdd_set_station_ops(struct net_device *pWlanDev) |
| 2391 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2392 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
| 2393 | pWlanDev->netdev_ops = &wlan_mon_drv_ops; |
| 2394 | else |
| 2395 | pWlanDev->netdev_ops = &wlan_drv_ops; |
| 2396 | } |
| 2397 | |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 2398 | #ifdef FEATURE_RUNTIME_PM |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 2399 | /** |
| 2400 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 2401 | * @hdd_ctx: HDD context |
| 2402 | * |
| 2403 | * Return: None |
| 2404 | */ |
| 2405 | static void hdd_runtime_suspend_context_init(hdd_context_t *hdd_ctx) |
| 2406 | { |
| 2407 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 2408 | |
| 2409 | ctx->scan = qdf_runtime_lock_init("scan"); |
Komal Seelam | aa75f26 | 2016-09-29 12:32:13 +0530 | [diff] [blame] | 2410 | ctx->roc = qdf_runtime_lock_init("roc"); |
Komal Seelam | 81cb166 | 2016-09-29 12:39:08 +0530 | [diff] [blame] | 2411 | ctx->dfs = qdf_runtime_lock_init("dfs"); |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 2412 | } |
| 2413 | |
| 2414 | /** |
| 2415 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 2416 | * @hdd_ctx: HDD Context |
| 2417 | * |
| 2418 | * Return: None |
| 2419 | */ |
| 2420 | static void hdd_runtime_suspend_context_deinit(hdd_context_t *hdd_ctx) |
| 2421 | { |
| 2422 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 2423 | |
| 2424 | qdf_runtime_lock_deinit(ctx->scan); |
| 2425 | ctx->scan = NULL; |
Komal Seelam | aa75f26 | 2016-09-29 12:32:13 +0530 | [diff] [blame] | 2426 | qdf_runtime_lock_deinit(ctx->roc); |
| 2427 | ctx->roc = NULL; |
Komal Seelam | 81cb166 | 2016-09-29 12:39:08 +0530 | [diff] [blame] | 2428 | qdf_runtime_lock_deinit(ctx->dfs); |
| 2429 | ctx->dfs = NULL; |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 2430 | } |
| 2431 | |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 2432 | static void hdd_adapter_runtime_suspend_init(hdd_adapter_t *adapter) |
| 2433 | { |
| 2434 | struct hdd_connect_pm_context *ctx = &adapter->connect_rpm_ctx; |
| 2435 | |
| 2436 | ctx->connect = qdf_runtime_lock_init("connect"); |
| 2437 | } |
| 2438 | |
| 2439 | static void hdd_adapter_runtime_suspend_denit(hdd_adapter_t *adapter) |
| 2440 | { |
| 2441 | struct hdd_connect_pm_context *ctx = &adapter->connect_rpm_ctx; |
| 2442 | |
| 2443 | qdf_runtime_lock_deinit(ctx->connect); |
| 2444 | ctx->connect = NULL; |
| 2445 | } |
| 2446 | #else /* FEATURE_RUNTIME_PM */ |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 2447 | static void hdd_runtime_suspend_context_init(hdd_context_t *hdd_ctx) {} |
| 2448 | static void hdd_runtime_suspend_context_deinit(hdd_context_t *hdd_ctx) {} |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 2449 | static inline void hdd_adapter_runtime_suspend_init(hdd_adapter_t *adapter) {} |
| 2450 | static inline void hdd_adapter_runtime_suspend_denit(hdd_adapter_t *adapter) {} |
| 2451 | #endif /* FEATURE_RUNTIME_PM */ |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2452 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 2453 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 2454 | * @hdd_ctx: global hdd context |
| 2455 | * @macAddr: mac address to assign to the interface |
| 2456 | * @name: User-visible name of the interface |
| 2457 | * |
| 2458 | * hdd adapter pointer would point to the netdev->priv space, this function |
| 2459 | * would retrive the pointer, and setup the hdd adapter configuration. |
| 2460 | * |
| 2461 | * Return: the pointer to hdd adapter, otherwise NULL |
| 2462 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2463 | static hdd_adapter_t *hdd_alloc_station_adapter(hdd_context_t *hdd_ctx, |
| 2464 | tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 2465 | unsigned char name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2466 | const char *name) |
| 2467 | { |
| 2468 | struct net_device *pWlanDev = NULL; |
| 2469 | hdd_adapter_t *adapter = NULL; |
| 2470 | /* |
| 2471 | * cfg80211 initialization and registration.... |
| 2472 | */ |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 2473 | pWlanDev = alloc_netdev_mq(sizeof(hdd_adapter_t), name, |
| 2474 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
| 2475 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2476 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2477 | (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam() ? |
| 2478 | hdd_mon_mode_ether_setup : ether_setup), |
| 2479 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2480 | |
| 2481 | if (pWlanDev != NULL) { |
| 2482 | |
| 2483 | /* Save the pointer to the net_device in the HDD adapter */ |
| 2484 | adapter = (hdd_adapter_t *) netdev_priv(pWlanDev); |
| 2485 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2486 | qdf_mem_zero(adapter, sizeof(hdd_adapter_t)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2487 | |
| 2488 | adapter->dev = pWlanDev; |
| 2489 | adapter->pHddCtx = hdd_ctx; |
| 2490 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Arun Khandavalli | 9ad88f0 | 2016-09-01 19:03:37 +0530 | [diff] [blame] | 2491 | adapter->sessionId = HDD_SESSION_ID_INVALID; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2492 | |
| 2493 | init_completion(&adapter->session_open_comp_var); |
| 2494 | init_completion(&adapter->session_close_comp_var); |
| 2495 | init_completion(&adapter->disconnect_comp_var); |
| 2496 | init_completion(&adapter->linkup_event_var); |
| 2497 | init_completion(&adapter->cancel_rem_on_chan_var); |
| 2498 | init_completion(&adapter->rem_on_chan_ready_event); |
| 2499 | init_completion(&adapter->sta_authorized_event); |
| 2500 | init_completion(&adapter->offchannel_tx_event); |
| 2501 | init_completion(&adapter->tx_action_cnf_event); |
| 2502 | #ifdef FEATURE_WLAN_TDLS |
| 2503 | init_completion(&adapter->tdls_add_station_comp); |
| 2504 | init_completion(&adapter->tdls_del_station_comp); |
| 2505 | init_completion(&adapter->tdls_mgmt_comp); |
| 2506 | init_completion(&adapter->tdls_link_establish_req_comp); |
| 2507 | #endif |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2508 | init_completion(&adapter->ibss_peer_info_comp); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2509 | init_completion(&adapter->change_country_code); |
| 2510 | |
| 2511 | |
| 2512 | init_completion(&adapter->scan_info.abortscan_event_var); |
| 2513 | |
| 2514 | adapter->offloads_configured = false; |
| 2515 | adapter->isLinkUpSvcNeeded = false; |
| 2516 | adapter->higherDtimTransition = true; |
| 2517 | /* Init the net_device structure */ |
| 2518 | strlcpy(pWlanDev->name, name, IFNAMSIZ); |
| 2519 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2520 | qdf_mem_copy(pWlanDev->dev_addr, (void *)macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2521 | sizeof(tSirMacAddr)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2522 | qdf_mem_copy(adapter->macAddressCurrent.bytes, macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2523 | sizeof(tSirMacAddr)); |
| 2524 | pWlanDev->watchdog_timeo = HDD_TX_TIMEOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2525 | |
| 2526 | if (hdd_ctx->config->enable_ip_tcp_udp_checksum_offload) |
| 2527 | pWlanDev->features |= |
| 2528 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
| 2529 | pWlanDev->features |= NETIF_F_RXCSUM; |
| 2530 | |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 2531 | hdd_set_tso_flags(hdd_ctx, pWlanDev); |
| 2532 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2533 | hdd_set_station_ops(adapter->dev); |
| 2534 | |
| 2535 | pWlanDev->destructor = free_netdev; |
| 2536 | pWlanDev->ieee80211_ptr = &adapter->wdev; |
Mohit Khanna | ee9e80f | 2015-11-10 11:32:49 -0800 | [diff] [blame] | 2537 | pWlanDev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2538 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
| 2539 | adapter->wdev.netdev = pWlanDev; |
| 2540 | /* set pWlanDev's parent to underlying device */ |
| 2541 | SET_NETDEV_DEV(pWlanDev, hdd_ctx->parent_dev); |
| 2542 | hdd_wmm_init(adapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 2543 | hdd_adapter_runtime_suspend_init(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2544 | spin_lock_init(&adapter->pause_map_lock); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 2545 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2546 | } |
| 2547 | |
| 2548 | return adapter; |
| 2549 | } |
| 2550 | |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2551 | static QDF_STATUS hdd_register_interface(hdd_adapter_t *adapter, |
| 2552 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2553 | { |
| 2554 | struct net_device *pWlanDev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2555 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 2556 | if (rtnl_held) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2557 | if (strnchr(pWlanDev->name, strlen(pWlanDev->name), '%')) { |
| 2558 | if (dev_alloc_name(pWlanDev, pWlanDev->name) < 0) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2559 | hdd_err("Failed:dev_alloc_name"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2560 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2561 | } |
| 2562 | } |
| 2563 | if (register_netdevice(pWlanDev)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2564 | hdd_err("Failed:register_netdev"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2565 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2566 | } |
| 2567 | } else { |
| 2568 | if (register_netdev(pWlanDev)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2569 | hdd_err("Failed:register_netdev"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2570 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2571 | } |
| 2572 | } |
| 2573 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 2574 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2575 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2576 | } |
| 2577 | |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 2578 | QDF_STATUS hdd_sme_close_session_callback(void *pContext) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2579 | { |
| 2580 | hdd_adapter_t *adapter = pContext; |
| 2581 | |
| 2582 | if (NULL == adapter) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2583 | hdd_alert("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2584 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2585 | } |
| 2586 | |
| 2587 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2588 | hdd_alert("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2589 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2590 | } |
| 2591 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 2592 | /* |
| 2593 | * For NAN Data interface, the close session results in the final |
| 2594 | * indication to the userspace |
| 2595 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 2596 | if (adapter->device_mode == QDF_NDI_MODE) |
| 2597 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 2598 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2599 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 2600 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2601 | /* |
| 2602 | * We can be blocked while waiting for scheduled work to be |
| 2603 | * flushed, and the adapter structure can potentially be freed, in |
| 2604 | * which case the magic will have been reset. So make sure the |
| 2605 | * magic is still good, and hence the adapter structure is still |
| 2606 | * valid, before signaling completion |
| 2607 | */ |
| 2608 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
| 2609 | complete(&adapter->session_close_comp_var); |
| 2610 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2611 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2612 | } |
| 2613 | |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 2614 | /** |
| 2615 | * hdd_check_and_init_tdls() - check and init TDLS operation for desired mode |
| 2616 | * @adapter: pointer to device adapter |
| 2617 | * @type: type of interface |
| 2618 | * |
| 2619 | * This routine will check the mode of adapter and if it is required then it |
| 2620 | * will initialize the TDLS operations |
| 2621 | * |
| 2622 | * Return: QDF_STATUS |
| 2623 | */ |
| 2624 | #ifdef FEATURE_WLAN_TDLS |
| 2625 | static QDF_STATUS hdd_check_and_init_tdls(hdd_adapter_t *adapter, uint32_t type) |
| 2626 | { |
| 2627 | if (QDF_IBSS_MODE != type) { |
| 2628 | if (0 != wlan_hdd_tdls_init(adapter)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2629 | hdd_err("wlan_hdd_tdls_init failed"); |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 2630 | return QDF_STATUS_E_FAILURE; |
| 2631 | } |
| 2632 | set_bit(TDLS_INIT_DONE, &adapter->event_flags); |
| 2633 | } |
| 2634 | return QDF_STATUS_SUCCESS; |
| 2635 | } |
| 2636 | #else |
| 2637 | static QDF_STATUS hdd_check_and_init_tdls(hdd_adapter_t *adapter, uint32_t type) |
| 2638 | { |
| 2639 | return QDF_STATUS_SUCCESS; |
| 2640 | } |
| 2641 | #endif |
| 2642 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2643 | QDF_STATUS hdd_init_station_mode(hdd_adapter_t *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2644 | { |
| 2645 | struct net_device *pWlanDev = adapter->dev; |
| 2646 | hdd_station_ctx_t *pHddStaCtx = &adapter->sessionCtx.station; |
| 2647 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2648 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2649 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2650 | uint32_t type, subType; |
| 2651 | unsigned long rc; |
| 2652 | int ret_val; |
| 2653 | |
| 2654 | INIT_COMPLETION(adapter->session_open_comp_var); |
| 2655 | sme_set_curr_device_mode(hdd_ctx->hHal, adapter->device_mode); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 2656 | 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] | 2657 | status = cds_get_vdev_types(adapter->device_mode, &type, &subType); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2658 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2659 | hdd_err("failed to get vdev type"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2660 | goto error_sme_open; |
| 2661 | } |
| 2662 | /* Open a SME session for future operation */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2663 | qdf_ret_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2664 | sme_open_session(hdd_ctx->hHal, hdd_sme_roam_callback, adapter, |
| 2665 | (uint8_t *) &adapter->macAddressCurrent, |
| 2666 | &adapter->sessionId, type, subType); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2667 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2668 | hdd_alert("sme_open_session() failed, status code %08d [x%08x]", |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2669 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2670 | status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2671 | goto error_sme_open; |
| 2672 | } |
| 2673 | /* Block on a completion variable. Can't wait forever though. */ |
| 2674 | rc = wait_for_completion_timeout( |
| 2675 | &adapter->session_open_comp_var, |
| 2676 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
| 2677 | if (!rc) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2678 | hdd_alert("Session is not opened within timeout period code %ld", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2679 | rc); |
Sandeep Puligilla | e806599 | 2016-11-14 00:23:43 -0800 | [diff] [blame] | 2680 | adapter->sessionId = HDD_SESSION_ID_INVALID; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2681 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2682 | } |
| 2683 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2684 | status = hdd_create_and_store_vdev(hdd_ctx->hdd_pdev, adapter); |
| 2685 | if (QDF_IS_STATUS_ERROR(status)) |
| 2686 | goto error_vdev_create; |
| 2687 | |
Naveen Rawat | a410c5a | 2016-09-19 14:22:33 -0700 | [diff] [blame] | 2688 | sme_set_vdev_ies_per_band(hdd_ctx->hHal, adapter->sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2689 | /* Register wireless extensions */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2690 | qdf_ret_status = hdd_register_wext(pWlanDev); |
| 2691 | if (QDF_STATUS_SUCCESS != qdf_ret_status) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2692 | hdd_alert("hdd_register_wext() failed, status code %08d [x%08x]", |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2693 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2694 | status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2695 | goto error_register_wext; |
| 2696 | } |
| 2697 | /* Set the Connection State to Not Connected */ |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2698 | hdd_notice("Set HDD connState to eConnectionState_NotConnected"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2699 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 2700 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 2701 | /* set fast roaming capability in sme session */ |
| 2702 | status = sme_config_fast_roaming(hdd_ctx->hHal, adapter->sessionId, |
| 2703 | adapter->fast_roaming_allowed); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2704 | /* Set the default operation channel */ |
| 2705 | pHddStaCtx->conn_info.operationChannel = |
| 2706 | hdd_ctx->config->OperatingChannel; |
| 2707 | |
| 2708 | /* Make the default Auth Type as OPEN */ |
| 2709 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 2710 | |
| 2711 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2712 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2713 | hdd_alert("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2714 | status, status); |
| 2715 | goto error_init_txrx; |
| 2716 | } |
| 2717 | |
| 2718 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 2719 | |
| 2720 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2721 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2722 | hdd_alert("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2723 | status, status); |
| 2724 | goto error_wmm_init; |
| 2725 | } |
| 2726 | |
| 2727 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 2728 | |
| 2729 | ret_val = wma_cli_set_command(adapter->sessionId, |
| 2730 | WMI_PDEV_PARAM_BURST_ENABLE, |
| 2731 | hdd_ctx->config->enableSifsBurst, |
| 2732 | PDEV_CMD); |
| 2733 | |
| 2734 | if (0 != ret_val) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2735 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2736 | ret_val); |
| 2737 | } |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 2738 | status = hdd_check_and_init_tdls(adapter, type); |
| 2739 | if (status != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2740 | goto error_tdls_init; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2741 | |
Himanshu Agarwal | 3d95b90 | 2016-08-24 16:27:03 +0530 | [diff] [blame] | 2742 | status = hdd_lro_enable(hdd_ctx, adapter); |
| 2743 | if (status != QDF_STATUS_SUCCESS) |
| 2744 | goto error_lro_enable; |
| 2745 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2746 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2747 | |
Himanshu Agarwal | 3d95b90 | 2016-08-24 16:27:03 +0530 | [diff] [blame] | 2748 | error_lro_enable: |
| 2749 | wlan_hdd_tdls_exit(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2750 | error_tdls_init: |
| 2751 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 2752 | hdd_wmm_adapter_close(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2753 | error_wmm_init: |
| 2754 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 2755 | hdd_deinit_tx_rx(adapter); |
| 2756 | error_init_txrx: |
| 2757 | hdd_unregister_wext(pWlanDev); |
| 2758 | error_register_wext: |
Rajeev Kumar | ba77885 | 2017-01-06 13:23:04 -0800 | [diff] [blame] | 2759 | status = hdd_release_and_destroy_vdev(adapter); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2760 | if (QDF_IS_STATUS_ERROR(status)) |
| 2761 | hdd_err("vdev delete failed"); |
| 2762 | error_vdev_create: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2763 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2764 | INIT_COMPLETION(adapter->session_close_comp_var); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2765 | if (QDF_STATUS_SUCCESS == sme_close_session(hdd_ctx->hHal, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2766 | adapter->sessionId, |
| 2767 | hdd_sme_close_session_callback, |
| 2768 | adapter)) { |
| 2769 | unsigned long rc; |
| 2770 | |
| 2771 | /* |
| 2772 | * Block on a completion variable. |
| 2773 | * Can't wait forever though. |
| 2774 | */ |
| 2775 | rc = wait_for_completion_timeout( |
| 2776 | &adapter->session_close_comp_var, |
| 2777 | msecs_to_jiffies |
| 2778 | (WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
| 2779 | if (rc <= 0) |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2780 | hdd_err("Session is not opened within timeout period code %ld", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2781 | rc); |
| 2782 | } |
| 2783 | } |
| 2784 | error_sme_open: |
| 2785 | return status; |
| 2786 | } |
| 2787 | |
| 2788 | void hdd_cleanup_actionframe(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter) |
| 2789 | { |
| 2790 | hdd_cfg80211_state_t *cfgState; |
| 2791 | |
| 2792 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR(adapter); |
| 2793 | |
| 2794 | if (NULL != cfgState->buf) { |
| 2795 | unsigned long rc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2796 | rc = wait_for_completion_timeout( |
| 2797 | &adapter->tx_action_cnf_event, |
| 2798 | msecs_to_jiffies(ACTION_FRAME_TX_TIMEOUT)); |
| 2799 | if (!rc) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 2800 | hdd_err("HDD Wait for Action Confirmation Failed!!"); |
Masti, Narayanraddi | f8f6e7e | 2015-08-25 10:22:46 +0530 | [diff] [blame] | 2801 | /* |
| 2802 | * Inform tx status as FAILURE to upper layer and free |
| 2803 | * cfgState->buf |
| 2804 | */ |
| 2805 | hdd_send_action_cnf(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2806 | } |
| 2807 | } |
| 2808 | return; |
| 2809 | } |
| 2810 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2811 | /** |
| 2812 | * hdd_station_adapter_deinit() - De-initialize the station adapter |
| 2813 | * @hdd_ctx: global hdd context |
| 2814 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2815 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 2816 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2817 | * |
| 2818 | * This function De-initializes the STA/P2P/OCB adapter. |
| 2819 | * |
| 2820 | * Return: None. |
| 2821 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2822 | static void hdd_station_adapter_deinit(hdd_context_t *hdd_ctx, |
| 2823 | hdd_adapter_t *adapter, |
| 2824 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2825 | { |
| 2826 | ENTER_DEV(adapter->dev); |
| 2827 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 2828 | if (adapter->dev) { |
| 2829 | if (rtnl_held) |
| 2830 | adapter->dev->wireless_handlers = NULL; |
| 2831 | else { |
| 2832 | rtnl_lock(); |
| 2833 | adapter->dev->wireless_handlers = NULL; |
| 2834 | rtnl_unlock(); |
| 2835 | } |
| 2836 | } |
| 2837 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2838 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 2839 | hdd_deinit_tx_rx(adapter); |
| 2840 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 2841 | } |
| 2842 | |
| 2843 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 2844 | hdd_wmm_adapter_close(adapter); |
| 2845 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 2846 | } |
| 2847 | |
| 2848 | hdd_cleanup_actionframe(hdd_ctx, adapter); |
| 2849 | wlan_hdd_tdls_exit(adapter); |
| 2850 | |
| 2851 | EXIT(); |
| 2852 | } |
| 2853 | |
| 2854 | /** |
| 2855 | * hdd_ap_adapter_deinit() - De-initialize the ap adapter |
| 2856 | * @hdd_ctx: global hdd context |
| 2857 | * @adapter: HDD adapter |
| 2858 | * @rtnl_held: the rtnl lock hold flag |
| 2859 | * This function De-initializes the AP/P2PGo adapter. |
| 2860 | * |
| 2861 | * Return: None. |
| 2862 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2863 | static void hdd_ap_adapter_deinit(hdd_context_t *hdd_ctx, |
| 2864 | hdd_adapter_t *adapter, |
| 2865 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2866 | { |
| 2867 | ENTER_DEV(adapter->dev); |
| 2868 | |
| 2869 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 2870 | hdd_wmm_adapter_close(adapter); |
| 2871 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 2872 | } |
Liangwei Dong | 8baf7c8 | 2016-10-11 01:26:59 -0400 | [diff] [blame] | 2873 | wlan_hdd_undo_acs(adapter); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2874 | |
| 2875 | hdd_cleanup_actionframe(hdd_ctx, adapter); |
| 2876 | |
| 2877 | hdd_unregister_hostapd(adapter, rtnl_held); |
| 2878 | |
| 2879 | EXIT(); |
| 2880 | } |
| 2881 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2882 | void hdd_deinit_adapter(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, |
| 2883 | bool rtnl_held) |
| 2884 | { |
| 2885 | ENTER(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2886 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2887 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 2888 | case QDF_STA_MODE: |
| 2889 | case QDF_P2P_CLIENT_MODE: |
| 2890 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2891 | { |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 2892 | hdd_station_adapter_deinit(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2893 | break; |
| 2894 | } |
| 2895 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 2896 | case QDF_SAP_MODE: |
| 2897 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2898 | { |
| 2899 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2900 | hdd_ap_adapter_deinit(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2901 | break; |
| 2902 | } |
| 2903 | |
| 2904 | default: |
| 2905 | break; |
| 2906 | } |
| 2907 | |
| 2908 | EXIT(); |
| 2909 | } |
| 2910 | |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2911 | static void hdd_cleanup_adapter(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, |
| 2912 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2913 | { |
| 2914 | struct net_device *pWlanDev = NULL; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2915 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2916 | |
| 2917 | if (adapter) |
| 2918 | pWlanDev = adapter->dev; |
| 2919 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 2920 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2921 | return; |
| 2922 | } |
| 2923 | |
Rajeev Kumar | ba77885 | 2017-01-06 13:23:04 -0800 | [diff] [blame] | 2924 | qdf_status = hdd_release_and_destroy_vdev(adapter); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2925 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 2926 | hdd_err("vdev delete failed"); |
| 2927 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 2928 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 2929 | |
| 2930 | if (adapter->scan_info.default_scan_ies) { |
| 2931 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 2932 | adapter->scan_info.default_scan_ies = NULL; |
| 2933 | } |
| 2934 | |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 2935 | hdd_adapter_runtime_suspend_denit(adapter); |
| 2936 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2937 | /* |
| 2938 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 2939 | * the driver is almost closed and cannot handle either control |
| 2940 | * messages or data. However, unregister_netdevice() call above will |
| 2941 | * eventually invoke hdd_stop (ndo_close) driver callback, which attempts |
| 2942 | * to close the active connections (basically excites control path) which |
| 2943 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 2944 | * the interface is closed and restricts any operations on that |
| 2945 | */ |
| 2946 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2947 | |
| 2948 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
| 2949 | if (rtnl_held) { |
| 2950 | unregister_netdevice(pWlanDev); |
| 2951 | } else { |
| 2952 | unregister_netdev(pWlanDev); |
| 2953 | } |
| 2954 | /* |
| 2955 | * Note that the adapter is no longer valid at this point |
| 2956 | * since the memory has been reclaimed |
| 2957 | */ |
| 2958 | } |
| 2959 | } |
| 2960 | |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2961 | static QDF_STATUS hdd_check_for_existing_macaddr(hdd_context_t *hdd_ctx, |
| 2962 | tSirMacAddr macAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2963 | { |
| 2964 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 2965 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2966 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2967 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2968 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2969 | adapter = adapterNode->pAdapter; |
| 2970 | if (adapter |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2971 | && !qdf_mem_cmp(adapter->macAddressCurrent.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2972 | macAddr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2973 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2974 | } |
| 2975 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 2976 | adapterNode = pNext; |
| 2977 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2978 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2979 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 2980 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 2981 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 2982 | /** |
| 2983 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 2984 | * @hdd_ctx: HDD Context |
| 2985 | * @adapter: HDD Adapter |
| 2986 | * |
| 2987 | * This function set the FW Debug log level based on the INI. |
| 2988 | * |
| 2989 | * Return: None |
| 2990 | */ |
| 2991 | static void hdd_set_fw_log_params(hdd_context_t *hdd_ctx, |
| 2992 | hdd_adapter_t *adapter) |
| 2993 | { |
| 2994 | uint8_t count = 0, numentries = 0, |
| 2995 | moduleloglevel[FW_MODULE_LOG_LEVEL_STRING_LENGTH]; |
| 2996 | uint32_t value = 0; |
| 2997 | int ret; |
| 2998 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2999 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 3000 | (!hdd_ctx->config->enable_fw_log)) { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3001 | hdd_info("enable_fw_log not enabled in INI or in FTM mode return"); |
| 3002 | return; |
| 3003 | } |
| 3004 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3005 | /* Enable FW logs based on INI configuration */ |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3006 | hdd_ctx->fw_log_settings.dl_type = |
| 3007 | hdd_ctx->config->enableFwLogType; |
| 3008 | ret = wma_cli_set_command(adapter->sessionId, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3009 | WMI_DBGLOG_TYPE, |
| 3010 | hdd_ctx->config->enableFwLogType, |
| 3011 | DBG_CMD); |
| 3012 | if (ret != 0) |
| 3013 | hdd_err("Failed to enable FW log type ret %d", |
| 3014 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3015 | |
| 3016 | hdd_ctx->fw_log_settings.dl_loglevel = |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3017 | hdd_ctx->config->enableFwLogLevel; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3018 | ret = wma_cli_set_command(adapter->sessionId, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3019 | WMI_DBGLOG_LOG_LEVEL, |
| 3020 | hdd_ctx->config->enableFwLogLevel, |
| 3021 | DBG_CMD); |
| 3022 | if (ret != 0) |
| 3023 | hdd_err("Failed to enable FW log level ret %d", |
| 3024 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3025 | |
| 3026 | hdd_string_to_u8_array( |
| 3027 | hdd_ctx->config->enableFwModuleLogLevel, |
| 3028 | moduleloglevel, |
| 3029 | &numentries, |
| 3030 | FW_MODULE_LOG_LEVEL_STRING_LENGTH); |
| 3031 | |
| 3032 | while (count < numentries) { |
| 3033 | /* |
| 3034 | * FW module log level input string looks like |
| 3035 | * below: |
| 3036 | * gFwDebugModuleLoglevel=<FW Module ID>, |
| 3037 | * <Log Level>,... |
| 3038 | * For example: |
| 3039 | * gFwDebugModuleLoglevel= |
| 3040 | * 1,0,2,1,3,2,4,3,5,4,6,5,7,6 |
| 3041 | * Above input string means : |
| 3042 | * For FW module ID 1 enable log level 0 |
| 3043 | * For FW module ID 2 enable log level 1 |
| 3044 | * For FW module ID 3 enable log level 2 |
| 3045 | * For FW module ID 4 enable log level 3 |
| 3046 | * For FW module ID 5 enable log level 4 |
| 3047 | * For FW module ID 6 enable log level 5 |
| 3048 | * For FW module ID 7 enable log level 6 |
| 3049 | */ |
| 3050 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3051 | /* FW expects WMI command value = |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3052 | * Module ID * 10 + Module Log level |
| 3053 | */ |
| 3054 | value = ((moduleloglevel[count] * 10) + |
| 3055 | moduleloglevel[count + 1]); |
| 3056 | ret = wma_cli_set_command(adapter->sessionId, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3057 | WMI_DBGLOG_MOD_LOG_LEVEL, |
| 3058 | value, DBG_CMD); |
| 3059 | if (ret != 0) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3060 | hdd_err("Failed to enable FW module log level %d ret %d", |
| 3061 | value, ret); |
| 3062 | |
| 3063 | count += 2; |
| 3064 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3065 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3066 | } |
| 3067 | #else |
| 3068 | static void hdd_set_fw_log_params(hdd_context_t *hdd_ctx, |
| 3069 | hdd_adapter_t *adapter) |
| 3070 | { |
| 3071 | } |
| 3072 | |
| 3073 | #endif |
| 3074 | |
| 3075 | /** |
| 3076 | * hdd_set_fw_params() - Set parameters to firmware |
| 3077 | * @adapter: HDD adapter |
| 3078 | * |
| 3079 | * This function Sets various parameters to fw once the |
| 3080 | * adapter is started. |
| 3081 | * |
| 3082 | * Return: 0 on success or errno on failure |
| 3083 | */ |
| 3084 | int hdd_set_fw_params(hdd_adapter_t *adapter) |
| 3085 | { |
| 3086 | int ret; |
| 3087 | hdd_context_t *hdd_ctx; |
| 3088 | |
| 3089 | ENTER_DEV(adapter->dev); |
| 3090 | |
| 3091 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3092 | if (!hdd_ctx) |
| 3093 | return -EINVAL; |
| 3094 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3095 | if ((cds_get_conparam() != QDF_GLOBAL_FTM_MODE) && |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3096 | (!hdd_ctx->config->enable2x2)) { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3097 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 3098 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3099 | /* |
| 3100 | * Disable DTIM 1 chain Rx when in 1x1, |
| 3101 | * we are passing two value |
| 3102 | * as param_id << 29 | param_value. |
| 3103 | * Below param_value = 0(disable) |
| 3104 | */ |
| 3105 | ret = wma_cli_set_command(adapter->sessionId, |
| 3106 | WMI_STA_SMPS_PARAM_CMDID, |
| 3107 | HDD_DTIM_1CHAIN_RX_ID << |
| 3108 | HDD_SMPS_PARAM_VALUE_S, |
| 3109 | VDEV_CMD); |
| 3110 | if (ret) { |
| 3111 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 3112 | goto error; |
| 3113 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3114 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3115 | ret = wma_cli_set_command(adapter->sessionId, |
| 3116 | WMI_PDEV_PARAM_TX_CHAIN_MASK, |
| 3117 | hdd_ctx->config->txchainmask1x1, |
| 3118 | PDEV_CMD); |
| 3119 | if (ret) { |
| 3120 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK set failed %d", |
| 3121 | ret); |
| 3122 | goto error; |
| 3123 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3124 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3125 | ret = wma_cli_set_command(adapter->sessionId, |
| 3126 | WMI_PDEV_PARAM_RX_CHAIN_MASK, |
| 3127 | hdd_ctx->config->rxchainmask1x1, |
| 3128 | PDEV_CMD); |
| 3129 | if (ret) { |
| 3130 | hdd_err("WMI_PDEV_PARAM_RX_CHAIN_MASK set failed %d", |
| 3131 | ret); |
| 3132 | goto error; |
| 3133 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3134 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 3135 | #undef HDD_SMPS_PARAM_VALUE_S |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3136 | } else { |
| 3137 | hdd_info("FTM Mode or 2x2 mode - Do not set 1x1 params"); |
| 3138 | } |
| 3139 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3140 | if (QDF_GLOBAL_FTM_MODE != cds_get_conparam()) { |
| 3141 | ret = wma_cli_set_command(adapter->sessionId, |
| 3142 | WMI_PDEV_PARAM_HYST_EN, |
| 3143 | hdd_ctx->config->enableMemDeepSleep, |
| 3144 | PDEV_CMD); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3145 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3146 | if (ret) { |
| 3147 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", |
| 3148 | ret); |
| 3149 | goto error; |
| 3150 | } |
Rajeev Kumar Sirasanagandla | 2dab3ec | 2016-10-18 16:10:15 +0530 | [diff] [blame] | 3151 | |
| 3152 | ret = wma_cli_set_command(adapter->sessionId, |
| 3153 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
| 3154 | hdd_ctx->config->rts_profile, |
| 3155 | VDEV_CMD); |
| 3156 | if (ret) { |
| 3157 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 3158 | goto error; |
| 3159 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3160 | } |
| 3161 | |
| 3162 | hdd_set_fw_log_params(hdd_ctx, adapter); |
| 3163 | |
| 3164 | EXIT(); |
| 3165 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3166 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3167 | error: |
| 3168 | return -EINVAL; |
| 3169 | } |
| 3170 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3171 | /** |
| 3172 | * hdd_open_adapter() - open and setup the hdd adatper |
| 3173 | * @hdd_ctx: global hdd context |
| 3174 | * @session_type: type of the interface to be created |
| 3175 | * @iface_name: User-visible name of the interface |
| 3176 | * @macAddr: MAC address to assign to the interface |
| 3177 | * @name_assign_type: the name of assign type of the netdev |
| 3178 | * @rtnl_held: the rtnl lock hold flag |
| 3179 | * |
| 3180 | * This function open and setup the hdd adpater according to the device |
| 3181 | * type request, assign the name, the mac address assigned, and then prepared |
| 3182 | * the hdd related parameters, queue, lock and ready to start. |
| 3183 | * |
| 3184 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 3185 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3186 | hdd_adapter_t *hdd_open_adapter(hdd_context_t *hdd_ctx, uint8_t session_type, |
| 3187 | const char *iface_name, tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3188 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3189 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3190 | { |
| 3191 | hdd_adapter_t *adapter = NULL; |
| 3192 | hdd_adapter_list_node_t *pHddAdapterNode = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3193 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3194 | hdd_cfg80211_state_t *cfgState; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3195 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3196 | hdd_info("iface(%s) type(%d)", iface_name, session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3197 | |
| 3198 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 3199 | /* |
| 3200 | * Max limit reached on the number of vdevs configured by the |
| 3201 | * host. Return error |
| 3202 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3203 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 3204 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3205 | return NULL; |
| 3206 | } |
| 3207 | |
| 3208 | if (macAddr == NULL) { |
| 3209 | /* Not received valid macAddr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3210 | 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] | 3211 | return NULL; |
| 3212 | } |
| 3213 | status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3214 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3215 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 3216 | " already exists", |
| 3217 | MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3218 | return NULL; |
| 3219 | } |
| 3220 | |
| 3221 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3222 | case QDF_STA_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3223 | /* Reset locally administered bit if the device mode is STA */ |
| 3224 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr); |
| 3225 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3226 | case QDF_P2P_CLIENT_MODE: |
| 3227 | case QDF_P2P_DEVICE_MODE: |
| 3228 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 3229 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3230 | case QDF_MONITOR_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3231 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 3232 | name_assign_type, |
| 3233 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3234 | |
| 3235 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3236 | hdd_err("failed to allocate adapter for session %d", |
| 3237 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3238 | return NULL; |
| 3239 | } |
| 3240 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3241 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3242 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3243 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3244 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3245 | else if (QDF_MONITOR_MODE == session_type) |
| 3246 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3247 | else |
| 3248 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 3249 | |
| 3250 | adapter->device_mode = session_type; |
| 3251 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3252 | if (QDF_NDI_MODE == session_type) { |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 3253 | status = hdd_init_nan_data_mode(adapter); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3254 | if (QDF_STATUS_SUCCESS != status) |
| 3255 | goto err_free_netdev; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3256 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3257 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3258 | /* |
| 3259 | * Workqueue which gets scheduled in IPv4 notification |
| 3260 | * callback |
| 3261 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3262 | INIT_WORK(&adapter->ipv4NotifierWorkQueue, |
| 3263 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3264 | |
| 3265 | #ifdef WLAN_NS_OFFLOAD |
| 3266 | /* |
| 3267 | * Workqueue which gets scheduled in IPv6 |
| 3268 | * notification callback. |
| 3269 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3270 | INIT_WORK(&adapter->ipv6NotifierWorkQueue, |
| 3271 | hdd_ipv6_notifier_work_queue); |
| 3272 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3273 | status = hdd_register_interface(adapter, rtnl_held); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3274 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3275 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 3276 | goto err_free_netdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3277 | } |
| 3278 | |
| 3279 | /* Stop the Interface TX queue. */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3280 | hdd_info("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3281 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3282 | WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 3283 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3284 | break; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3285 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3286 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3287 | case QDF_P2P_GO_MODE: |
| 3288 | case QDF_SAP_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3289 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr, |
| 3290 | name_assign_type, |
| 3291 | (uint8_t *) iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3292 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3293 | hdd_alert("failed to allocate adapter for session %d", |
| 3294 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3295 | return NULL; |
| 3296 | } |
| 3297 | |
| 3298 | adapter->wdev.iftype = |
| 3299 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3300 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3301 | NL80211_IFTYPE_P2P_GO; |
| 3302 | adapter->device_mode = session_type; |
| 3303 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3304 | status = hdd_register_hostapd(adapter, rtnl_held); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3305 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3306 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
| 3307 | goto err_free_netdev; |
| 3308 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3309 | hdd_info("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3310 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3311 | WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 3312 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3313 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3314 | case QDF_FTM_MODE: |
| 3315 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 3316 | name_assign_type, |
| 3317 | "wlan0"); |
| 3318 | if (NULL == adapter) { |
| 3319 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 3320 | return NULL; |
| 3321 | } |
| 3322 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 3323 | adapter->device_mode = session_type; |
| 3324 | status = hdd_register_interface(adapter, rtnl_held); |
| 3325 | if (QDF_STATUS_SUCCESS != status) { |
| 3326 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
| 3327 | goto err_free_netdev; |
| 3328 | } |
| 3329 | /* Stop the Interface TX queue. */ |
| 3330 | hdd_info("Disabling queues"); |
| 3331 | wlan_hdd_netif_queue_control(adapter, |
| 3332 | WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 3333 | WLAN_CONTROL_PATH); |
| 3334 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3335 | default: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3336 | hdd_alert("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3337 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3338 | return NULL; |
| 3339 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3340 | |
| 3341 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR(adapter); |
| 3342 | mutex_init(&cfgState->remain_on_chan_ctx_lock); |
| 3343 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3344 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3345 | /* Add it to the hdd's session list. */ |
| 3346 | pHddAdapterNode = |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3347 | qdf_mem_malloc(sizeof(hdd_adapter_list_node_t)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3348 | if (NULL == pHddAdapterNode) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3349 | status = QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3350 | } else { |
| 3351 | pHddAdapterNode->pAdapter = adapter; |
| 3352 | status = hdd_add_adapter_back(hdd_ctx, pHddAdapterNode); |
| 3353 | } |
| 3354 | } |
| 3355 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3356 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3357 | if (NULL != adapter) { |
| 3358 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 3359 | adapter = NULL; |
| 3360 | } |
| 3361 | if (NULL != pHddAdapterNode) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3362 | qdf_mem_free(pHddAdapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3363 | } |
| 3364 | return NULL; |
| 3365 | } |
| 3366 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3367 | if (QDF_STATUS_SUCCESS == status) { |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 3368 | cds_set_concurrency_mode(session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3369 | |
| 3370 | /* Initialize the WoWL service */ |
| 3371 | if (!hdd_init_wowl(adapter)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3372 | hdd_alert("hdd_init_wowl failed"); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 3373 | goto err_close_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3374 | } |
| 3375 | |
| 3376 | /* Adapter successfully added. Increment the vdev count */ |
| 3377 | hdd_ctx->current_intf_count++; |
| 3378 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3379 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3380 | hdd_ctx->current_intf_count); |
| 3381 | |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 3382 | cds_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3383 | } |
| 3384 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 3385 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
| 3386 | hdd_err("Interface %s wow debug_fs init failed", iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3387 | |
| 3388 | return adapter; |
| 3389 | |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 3390 | err_close_adapter: |
| 3391 | hdd_close_adapter(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3392 | err_free_netdev: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3393 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->macAddressCurrent.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 3394 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3395 | |
| 3396 | return NULL; |
| 3397 | } |
| 3398 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3399 | 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] | 3400 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3401 | { |
| 3402 | hdd_adapter_list_node_t *adapterNode, *pCurrent, *pNext; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3403 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3404 | |
| 3405 | status = hdd_get_front_adapter(hdd_ctx, &pCurrent); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3406 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3407 | hdd_warn("adapter list empty %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3408 | status); |
| 3409 | return status; |
| 3410 | } |
| 3411 | |
| 3412 | while (pCurrent->pAdapter != adapter) { |
| 3413 | status = hdd_get_next_adapter(hdd_ctx, pCurrent, &pNext); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3414 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3415 | break; |
| 3416 | |
| 3417 | pCurrent = pNext; |
| 3418 | } |
| 3419 | adapterNode = pCurrent; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3420 | if (QDF_STATUS_SUCCESS == status) { |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 3421 | hdd_info("wait for bus bw work to flush"); |
| 3422 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 3423 | cds_clear_concurrency_mode(adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3424 | hdd_cleanup_adapter(hdd_ctx, adapterNode->pAdapter, rtnl_held); |
| 3425 | |
| 3426 | hdd_remove_adapter(hdd_ctx, adapterNode); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3427 | qdf_mem_free(adapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3428 | adapterNode = NULL; |
| 3429 | |
| 3430 | /* Adapter removed. Decrement vdev count */ |
| 3431 | if (hdd_ctx->current_intf_count != 0) |
| 3432 | hdd_ctx->current_intf_count--; |
| 3433 | |
| 3434 | /* Fw will take care incase of concurrency */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3435 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3436 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3437 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3438 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3439 | } |
| 3440 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3441 | /** |
| 3442 | * hdd_close_all_adapters - Close all open adapters |
| 3443 | * @hdd_ctx: Hdd context |
| 3444 | * rtnl_held: True if RTNL lock held |
| 3445 | * |
| 3446 | * Close all open adapters. |
| 3447 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3448 | * Return: QDF status code |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3449 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3450 | 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] | 3451 | { |
| 3452 | hdd_adapter_list_node_t *pHddAdapterNode; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3453 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3454 | |
| 3455 | ENTER(); |
| 3456 | |
| 3457 | do { |
| 3458 | status = hdd_remove_front_adapter(hdd_ctx, &pHddAdapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3459 | if (pHddAdapterNode && QDF_STATUS_SUCCESS == status) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3460 | wlan_hdd_release_intf_addr(hdd_ctx, |
| 3461 | pHddAdapterNode->pAdapter->macAddressCurrent.bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3462 | hdd_cleanup_adapter(hdd_ctx, pHddAdapterNode->pAdapter, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3463 | rtnl_held); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3464 | qdf_mem_free(pHddAdapterNode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3465 | /* Adapter removed. Decrement vdev count */ |
| 3466 | if (hdd_ctx->current_intf_count != 0) |
| 3467 | hdd_ctx->current_intf_count--; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3468 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3469 | } while (NULL != pHddAdapterNode && QDF_STATUS_E_EMPTY != status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3470 | |
| 3471 | EXIT(); |
| 3472 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3473 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3474 | } |
| 3475 | |
| 3476 | void wlan_hdd_reset_prob_rspies(hdd_adapter_t *pHostapdAdapter) |
| 3477 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3478 | struct qdf_mac_addr *bssid = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3479 | tSirUpdateIE updateIE; |
| 3480 | switch (pHostapdAdapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3481 | case QDF_STA_MODE: |
| 3482 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3483 | { |
| 3484 | hdd_station_ctx_t *pHddStaCtx = |
| 3485 | WLAN_HDD_GET_STATION_CTX_PTR(pHostapdAdapter); |
Srinivas Girigowda | 8b98396 | 2015-11-18 22:14:34 -0800 | [diff] [blame] | 3486 | bssid = &pHddStaCtx->conn_info.bssId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3487 | break; |
| 3488 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3489 | case QDF_SAP_MODE: |
| 3490 | case QDF_P2P_GO_MODE: |
| 3491 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3492 | { |
Srinivas Girigowda | 8b98396 | 2015-11-18 22:14:34 -0800 | [diff] [blame] | 3493 | bssid = &pHostapdAdapter->macAddressCurrent; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3494 | break; |
| 3495 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3496 | case QDF_FTM_MODE: |
| 3497 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3498 | default: |
| 3499 | /* |
| 3500 | * wlan_hdd_reset_prob_rspies should not have been called |
| 3501 | * for these kind of devices |
| 3502 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3503 | hdd_err("Unexpected request for the current device type %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3504 | pHostapdAdapter->device_mode); |
| 3505 | return; |
| 3506 | } |
| 3507 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 3508 | qdf_copy_macaddr(&updateIE.bssid, bssid); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3509 | updateIE.smeSessionId = pHostapdAdapter->sessionId; |
| 3510 | updateIE.ieBufferlength = 0; |
| 3511 | updateIE.pAdditionIEBuffer = NULL; |
| 3512 | updateIE.append = true; |
| 3513 | updateIE.notify = false; |
| 3514 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(pHostapdAdapter), |
| 3515 | &updateIE, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3516 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3517 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3518 | } |
| 3519 | } |
| 3520 | |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 3521 | /** |
| 3522 | * hdd_wait_for_sme_close_sesion() - Close and wait for SME session close |
| 3523 | * @hdd_ctx: HDD context which is already NULL validated |
| 3524 | * @adapter: HDD adapter which is already NULL validated |
| 3525 | * |
| 3526 | * Close the SME session and wait for its completion, if needed. |
| 3527 | * |
| 3528 | * Return: None |
| 3529 | */ |
| 3530 | static void hdd_wait_for_sme_close_sesion(hdd_context_t *hdd_ctx, |
| 3531 | hdd_adapter_t *adapter) |
| 3532 | { |
| 3533 | unsigned long rc; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 3534 | QDF_STATUS qdf_status; |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 3535 | |
| 3536 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 3537 | hdd_err("session is not opened:%d", adapter->sessionId); |
| 3538 | return; |
| 3539 | } |
| 3540 | |
| 3541 | INIT_COMPLETION(adapter->session_close_comp_var); |
| 3542 | if (QDF_STATUS_SUCCESS == |
| 3543 | sme_close_session(hdd_ctx->hHal, adapter->sessionId, |
| 3544 | hdd_sme_close_session_callback, |
| 3545 | adapter)) { |
| 3546 | /* |
| 3547 | * Block on a completion variable. Can't wait |
| 3548 | * forever though. |
| 3549 | */ |
| 3550 | rc = wait_for_completion_timeout( |
| 3551 | &adapter->session_close_comp_var, |
| 3552 | msecs_to_jiffies |
| 3553 | (WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
Sandeep Puligilla | ada7292 | 2016-09-29 19:31:21 -0700 | [diff] [blame] | 3554 | if (!rc) { |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 3555 | hdd_err("failure waiting for session_close_comp_var"); |
Sandeep Puligilla | ada7292 | 2016-09-29 19:31:21 -0700 | [diff] [blame] | 3556 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3557 | hdd_ndp_session_end_handler(adapter); |
| 3558 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Hanumanth Reddy Pothula | 3370212 | 2016-10-07 17:27:04 +0530 | [diff] [blame] | 3559 | return; |
Sandeep Puligilla | ada7292 | 2016-09-29 19:31:21 -0700 | [diff] [blame] | 3560 | } |
Rajeev Kumar | ba77885 | 2017-01-06 13:23:04 -0800 | [diff] [blame] | 3561 | qdf_status = hdd_release_and_destroy_vdev(adapter); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 3562 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 3563 | hdd_err("vdev delete failed"); |
| 3564 | |
Hanumanth Reddy Pothula | 3370212 | 2016-10-07 17:27:04 +0530 | [diff] [blame] | 3565 | adapter->sessionId = HDD_SESSION_ID_INVALID; |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 3566 | } |
| 3567 | } |
| 3568 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3569 | 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] | 3570 | const bool bCloseSession) |
| 3571 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3572 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3573 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(adapter); |
| 3574 | union iwreq_data wrqu; |
| 3575 | tSirUpdateIE updateIE; |
| 3576 | unsigned long rc; |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 3577 | hdd_scaninfo_t *scan_info = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3578 | |
| 3579 | ENTER(); |
| 3580 | |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 3581 | scan_info = &adapter->scan_info; |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3582 | hdd_notice("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3583 | wlan_hdd_netif_queue_control(adapter, WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 3584 | WLAN_CONTROL_PATH); |
| 3585 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3586 | case QDF_STA_MODE: |
| 3587 | case QDF_P2P_CLIENT_MODE: |
| 3588 | case QDF_IBSS_MODE: |
| 3589 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3590 | case QDF_NDI_MODE: |
| 3591 | if ((QDF_NDI_MODE == adapter->device_mode) || |
| 3592 | hdd_conn_is_connected( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3593 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)) || |
| 3594 | hdd_is_connecting( |
| 3595 | WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3596 | INIT_COMPLETION(adapter->disconnect_comp_var); |
| 3597 | /* |
| 3598 | * For NDI do not use pWextState from sta_ctx, if needed |
| 3599 | * extract from ndi_ctx. |
| 3600 | */ |
| 3601 | if (QDF_NDI_MODE == adapter->device_mode) |
| 3602 | qdf_ret_status = sme_roam_disconnect( |
| 3603 | hdd_ctx->hHal, |
| 3604 | adapter->sessionId, |
| 3605 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
| 3606 | else if (pWextState->roamProfile.BSSType == |
| 3607 | eCSR_BSS_TYPE_START_IBSS) |
| 3608 | qdf_ret_status = sme_roam_disconnect( |
| 3609 | hdd_ctx->hHal, |
| 3610 | adapter->sessionId, |
| 3611 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3612 | else |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3613 | qdf_ret_status = sme_roam_disconnect( |
| 3614 | hdd_ctx->hHal, |
| 3615 | adapter->sessionId, |
| 3616 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3617 | /* success implies disconnect command got queued up successfully */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3618 | if (qdf_ret_status == QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3619 | rc = wait_for_completion_timeout( |
| 3620 | &adapter->disconnect_comp_var, |
| 3621 | msecs_to_jiffies |
| 3622 | (WLAN_WAIT_TIME_DISCONNECT)); |
| 3623 | if (!rc) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3624 | hdd_err("wait on disconnect_comp_var failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3625 | } |
| 3626 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3627 | hdd_err("failed to post disconnect event to SME"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3628 | } |
| 3629 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 3630 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 3631 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 3632 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 3633 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 3634 | } |
| 3635 | if (scan_info != NULL && scan_info->mScanPending) { |
Mahesh A Saptasagar | ebb47fa | 2016-07-21 18:11:38 +0530 | [diff] [blame] | 3636 | wlan_hdd_scan_abort(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3637 | } |
Himanshu Agarwal | 3d95b90 | 2016-08-24 16:27:03 +0530 | [diff] [blame] | 3638 | hdd_lro_disable(hdd_ctx, adapter); |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 3639 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3640 | |
| 3641 | #ifdef WLAN_OPEN_SOURCE |
| 3642 | cancel_work_sync(&adapter->ipv4NotifierWorkQueue); |
| 3643 | #endif |
| 3644 | |
| 3645 | hdd_deregister_tx_flow_control(adapter); |
| 3646 | |
| 3647 | #ifdef WLAN_NS_OFFLOAD |
| 3648 | #ifdef WLAN_OPEN_SOURCE |
| 3649 | cancel_work_sync(&adapter->ipv6NotifierWorkQueue); |
| 3650 | #endif |
| 3651 | #endif |
| 3652 | |
| 3653 | /* |
| 3654 | * It is possible that the caller of this function does not |
| 3655 | * wish to close the session |
| 3656 | */ |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 3657 | if (true == bCloseSession) |
| 3658 | hdd_wait_for_sme_close_sesion(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3659 | break; |
| 3660 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3661 | case QDF_SAP_MODE: |
| 3662 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3663 | if (hdd_ctx->config->conc_custom_rule1 && |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3664 | (QDF_SAP_MODE == adapter->device_mode)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3665 | /* |
| 3666 | * Before stopping the sap adapter, lets make sure there |
| 3667 | * is no sap restart work pending. |
| 3668 | */ |
| 3669 | cds_flush_work(&hdd_ctx->sap_start_work); |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3670 | hdd_info("Canceled the pending SAP restart work"); |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 3671 | cds_change_sap_restart_required_status(false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3672 | } |
| 3673 | /* Any softap specific cleanup here... */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3674 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3675 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 3676 | |
| 3677 | hdd_deregister_tx_flow_control(adapter); |
| 3678 | |
| 3679 | mutex_lock(&hdd_ctx->sap_lock); |
| 3680 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3681 | QDF_STATUS status; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 3682 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3683 | |
| 3684 | /* Stop Bss. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3685 | status = wlansap_stop_bss( |
| 3686 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3687 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3688 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3689 | hdd_hostapd_state_t *hostapd_state = |
| 3690 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 3691 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3692 | qdf_stop_bss_event); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 3693 | qdf_status = |
| 3694 | qdf_wait_single_event(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 3695 | qdf_stop_bss_event, |
| 3696 | SME_CMD_TIMEOUT_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3697 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 3698 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3699 | hdd_err("failure waiting for wlansap_stop_bss %d", |
| 3700 | qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3701 | } |
| 3702 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3703 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3704 | } |
| 3705 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 3706 | cds_decr_session_set_pcl( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3707 | adapter->device_mode, |
| 3708 | adapter->sessionId); |
| 3709 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 3710 | qdf_copy_macaddr(&updateIE.bssid, |
Srinivas Girigowda | 8b98396 | 2015-11-18 22:14:34 -0800 | [diff] [blame] | 3711 | &adapter->macAddressCurrent); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3712 | updateIE.smeSessionId = adapter->sessionId; |
| 3713 | updateIE.ieBufferlength = 0; |
| 3714 | updateIE.pAdditionIEBuffer = NULL; |
| 3715 | updateIE.append = false; |
| 3716 | updateIE.notify = false; |
| 3717 | /* Probe bcn reset */ |
| 3718 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 3719 | &updateIE, eUPDATE_IE_PROBE_BCN) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3720 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3721 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3722 | } |
| 3723 | /* Assoc resp reset */ |
| 3724 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 3725 | &updateIE, |
| 3726 | eUPDATE_IE_ASSOC_RESP) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3727 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3728 | hdd_err("Could not pass on ASSOC_RSP data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3729 | } |
| 3730 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 3731 | wlan_hdd_reset_prob_rspies(adapter); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 3732 | qdf_mem_free(adapter->sessionCtx.ap.beacon); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3733 | adapter->sessionCtx.ap.beacon = NULL; |
| 3734 | } |
| 3735 | mutex_unlock(&hdd_ctx->sap_lock); |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 3736 | if (true == bCloseSession) |
| 3737 | hdd_wait_for_sme_close_sesion(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3738 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3739 | case QDF_OCB_MODE: |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 3740 | cdp_peer_clear(cds_get_context(QDF_MODULE_ID_SOC), |
| 3741 | cds_get_context(QDF_MODULE_ID_TXRX), |
| 3742 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.staId[0]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3743 | break; |
| 3744 | default: |
| 3745 | break; |
| 3746 | } |
| 3747 | |
| 3748 | EXIT(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3749 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3750 | } |
| 3751 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 3752 | /** |
| 3753 | * hdd_deinit_all_adapters - deinit all adapters |
| 3754 | * @hdd_ctx: HDD context |
| 3755 | * @rtnl_held: True if RTNL lock held |
| 3756 | * |
| 3757 | */ |
| 3758 | void hdd_deinit_all_adapters(hdd_context_t *hdd_ctx, bool rtnl_held) |
| 3759 | { |
| 3760 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 3761 | QDF_STATUS status; |
| 3762 | hdd_adapter_t *adapter; |
| 3763 | |
| 3764 | ENTER(); |
| 3765 | |
| 3766 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 3767 | |
| 3768 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 3769 | adapter = adapter_node->pAdapter; |
| 3770 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
| 3771 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 3772 | adapter_node = next; |
| 3773 | } |
| 3774 | |
| 3775 | EXIT(); |
| 3776 | } |
| 3777 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3778 | QDF_STATUS hdd_stop_all_adapters(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3779 | { |
| 3780 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3781 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3782 | hdd_adapter_t *adapter; |
| 3783 | |
| 3784 | ENTER(); |
| 3785 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 3786 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 3787 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3788 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 3789 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3790 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3791 | adapter = adapterNode->pAdapter; |
| 3792 | hdd_stop_adapter(hdd_ctx, adapter, true); |
| 3793 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 3794 | adapterNode = pNext; |
| 3795 | } |
| 3796 | |
| 3797 | EXIT(); |
| 3798 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3799 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3800 | } |
| 3801 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3802 | QDF_STATUS hdd_reset_all_adapters(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3803 | { |
| 3804 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3805 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3806 | hdd_adapter_t *adapter; |
| 3807 | |
| 3808 | ENTER(); |
| 3809 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 3810 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 3811 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3812 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 3813 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3814 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3815 | adapter = adapterNode->pAdapter; |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3816 | hdd_notice("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3817 | wlan_hdd_netif_queue_control(adapter, |
| 3818 | WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 3819 | WLAN_CONTROL_PATH); |
| 3820 | |
| 3821 | adapter->sessionCtx.station.hdd_ReassocScenario = false; |
| 3822 | |
| 3823 | hdd_deinit_tx_rx(adapter); |
Tushnim Bhattacharyya | 4adb368 | 2016-01-07 15:07:12 -0800 | [diff] [blame] | 3824 | cds_decr_session_set_pcl(adapter->device_mode, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3825 | adapter->sessionId); |
| 3826 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 3827 | hdd_wmm_adapter_close(adapter); |
| 3828 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3829 | } |
| 3830 | |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 3831 | /* |
| 3832 | * If adapter is SAP, set session ID to invalid since SAP |
| 3833 | * session will be cleanup during SSR. |
| 3834 | */ |
| 3835 | if (adapter->device_mode == QDF_SAP_MODE) |
| 3836 | wlansap_set_invalid_session( |
| 3837 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 3838 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3839 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 3840 | adapterNode = pNext; |
| 3841 | } |
| 3842 | |
| 3843 | EXIT(); |
| 3844 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3845 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3846 | } |
| 3847 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3848 | /** |
| 3849 | * hdd_is_interface_up()- Checkfor interface up before ssr |
| 3850 | * @hdd_ctx: HDD context |
| 3851 | * |
| 3852 | * check if there are any wlan interfaces before SSR accordingly start |
| 3853 | * the interface. |
| 3854 | * |
| 3855 | * Return: 0 if interface was opened else false |
| 3856 | */ |
| 3857 | static bool hdd_is_interface_up(hdd_adapter_t *adapter) |
| 3858 | { |
| 3859 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 3860 | return true; |
| 3861 | else |
| 3862 | return false; |
| 3863 | } |
| 3864 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3865 | #if defined CFG80211_CONNECT_BSS |
| 3866 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
| 3867 | && !defined(WITH_BACKPORTS) && !defined(IEEE80211_PRIVACY) |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3868 | static |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3869 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 3870 | struct ieee80211_channel *channel, |
| 3871 | const u8 *bssid, const u8 *ssid, |
| 3872 | size_t ssid_len) |
| 3873 | { |
| 3874 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 3875 | ssid, ssid_len, |
| 3876 | WLAN_CAPABILITY_ESS, |
| 3877 | WLAN_CAPABILITY_ESS); |
| 3878 | } |
| 3879 | #else |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3880 | static |
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 | IEEE80211_BSS_TYPE_ESS, |
| 3889 | IEEE80211_PRIVACY_ANY); |
| 3890 | } |
| 3891 | #endif |
| 3892 | #endif |
| 3893 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 3894 | #if defined CFG80211_CONNECT_BSS |
| 3895 | /** |
| 3896 | * hdd_connect_bss() - API to send connection status to supplicant |
| 3897 | * @dev: network device |
| 3898 | * @bssid: bssid to which we want to associate |
| 3899 | * @req_ie: Request Information Element |
| 3900 | * @req_ie_len: len of the req IE |
| 3901 | * @resp_ie: Response IE |
| 3902 | * @resp_ie_len: len of ht response IE |
| 3903 | * @status: status |
| 3904 | * @gfp: Kernel Flag |
| 3905 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 3906 | * |
| 3907 | * The API is a wrapper to send connection status to supplicant |
| 3908 | * |
| 3909 | * Return: Void |
| 3910 | */ |
| 3911 | #if defined CFG80211_CONNECT_TIMEOUT |
| 3912 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 3913 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 3914 | size_t req_ie_len, const u8 *resp_ie, |
| 3915 | size_t resp_ie_len, int status, gfp_t gfp, |
| 3916 | bool connect_timeout) |
| 3917 | { |
| 3918 | if (connect_timeout) |
| 3919 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 3920 | else |
| 3921 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 3922 | resp_ie, resp_ie_len, status, gfp); |
| 3923 | } |
| 3924 | #else |
| 3925 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 3926 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 3927 | size_t req_ie_len, const u8 *resp_ie, |
| 3928 | size_t resp_ie_len, int status, gfp_t gfp, |
| 3929 | bool connect_timeout) |
| 3930 | { |
| 3931 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 3932 | resp_ie, resp_ie_len, status, gfp); |
| 3933 | } |
| 3934 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3935 | |
| 3936 | /** |
| 3937 | * hdd_connect_result() - API to send connection status to supplicant |
| 3938 | * @dev: network device |
| 3939 | * @bssid: bssid to which we want to associate |
| 3940 | * @roam_info: information about connected bss |
| 3941 | * @req_ie: Request Information Element |
| 3942 | * @req_ie_len: len of the req IE |
| 3943 | * @resp_ie: Response IE |
| 3944 | * @resp_ie_len: len of ht response IE |
| 3945 | * @status: status |
| 3946 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 3947 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3948 | * |
| 3949 | * The API is a wrapper to send connection status to supplicant |
| 3950 | * and allow runtime suspend |
| 3951 | * |
| 3952 | * Return: Void |
| 3953 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3954 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
| 3955 | tCsrRoamInfo *roam_info, const u8 *req_ie, |
| 3956 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 3957 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 3958 | bool connect_timeout) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3959 | { |
| 3960 | hdd_adapter_t *padapter = (hdd_adapter_t *) netdev_priv(dev); |
| 3961 | struct cfg80211_bss *bss = NULL; |
| 3962 | |
| 3963 | if (WLAN_STATUS_SUCCESS == status) { |
| 3964 | struct ieee80211_channel *chan; |
| 3965 | int freq; |
| 3966 | int chan_no = roam_info->pBssDesc->channelId; |
| 3967 | |
| 3968 | if (chan_no <= 14) |
| 3969 | freq = ieee80211_channel_to_frequency(chan_no, |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 3970 | NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3971 | else |
| 3972 | freq = ieee80211_channel_to_frequency(chan_no, |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 3973 | NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3974 | |
| 3975 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
| 3976 | bss = hdd_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
| 3977 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 3978 | roam_info->u.pConnectedProfile->SSID.length); |
| 3979 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3980 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 3981 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 3982 | req_ie_len, resp_ie, resp_ie_len, |
| 3983 | status, gfp, connect_timeout); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3984 | |
| 3985 | qdf_runtime_pm_allow_suspend(padapter->connect_rpm_ctx.connect); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3986 | } |
| 3987 | #else |
| 3988 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
| 3989 | tCsrRoamInfo *roam_info, const u8 *req_ie, |
| 3990 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 3991 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 3992 | bool connect_timeout) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3993 | { |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3994 | hdd_adapter_t *padapter = (hdd_adapter_t *) netdev_priv(dev); |
| 3995 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3996 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 3997 | resp_ie, resp_ie_len, status, gfp); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3998 | qdf_runtime_pm_allow_suspend(padapter->connect_rpm_ctx.connect); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3999 | } |
| 4000 | #endif |
| 4001 | |
| 4002 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4003 | QDF_STATUS hdd_start_all_adapters(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4004 | { |
| 4005 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4006 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4007 | hdd_adapter_t *adapter; |
| 4008 | #ifndef MSM_PLATFORM |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4009 | struct qdf_mac_addr bcastMac = QDF_MAC_ADDR_BROADCAST_INITIALIZER; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4010 | #endif |
| 4011 | eConnectionState connState; |
| 4012 | |
| 4013 | ENTER(); |
| 4014 | |
| 4015 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4016 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4017 | adapter = adapterNode->pAdapter; |
| 4018 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4019 | if (!hdd_is_interface_up(adapter)) |
Hanumanth Reddy Pothula | c1c4d2b | 2016-09-22 15:45:16 +0530 | [diff] [blame] | 4020 | goto get_adapter; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4021 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4022 | hdd_wmm_init(adapter); |
| 4023 | |
| 4024 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4025 | case QDF_STA_MODE: |
| 4026 | case QDF_P2P_CLIENT_MODE: |
| 4027 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4028 | |
| 4029 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 4030 | ->conn_info.connState; |
| 4031 | |
| 4032 | hdd_init_station_mode(adapter); |
| 4033 | /* Open the gates for HDD to receive Wext commands */ |
| 4034 | adapter->isLinkUpSvcNeeded = false; |
| 4035 | adapter->scan_info.mScanPending = false; |
| 4036 | |
| 4037 | /* Indicate disconnect event to supplicant if associated previously */ |
| 4038 | if (eConnectionState_Associated == connState || |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 4039 | eConnectionState_IbssConnected == connState || |
| 4040 | eConnectionState_NotConnected == connState || |
| 4041 | eConnectionState_IbssDisconnected == connState || |
| 4042 | eConnectionState_Disconnecting == connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4043 | union iwreq_data wrqu; |
| 4044 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 4045 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 4046 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 4047 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 4048 | &wrqu, NULL); |
| 4049 | adapter->sessionCtx.station. |
| 4050 | hdd_ReassocScenario = false; |
| 4051 | |
| 4052 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 4053 | wlan_hdd_cfg80211_indicate_disconnect( |
| 4054 | adapter->dev, false, |
| 4055 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4056 | } else if (eConnectionState_Connecting == connState) { |
| 4057 | /* |
| 4058 | * Indicate connect failure to supplicant if we were in the |
| 4059 | * process of connecting |
| 4060 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4061 | hdd_connect_result(adapter->dev, NULL, NULL, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4062 | NULL, 0, NULL, 0, |
| 4063 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4064 | GFP_KERNEL, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4065 | } |
| 4066 | |
| 4067 | hdd_register_tx_flow_control(adapter, |
| 4068 | hdd_tx_resume_timer_expired_handler, |
| 4069 | hdd_tx_resume_cb); |
| 4070 | |
| 4071 | break; |
| 4072 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4073 | case QDF_SAP_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4074 | /* softAP can handle SSR */ |
| 4075 | break; |
| 4076 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4077 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4078 | #ifdef MSM_PLATFORM |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4079 | hdd_err("[SSR] send stop ap to supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4080 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 4081 | #else |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4082 | hdd_err("[SSR] send restart supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4083 | /* event supplicant to restart */ |
| 4084 | cfg80211_del_sta(adapter->dev, |
| 4085 | (const u8 *)&bcastMac.bytes[0], |
| 4086 | GFP_KERNEL); |
| 4087 | #endif |
| 4088 | break; |
| 4089 | |
| 4090 | default: |
| 4091 | break; |
| 4092 | } |
Hanumanth Reddy Pothula | c1c4d2b | 2016-09-22 15:45:16 +0530 | [diff] [blame] | 4093 | get_adapter: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4094 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4095 | adapterNode = pNext; |
| 4096 | } |
| 4097 | |
| 4098 | EXIT(); |
| 4099 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4100 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4101 | } |
| 4102 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4103 | QDF_STATUS hdd_get_front_adapter(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4104 | hdd_adapter_list_node_t **padapterNode) |
| 4105 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4106 | QDF_STATUS status; |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4107 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4108 | status = qdf_list_peek_front(&hdd_ctx->hddAdapters, |
| 4109 | (qdf_list_node_t **) padapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4110 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4111 | return status; |
| 4112 | } |
| 4113 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4114 | QDF_STATUS hdd_get_next_adapter(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4115 | hdd_adapter_list_node_t *adapterNode, |
| 4116 | hdd_adapter_list_node_t **pNextAdapterNode) |
| 4117 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4118 | QDF_STATUS status; |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4119 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4120 | status = qdf_list_peek_next(&hdd_ctx->hddAdapters, |
| 4121 | (qdf_list_node_t *) adapterNode, |
| 4122 | (qdf_list_node_t **) pNextAdapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4123 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4124 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4125 | return status; |
| 4126 | } |
| 4127 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4128 | QDF_STATUS hdd_remove_adapter(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4129 | hdd_adapter_list_node_t *adapterNode) |
| 4130 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4131 | QDF_STATUS status; |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4132 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4133 | status = qdf_list_remove_node(&hdd_ctx->hddAdapters, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4134 | &adapterNode->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4135 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4136 | return status; |
| 4137 | } |
| 4138 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4139 | QDF_STATUS hdd_remove_front_adapter(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4140 | hdd_adapter_list_node_t **padapterNode) |
| 4141 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4142 | QDF_STATUS status; |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4143 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4144 | status = qdf_list_remove_front(&hdd_ctx->hddAdapters, |
| 4145 | (qdf_list_node_t **) padapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4146 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4147 | return status; |
| 4148 | } |
| 4149 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4150 | QDF_STATUS hdd_add_adapter_back(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4151 | hdd_adapter_list_node_t *adapterNode) |
| 4152 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4153 | QDF_STATUS status; |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4154 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4155 | status = qdf_list_insert_back(&hdd_ctx->hddAdapters, |
| 4156 | (qdf_list_node_t *) adapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4157 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4158 | return status; |
| 4159 | } |
| 4160 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4161 | QDF_STATUS hdd_add_adapter_front(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4162 | hdd_adapter_list_node_t *adapterNode) |
| 4163 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4164 | QDF_STATUS status; |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4165 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4166 | status = qdf_list_insert_front(&hdd_ctx->hddAdapters, |
| 4167 | (qdf_list_node_t *) adapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4168 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4169 | return status; |
| 4170 | } |
| 4171 | |
| 4172 | hdd_adapter_t *hdd_get_adapter_by_macaddr(hdd_context_t *hdd_ctx, |
| 4173 | tSirMacAddr macAddr) |
| 4174 | { |
| 4175 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 4176 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4177 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4178 | |
| 4179 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4180 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4181 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4182 | adapter = adapterNode->pAdapter; |
| 4183 | |
| 4184 | if (adapter |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4185 | && !qdf_mem_cmp(adapter->macAddressCurrent.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4186 | macAddr, sizeof(tSirMacAddr))) { |
| 4187 | return adapter; |
| 4188 | } |
| 4189 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4190 | adapterNode = pNext; |
| 4191 | } |
| 4192 | |
| 4193 | return NULL; |
| 4194 | |
| 4195 | } |
| 4196 | |
| 4197 | hdd_adapter_t *hdd_get_adapter_by_vdev(hdd_context_t *hdd_ctx, |
| 4198 | uint32_t vdev_id) |
| 4199 | { |
| 4200 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 4201 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4202 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4203 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4204 | qdf_status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4205 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4206 | while ((NULL != adapterNode) && (QDF_STATUS_SUCCESS == qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4207 | adapter = adapterNode->pAdapter; |
| 4208 | |
| 4209 | if (adapter->sessionId == vdev_id) |
| 4210 | return adapter; |
| 4211 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4212 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4213 | hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4214 | adapterNode = pNext; |
| 4215 | } |
| 4216 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4217 | hdd_err("vdev_id %d does not exist with host", vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4218 | |
| 4219 | return NULL; |
| 4220 | } |
| 4221 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 4222 | /** |
| 4223 | * hdd_get_adapter_by_sme_session_id() - Return adapter with |
| 4224 | * the sessionid |
| 4225 | * @hdd_ctx: hdd context. |
| 4226 | * @sme_session_id: sme session is for the adapter to get. |
| 4227 | * |
| 4228 | * This function is used to get the adapter with provided session id |
| 4229 | * |
| 4230 | * Return: adapter pointer if found |
| 4231 | * |
| 4232 | */ |
| 4233 | hdd_adapter_t *hdd_get_adapter_by_sme_session_id(hdd_context_t *hdd_ctx, |
| 4234 | uint32_t sme_session_id) |
| 4235 | { |
| 4236 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 4237 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4238 | QDF_STATUS qdf_status; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 4239 | |
| 4240 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4241 | qdf_status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 4242 | |
| 4243 | while ((NULL != adapter_node) && |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4244 | (QDF_STATUS_SUCCESS == qdf_status)) { |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 4245 | adapter = adapter_node->pAdapter; |
| 4246 | |
| 4247 | if (adapter && |
| 4248 | adapter->sessionId == sme_session_id) |
| 4249 | return adapter; |
| 4250 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4251 | qdf_status = |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 4252 | hdd_get_next_adapter(hdd_ctx, |
| 4253 | adapter_node, &next); |
| 4254 | adapter_node = next; |
| 4255 | } |
| 4256 | return NULL; |
| 4257 | } |
| 4258 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4259 | /** |
| 4260 | * hdd_get_adapter() - to get adapter matching the mode |
| 4261 | * @hdd_ctx: hdd context |
| 4262 | * @mode: adapter mode |
| 4263 | * |
| 4264 | * This routine will return the pointer to adapter matching |
| 4265 | * with the passed mode. |
| 4266 | * |
| 4267 | * Return: pointer to adapter or null |
| 4268 | */ |
| 4269 | hdd_adapter_t *hdd_get_adapter(hdd_context_t *hdd_ctx, |
| 4270 | enum tQDF_ADAPTER_MODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4271 | { |
| 4272 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 4273 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4274 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4275 | |
| 4276 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4277 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4278 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4279 | adapter = adapterNode->pAdapter; |
| 4280 | |
| 4281 | if (adapter && (mode == adapter->device_mode)) |
| 4282 | return adapter; |
| 4283 | |
| 4284 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4285 | adapterNode = pNext; |
| 4286 | } |
| 4287 | |
| 4288 | return NULL; |
| 4289 | |
| 4290 | } |
| 4291 | |
| 4292 | /** |
| 4293 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 4294 | * @hdd_ctx: Pointer to the HDD context. |
| 4295 | * @mode: Device mode for which operating channel is required. |
| 4296 | * Suported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4297 | * QDF_STA_MODE, |
| 4298 | * QDF_P2P_CLIENT_MODE, |
| 4299 | * QDF_SAP_MODE, |
| 4300 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4301 | * |
| 4302 | * This API returns the operating channel of the requested device mode |
| 4303 | * |
| 4304 | * Return: channel number. "0" id the requested device is not found OR it is |
| 4305 | * not connected. |
| 4306 | */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4307 | uint8_t hdd_get_operating_channel(hdd_context_t *hdd_ctx, |
| 4308 | enum tQDF_ADAPTER_MODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4309 | { |
| 4310 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4311 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4312 | hdd_adapter_t *adapter; |
| 4313 | uint8_t operatingChannel = 0; |
| 4314 | |
| 4315 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4316 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4317 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4318 | adapter = adapterNode->pAdapter; |
| 4319 | |
| 4320 | if (mode == adapter->device_mode) { |
| 4321 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4322 | case QDF_STA_MODE: |
| 4323 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4324 | if (hdd_conn_is_connected |
| 4325 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 4326 | (adapter))) { |
| 4327 | operatingChannel = |
| 4328 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 4329 | (adapter))->conn_info. |
| 4330 | operationChannel; |
| 4331 | } |
| 4332 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4333 | case QDF_SAP_MODE: |
| 4334 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4335 | /* softap connection info */ |
| 4336 | if (test_bit |
| 4337 | (SOFTAP_BSS_STARTED, |
| 4338 | &adapter->event_flags)) |
| 4339 | operatingChannel = |
| 4340 | (WLAN_HDD_GET_AP_CTX_PTR |
| 4341 | (adapter))->operatingChannel; |
| 4342 | break; |
| 4343 | default: |
| 4344 | break; |
| 4345 | } |
| 4346 | |
| 4347 | break; /* Found the device of interest. break the loop */ |
| 4348 | } |
| 4349 | |
| 4350 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4351 | adapterNode = pNext; |
| 4352 | } |
| 4353 | return operatingChannel; |
| 4354 | } |
| 4355 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4356 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(hdd_context_t * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4357 | hdd_ctx) |
| 4358 | { |
| 4359 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4360 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4361 | hdd_adapter_t *adapter; |
| 4362 | |
| 4363 | ENTER(); |
| 4364 | |
| 4365 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4366 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4367 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4368 | adapter = adapterNode->pAdapter; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4369 | if ((adapter->device_mode == QDF_STA_MODE) || |
| 4370 | (adapter->device_mode == QDF_P2P_CLIENT_MODE) || |
| 4371 | (adapter->device_mode == QDF_IBSS_MODE) || |
| 4372 | (adapter->device_mode == QDF_P2P_DEVICE_MODE) || |
| 4373 | (adapter->device_mode == QDF_SAP_MODE) || |
| 4374 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4375 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 4376 | hdd_unregister_wext(adapter->dev); |
| 4377 | } |
| 4378 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4379 | adapterNode = pNext; |
| 4380 | } |
| 4381 | |
| 4382 | EXIT(); |
| 4383 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4384 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4385 | } |
| 4386 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4387 | 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] | 4388 | { |
| 4389 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4390 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4391 | hdd_adapter_t *adapter; |
| 4392 | |
| 4393 | ENTER(); |
| 4394 | |
| 4395 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4396 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4397 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4398 | adapter = adapterNode->pAdapter; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4399 | if ((adapter->device_mode == QDF_STA_MODE) || |
| 4400 | (adapter->device_mode == QDF_P2P_CLIENT_MODE) || |
| 4401 | (adapter->device_mode == QDF_IBSS_MODE) || |
| 4402 | (adapter->device_mode == QDF_P2P_DEVICE_MODE) || |
| 4403 | (adapter->device_mode == QDF_SAP_MODE) || |
| 4404 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4405 | hdd_abort_mac_scan(hdd_ctx, adapter->sessionId, |
| 4406 | eCSR_SCAN_ABORT_DEFAULT); |
| 4407 | } |
| 4408 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4409 | adapterNode = pNext; |
| 4410 | } |
| 4411 | |
| 4412 | EXIT(); |
| 4413 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4414 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4415 | } |
| 4416 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 4417 | /** |
| 4418 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 4419 | * adapters |
| 4420 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 4421 | * |
| 4422 | * return: QDF_STATUS_SUCCESS |
| 4423 | */ |
| 4424 | static QDF_STATUS hdd_abort_sched_scan_all_adapters(hdd_context_t *hdd_ctx) |
| 4425 | { |
| 4426 | hdd_adapter_list_node_t *adapter_node = NULL, *next_node = NULL; |
| 4427 | QDF_STATUS status; |
| 4428 | hdd_adapter_t *adapter; |
| 4429 | int err; |
| 4430 | |
| 4431 | ENTER(); |
| 4432 | |
| 4433 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 4434 | |
| 4435 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 4436 | adapter = adapter_node->pAdapter; |
| 4437 | if ((adapter->device_mode == QDF_STA_MODE) || |
| 4438 | (adapter->device_mode == QDF_P2P_CLIENT_MODE) || |
| 4439 | (adapter->device_mode == QDF_IBSS_MODE) || |
| 4440 | (adapter->device_mode == QDF_P2P_DEVICE_MODE) || |
| 4441 | (adapter->device_mode == QDF_SAP_MODE) || |
| 4442 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
| 4443 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 4444 | if (err) |
| 4445 | hdd_err("Unable to stop scheduled scan"); |
| 4446 | } |
| 4447 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next_node); |
| 4448 | adapter_node = next_node; |
| 4449 | } |
| 4450 | |
| 4451 | EXIT(); |
| 4452 | |
| 4453 | return QDF_STATUS_SUCCESS; |
| 4454 | } |
| 4455 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4456 | #ifdef WLAN_NS_OFFLOAD |
| 4457 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4458 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4459 | * @hdd_ctx: Pointer to hdd context |
| 4460 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4461 | * Unregister for IPv6 address change notifications. |
| 4462 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4463 | * Return: None |
| 4464 | */ |
| 4465 | static void hdd_wlan_unregister_ip6_notifier(hdd_context_t *hdd_ctx) |
| 4466 | { |
| 4467 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
| 4468 | |
| 4469 | return; |
| 4470 | } |
| 4471 | |
| 4472 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4473 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4474 | * @hdd_ctx: Pointer to hdd context |
| 4475 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4476 | * Register for IPv6 address change notifications. |
| 4477 | * |
| 4478 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4479 | */ |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4480 | static int hdd_wlan_register_ip6_notifier(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4481 | { |
| 4482 | int ret; |
| 4483 | |
| 4484 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 4485 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4486 | if (ret) { |
| 4487 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 4488 | goto out; |
| 4489 | } |
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 | hdd_info("Registered IPv6 notifier"); |
| 4492 | out: |
| 4493 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4494 | } |
| 4495 | #else |
| 4496 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4497 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4498 | * @hdd_ctx: Pointer to hdd context |
| 4499 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4500 | * Unregister for IPv6 address change notifications. |
| 4501 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4502 | * Return: None |
| 4503 | */ |
| 4504 | static void hdd_wlan_unregister_ip6_notifier(hdd_context_t *hdd_ctx) |
| 4505 | { |
| 4506 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4507 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4508 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4509 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4510 | * @hdd_ctx: Pointer to hdd context |
| 4511 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4512 | * Register for IPv6 address change notifications. |
| 4513 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4514 | * Return: None |
| 4515 | */ |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4516 | static int hdd_wlan_register_ip6_notifier(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4517 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4518 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4519 | } |
| 4520 | #endif |
| 4521 | |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 4522 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 4523 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4524 | * hdd_logging_sock_activate_svc() - Activate logging |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 4525 | * @hdd_ctx: HDD context |
| 4526 | * |
| 4527 | * Activates the logging service |
| 4528 | * |
| 4529 | * Return: Zero in case of success, negative value otherwise |
| 4530 | */ |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4531 | static int hdd_logging_sock_activate_svc(hdd_context_t *hdd_ctx) |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 4532 | { |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4533 | int ret; |
| 4534 | struct hdd_config *config = hdd_ctx->config; |
| 4535 | |
| 4536 | if (!config->wlanLoggingEnable) |
| 4537 | return 0; |
| 4538 | |
| 4539 | ret = wlan_logging_sock_activate_svc(config->wlanLoggingFEToConsole, |
| 4540 | config->wlanLoggingNumBuf); |
| 4541 | if (ret) |
| 4542 | hdd_err("wlan_logging_sock_activate_svc failed: %d", ret); |
| 4543 | return ret; |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 4544 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4545 | |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 4546 | /** |
| 4547 | * wlan_hdd_logging_sock_deactivate_svc() - Deactivate logging |
| 4548 | * @hdd_ctx: HDD context |
| 4549 | * |
| 4550 | * Deactivates the logging service |
| 4551 | * |
| 4552 | * Return: 0 on deactivating the logging service |
| 4553 | */ |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4554 | static int hdd_logging_sock_deactivate_svc(hdd_context_t *hdd_ctx) |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 4555 | { |
| 4556 | if (hdd_ctx && hdd_ctx->config->wlanLoggingEnable) |
| 4557 | return wlan_logging_sock_deactivate_svc(); |
| 4558 | |
| 4559 | return 0; |
| 4560 | } |
| 4561 | #else |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4562 | 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] | 4563 | { |
| 4564 | return 0; |
| 4565 | } |
| 4566 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4567 | 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] | 4568 | { |
| 4569 | return 0; |
| 4570 | } |
| 4571 | #endif |
| 4572 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4573 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4574 | * hdd_register_notifiers - Register netdev notifiers. |
| 4575 | * @hdd_ctx: HDD context |
| 4576 | * |
| 4577 | * Register netdev notifiers like IPv4 and IPv6. |
| 4578 | * |
| 4579 | * Return: 0 on success and errno on failure |
| 4580 | */ |
| 4581 | static int hdd_register_notifiers(hdd_context_t *hdd_ctx) |
| 4582 | { |
| 4583 | int ret; |
| 4584 | |
| 4585 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 4586 | if (ret) { |
| 4587 | hdd_err("register_netdevice_notifier failed: %d", ret); |
| 4588 | goto out; |
| 4589 | } |
| 4590 | |
| 4591 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 4592 | if (ret) |
| 4593 | goto unregister_notifier; |
| 4594 | |
| 4595 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 4596 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 4597 | if (ret) { |
| 4598 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 4599 | goto unregister_ip6_notifier; |
| 4600 | } |
| 4601 | |
| 4602 | return 0; |
| 4603 | |
| 4604 | unregister_ip6_notifier: |
| 4605 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 4606 | unregister_notifier: |
| 4607 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 4608 | out: |
| 4609 | return ret; |
| 4610 | |
| 4611 | } |
| 4612 | |
| 4613 | /** |
| 4614 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 4615 | * @hdd_ctx: HDD context |
| 4616 | * |
| 4617 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 4618 | * |
| 4619 | * Return: None. |
| 4620 | */ |
| 4621 | static void hdd_unregister_notifiers(hdd_context_t *hdd_ctx) |
| 4622 | { |
| 4623 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 4624 | |
| 4625 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 4626 | |
| 4627 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 4628 | } |
| 4629 | |
| 4630 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4631 | * hdd_exit_netlink_services - Exit netlink services |
| 4632 | * @hdd_ctx: HDD context |
| 4633 | * |
| 4634 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 4635 | * nl service. |
| 4636 | * |
| 4637 | * Return: None. |
| 4638 | */ |
| 4639 | static void hdd_exit_netlink_services(hdd_context_t *hdd_ctx) |
| 4640 | { |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4641 | hdd_close_cesium_nl_sock(); |
| 4642 | |
| 4643 | ptt_sock_deactivate_svc(); |
| 4644 | |
| 4645 | nl_srv_exit(); |
| 4646 | } |
| 4647 | |
| 4648 | /** |
| 4649 | * hdd_init_netlink_services- Init netlink services |
| 4650 | * @hdd_ctx: HDD context |
| 4651 | * |
| 4652 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 4653 | * nl service. |
| 4654 | * |
| 4655 | * Return: 0 on success and errno on failure. |
| 4656 | */ |
| 4657 | static int hdd_init_netlink_services(hdd_context_t *hdd_ctx) |
| 4658 | { |
| 4659 | int ret; |
| 4660 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 4661 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4662 | if (ret) { |
| 4663 | hdd_alert("nl_srv_init failed: %d", ret); |
| 4664 | goto out; |
| 4665 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 4666 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4667 | |
| 4668 | ret = oem_activate_service(hdd_ctx); |
| 4669 | if (ret) { |
| 4670 | hdd_alert("oem_activate_service failed: %d", ret); |
| 4671 | goto err_nl_srv; |
| 4672 | } |
| 4673 | |
| 4674 | ret = ptt_sock_activate_svc(); |
| 4675 | if (ret) { |
| 4676 | hdd_alert("ptt_sock_activate_svc failed: %d", ret); |
| 4677 | goto err_nl_srv; |
| 4678 | } |
| 4679 | |
| 4680 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 4681 | if (ret) |
| 4682 | hdd_warn("hdd_open_cesium_nl_sock failed"); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4683 | |
| 4684 | ret = cnss_diag_activate_service(); |
| 4685 | if (ret) { |
| 4686 | hdd_alert("cnss_diag_activate_service failed: %d", ret); |
| 4687 | goto err_close_cesium; |
| 4688 | } |
| 4689 | |
| 4690 | return 0; |
| 4691 | |
| 4692 | err_close_cesium: |
| 4693 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4694 | ptt_sock_deactivate_svc(); |
| 4695 | err_nl_srv: |
| 4696 | nl_srv_exit(); |
| 4697 | out: |
| 4698 | return ret; |
| 4699 | } |
| 4700 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 4701 | /** |
| 4702 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 4703 | * @hdd_ctx: HDD context. |
| 4704 | * |
| 4705 | * Destroy RX wakelock. |
| 4706 | * |
| 4707 | * Return: None. |
| 4708 | */ |
| 4709 | static void hdd_rx_wake_lock_destroy(hdd_context_t *hdd_ctx) |
| 4710 | { |
| 4711 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 4712 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4713 | |
| 4714 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 4715 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 4716 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4717 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 4718 | * Create RX wakelock. |
| 4719 | * |
| 4720 | * Return: None. |
| 4721 | */ |
| 4722 | static void hdd_rx_wake_lock_create(hdd_context_t *hdd_ctx) |
| 4723 | { |
| 4724 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 4725 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 4726 | |
| 4727 | /** |
| 4728 | * hdd_roc_context_init() - Init ROC context |
| 4729 | * @hdd_ctx: HDD context. |
| 4730 | * |
| 4731 | * Initialize ROC context. |
| 4732 | * |
| 4733 | * Return: 0 on success and errno on failure. |
| 4734 | */ |
| 4735 | static int hdd_roc_context_init(hdd_context_t *hdd_ctx) |
| 4736 | { |
| 4737 | qdf_spinlock_create(&hdd_ctx->hdd_roc_req_q_lock); |
| 4738 | qdf_list_create(&hdd_ctx->hdd_roc_req_q, MAX_ROC_REQ_QUEUE_ENTRY); |
| 4739 | |
| 4740 | INIT_DELAYED_WORK(&hdd_ctx->roc_req_work, wlan_hdd_roc_request_dequeue); |
| 4741 | |
| 4742 | return 0; |
| 4743 | } |
| 4744 | |
| 4745 | /** |
| 4746 | * hdd_roc_context_destroy() - Destroy ROC context |
| 4747 | * @hdd_ctx: HDD context. |
| 4748 | * |
| 4749 | * Destroy roc list and flush the pending roc work. |
| 4750 | * |
| 4751 | * Return: None. |
| 4752 | */ |
| 4753 | static void hdd_roc_context_destroy(hdd_context_t *hdd_ctx) |
| 4754 | { |
| 4755 | flush_delayed_work(&hdd_ctx->roc_req_work); |
| 4756 | qdf_list_destroy(&hdd_ctx->hdd_roc_req_q); |
| 4757 | } |
| 4758 | |
| 4759 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 4760 | * hdd_context_deinit() - Deinitialize HDD context |
| 4761 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 4762 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 4763 | * Deinitialize HDD context along with all the feature specific contexts but |
| 4764 | * do not free hdd context itself. Caller of this API is supposed to free |
| 4765 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4766 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 4767 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4768 | */ |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 4769 | static int hdd_context_deinit(hdd_context_t *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4770 | { |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 4771 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4772 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 4773 | hdd_roc_context_destroy(hdd_ctx); |
| 4774 | |
| 4775 | hdd_sap_context_destroy(hdd_ctx); |
| 4776 | |
| 4777 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 4778 | |
| 4779 | hdd_tdls_context_destroy(hdd_ctx); |
| 4780 | |
| 4781 | hdd_scan_context_destroy(hdd_ctx); |
| 4782 | |
| 4783 | qdf_list_destroy(&hdd_ctx->hddAdapters); |
| 4784 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 4785 | return 0; |
| 4786 | } |
| 4787 | |
| 4788 | /** |
| 4789 | * hdd_context_destroy() - Destroy HDD context |
| 4790 | * @hdd_ctx: HDD context to be destroyed. |
| 4791 | * |
| 4792 | * Free config and HDD context as well as destroy all the resources. |
| 4793 | * |
| 4794 | * Return: None |
| 4795 | */ |
| 4796 | static void hdd_context_destroy(hdd_context_t *hdd_ctx) |
| 4797 | { |
| 4798 | if (QDF_GLOBAL_FTM_MODE != hdd_get_conparam()) |
| 4799 | hdd_logging_sock_deactivate_svc(hdd_ctx); |
| 4800 | |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 4801 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 4802 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 4803 | hdd_context_deinit(hdd_ctx); |
| 4804 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4805 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4806 | hdd_ctx->config = NULL; |
| 4807 | |
| 4808 | wiphy_free(hdd_ctx->wiphy); |
| 4809 | } |
| 4810 | |
| 4811 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4812 | * hdd_wlan_exit() - HDD WLAN exit function |
| 4813 | * @hdd_ctx: Pointer to the HDD Context |
| 4814 | * |
| 4815 | * This is the driver exit point (invoked during rmmod) |
| 4816 | * |
| 4817 | * Return: None |
| 4818 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4819 | static void hdd_wlan_exit(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4820 | { |
| 4821 | v_CONTEXT_t p_cds_context = hdd_ctx->pcds_context; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4822 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4823 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4824 | int driver_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4825 | |
| 4826 | ENTER(); |
| 4827 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4828 | if (QDF_TIMER_STATE_RUNNING == |
| 4829 | qdf_mc_timer_get_current_state(&hdd_ctx->iface_change_timer)) { |
| 4830 | hdd_info("Stpp interface change timer"); |
| 4831 | qdf_mc_timer_stop(&hdd_ctx->iface_change_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4832 | } |
| 4833 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4834 | if (!QDF_IS_STATUS_SUCCESS |
| 4835 | (qdf_mc_timer_destroy(&hdd_ctx->iface_change_timer))) |
| 4836 | hdd_err("Cannot delete interface change timer"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4837 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4838 | |
| 4839 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4840 | |
Nitesh Shah | 61c10d9 | 2016-10-19 19:29:15 +0530 | [diff] [blame] | 4841 | qdf_mc_timer_destroy(&hdd_ctx->tdls_source_timer); |
| 4842 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 4843 | hdd_bus_bandwidth_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4844 | |
| 4845 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 4846 | if (QDF_TIMER_STATE_RUNNING == |
| 4847 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 4848 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4849 | } |
| 4850 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4851 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 4852 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4853 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4854 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 4855 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 4856 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 4857 | hdd_ctx->last_acs_channel_list = NULL; |
| 4858 | hdd_ctx->num_of_channels = 0; |
| 4859 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4860 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4861 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4862 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 4863 | driver_status = hdd_ctx->driver_status; |
| 4864 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 4865 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4866 | /* |
| 4867 | * Powersave Offload Case |
| 4868 | * Disable Idle Power Save Mode |
| 4869 | */ |
| 4870 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 4871 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4872 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 4873 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 4874 | /* |
| 4875 | * Cancel any outstanding scan requests. We are about to close |
| 4876 | * all of our adapters, but an adapter structure is what SME |
| 4877 | * passes back to our callback function. Hence if there |
| 4878 | * are any outstanding scan requests then there is a |
| 4879 | * race condition between when the adapter is closed and |
| 4880 | * when the callback is invoked. We try to resolve that |
| 4881 | * race condition here by canceling any outstanding scans |
| 4882 | * before we close the adapters. |
| 4883 | * Note that the scans may be cancelled in an asynchronous |
| 4884 | * manner, so ideally there needs to be some kind of |
| 4885 | * synchronization. Rather than introduce a new |
| 4886 | * synchronization here, we will utilize the fact that we are |
| 4887 | * about to Request Full Power, and since that is synchronized, |
| 4888 | * the expectation is that by the time Request Full Power has |
| 4889 | * completed, all scans will be cancelled |
| 4890 | */ |
| 4891 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 4892 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4893 | hdd_stop_all_adapters(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4894 | } |
| 4895 | |
| 4896 | /* |
| 4897 | * Close the scheduler before calling cds_close to make sure no thread |
| 4898 | * is scheduled after the each module close is called i.e after all the |
| 4899 | * data structures are freed. |
| 4900 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4901 | qdf_status = cds_sched_close(p_cds_context); |
| 4902 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4903 | hdd_alert("Failed to close CDS Scheduler"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4904 | QDF_ASSERT(QDF_IS_STATUS_SUCCESS(qdf_status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4905 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4906 | |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 4907 | hdd_wlan_stop_modules(hdd_ctx); |
| 4908 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 4909 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
| 4910 | qdf_spinlock_destroy(&hdd_ctx->sta_update_info_lock); |
| 4911 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
| 4912 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4913 | /* |
| 4914 | * Close CDS |
| 4915 | * This frees pMac(HAL) context. There should not be any call |
| 4916 | * that requires pMac access after this. |
| 4917 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4918 | |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 4919 | hdd_green_ap_deinit(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4920 | |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 4921 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4922 | hdd_close_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4923 | |
| 4924 | hdd_ipa_cleanup(hdd_ctx); |
| 4925 | |
| 4926 | /* Free up RoC request queue and flush workqueue */ |
| 4927 | cds_flush_work(&hdd_ctx->roc_req_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4928 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 4929 | wlansap_global_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4930 | wiphy_unregister(wiphy); |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 4931 | wlan_hdd_cfg80211_deinit(wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4932 | |
Jeff Johnson | f7f66f0 | 2016-09-23 14:50:11 -0700 | [diff] [blame] | 4933 | hdd_lpass_notify_stop(hdd_ctx); |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 4934 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4935 | hdd_exit_netlink_services(hdd_ctx); |
| 4936 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 4937 | hdd_context_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4938 | } |
| 4939 | |
| 4940 | void __hdd_wlan_exit(void) |
| 4941 | { |
| 4942 | hdd_context_t *hdd_ctx; |
| 4943 | |
| 4944 | ENTER(); |
| 4945 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4946 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4947 | if (!hdd_ctx) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4948 | hdd_alert("Invalid HDD Context"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4949 | EXIT(); |
| 4950 | return; |
| 4951 | } |
| 4952 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 4953 | /* Check IPA HW Pipe shutdown */ |
| 4954 | hdd_ipa_uc_force_pipe_shutdown(hdd_ctx); |
| 4955 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 4956 | memdump_deinit(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 4957 | hdd_driver_memdump_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 4958 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4959 | /* Do all the cleanup before deregistering the driver */ |
| 4960 | hdd_wlan_exit(hdd_ctx); |
Mohit Khanna | ebf8a86 | 2016-04-28 17:53:59 -0700 | [diff] [blame] | 4961 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4962 | EXIT(); |
| 4963 | } |
| 4964 | |
| 4965 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 4966 | /** |
| 4967 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
| 4968 | * @data: pointer to hdd_context_t |
| 4969 | * |
| 4970 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 4971 | * Then new ACS request will do a fresh scan without reusing the cached |
| 4972 | * scan information. |
| 4973 | * |
| 4974 | * Return: void |
| 4975 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4976 | void hdd_skip_acs_scan_timer_handler(void *data) |
| 4977 | { |
| 4978 | hdd_context_t *hdd_ctx = (hdd_context_t *) data; |
| 4979 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 4980 | hdd_notice("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4981 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 4982 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 4983 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 4984 | hdd_ctx->last_acs_channel_list = NULL; |
| 4985 | hdd_ctx->num_of_channels = 0; |
| 4986 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4987 | |
| 4988 | if (!hdd_ctx->hHal) |
| 4989 | return; |
| 4990 | sme_scan_flush_result(hdd_ctx->hHal); |
| 4991 | } |
| 4992 | #endif |
| 4993 | |
| 4994 | #ifdef QCA_HT_2040_COEX |
| 4995 | /** |
| 4996 | * hdd_wlan_set_ht2040_mode() - notify FW with HT20/HT40 mode |
| 4997 | * @adapter: pointer to adapter |
| 4998 | * @staId: station id |
| 4999 | * @macAddrSTA: station MAC address |
| 5000 | * @channel_type: channel type |
| 5001 | * |
| 5002 | * This function notifies FW with HT20/HT40 mode |
| 5003 | * |
| 5004 | * Return: 0 if successful, error number otherwise |
| 5005 | */ |
| 5006 | 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] | 5007 | struct qdf_mac_addr macAddrSTA, int channel_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5008 | { |
| 5009 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5010 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5011 | hdd_context_t *hdd_ctx = NULL; |
| 5012 | |
| 5013 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 5014 | |
| 5015 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 5016 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5017 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 5018 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5019 | if (!hdd_ctx->hHal) |
| 5020 | return -EINVAL; |
| 5021 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5022 | qdf_status = sme_notify_ht2040_mode(hdd_ctx->hHal, staId, macAddrSTA, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5023 | adapter->sessionId, channel_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5024 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5025 | hdd_err("Fail to send notification with ht2040 mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5026 | return -EINVAL; |
| 5027 | } |
| 5028 | |
| 5029 | return 0; |
| 5030 | } |
| 5031 | #endif |
| 5032 | |
| 5033 | /** |
| 5034 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 5035 | * @state: state |
| 5036 | * |
| 5037 | * This function notifies FW with modem power status |
| 5038 | * |
| 5039 | * Return: 0 if successful, error number otherwise |
| 5040 | */ |
| 5041 | int hdd_wlan_notify_modem_power_state(int state) |
| 5042 | { |
| 5043 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5044 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5045 | hdd_context_t *hdd_ctx; |
| 5046 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5047 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5048 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 5049 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5050 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 5051 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5052 | if (!hdd_ctx->hHal) |
| 5053 | return -EINVAL; |
| 5054 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5055 | qdf_status = sme_notify_modem_power_state(hdd_ctx->hHal, state); |
| 5056 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5057 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5058 | state); |
| 5059 | return -EINVAL; |
| 5060 | } |
| 5061 | return 0; |
| 5062 | } |
| 5063 | |
| 5064 | /** |
| 5065 | * |
| 5066 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 5067 | * @adapter - Pointer to the HDD |
| 5068 | * |
| 5069 | * Return: None |
| 5070 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5071 | QDF_STATUS hdd_post_cds_enable_config(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5072 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5073 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5074 | |
| 5075 | /* |
| 5076 | * Send ready indication to the HDD. This will kick off the MAC |
| 5077 | * into a 'running' state and should kick off an initial scan. |
| 5078 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5079 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->hHal); |
| 5080 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5081 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 5082 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5083 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5084 | } |
| 5085 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5086 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5087 | } |
| 5088 | |
| 5089 | /* wake lock APIs for HDD */ |
| 5090 | void hdd_prevent_suspend(uint32_t reason) |
| 5091 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5092 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5093 | } |
| 5094 | |
| 5095 | void hdd_allow_suspend(uint32_t reason) |
| 5096 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5097 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5098 | } |
| 5099 | |
| 5100 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 5101 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 5102 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 5103 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5104 | } |
| 5105 | |
| 5106 | /** |
| 5107 | * hdd_exchange_version_and_caps() - exchange version and capability with target |
| 5108 | * @hdd_ctx: Pointer to HDD context |
| 5109 | * |
| 5110 | * This is the HDD function to exchange version and capability information |
| 5111 | * between Host and Target |
| 5112 | * |
| 5113 | * This function gets reported version of FW. |
| 5114 | * It also finds the version of target headers used to compile the host; |
| 5115 | * It compares the above two and prints a warning if they are different; |
| 5116 | * It gets the SW and HW version string; |
| 5117 | * Finally, it exchanges capabilities between host and target i.e. host |
| 5118 | * and target exchange a msg indicating the features they support through a |
| 5119 | * bitmap |
| 5120 | * |
| 5121 | * Return: None |
| 5122 | */ |
| 5123 | void hdd_exchange_version_and_caps(hdd_context_t *hdd_ctx) |
| 5124 | { |
| 5125 | |
| 5126 | tSirVersionType versionCompiled; |
| 5127 | tSirVersionType versionReported; |
| 5128 | tSirVersionString versionString; |
| 5129 | uint8_t fwFeatCapsMsgSupported = 0; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5130 | QDF_STATUS vstatus; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5131 | |
| 5132 | memset(&versionCompiled, 0, sizeof(versionCompiled)); |
| 5133 | memset(&versionReported, 0, sizeof(versionReported)); |
| 5134 | |
| 5135 | /* retrieve and display WCNSS version information */ |
| 5136 | do { |
| 5137 | |
| 5138 | vstatus = sme_get_wcnss_wlan_compiled_version(hdd_ctx->hHal, |
| 5139 | &versionCompiled); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5140 | if (!QDF_IS_STATUS_SUCCESS(vstatus)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5141 | hdd_alert("unable to retrieve WCNSS WLAN compiled version"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5142 | break; |
| 5143 | } |
| 5144 | |
| 5145 | vstatus = sme_get_wcnss_wlan_reported_version(hdd_ctx->hHal, |
| 5146 | &versionReported); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5147 | if (!QDF_IS_STATUS_SUCCESS(vstatus)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5148 | hdd_alert("unable to retrieve WCNSS WLAN reported version"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5149 | break; |
| 5150 | } |
| 5151 | |
| 5152 | if ((versionCompiled.major != versionReported.major) || |
| 5153 | (versionCompiled.minor != versionReported.minor) || |
| 5154 | (versionCompiled.version != versionReported.version) || |
| 5155 | (versionCompiled.revision != versionReported.revision)) { |
| 5156 | pr_err("%s: WCNSS WLAN Version %u.%u.%u.%u, " |
| 5157 | "Host expected %u.%u.%u.%u\n", |
| 5158 | WLAN_MODULE_NAME, |
| 5159 | (int)versionReported.major, |
| 5160 | (int)versionReported.minor, |
| 5161 | (int)versionReported.version, |
| 5162 | (int)versionReported.revision, |
| 5163 | (int)versionCompiled.major, |
| 5164 | (int)versionCompiled.minor, |
| 5165 | (int)versionCompiled.version, |
| 5166 | (int)versionCompiled.revision); |
| 5167 | } else { |
| 5168 | pr_info("%s: WCNSS WLAN version %u.%u.%u.%u\n", |
| 5169 | WLAN_MODULE_NAME, |
| 5170 | (int)versionReported.major, |
| 5171 | (int)versionReported.minor, |
| 5172 | (int)versionReported.version, |
| 5173 | (int)versionReported.revision); |
| 5174 | } |
| 5175 | |
| 5176 | vstatus = sme_get_wcnss_software_version(hdd_ctx->hHal, |
| 5177 | versionString, |
| 5178 | sizeof(versionString)); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5179 | if (!QDF_IS_STATUS_SUCCESS(vstatus)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5180 | hdd_alert("unable to retrieve WCNSS software version string"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5181 | break; |
| 5182 | } |
| 5183 | |
| 5184 | pr_info("%s: WCNSS software version %s\n", |
| 5185 | WLAN_MODULE_NAME, versionString); |
| 5186 | |
| 5187 | vstatus = sme_get_wcnss_hardware_version(hdd_ctx->hHal, |
| 5188 | versionString, |
| 5189 | sizeof(versionString)); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5190 | if (!QDF_IS_STATUS_SUCCESS(vstatus)) { |
Jeff Johnson | b7082ae | 2016-08-23 13:13:30 -0700 | [diff] [blame] | 5191 | hdd_alert("unable to retrieve WCNSS hardware version string"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5192 | break; |
| 5193 | } |
| 5194 | |
| 5195 | pr_info("%s: WCNSS hardware version %s\n", |
| 5196 | WLAN_MODULE_NAME, versionString); |
| 5197 | |
| 5198 | /* |
| 5199 | * 1.Check if FW version is greater than 0.1.1.0. Only then |
| 5200 | * send host-FW capability exchange message |
| 5201 | * 2.Host-FW capability exchange message is only present on |
| 5202 | * target 1.1 so send the message only if it the target is 1.1 |
| 5203 | * minor numbers for different target branches: |
| 5204 | * 0 -> (1.0)Mainline Build |
| 5205 | * 1 -> (1.1)Mainline Build |
| 5206 | * 2->(1.04) Stability Build |
| 5207 | */ |
| 5208 | if (((versionReported.major > 0) || (versionReported.minor > 1) |
| 5209 | || ((versionReported.minor >= 1) |
| 5210 | && (versionReported.version >= 1))) |
| 5211 | && ((versionReported.major == 1) |
| 5212 | && (versionReported.minor >= 1))) |
| 5213 | fwFeatCapsMsgSupported = 1; |
| 5214 | |
| 5215 | if (fwFeatCapsMsgSupported) { |
| 5216 | /* |
| 5217 | * Indicate if IBSS heartbeat monitoring needs to be |
| 5218 | * offloaded |
| 5219 | */ |
| 5220 | if (!hdd_ctx->config->enableIbssHeartBeatOffload) { |
| 5221 | sme_disable_feature_capablity |
| 5222 | (IBSS_HEARTBEAT_OFFLOAD); |
| 5223 | } |
| 5224 | |
| 5225 | sme_feature_caps_exchange(hdd_ctx->hHal); |
| 5226 | } |
| 5227 | |
| 5228 | } while (0); |
| 5229 | |
| 5230 | } |
| 5231 | |
| 5232 | /* Initialize channel list in sme based on the country code */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5233 | QDF_STATUS hdd_set_sme_chan_list(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5234 | { |
| 5235 | return sme_init_chan_list(hdd_ctx->hHal, hdd_ctx->reg.alpha2, |
| 5236 | hdd_ctx->reg.cc_src); |
| 5237 | } |
| 5238 | |
| 5239 | /** |
| 5240 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 5241 | * @hdd_ctx: Pointer to the hdd context |
| 5242 | * |
| 5243 | * HDD function to know if hardware supports 5GHz |
| 5244 | * |
| 5245 | * Return: true if hardware supports 5GHz |
| 5246 | */ |
| 5247 | bool hdd_is_5g_supported(hdd_context_t *hdd_ctx) |
| 5248 | { |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 5249 | if (!hdd_ctx || !hdd_ctx->config) |
| 5250 | return true; |
| 5251 | |
| 5252 | if (hdd_ctx->config->nBandCapability != eCSR_BAND_24) |
| 5253 | return true; |
| 5254 | else |
| 5255 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5256 | } |
| 5257 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 5258 | static int hdd_wiphy_init(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5259 | { |
| 5260 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 5261 | int ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5262 | |
| 5263 | wiphy = hdd_ctx->wiphy; |
| 5264 | |
| 5265 | /* |
| 5266 | * The channel information in |
| 5267 | * wiphy needs to be initialized before wiphy registration |
| 5268 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 5269 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 5270 | if (ret_val) { |
| 5271 | hdd_alert("regulatory init failed"); |
| 5272 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5273 | } |
| 5274 | |
| 5275 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 5276 | wiphy->wowlan = &wowlan_support_reg_init; |
| 5277 | #else |
| 5278 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 5279 | WIPHY_WOWLAN_MAGIC_PKT | |
| 5280 | WIPHY_WOWLAN_DISCONNECT | |
| 5281 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 5282 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 5283 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 5284 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 5285 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 5286 | |
| 5287 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 5288 | WOW_MAX_FILTERS_PER_LIST); |
| 5289 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 5290 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 5291 | #endif |
| 5292 | |
| 5293 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 5294 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
| 5295 | if (0 > ret_val) |
| 5296 | hdd_err("wiphy registration failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5297 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 5298 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5299 | } |
| 5300 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 5301 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5302 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 5303 | * @hdd_ctx - handle to hdd context |
| 5304 | * @tx_packets - transmit packet count |
| 5305 | * @rx_packets - receive packet count |
| 5306 | * |
| 5307 | * The function controls the bus bandwidth and dynamic control of |
| 5308 | * tcp delayed ack configuration |
| 5309 | * |
| 5310 | * Returns: None |
| 5311 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5312 | #ifdef MSM_PLATFORM |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 5313 | static void hdd_pld_request_bus_bandwidth(hdd_context_t *hdd_ctx, |
| 5314 | const uint64_t tx_packets, |
| 5315 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5316 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5317 | uint64_t total = tx_packets + rx_packets; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5318 | uint64_t temp_rx = 0; |
| 5319 | uint64_t temp_tx = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5320 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5321 | enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
| 5322 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 5323 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5324 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5325 | if (total > hdd_ctx->config->busBandwidthHighThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5326 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5327 | else if (total > hdd_ctx->config->busBandwidthMediumThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5328 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 5329 | else if (total > hdd_ctx->config->busBandwidthLowThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5330 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 5331 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5332 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5333 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5334 | hdd_ctx->hdd_txrx_hist[hdd_ctx->hdd_txrx_hist_idx].next_vote_level = |
| 5335 | next_vote_level; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5336 | |
| 5337 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 5338 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 5339 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5340 | hdd_ctx->cur_vote_level = next_vote_level; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5341 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 5342 | if (next_vote_level == PLD_BUS_WIDTH_LOW) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 5343 | if (hdd_ctx->hbw_requested) { |
| 5344 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 5345 | hdd_ctx->hbw_requested = false; |
| 5346 | } |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 5347 | if (cds_sched_handle_throughput_req(false)) |
Jeff Johnson | b7082ae | 2016-08-23 13:13:30 -0700 | [diff] [blame] | 5348 | hdd_err("low bandwidth set rx affinity fail"); |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 5349 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 5350 | if (!hdd_ctx->hbw_requested) { |
| 5351 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 5352 | hdd_ctx->hbw_requested = true; |
| 5353 | } |
| 5354 | |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 5355 | if (cds_sched_handle_throughput_req(true)) |
Jeff Johnson | b7082ae | 2016-08-23 13:13:30 -0700 | [diff] [blame] | 5356 | hdd_err("high bandwidth set rx affinity fail"); |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 5357 | } |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 5358 | hdd_napi_apply_throughput_policy(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5359 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5360 | |
| 5361 | /* fine-tuning parameters for RX Flows */ |
| 5362 | temp_rx = (rx_packets + hdd_ctx->prev_rx) / 2; |
| 5363 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5364 | hdd_ctx->prev_rx = rx_packets; |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 5365 | if (temp_rx > hdd_ctx->config->tcpDelackThresholdHigh) { |
| 5366 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 5367 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 5368 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 5369 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 5370 | } else { |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5371 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 5372 | hdd_ctx->rx_high_ind_cnt = 0; |
| 5373 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5374 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5375 | hdd_ctx->hdd_txrx_hist[hdd_ctx->hdd_txrx_hist_idx].next_rx_level = |
| 5376 | next_rx_level; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5377 | |
| 5378 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 5379 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5380 | next_rx_level, temp_rx); |
| 5381 | hdd_ctx->cur_rx_level = next_rx_level; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 5382 | /* Send throughput indication only if it is enabled. |
| 5383 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 5384 | * to default delayed ack. Note that this will disable the |
| 5385 | * dynamic delayed ack mechanism across the system |
| 5386 | */ |
| 5387 | if (hdd_ctx->config->enable_tcp_delack) |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 5388 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 5389 | WLAN_SVC_WLAN_TP_IND, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5390 | &next_rx_level, |
| 5391 | sizeof(next_rx_level)); |
| 5392 | } |
| 5393 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5394 | /* fine-tuning parameters for TX Flows */ |
| 5395 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 5396 | hdd_ctx->prev_tx = tx_packets; |
| 5397 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 5398 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 5399 | else |
| 5400 | next_tx_level = WLAN_SVC_TP_LOW; |
| 5401 | |
| 5402 | if (hdd_ctx->cur_tx_level != next_tx_level) { |
| 5403 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 5404 | next_tx_level, temp_tx); |
| 5405 | hdd_ctx->cur_tx_level = next_tx_level; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 5406 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 5407 | WLAN_SVC_WLAN_TP_TX_IND, |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 5408 | &next_tx_level, |
| 5409 | sizeof(next_tx_level)); |
| 5410 | } |
| 5411 | |
| 5412 | hdd_ctx->hdd_txrx_hist[hdd_ctx->hdd_txrx_hist_idx].next_tx_level = |
| 5413 | next_tx_level; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5414 | hdd_ctx->hdd_txrx_hist_idx++; |
| 5415 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5416 | } |
| 5417 | |
| 5418 | #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] | 5419 | static void hdd_bus_bw_work_handler(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5420 | { |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 5421 | hdd_context_t *hdd_ctx = container_of(work, hdd_context_t, |
| 5422 | bus_bw_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5423 | hdd_adapter_t *adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 5424 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 5425 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 5426 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5427 | uint64_t total_tx = 0, total_rx = 0; |
| 5428 | hdd_adapter_list_node_t *adapterNode = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5429 | QDF_STATUS status = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 5430 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5431 | bool connected = false; |
| 5432 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 5433 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 5434 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 5435 | return; |
| 5436 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5437 | for (status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5438 | NULL != adapterNode && QDF_STATUS_SUCCESS == status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5439 | status = |
| 5440 | hdd_get_next_adapter(hdd_ctx, adapterNode, &adapterNode)) { |
| 5441 | |
| 5442 | if (adapterNode->pAdapter == NULL) |
| 5443 | continue; |
| 5444 | adapter = adapterNode->pAdapter; |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 5445 | /* |
| 5446 | * Validate magic so we don't end up accessing |
| 5447 | * an invalid adapter. |
| 5448 | */ |
| 5449 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 5450 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5451 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5452 | if ((adapter->device_mode == QDF_STA_MODE || |
| 5453 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5454 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.connState |
| 5455 | != eConnectionState_Associated) { |
| 5456 | |
| 5457 | continue; |
| 5458 | } |
| 5459 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5460 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 5461 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5462 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->bApActive == false) { |
| 5463 | |
| 5464 | continue; |
| 5465 | } |
| 5466 | |
| 5467 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 5468 | adapter->prev_tx_packets); |
| 5469 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 5470 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 5471 | |
| 5472 | if (adapter->device_mode == QDF_SAP_MODE || |
| 5473 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 5474 | adapter->device_mode == QDF_IBSS_MODE) { |
| 5475 | |
| 5476 | ret = ol_get_intra_bss_fwd_pkts_count( |
| 5477 | adapter->sessionId, |
| 5478 | &fwd_tx_packets, &fwd_rx_packets); |
| 5479 | if (ret == A_OK) { |
| 5480 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 5481 | fwd_tx_packets, |
| 5482 | adapter->prev_fwd_tx_packets); |
| 5483 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 5484 | fwd_tx_packets, |
| 5485 | adapter->prev_fwd_rx_packets); |
| 5486 | } |
| 5487 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5488 | |
| 5489 | total_rx += adapter->stats.rx_packets; |
| 5490 | total_tx += adapter->stats.tx_packets; |
| 5491 | |
| 5492 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 5493 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 5494 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 5495 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 5496 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5497 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 5498 | connected = true; |
| 5499 | } |
| 5500 | |
| 5501 | hdd_ctx->hdd_txrx_hist[hdd_ctx->hdd_txrx_hist_idx].total_rx = total_rx; |
| 5502 | hdd_ctx->hdd_txrx_hist[hdd_ctx->hdd_txrx_hist_idx].total_tx = total_tx; |
| 5503 | hdd_ctx->hdd_txrx_hist[hdd_ctx->hdd_txrx_hist_idx].interval_rx = |
| 5504 | rx_packets; |
| 5505 | hdd_ctx->hdd_txrx_hist[hdd_ctx->hdd_txrx_hist_idx].interval_tx = |
| 5506 | tx_packets; |
| 5507 | |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 5508 | /* add intra bss forwarded tx and rx packets */ |
| 5509 | tx_packets += fwd_tx_packets_diff; |
| 5510 | rx_packets += fwd_rx_packets_diff; |
| 5511 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5512 | hdd_ipa_uc_stat_query(hdd_ctx, &ipa_tx_packets, &ipa_rx_packets); |
| 5513 | tx_packets += (uint64_t)ipa_tx_packets; |
| 5514 | rx_packets += (uint64_t)ipa_rx_packets; |
| 5515 | |
| 5516 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5517 | hdd_err("bus bandwidth timer running in disconnected state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5518 | return; |
| 5519 | } |
| 5520 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5521 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5522 | |
| 5523 | hdd_ipa_set_perf_level(hdd_ctx, tx_packets, rx_packets); |
| 5524 | hdd_ipa_uc_stat_request(adapter, 2); |
| 5525 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 5526 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5527 | hdd_ctx->config->busBandwidthComputeInterval); |
| 5528 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 5529 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 5530 | /** |
| 5531 | * __hdd_bus_bw_cbk() - Bus bandwidth data structure callback. |
| 5532 | * @arg: Argument of timer function |
| 5533 | * |
| 5534 | * Schedule a workqueue in this function where all the processing is done. |
| 5535 | * |
| 5536 | * Return: None. |
| 5537 | */ |
| 5538 | static void __hdd_bus_bw_cbk(void *arg) |
| 5539 | { |
| 5540 | hdd_context_t *hdd_ctx = (hdd_context_t *) arg; |
| 5541 | |
| 5542 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 5543 | return; |
| 5544 | |
| 5545 | schedule_work(&hdd_ctx->bus_bw_work); |
| 5546 | } |
| 5547 | |
| 5548 | /** |
| 5549 | * hdd_bus_bw_cbk() - Wrapper for bus bw callback for SSR protection. |
| 5550 | * @arg: Argument of timer function |
| 5551 | * |
| 5552 | * Return: None. |
| 5553 | */ |
| 5554 | static void hdd_bus_bw_cbk(void *arg) |
| 5555 | { |
| 5556 | cds_ssr_protect(__func__); |
| 5557 | __hdd_bus_bw_cbk(arg); |
| 5558 | cds_ssr_unprotect(__func__); |
| 5559 | } |
| 5560 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 5561 | int hdd_bus_bandwidth_init(hdd_context_t *hdd_ctx) |
| 5562 | { |
| 5563 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 5564 | INIT_WORK(&hdd_ctx->bus_bw_work, |
| 5565 | hdd_bus_bw_work_handler); |
| 5566 | qdf_timer_init(NULL, |
| 5567 | &hdd_ctx->bus_bw_timer, |
| 5568 | hdd_bus_bw_cbk, (void *)hdd_ctx, |
| 5569 | QDF_TIMER_TYPE_SW); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 5570 | |
| 5571 | return 0; |
| 5572 | } |
| 5573 | |
| 5574 | void hdd_bus_bandwidth_destroy(hdd_context_t *hdd_ctx) |
| 5575 | { |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 5576 | if (hdd_ctx->bus_bw_timer_started) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 5577 | hdd_reset_tcp_delack(hdd_ctx); |
| 5578 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 5579 | hdd_info("wait for bus bw work to flush"); |
| 5580 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 5581 | qdf_timer_free(&hdd_ctx->bus_bw_timer); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 5582 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5583 | #endif |
| 5584 | |
| 5585 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 5586 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 5587 | * @hdd_ctx: hdd context |
| 5588 | * |
| 5589 | * Return: 0 for success or error code |
| 5590 | */ |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 5591 | 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] | 5592 | { |
| 5593 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 5594 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
| 5595 | if (hdd_ctx->hdd_txrx_hist == NULL) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5596 | hdd_err("Failed malloc for hdd_txrx_hist"); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 5597 | return -ENOMEM; |
| 5598 | } |
| 5599 | return 0; |
| 5600 | } |
| 5601 | |
| 5602 | /** |
| 5603 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 5604 | * @hdd_ctx: hdd context |
| 5605 | * |
| 5606 | * Return: none |
| 5607 | */ |
| 5608 | void wlan_hdd_deinit_tx_rx_histogram(hdd_context_t *hdd_ctx) |
| 5609 | { |
| 5610 | if (hdd_ctx->hdd_txrx_hist) { |
| 5611 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 5612 | hdd_ctx->hdd_txrx_hist = NULL; |
| 5613 | } |
| 5614 | } |
| 5615 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5616 | static uint8_t *convert_level_to_string(uint32_t level) |
| 5617 | { |
| 5618 | switch (level) { |
| 5619 | /* initialize the wlan sub system */ |
| 5620 | case WLAN_SVC_TP_NONE: |
| 5621 | return "NONE"; |
| 5622 | case WLAN_SVC_TP_LOW: |
| 5623 | return "LOW"; |
| 5624 | case WLAN_SVC_TP_MEDIUM: |
| 5625 | return "MED"; |
| 5626 | case WLAN_SVC_TP_HIGH: |
| 5627 | return "HIGH"; |
| 5628 | default: |
| 5629 | return "INVAL"; |
| 5630 | } |
| 5631 | } |
| 5632 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 5633 | |
| 5634 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5635 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 5636 | * @hdd_ctx: hdd context |
| 5637 | * |
| 5638 | * Return: none |
| 5639 | */ |
| 5640 | void wlan_hdd_display_tx_rx_histogram(hdd_context_t *hdd_ctx) |
| 5641 | { |
| 5642 | int i; |
| 5643 | |
| 5644 | #ifdef MSM_PLATFORM |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5645 | hdd_err("BW compute Interval: %dms", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5646 | hdd_ctx->config->busBandwidthComputeInterval); |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5647 | 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] | 5648 | hdd_ctx->config->busBandwidthHighThreshold, |
| 5649 | hdd_ctx->config->busBandwidthMediumThreshold, |
| 5650 | hdd_ctx->config->busBandwidthLowThreshold); |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5651 | hdd_err("Enable TCP DEL ACK: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5652 | hdd_ctx->config->enable_tcp_delack); |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5653 | hdd_err("TCP DEL High TH: %d TCP DEL Low TH: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5654 | hdd_ctx->config->tcpDelackThresholdHigh, |
| 5655 | hdd_ctx->config->tcpDelackThresholdLow); |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5656 | 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] | 5657 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5658 | #endif |
| 5659 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5660 | hdd_err("Total entries: %d Current index: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5661 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
| 5662 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5663 | 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] | 5664 | |
| 5665 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5666 | hdd_err("%d: %llu, %llu, %llu, %llu, %s, %s, %s", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5667 | i, hdd_ctx->hdd_txrx_hist[i].total_rx, |
| 5668 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
| 5669 | hdd_ctx->hdd_txrx_hist[i].total_tx, |
| 5670 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5671 | convert_level_to_string( |
| 5672 | hdd_ctx->hdd_txrx_hist[i].next_vote_level), |
| 5673 | convert_level_to_string( |
| 5674 | hdd_ctx->hdd_txrx_hist[i].next_rx_level), |
| 5675 | convert_level_to_string( |
| 5676 | hdd_ctx->hdd_txrx_hist[i].next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5677 | } |
| 5678 | return; |
| 5679 | } |
| 5680 | |
| 5681 | /** |
| 5682 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 5683 | * @hdd_ctx: hdd context |
| 5684 | * |
| 5685 | * Return: none |
| 5686 | */ |
| 5687 | void wlan_hdd_clear_tx_rx_histogram(hdd_context_t *hdd_ctx) |
| 5688 | { |
| 5689 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 5690 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 5691 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5692 | } |
| 5693 | |
| 5694 | /** |
| 5695 | * wlan_hdd_display_netif_queue_history() - display netif queue operation history |
| 5696 | * @pHddCtx: hdd context |
| 5697 | * |
| 5698 | * Return: none |
| 5699 | */ |
| 5700 | void wlan_hdd_display_netif_queue_history(hdd_context_t *hdd_ctx) |
| 5701 | { |
| 5702 | |
| 5703 | hdd_adapter_t *adapter = NULL; |
| 5704 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5705 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5706 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5707 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5708 | |
| 5709 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5710 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5711 | adapter = adapter_node->pAdapter; |
| 5712 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5713 | hdd_err("\nNetif queue operation statistics:"); |
| 5714 | hdd_err("Session_id %d device mode %d", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 5715 | adapter->sessionId, adapter->device_mode); |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5716 | hdd_err("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 5717 | curr_time = qdf_system_ticks(); |
| 5718 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5719 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 5720 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5721 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 5722 | unpause = adapter->total_unpause_time; |
| 5723 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5724 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 5725 | pause = adapter->total_pause_time; |
| 5726 | } |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5727 | hdd_err("Total: %ums Pause: %ums Unpause: %ums", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 5728 | qdf_system_ticks_to_msecs(total), |
| 5729 | qdf_system_ticks_to_msecs(pause), |
| 5730 | qdf_system_ticks_to_msecs(unpause)); |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5731 | hdd_err("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5732 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5733 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 5734 | qdf_time_t pause_delta = 0; |
| 5735 | |
| 5736 | if (adapter->pause_map & (1 << i)) |
| 5737 | pause_delta = delta; |
| 5738 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5739 | hdd_err("%s: %d: %d: %ums", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5740 | hdd_reason_type_to_string(i), |
| 5741 | adapter->queue_oper_stats[i].pause_count, |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5742 | adapter->queue_oper_stats[i].unpause_count, |
| 5743 | qdf_system_ticks_to_msecs( |
| 5744 | adapter->queue_oper_stats[i].total_pause_time + |
| 5745 | pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5746 | } |
| 5747 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5748 | hdd_err("\nNetif queue operation history:"); |
| 5749 | hdd_err("Total entries: %d current index %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5750 | WLAN_HDD_MAX_HISTORY_ENTRY, adapter->history_index); |
| 5751 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5752 | hdd_err("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5753 | |
| 5754 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5755 | hdd_err("%d: %u: %s: %s: %x", |
Anurag Chouhan | 50220ce | 2016-02-18 20:11:33 +0530 | [diff] [blame] | 5756 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5757 | adapter->queue_oper_history[i].time), |
| 5758 | hdd_action_type_to_string( |
| 5759 | adapter->queue_oper_history[i].netif_action), |
| 5760 | hdd_reason_type_to_string( |
| 5761 | adapter->queue_oper_history[i].netif_reason), |
| 5762 | adapter->queue_oper_history[i].pause_map); |
| 5763 | } |
| 5764 | |
| 5765 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 5766 | adapter_node = next; |
| 5767 | } |
| 5768 | |
| 5769 | |
| 5770 | } |
| 5771 | |
| 5772 | /** |
| 5773 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 5774 | * @hdd_ctx: hdd context |
| 5775 | * |
| 5776 | * Return: none |
| 5777 | */ |
| 5778 | void wlan_hdd_clear_netif_queue_history(hdd_context_t *hdd_ctx) |
| 5779 | { |
| 5780 | hdd_adapter_t *adapter = NULL; |
| 5781 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5782 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5783 | |
| 5784 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5785 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5786 | adapter = adapter_node->pAdapter; |
| 5787 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5788 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5789 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5790 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5791 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 5792 | adapter->history_index = 0; |
| 5793 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 5794 | adapter->total_pause_time = 0; |
| 5795 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5796 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 5797 | adapter_node = next; |
| 5798 | } |
| 5799 | } |
| 5800 | |
| 5801 | /** |
| 5802 | * hdd_11d_scan_done() - callback for 11d scan completion of flushing results |
| 5803 | * @halHandle: Hal handle |
| 5804 | * @pContext: Pointer to the context |
| 5805 | * @sessionId: Session ID |
| 5806 | * @scanId: Scan ID |
| 5807 | * @status: Status |
| 5808 | * |
| 5809 | * This is the callback to be executed when 11d scan is completed to flush out |
| 5810 | * the scan results |
| 5811 | * |
| 5812 | * 11d scan is done during driver load and is a passive scan on all |
| 5813 | * channels supported by the device, 11d scans may find some APs on |
| 5814 | * frequencies which are forbidden to be used in the regulatory domain |
| 5815 | * the device is operating in. If these APs are notified to the supplicant |
| 5816 | * it may try to connect to these APs, thus flush out all the scan results |
| 5817 | * which are present in SME after 11d scan is done. |
| 5818 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5819 | * Return: QDF_STATUS_SUCCESS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5820 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5821 | static QDF_STATUS hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5822 | uint8_t sessionId, uint32_t scanId, |
| 5823 | eCsrScanStatus status) |
| 5824 | { |
| 5825 | ENTER(); |
| 5826 | |
| 5827 | sme_scan_flush_result(halHandle); |
| 5828 | |
| 5829 | EXIT(); |
| 5830 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5831 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5832 | } |
| 5833 | |
| 5834 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 5835 | /** |
| 5836 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 5837 | * @hdd_ctx: hdd global context |
| 5838 | * |
| 5839 | * Return: none |
| 5840 | */ |
| 5841 | static void hdd_init_offloaded_packets_ctx(hdd_context_t *hdd_ctx) |
| 5842 | { |
| 5843 | uint8_t i; |
| 5844 | |
| 5845 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 5846 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 5847 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 5848 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 5849 | } |
| 5850 | } |
| 5851 | #else |
| 5852 | static void hdd_init_offloaded_packets_ctx(hdd_context_t *hdd_ctx) |
| 5853 | { |
| 5854 | } |
| 5855 | #endif |
| 5856 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 5857 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 5858 | /** |
| 5859 | * wlan_hdd_set_wow_pulse() - call SME to send wmi cmd of wow pulse |
| 5860 | * @phddctx: hdd_context_t structure pointer |
| 5861 | * @enable: enable or disable this behaviour |
| 5862 | * |
| 5863 | * Return: int |
| 5864 | */ |
| 5865 | static int wlan_hdd_set_wow_pulse(hdd_context_t *phddctx, bool enable) |
| 5866 | { |
| 5867 | struct hdd_config *pcfg_ini = phddctx->config; |
| 5868 | struct wow_pulse_mode wow_pulse_set_info; |
| 5869 | QDF_STATUS status; |
| 5870 | |
| 5871 | hdd_notice("wow pulse enable flag is %d", enable); |
| 5872 | |
| 5873 | if (false == phddctx->config->wow_pulse_support) |
| 5874 | return 0; |
| 5875 | |
| 5876 | /* prepare the request to send to SME */ |
| 5877 | if (enable == true) { |
| 5878 | wow_pulse_set_info.wow_pulse_enable = true; |
| 5879 | wow_pulse_set_info.wow_pulse_pin = |
| 5880 | pcfg_ini->wow_pulse_pin; |
| 5881 | wow_pulse_set_info.wow_pulse_interval_low = |
| 5882 | pcfg_ini->wow_pulse_interval_low; |
| 5883 | wow_pulse_set_info.wow_pulse_interval_high = |
| 5884 | pcfg_ini->wow_pulse_interval_high; |
| 5885 | } else { |
| 5886 | wow_pulse_set_info.wow_pulse_enable = false; |
| 5887 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 5888 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 5889 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 5890 | } |
| 5891 | hdd_notice("enable %d pin %d low %d high %d", |
| 5892 | wow_pulse_set_info.wow_pulse_enable, |
| 5893 | wow_pulse_set_info.wow_pulse_pin, |
| 5894 | wow_pulse_set_info.wow_pulse_interval_low, |
| 5895 | wow_pulse_set_info.wow_pulse_interval_high); |
| 5896 | |
| 5897 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 5898 | if (QDF_STATUS_E_FAILURE == status) { |
| 5899 | hdd_notice("sme_set_wow_pulse failure!"); |
| 5900 | return -EIO; |
| 5901 | } |
| 5902 | hdd_notice("sme_set_wow_pulse success!"); |
| 5903 | return 0; |
| 5904 | } |
| 5905 | #else |
| 5906 | static inline int wlan_hdd_set_wow_pulse(hdd_context_t *phddctx, bool enable) |
| 5907 | { |
| 5908 | return 0; |
| 5909 | } |
| 5910 | #endif |
| 5911 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5912 | #ifdef WLAN_FEATURE_FASTPATH |
| 5913 | /** |
| 5914 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 5915 | * @hdd_cfg: hdd config |
| 5916 | * @context: lower layer context |
| 5917 | * |
| 5918 | * Return: none |
| 5919 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5920 | void hdd_enable_fastpath(struct hdd_config *hdd_cfg, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5921 | void *context) |
| 5922 | { |
| 5923 | if (hdd_cfg->fastpath_enable) |
| 5924 | hif_enable_fastpath(context); |
| 5925 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5926 | #endif |
| 5927 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5928 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5929 | /** |
| 5930 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 5931 | * @context: hdd context pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5932 | * @level: thermal level |
| 5933 | * |
| 5934 | * Change IPA data path to SW path when the thermal throttle level greater |
| 5935 | * than 0, and restore the original data path when throttle level is 0 |
| 5936 | * |
| 5937 | * Return: none |
| 5938 | */ |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 5939 | 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] | 5940 | { |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 5941 | hdd_context_t *hdd_ctx = context; |
| 5942 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5943 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 5944 | if (level > THROTTLE_LEVEL_0) |
| 5945 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, true); |
| 5946 | else |
| 5947 | /* restore original concurrency mode */ |
| 5948 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, hdd_ctx->mcc_mode); |
| 5949 | } |
| 5950 | |
| 5951 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 5952 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 5953 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 5954 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5955 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 5956 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 5957 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 5958 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5959 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 5960 | * Return: Channel number to restart SAP in case of success. In case of any |
| 5961 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5962 | */ |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 5963 | static uint8_t hdd_get_safe_channel_from_pcl_and_acs_range( |
| 5964 | hdd_adapter_t *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5965 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 5966 | struct sir_pcl_list pcl; |
| 5967 | QDF_STATUS status; |
| 5968 | uint32_t i, j; |
| 5969 | tHalHandle *hal_handle; |
| 5970 | hdd_context_t *hdd_ctx; |
| 5971 | bool found = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5972 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 5973 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 5974 | if (!hdd_ctx) { |
| 5975 | hdd_err("invalid HDD context"); |
| 5976 | return INVALID_CHANNEL_ID; |
| 5977 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5978 | |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 5979 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 5980 | if (!hal_handle) { |
| 5981 | hdd_err("invalid HAL handle"); |
| 5982 | return INVALID_CHANNEL_ID; |
| 5983 | } |
| 5984 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 5985 | status = cds_get_pcl_for_existing_conn(CDS_SAP_MODE, |
| 5986 | pcl.pcl_list, &pcl.pcl_len, |
| 5987 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list)); |
| 5988 | if (QDF_IS_STATUS_ERROR(status)) { |
| 5989 | hdd_err("Get PCL failed"); |
| 5990 | return INVALID_CHANNEL_ID; |
| 5991 | } |
| 5992 | |
| 5993 | if (!pcl.pcl_len) { |
| 5994 | hdd_alert("pcl length is zero. this is not expected"); |
| 5995 | return INVALID_CHANNEL_ID; |
| 5996 | } |
| 5997 | |
| 5998 | hdd_info("start:%d end:%d", |
| 5999 | adapter->sessionCtx.ap.sapConfig.acs_cfg.start_ch, |
| 6000 | adapter->sessionCtx.ap.sapConfig.acs_cfg.end_ch); |
| 6001 | |
| 6002 | /* PCL already takes unsafe channel into account */ |
| 6003 | for (i = 0; i < pcl.pcl_len; i++) { |
| 6004 | hdd_info("chan[%d]:%d", i, pcl.pcl_list[i]); |
| 6005 | if ((pcl.pcl_list[i] >= |
| 6006 | adapter->sessionCtx.ap.sapConfig.acs_cfg.start_ch) && |
| 6007 | (pcl.pcl_list[i] <= |
| 6008 | adapter->sessionCtx.ap.sapConfig.acs_cfg.end_ch)) { |
| 6009 | hdd_info("found PCL safe chan:%d", pcl.pcl_list[i]); |
| 6010 | return pcl.pcl_list[i]; |
| 6011 | } |
| 6012 | } |
| 6013 | |
| 6014 | hdd_info("no safe channel from PCL found in ACS range"); |
| 6015 | |
| 6016 | /* Try for safe channel from all valid channel */ |
| 6017 | pcl.pcl_len = MAX_NUM_CHAN; |
| 6018 | status = sme_get_cfg_valid_channels(hal_handle, pcl.pcl_list, |
| 6019 | &pcl.pcl_len); |
| 6020 | if (QDF_IS_STATUS_ERROR(status)) { |
| 6021 | hdd_err("error in getting valid channel list"); |
| 6022 | return INVALID_CHANNEL_ID; |
| 6023 | } |
| 6024 | |
| 6025 | for (i = 0; i < pcl.pcl_len; i++) { |
| 6026 | hdd_info("chan[%d]:%d", i, pcl.pcl_list[i]); |
| 6027 | found = false; |
| 6028 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 6029 | if (pcl.pcl_list[i] == |
| 6030 | hdd_ctx->unsafe_channel_list[j]) { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6031 | hdd_info("unsafe chan:%d", pcl.pcl_list[i]); |
| 6032 | found = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6033 | break; |
| 6034 | } |
| 6035 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6036 | |
| 6037 | if (found) |
| 6038 | continue; |
| 6039 | |
| 6040 | if ((pcl.pcl_list[i] >= |
| 6041 | adapter->sessionCtx.ap.sapConfig.acs_cfg.start_ch) && |
| 6042 | (pcl.pcl_list[i] <= |
| 6043 | adapter->sessionCtx.ap.sapConfig.acs_cfg.end_ch)) { |
| 6044 | hdd_info("found safe chan:%d", pcl.pcl_list[i]); |
| 6045 | return pcl.pcl_list[i]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6046 | } |
| 6047 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6048 | |
| 6049 | return INVALID_CHANNEL_ID; |
| 6050 | } |
| 6051 | |
| 6052 | /** |
| 6053 | * hdd_restart_sap() - Restarts SAP on the given channel |
| 6054 | * @adapter: AP adapter |
| 6055 | * @channel: Channel |
| 6056 | * |
| 6057 | * Restarts the SAP interface by invoking the function which executes the |
| 6058 | * callback to perform channel switch using (E)CSA. |
| 6059 | * |
| 6060 | * Return: None |
| 6061 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 6062 | static void hdd_restart_sap(hdd_adapter_t *adapter, uint8_t channel) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6063 | { |
| 6064 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 6065 | tHalHandle *hal_handle; |
| 6066 | |
| 6067 | if (!adapter) { |
| 6068 | hdd_err("invalid adapter"); |
| 6069 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6070 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6071 | |
| 6072 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 6073 | |
| 6074 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 6075 | if (!hal_handle) { |
| 6076 | hdd_err("invalid HAL handle"); |
| 6077 | return; |
| 6078 | } |
| 6079 | |
| 6080 | hdd_ap_ctx->sapConfig.channel = channel; |
| 6081 | hdd_ap_ctx->sapConfig.ch_params.ch_width = |
| 6082 | hdd_ap_ctx->sapConfig.ch_width_orig; |
| 6083 | |
| 6084 | hdd_info("chan:%d width:%d", |
| 6085 | channel, hdd_ap_ctx->sapConfig.ch_width_orig); |
| 6086 | |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 6087 | cds_set_channel_params(hdd_ap_ctx->sapConfig.channel, |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6088 | hdd_ap_ctx->sapConfig.sec_ch, |
| 6089 | &hdd_ap_ctx->sapConfig.ch_params); |
| 6090 | |
| 6091 | cds_change_sap_channel_with_csa(adapter, hdd_ap_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6092 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6093 | /** |
| 6094 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 6095 | * @hdd_ctx: hdd context pointer |
| 6096 | * |
| 6097 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 6098 | * and if ACS is enabled, driver will ask userspace to restart the |
| 6099 | * sap. User space on LTE coex indication restart driver. |
| 6100 | * |
| 6101 | * Return - none |
| 6102 | */ |
| 6103 | void hdd_unsafe_channel_restart_sap(hdd_context_t *hdd_ctxt) |
| 6104 | { |
| 6105 | QDF_STATUS status; |
| 6106 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 6107 | hdd_adapter_t *adapter_temp; |
| 6108 | uint32_t i; |
| 6109 | bool found = false; |
| 6110 | uint8_t restart_chan; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6111 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6112 | status = hdd_get_front_adapter(hdd_ctxt, &adapter_node); |
| 6113 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 6114 | adapter_temp = adapter_node->pAdapter; |
| 6115 | |
| 6116 | if (!adapter_temp) { |
| 6117 | hdd_err("adapter is NULL, moving to next one"); |
| 6118 | goto next_adapater; |
| 6119 | } |
| 6120 | |
| 6121 | if (!((adapter_temp->device_mode == QDF_SAP_MODE) && |
| 6122 | (adapter_temp->sessionCtx.ap.sapConfig.acs_cfg.acs_mode))) { |
| 6123 | hdd_info("skip device mode:%d acs:%d", |
| 6124 | adapter_temp->device_mode, |
| 6125 | adapter_temp->sessionCtx.ap.sapConfig. |
| 6126 | acs_cfg.acs_mode); |
| 6127 | goto next_adapater; |
| 6128 | } |
| 6129 | |
| 6130 | found = false; |
| 6131 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 6132 | if (adapter_temp->sessionCtx.ap.operatingChannel == |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6133 | hdd_ctxt->unsafe_channel_list[i]) { |
| 6134 | found = true; |
| 6135 | hdd_info("operating ch:%d is unsafe", |
| 6136 | adapter_temp->sessionCtx.ap.operatingChannel); |
| 6137 | break; |
| 6138 | } |
| 6139 | } |
| 6140 | |
| 6141 | if (!found) { |
| 6142 | hdd_info("ch:%d is safe. no need to change channel", |
| 6143 | adapter_temp->sessionCtx.ap.operatingChannel); |
| 6144 | goto next_adapater; |
| 6145 | } |
| 6146 | |
| 6147 | restart_chan = |
| 6148 | hdd_get_safe_channel_from_pcl_and_acs_range( |
| 6149 | adapter_temp); |
| 6150 | if (!restart_chan) { |
| 6151 | hdd_alert("fail to restart SAP"); |
| 6152 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame^] | 6153 | /* |
| 6154 | * SAP restart due to unsafe channel. While |
| 6155 | * restarting the SAP, make sure to clear |
| 6156 | * acs_channel, channel to reset to |
| 6157 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 6158 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame^] | 6159 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 6160 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
| 6161 | adapter_temp->sessionCtx.ap.sapConfig.channel = |
| 6162 | AUTO_CHANNEL_SELECT; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6163 | hdd_info("sending coex indication"); |
| 6164 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 6165 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
| 6166 | hdd_restart_sap(adapter_temp, restart_chan); |
| 6167 | } |
| 6168 | |
| 6169 | next_adapater: |
| 6170 | status = hdd_get_next_adapter(hdd_ctxt, adapter_node, &next); |
| 6171 | adapter_node = next; |
| 6172 | } |
| 6173 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6174 | /** |
| 6175 | * hdd_ch_avoid_cb() - Avoid notified channels from FW handler |
| 6176 | * @adapter: HDD adapter pointer |
| 6177 | * @indParam: Channel avoid notification parameter |
| 6178 | * |
| 6179 | * Avoid channel notification from FW handler. |
| 6180 | * FW will send un-safe channel list to avoid over wrapping. |
| 6181 | * hostapd should not use notified channel |
| 6182 | * |
| 6183 | * Return: None |
| 6184 | */ |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6185 | void hdd_ch_avoid_cb(void *hdd_context, void *indi_param) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6186 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6187 | hdd_context_t *hdd_ctxt; |
| 6188 | tSirChAvoidIndType *ch_avoid_indi; |
| 6189 | uint8_t range_loop; |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6190 | enum channel_enum channel_loop, start_channel_idx = INVALID_CHANNEL, |
| 6191 | end_channel_idx = INVALID_CHANNEL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6192 | uint16_t start_channel; |
| 6193 | uint16_t end_channel; |
| 6194 | v_CONTEXT_t cds_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6195 | tHddAvoidFreqList hdd_avoid_freq_list; |
| 6196 | uint32_t i; |
| 6197 | |
| 6198 | /* Basic sanity */ |
| 6199 | if (!hdd_context || !indi_param) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6200 | hdd_err("Invalid arguments"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6201 | return; |
| 6202 | } |
| 6203 | |
| 6204 | hdd_ctxt = (hdd_context_t *) hdd_context; |
| 6205 | ch_avoid_indi = (tSirChAvoidIndType *) indi_param; |
| 6206 | cds_context = hdd_ctxt->pcds_context; |
| 6207 | |
| 6208 | /* Make unsafe channel list */ |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6209 | hdd_notice("band count %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6210 | ch_avoid_indi->avoid_range_count); |
| 6211 | |
| 6212 | /* generate vendor specific event */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6213 | qdf_mem_zero((void *)&hdd_avoid_freq_list, sizeof(tHddAvoidFreqList)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6214 | for (i = 0; i < ch_avoid_indi->avoid_range_count; i++) { |
| 6215 | hdd_avoid_freq_list.avoidFreqRange[i].startFreq = |
| 6216 | ch_avoid_indi->avoid_freq_range[i].start_freq; |
| 6217 | hdd_avoid_freq_list.avoidFreqRange[i].endFreq = |
| 6218 | ch_avoid_indi->avoid_freq_range[i].end_freq; |
| 6219 | } |
| 6220 | hdd_avoid_freq_list.avoidFreqRangeCount = |
| 6221 | ch_avoid_indi->avoid_range_count; |
| 6222 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6223 | /* clear existing unsafe channel cache */ |
| 6224 | hdd_ctxt->unsafe_channel_count = 0; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6225 | qdf_mem_zero(hdd_ctxt->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6226 | sizeof(hdd_ctxt->unsafe_channel_list)); |
| 6227 | |
| 6228 | for (range_loop = 0; range_loop < ch_avoid_indi->avoid_range_count; |
| 6229 | range_loop++) { |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6230 | if (hdd_ctxt->unsafe_channel_count >= NUM_CHANNELS) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6231 | hdd_warn("LTE Coex unsafe channel list full"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6232 | break; |
| 6233 | } |
| 6234 | |
| 6235 | start_channel = ieee80211_frequency_to_channel( |
| 6236 | ch_avoid_indi->avoid_freq_range[range_loop].start_freq); |
| 6237 | end_channel = ieee80211_frequency_to_channel( |
| 6238 | ch_avoid_indi->avoid_freq_range[range_loop].end_freq); |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6239 | hdd_notice("start %d : %d, end %d : %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6240 | ch_avoid_indi->avoid_freq_range[range_loop].start_freq, |
| 6241 | start_channel, |
| 6242 | ch_avoid_indi->avoid_freq_range[range_loop].end_freq, |
| 6243 | end_channel); |
| 6244 | |
| 6245 | /* do not process frequency bands that are not mapped to |
| 6246 | * predefined channels |
| 6247 | */ |
| 6248 | if (start_channel == 0 || end_channel == 0) |
| 6249 | continue; |
| 6250 | |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6251 | for (channel_loop = CHAN_ENUM_1; channel_loop <= |
| 6252 | CHAN_ENUM_184; channel_loop++) { |
Amar Singhal | 7a1726a | 2015-10-14 16:28:11 -0700 | [diff] [blame] | 6253 | if (CDS_CHANNEL_FREQ(channel_loop) >= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6254 | ch_avoid_indi->avoid_freq_range[ |
| 6255 | range_loop].start_freq) { |
| 6256 | start_channel_idx = channel_loop; |
| 6257 | break; |
| 6258 | } |
| 6259 | } |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6260 | for (channel_loop = CHAN_ENUM_1; channel_loop <= |
| 6261 | CHAN_ENUM_184; channel_loop++) { |
Amar Singhal | 7a1726a | 2015-10-14 16:28:11 -0700 | [diff] [blame] | 6262 | if (CDS_CHANNEL_FREQ(channel_loop) >= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6263 | ch_avoid_indi->avoid_freq_range[ |
| 6264 | range_loop].end_freq) { |
| 6265 | end_channel_idx = channel_loop; |
Amar Singhal | 7a1726a | 2015-10-14 16:28:11 -0700 | [diff] [blame] | 6266 | if (CDS_CHANNEL_FREQ(channel_loop) > |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6267 | ch_avoid_indi->avoid_freq_range[ |
| 6268 | range_loop].end_freq) |
| 6269 | end_channel_idx--; |
| 6270 | break; |
| 6271 | } |
| 6272 | } |
| 6273 | |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6274 | if (start_channel_idx == INVALID_CHANNEL || |
| 6275 | end_channel_idx == INVALID_CHANNEL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6276 | continue; |
| 6277 | |
| 6278 | for (channel_loop = start_channel_idx; channel_loop <= |
| 6279 | end_channel_idx; channel_loop++) { |
| 6280 | hdd_ctxt->unsafe_channel_list[ |
Amar Singhal | 7a1726a | 2015-10-14 16:28:11 -0700 | [diff] [blame] | 6281 | hdd_ctxt->unsafe_channel_count++] = |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 6282 | CDS_CHANNEL_NUM(channel_loop); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6283 | if (hdd_ctxt->unsafe_channel_count >= |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6284 | NUM_CHANNELS) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6285 | hdd_warn("LTECoex unsafe ch list full"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6286 | break; |
| 6287 | } |
| 6288 | } |
| 6289 | } |
| 6290 | |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6291 | hdd_notice("number of unsafe channels is %d ", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6292 | hdd_ctxt->unsafe_channel_count); |
| 6293 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6294 | if (pld_set_wlan_unsafe_channel(hdd_ctxt->parent_dev, |
| 6295 | hdd_ctxt->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6296 | hdd_ctxt->unsafe_channel_count)) { |
| 6297 | hdd_err("Failed to set unsafe channel"); |
| 6298 | |
| 6299 | /* clear existing unsafe channel cache */ |
| 6300 | hdd_ctxt->unsafe_channel_count = 0; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6301 | qdf_mem_zero(hdd_ctxt->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6302 | sizeof(hdd_ctxt->unsafe_channel_list)); |
| 6303 | |
| 6304 | return; |
| 6305 | } |
| 6306 | |
| 6307 | for (channel_loop = 0; |
| 6308 | channel_loop < hdd_ctxt->unsafe_channel_count; channel_loop++) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6309 | hdd_notice("channel %d is not safe ", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6310 | hdd_ctxt->unsafe_channel_list[channel_loop]); |
| 6311 | } |
| 6312 | |
Kondabattini, Ganesh | cf7b60f | 2016-08-10 16:31:55 +0530 | [diff] [blame] | 6313 | /* |
| 6314 | * first update the unsafe channel list to the platform driver and |
| 6315 | * send the avoid freq event to the application |
| 6316 | */ |
| 6317 | wlan_hdd_send_avoid_freq_event(hdd_ctxt, &hdd_avoid_freq_list); |
| 6318 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6319 | if (!hdd_ctxt->unsafe_channel_count) { |
| 6320 | hdd_info("no unsafe channels - not restarting SAP"); |
| 6321 | return; |
| 6322 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6323 | hdd_unsafe_channel_restart_sap(hdd_ctxt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6324 | return; |
| 6325 | } |
| 6326 | |
| 6327 | /** |
| 6328 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 6329 | * @hdd_ctx: HDD global context |
| 6330 | * |
| 6331 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6332 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6333 | * down to the lower layers. Then subscribe to subsequent channel |
| 6334 | * avoidance events. |
| 6335 | * |
| 6336 | * Return: None |
| 6337 | */ |
| 6338 | static void hdd_init_channel_avoidance(hdd_context_t *hdd_ctx) |
| 6339 | { |
| 6340 | uint16_t unsafe_channel_count; |
| 6341 | int index; |
| 6342 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6343 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 6344 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6345 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6346 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6347 | |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6348 | hdd_notice("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6349 | hdd_ctx->unsafe_channel_count); |
| 6350 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6351 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6352 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6353 | |
| 6354 | for (index = 0; index < unsafe_channel_count; index++) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6355 | hdd_notice("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6356 | hdd_ctx->unsafe_channel_list[index]); |
| 6357 | |
| 6358 | } |
| 6359 | |
| 6360 | /* Plug in avoid channel notification callback */ |
| 6361 | sme_add_ch_avoid_callback(hdd_ctx->hHal, hdd_ch_avoid_cb); |
| 6362 | } |
| 6363 | #else |
| 6364 | static void hdd_init_channel_avoidance(hdd_context_t *hdd_ctx) |
| 6365 | { |
| 6366 | } |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 6367 | 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] | 6368 | { |
| 6369 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6370 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6371 | |
| 6372 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 6373 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 6374 | * user space |
| 6375 | * @frame_ind: Management frame data to be informed. |
| 6376 | * |
| 6377 | * This function is used to indicate management frame to |
| 6378 | * user space |
| 6379 | * |
| 6380 | * Return: None |
| 6381 | * |
| 6382 | */ |
| 6383 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 6384 | { |
| 6385 | hdd_context_t *hdd_ctx = NULL; |
| 6386 | hdd_adapter_t *adapter = NULL; |
| 6387 | void *cds_context = NULL; |
| 6388 | int i; |
| 6389 | |
| 6390 | /* Get the global VOSS context.*/ |
| 6391 | cds_context = cds_get_global_context(); |
| 6392 | if (!cds_context) { |
| 6393 | hdd_err("Global CDS context is Null"); |
| 6394 | return; |
| 6395 | } |
| 6396 | /* Get the HDD context.*/ |
| 6397 | hdd_ctx = (hdd_context_t *)cds_get_context(QDF_MODULE_ID_HDD); |
| 6398 | |
| 6399 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 6400 | return; |
| 6401 | |
| 6402 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
| 6403 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 6404 | adapter = |
| 6405 | hdd_get_adapter_by_sme_session_id(hdd_ctx, i); |
| 6406 | if (adapter) |
| 6407 | break; |
| 6408 | } |
| 6409 | } else { |
| 6410 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 6411 | frame_ind->sessionId); |
| 6412 | } |
| 6413 | |
| 6414 | if ((NULL != adapter) && |
| 6415 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 6416 | __hdd_indicate_mgmt_frame(adapter, |
| 6417 | frame_ind->frame_len, |
| 6418 | frame_ind->frameBuf, |
| 6419 | frame_ind->frameType, |
| 6420 | frame_ind->rxChan, |
| 6421 | frame_ind->rxRssi); |
| 6422 | return; |
| 6423 | } |
| 6424 | |
| 6425 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6426 | * wlan_hdd_disable_all_dual_mac_features() - Disable dual mac features |
| 6427 | * @hdd_ctx: HDD context |
| 6428 | * |
| 6429 | * Disables all the dual mac features like DBS, Agile DFS etc. |
| 6430 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6431 | * Return: QDF_STATUS_SUCCESS on success |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6432 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6433 | 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] | 6434 | { |
| 6435 | struct sir_dual_mac_config cfg; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6436 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6437 | |
| 6438 | if (!hdd_ctx) { |
| 6439 | hdd_err("HDD context is NULL"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6440 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6441 | } |
| 6442 | |
| 6443 | cfg.scan_config = 0; |
| 6444 | cfg.fw_mode_config = 0; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 6445 | cfg.set_dual_mac_cb = cds_soc_set_dual_mac_cfg_cb; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6446 | |
| 6447 | hdd_debug("Disabling all dual mac features..."); |
| 6448 | |
| 6449 | status = sme_soc_set_dual_mac_config(hdd_ctx->hHal, cfg); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6450 | if (status != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6451 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 6452 | return status; |
| 6453 | } |
| 6454 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6455 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6456 | } |
| 6457 | |
| 6458 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6459 | * hdd_override_ini_config - Override INI config |
| 6460 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6461 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6462 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6463 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6464 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6465 | */ |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6466 | static void hdd_override_ini_config(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6467 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6468 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6469 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
| 6470 | hdd_ctx->config->enableDFSChnlScan = enable_dfs_chan_scan; |
| 6471 | hdd_notice("Module enable_dfs_chan_scan set to %d", |
| 6472 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6473 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6474 | if (0 == enable_11d || 1 == enable_11d) { |
| 6475 | hdd_ctx->config->Is11dSupportEnabled = enable_11d; |
| 6476 | hdd_notice("Module enable_11d set to %d", enable_11d); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6477 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 6478 | |
| 6479 | if (!hdd_ipa_is_present(hdd_ctx)) |
| 6480 | hdd_ctx->config->IpaConfig = 0; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6481 | } |
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 | /** |
| 6484 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 6485 | * @hdd_ctx - HDD context |
| 6486 | * |
| 6487 | * Set trace level for each module based on INI config. |
| 6488 | * |
| 6489 | * Return: None |
| 6490 | */ |
| 6491 | static void hdd_set_trace_level_for_each(hdd_context_t *hdd_ctx) |
| 6492 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6493 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMI, |
| 6494 | hdd_ctx->config->qdf_trace_enable_wdi); |
| 6495 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD, |
| 6496 | hdd_ctx->config->qdf_trace_enable_hdd); |
| 6497 | hdd_qdf_trace_enable(QDF_MODULE_ID_SME, |
| 6498 | hdd_ctx->config->qdf_trace_enable_sme); |
| 6499 | hdd_qdf_trace_enable(QDF_MODULE_ID_PE, |
| 6500 | hdd_ctx->config->qdf_trace_enable_pe); |
| 6501 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMA, |
| 6502 | hdd_ctx->config->qdf_trace_enable_wma); |
| 6503 | hdd_qdf_trace_enable(QDF_MODULE_ID_SYS, |
| 6504 | hdd_ctx->config->qdf_trace_enable_sys); |
| 6505 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF, |
| 6506 | hdd_ctx->config->qdf_trace_enable_qdf); |
| 6507 | hdd_qdf_trace_enable(QDF_MODULE_ID_SAP, |
| 6508 | hdd_ctx->config->qdf_trace_enable_sap); |
| 6509 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SOFTAP, |
| 6510 | hdd_ctx->config->qdf_trace_enable_hdd_sap); |
| 6511 | hdd_qdf_trace_enable(QDF_MODULE_ID_BMI, |
| 6512 | hdd_ctx->config->qdf_trace_enable_bmi); |
| 6513 | hdd_qdf_trace_enable(QDF_MODULE_ID_CFG, |
| 6514 | hdd_ctx->config->qdf_trace_enable_cfg); |
| 6515 | hdd_qdf_trace_enable(QDF_MODULE_ID_EPPING, |
| 6516 | hdd_ctx->config->qdf_trace_enable_epping); |
| 6517 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF_DEVICE, |
| 6518 | hdd_ctx->config->qdf_trace_enable_qdf_devices); |
| 6519 | hdd_qdf_trace_enable(QDF_MODULE_ID_TXRX, |
Bhargav Shah | 480a90f | 2015-06-24 15:10:14 +0530 | [diff] [blame] | 6520 | hdd_ctx->config->cfd_trace_enable_txrx); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6521 | hdd_qdf_trace_enable(QDF_MODULE_ID_HTC, |
| 6522 | hdd_ctx->config->qdf_trace_enable_htc); |
| 6523 | hdd_qdf_trace_enable(QDF_MODULE_ID_HIF, |
| 6524 | hdd_ctx->config->qdf_trace_enable_hif); |
| 6525 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SAP_DATA, |
| 6526 | hdd_ctx->config->qdf_trace_enable_hdd_sap_data); |
| 6527 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_DATA, |
| 6528 | hdd_ctx->config->qdf_trace_enable_hdd_data); |
Bhargav Shah | 480a90f | 2015-06-24 15:10:14 +0530 | [diff] [blame] | 6529 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6530 | hdd_cfg_print(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6531 | } |
| 6532 | |
| 6533 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6534 | * hdd_context_init() - Initialize HDD context |
| 6535 | * @hdd_ctx: HDD context. |
| 6536 | * |
| 6537 | * Initialize HDD context along with all the feature specific contexts. |
| 6538 | * |
| 6539 | * return: 0 on success and errno on failure. |
| 6540 | */ |
| 6541 | static int hdd_context_init(hdd_context_t *hdd_ctx) |
| 6542 | { |
| 6543 | int ret; |
| 6544 | |
| 6545 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 6546 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 6547 | |
| 6548 | hdd_init_ll_stats_ctx(); |
| 6549 | |
| 6550 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 6551 | init_completion(&hdd_ctx->ready_to_suspend); |
| 6552 | |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6553 | hdd_init_bpf_completion(); |
| 6554 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6555 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 6556 | qdf_spinlock_create(&hdd_ctx->sta_update_info_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6557 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 6558 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6559 | qdf_list_create(&hdd_ctx->hddAdapters, MAX_NUMBER_OF_ADAPTERS); |
| 6560 | |
| 6561 | init_completion(&hdd_ctx->set_antenna_mode_cmpl); |
| 6562 | |
| 6563 | ret = hdd_scan_context_init(hdd_ctx); |
| 6564 | if (ret) |
| 6565 | goto list_destroy; |
| 6566 | |
| 6567 | hdd_tdls_context_init(hdd_ctx); |
| 6568 | |
| 6569 | hdd_rx_wake_lock_create(hdd_ctx); |
| 6570 | |
| 6571 | ret = hdd_sap_context_init(hdd_ctx); |
| 6572 | if (ret) |
| 6573 | goto scan_destroy; |
| 6574 | |
| 6575 | ret = hdd_roc_context_init(hdd_ctx); |
| 6576 | if (ret) |
| 6577 | goto sap_destroy; |
| 6578 | |
| 6579 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 6580 | |
| 6581 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 6582 | |
| 6583 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 6584 | hdd_ctx->config); |
| 6585 | if (ret) |
| 6586 | goto roc_destroy; |
| 6587 | |
| 6588 | return 0; |
| 6589 | |
| 6590 | roc_destroy: |
| 6591 | hdd_roc_context_destroy(hdd_ctx); |
| 6592 | |
| 6593 | sap_destroy: |
| 6594 | hdd_sap_context_destroy(hdd_ctx); |
| 6595 | |
| 6596 | scan_destroy: |
| 6597 | hdd_scan_context_destroy(hdd_ctx); |
| 6598 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 6599 | hdd_tdls_context_destroy(hdd_ctx); |
| 6600 | |
| 6601 | list_destroy: |
| 6602 | qdf_list_destroy(&hdd_ctx->hddAdapters); |
| 6603 | return ret; |
| 6604 | } |
| 6605 | |
| 6606 | /** |
| 6607 | * hdd_context_create() - Allocate and inialize HDD context. |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6608 | * @dev: Device Pointer to the underlying device |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6609 | * |
| 6610 | * Allocate and initialize HDD context. HDD context is allocated as part of |
| 6611 | * wiphy allocation and then context is initialized. |
| 6612 | * |
| 6613 | * Return: HDD context on success and ERR_PTR on failure |
| 6614 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 6615 | static hdd_context_t *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6616 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6617 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6618 | int ret = 0; |
| 6619 | hdd_context_t *hdd_ctx; |
| 6620 | v_CONTEXT_t p_cds_context; |
| 6621 | |
| 6622 | ENTER(); |
| 6623 | |
| 6624 | p_cds_context = cds_get_global_context(); |
| 6625 | if (p_cds_context == NULL) { |
| 6626 | hdd_alert("Failed to get CDS global context"); |
| 6627 | ret = -EINVAL; |
| 6628 | goto err_out; |
| 6629 | } |
| 6630 | |
| 6631 | hdd_ctx = hdd_cfg80211_wiphy_alloc(sizeof(hdd_context_t)); |
| 6632 | |
| 6633 | if (hdd_ctx == NULL) { |
| 6634 | ret = -ENOMEM; |
| 6635 | goto err_out; |
| 6636 | } |
| 6637 | |
| 6638 | hdd_ctx->pcds_context = p_cds_context; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6639 | hdd_ctx->parent_dev = dev; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6640 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6641 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6642 | if (hdd_ctx->config == NULL) { |
| 6643 | hdd_alert("Failed to alloc memory for HDD config!"); |
| 6644 | ret = -ENOMEM; |
| 6645 | goto err_free_hdd_context; |
| 6646 | } |
| 6647 | |
| 6648 | /* Read and parse the qcom_cfg.ini file */ |
| 6649 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6650 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6651 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6652 | WLAN_INI_FILE); |
| 6653 | ret = -EINVAL; |
| 6654 | goto err_free_config; |
| 6655 | } |
| 6656 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6657 | hdd_ctx->configuredMcastBcastFilter = |
| 6658 | hdd_ctx->config->mcastBcastFilterSetting; |
| 6659 | |
| 6660 | hdd_notice("Setting configuredMcastBcastFilter: %d", |
| 6661 | hdd_ctx->config->mcastBcastFilterSetting); |
| 6662 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 6663 | if (hdd_ctx->config->fhostNSOffload) |
| 6664 | hdd_ctx->ns_offload_enable = true; |
| 6665 | |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 6666 | cds_set_fatal_event(hdd_ctx->config->enable_fatal_event); |
| 6667 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6668 | hdd_override_ini_config(hdd_ctx); |
| 6669 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6670 | ((cds_context_type *) (p_cds_context))->pHDDContext = (void *)hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6671 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6672 | ret = hdd_context_init(hdd_ctx); |
| 6673 | |
| 6674 | if (ret) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6675 | goto err_free_config; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6676 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6677 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6678 | pld_set_fw_debug_mode(hdd_ctx->parent_dev, |
| 6679 | hdd_ctx->config->enable_fw_log); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6680 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6681 | |
| 6682 | /* Uses to enabled logging after SSR */ |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 6683 | hdd_ctx->fw_log_settings.enable = hdd_ctx->config->enable_fw_log; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6684 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6685 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6686 | goto skip_multicast_logging; |
| 6687 | |
| 6688 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 6689 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 6690 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 6691 | if (ret) |
| 6692 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6693 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6694 | ret = hdd_logging_sock_activate_svc(hdd_ctx); |
| 6695 | if (ret) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6696 | goto err_free_histogram; |
| 6697 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6698 | |
| 6699 | /* |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6700 | * Update QDF trace levels based upon the code. The multicast |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6701 | * levels of the code need not be set when the logger thread |
| 6702 | * is not enabled. |
| 6703 | */ |
| 6704 | if (cds_is_multicast_logging()) |
| 6705 | wlan_logging_set_log_level(); |
| 6706 | |
| 6707 | skip_multicast_logging: |
| 6708 | hdd_set_trace_level_for_each(hdd_ctx); |
| 6709 | |
| 6710 | return hdd_ctx; |
| 6711 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6712 | err_free_histogram: |
| 6713 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 6714 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 6715 | err_deinit_hdd_context: |
| 6716 | hdd_context_deinit(hdd_ctx); |
| 6717 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6718 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6719 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6720 | |
| 6721 | err_free_hdd_context: |
| 6722 | wiphy_free(hdd_ctx->wiphy); |
| 6723 | |
| 6724 | err_out: |
| 6725 | return ERR_PTR(ret); |
| 6726 | } |
| 6727 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6728 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 6729 | /** |
| 6730 | * hdd_open_p2p_interface - Open P2P interface |
| 6731 | * @hdd_ctx: HDD context |
| 6732 | * @rtnl_held: True if RTNL lock held |
| 6733 | * |
| 6734 | * Open P2P interface during probe. This function called to open the P2P |
| 6735 | * interface at probe along with STA interface. |
| 6736 | * |
| 6737 | * Return: 0 on success and errno on failure |
| 6738 | */ |
| 6739 | static int hdd_open_p2p_interface(hdd_context_t *hdd_ctx, bool rtnl_held) |
| 6740 | { |
| 6741 | hdd_adapter_t *adapter; |
| 6742 | uint8_t *p2p_dev_addr; |
| 6743 | |
| 6744 | if (hdd_ctx->config->isP2pDeviceAddrAdministrated && |
| 6745 | !(hdd_ctx->config->intfMacAddr[0].bytes[0] & 0x02)) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6746 | qdf_mem_copy(hdd_ctx->p2pDeviceAddress.bytes, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6747 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 6748 | sizeof(tSirMacAddr)); |
| 6749 | |
| 6750 | /* |
| 6751 | * Generate the P2P Device Address. This consists of |
| 6752 | * the device's primary MAC address with the locally |
| 6753 | * administered bit set. |
| 6754 | */ |
| 6755 | hdd_ctx->p2pDeviceAddress.bytes[0] |= 0x02; |
| 6756 | } else { |
| 6757 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx); |
| 6758 | if (p2p_dev_addr == NULL) { |
| 6759 | hdd_alert("Failed to allocate mac_address for p2p_device"); |
| 6760 | return -ENOSPC; |
| 6761 | } |
| 6762 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6763 | qdf_mem_copy(&hdd_ctx->p2pDeviceAddress.bytes[0], p2p_dev_addr, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6764 | QDF_MAC_ADDR_SIZE); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6765 | } |
| 6766 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6767 | adapter = hdd_open_adapter(hdd_ctx, QDF_P2P_DEVICE_MODE, "p2p%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6768 | &hdd_ctx->p2pDeviceAddress.bytes[0], |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 6769 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6770 | |
| 6771 | if (NULL == adapter) { |
| 6772 | hdd_alert("Failed to do hdd_open_adapter for P2P Device Interface"); |
| 6773 | return -ENOSPC; |
| 6774 | } |
| 6775 | |
| 6776 | return 0; |
| 6777 | } |
| 6778 | #else |
Manishekar Chandrasekaran | c81ba24 | 2016-07-18 17:44:44 +0530 | [diff] [blame] | 6779 | static inline int hdd_open_p2p_interface(hdd_context_t *hdd_ctx, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6780 | bool rtnl_held) |
| 6781 | { |
| 6782 | return 0; |
| 6783 | } |
| 6784 | #endif |
| 6785 | |
| 6786 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 6787 | * hdd_start_station_adapter()- Start the Station Adapter |
| 6788 | * @adapter: HDD adapter |
| 6789 | * |
| 6790 | * This function initializes the adapter for the station mode. |
| 6791 | * |
| 6792 | * Return: 0 on success or errno on failure. |
| 6793 | */ |
| 6794 | int hdd_start_station_adapter(hdd_adapter_t *adapter) |
| 6795 | { |
| 6796 | QDF_STATUS status; |
| 6797 | |
| 6798 | ENTER_DEV(adapter->dev); |
| 6799 | |
| 6800 | status = hdd_init_station_mode(adapter); |
| 6801 | |
| 6802 | if (QDF_STATUS_SUCCESS != status) { |
| 6803 | hdd_err("Error Initializing station mode: %d", status); |
| 6804 | return qdf_status_to_os_return(status); |
| 6805 | } |
| 6806 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6807 | hdd_register_tx_flow_control(adapter, |
| 6808 | hdd_tx_resume_timer_expired_handler, |
| 6809 | hdd_tx_resume_cb); |
| 6810 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 6811 | EXIT(); |
| 6812 | return 0; |
| 6813 | } |
| 6814 | |
| 6815 | /** |
| 6816 | * hdd_start_ap_adapter()- Start AP Adapter |
| 6817 | * @adapter: HDD adapter |
| 6818 | * |
| 6819 | * This function initializes the adapter for the AP mode. |
| 6820 | * |
| 6821 | * Return: 0 on success errno on failure. |
| 6822 | */ |
| 6823 | int hdd_start_ap_adapter(hdd_adapter_t *adapter) |
| 6824 | { |
| 6825 | QDF_STATUS status; |
| 6826 | |
| 6827 | ENTER(); |
| 6828 | |
| 6829 | status = hdd_init_ap_mode(adapter); |
| 6830 | |
| 6831 | if (QDF_STATUS_SUCCESS != status) { |
| 6832 | hdd_err("Error Initializing the AP mode: %d", status); |
| 6833 | return qdf_status_to_os_return(status); |
| 6834 | } |
| 6835 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6836 | hdd_register_tx_flow_control(adapter, |
| 6837 | hdd_softap_tx_resume_timer_expired_handler, |
| 6838 | hdd_softap_tx_resume_cb); |
| 6839 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 6840 | EXIT(); |
| 6841 | return 0; |
| 6842 | } |
| 6843 | |
| 6844 | /** |
| 6845 | * hdd_start_ftm_adapter()- Start FTM adapter |
| 6846 | * @adapter: HDD adapter |
| 6847 | * |
| 6848 | * This function initializes the adapter for the FTM mode. |
| 6849 | * |
| 6850 | * Return: 0 on success or errno on failure. |
| 6851 | */ |
| 6852 | int hdd_start_ftm_adapter(hdd_adapter_t *adapter) |
| 6853 | { |
| 6854 | QDF_STATUS qdf_status; |
| 6855 | |
| 6856 | ENTER_DEV(adapter->dev); |
| 6857 | |
| 6858 | qdf_status = hdd_init_tx_rx(adapter); |
| 6859 | |
| 6860 | if (QDF_STATUS_SUCCESS != qdf_status) { |
| 6861 | hdd_err("Failed to start FTM adapter: %d", qdf_status); |
| 6862 | return qdf_status_to_os_return(qdf_status); |
| 6863 | } |
| 6864 | |
| 6865 | return 0; |
| 6866 | EXIT(); |
| 6867 | } |
| 6868 | |
| 6869 | /** |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6870 | * hdd_open_interfaces - Open all required interfaces |
| 6871 | * hdd_ctx: HDD context |
| 6872 | * rtnl_held: True if RTNL lock is held |
| 6873 | * |
| 6874 | * Open all the interfaces like STA, P2P and OCB based on the configuration. |
| 6875 | * |
| 6876 | * Return: Primary adapter on success and PTR_ERR on failure |
| 6877 | */ |
| 6878 | static hdd_adapter_t *hdd_open_interfaces(hdd_context_t *hdd_ctx, |
| 6879 | bool rtnl_held) |
| 6880 | { |
| 6881 | hdd_adapter_t *adapter = NULL; |
| 6882 | hdd_adapter_t *adapter_11p = NULL; |
| 6883 | int ret; |
| 6884 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6885 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_STANDALONE) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6886 | /* Create only 802.11p interface */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6887 | adapter = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, "wlanocb%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6888 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 6889 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6890 | |
| 6891 | if (adapter == NULL) |
| 6892 | return ERR_PTR(-ENOSPC); |
| 6893 | |
| 6894 | return adapter; |
| 6895 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6896 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, "wlan%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6897 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 6898 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6899 | |
| 6900 | if (adapter == NULL) |
| 6901 | return ERR_PTR(-ENOSPC); |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 6902 | /* fast roaming is allowed only on first STA, i.e. wlan adapter */ |
| 6903 | adapter->fast_roaming_allowed = true; |
| 6904 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6905 | ret = hdd_open_p2p_interface(hdd_ctx, rtnl_held); |
| 6906 | if (ret) |
| 6907 | goto err_close_adapter; |
| 6908 | |
| 6909 | /* Open 802.11p Interface */ |
| 6910 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_CONCURRENT) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6911 | adapter_11p = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6912 | "wlanocb%d", |
| 6913 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 6914 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6915 | if (adapter_11p == NULL) { |
| 6916 | hdd_err("Failed to open 802.11p interface"); |
| 6917 | goto err_close_adapter; |
| 6918 | } |
| 6919 | } |
| 6920 | |
| 6921 | return adapter; |
| 6922 | |
| 6923 | err_close_adapter: |
| 6924 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
| 6925 | return ERR_PTR(ret); |
| 6926 | } |
| 6927 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 6928 | /** |
| 6929 | * hdd_update_country_code - Update country code |
| 6930 | * @hdd_ctx: HDD context |
| 6931 | * @adapter: Primary adapter context |
| 6932 | * |
| 6933 | * Update country code based on module parameter country_code at SME and wait |
| 6934 | * for the settings to take effect. |
| 6935 | * |
| 6936 | * Return: 0 on success and errno on failure |
| 6937 | */ |
| 6938 | static int hdd_update_country_code(hdd_context_t *hdd_ctx, |
| 6939 | hdd_adapter_t *adapter) |
| 6940 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6941 | QDF_STATUS status; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 6942 | int ret = 0; |
| 6943 | unsigned long rc; |
| 6944 | |
| 6945 | if (country_code == NULL) |
| 6946 | return 0; |
| 6947 | |
| 6948 | INIT_COMPLETION(adapter->change_country_code); |
| 6949 | |
| 6950 | status = sme_change_country_code(hdd_ctx->hHal, |
| 6951 | wlan_hdd_change_country_code_callback, |
| 6952 | country_code, adapter, |
| 6953 | hdd_ctx->pcds_context, eSIR_TRUE, |
| 6954 | eSIR_TRUE); |
| 6955 | |
| 6956 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6957 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 6958 | hdd_err("SME Change Country code from module param fail ret=%d", |
| 6959 | ret); |
| 6960 | return -EINVAL; |
| 6961 | } |
| 6962 | |
| 6963 | rc = wait_for_completion_timeout(&adapter->change_country_code, |
| 6964 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 6965 | if (!rc) { |
| 6966 | hdd_err("SME while setting country code timed out"); |
| 6967 | ret = -ETIMEDOUT; |
| 6968 | } |
| 6969 | |
| 6970 | return ret; |
| 6971 | } |
| 6972 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 6973 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 6974 | /** |
| 6975 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 6976 | * @cds_cfg: CDS Configuration |
| 6977 | * @hdd_ctx: Pointer to hdd context |
| 6978 | * |
| 6979 | * Return: none |
| 6980 | */ |
| 6981 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 6982 | *cds_cfg, |
| 6983 | hdd_context_t *hdd_ctx) |
| 6984 | { |
| 6985 | cds_cfg->tx_flow_stop_queue_th = |
| 6986 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 6987 | cds_cfg->tx_flow_start_queue_offset = |
| 6988 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 6989 | } |
| 6990 | #else |
| 6991 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 6992 | *cds_cfg, |
| 6993 | hdd_context_t *hdd_ctx) |
| 6994 | { |
| 6995 | } |
| 6996 | #endif |
| 6997 | |
| 6998 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 6999 | /** |
| 7000 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 7001 | * @cds_cfg: CDS Configuration |
| 7002 | * @hdd_ctx: Pointer to hdd context |
| 7003 | * |
| 7004 | * Return: none |
| 7005 | */ |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 7006 | 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] | 7007 | hdd_context_t *hdd_ctx) |
| 7008 | { |
| 7009 | cds_cfg->ra_ratelimit_interval = |
| 7010 | hdd_ctx->config->RArateLimitInterval; |
| 7011 | cds_cfg->is_ra_ratelimit_enabled = |
| 7012 | hdd_ctx->config->IsRArateLimitEnabled; |
| 7013 | } |
| 7014 | #else |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 7015 | 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] | 7016 | hdd_context_t *hdd_ctx) |
| 7017 | { |
| 7018 | } |
| 7019 | #endif |
| 7020 | |
| 7021 | /** |
| 7022 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 7023 | * @hdd_ctx: HDD Context |
| 7024 | * |
| 7025 | * Return: 0 for Success, errno on failure |
| 7026 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 7027 | static int hdd_update_cds_config(hdd_context_t *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7028 | { |
| 7029 | struct cds_config_info *cds_cfg; |
| 7030 | |
| 7031 | cds_cfg = (struct cds_config_info *)qdf_mem_malloc(sizeof(*cds_cfg)); |
| 7032 | if (!cds_cfg) { |
| 7033 | hdd_err("failed to allocate cds config"); |
| 7034 | return -ENOMEM; |
| 7035 | } |
| 7036 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7037 | cds_cfg->driver_type = DRIVER_TYPE_PRODUCTION; |
| 7038 | cds_cfg->powersave_offload_enabled = |
| 7039 | hdd_ctx->config->enablePowersaveOffload; |
| 7040 | cds_cfg->sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 7041 | cds_cfg->sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 7042 | cds_cfg->sta_maxlimod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 7043 | cds_cfg->wow_enable = hdd_ctx->config->wowEnable; |
| 7044 | cds_cfg->max_wow_filters = hdd_ctx->config->maxWoWFilters; |
| 7045 | |
| 7046 | /* Here ol_ini_info is used to store ini status of arp offload |
| 7047 | * ns offload and others. Currently 1st bit is used for arp |
| 7048 | * off load and 2nd bit for ns offload currently, rest bits are unused |
| 7049 | */ |
| 7050 | if (hdd_ctx->config->fhostArpOffload) |
| 7051 | cds_cfg->ol_ini_info = cds_cfg->ol_ini_info | 0x1; |
| 7052 | if (hdd_ctx->config->fhostNSOffload) |
| 7053 | cds_cfg->ol_ini_info = cds_cfg->ol_ini_info | 0x2; |
| 7054 | |
| 7055 | /* |
| 7056 | * Copy the DFS Phyerr Filtering Offload status. |
| 7057 | * This parameter reflects the value of the |
| 7058 | * dfs_phyerr_filter_offload flag as set in the ini. |
| 7059 | */ |
| 7060 | cds_cfg->dfs_phyerr_filter_offload = |
| 7061 | hdd_ctx->config->fDfsPhyerrFilterOffload; |
| 7062 | if (hdd_ctx->config->ssdp) |
| 7063 | cds_cfg->ssdp = hdd_ctx->config->ssdp; |
| 7064 | |
| 7065 | cds_cfg->enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 7066 | cds_cfg->ap_maxoffload_peers = hdd_ctx->config->apMaxOffloadPeers; |
| 7067 | |
| 7068 | cds_cfg->ap_maxoffload_reorderbuffs = |
| 7069 | hdd_ctx->config->apMaxOffloadReorderBuffs; |
| 7070 | |
| 7071 | cds_cfg->ap_disable_intrabss_fwd = |
| 7072 | hdd_ctx->config->apDisableIntraBssFwd; |
| 7073 | |
| 7074 | cds_cfg->dfs_pri_multiplier = |
| 7075 | hdd_ctx->config->dfsRadarPriMultiplier; |
| 7076 | cds_cfg->reorder_offload = |
| 7077 | hdd_ctx->config->reorderOffloadSupport; |
| 7078 | |
| 7079 | /* IPA micro controller data path offload resource config item */ |
| 7080 | cds_cfg->uc_offload_enabled = hdd_ipa_uc_is_enabled(hdd_ctx); |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 7081 | if (!is_power_of_2(hdd_ctx->config->IpaUcTxBufCount)) { |
| 7082 | /* IpaUcTxBufCount should be power of 2 */ |
| 7083 | hdd_err("Round down IpaUcTxBufCount %d to nearest power of 2", |
| 7084 | hdd_ctx->config->IpaUcTxBufCount); |
| 7085 | hdd_ctx->config->IpaUcTxBufCount = |
| 7086 | rounddown_pow_of_two( |
| 7087 | hdd_ctx->config->IpaUcTxBufCount); |
| 7088 | if (!hdd_ctx->config->IpaUcTxBufCount) { |
| 7089 | hdd_err("Failed to round down IpaUcTxBufCount"); |
| 7090 | return -EINVAL; |
| 7091 | } |
| 7092 | hdd_err("IpaUcTxBufCount rounded down to %d", |
| 7093 | hdd_ctx->config->IpaUcTxBufCount); |
| 7094 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7095 | cds_cfg->uc_txbuf_count = hdd_ctx->config->IpaUcTxBufCount; |
| 7096 | cds_cfg->uc_txbuf_size = hdd_ctx->config->IpaUcTxBufSize; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 7097 | if (!is_power_of_2(hdd_ctx->config->IpaUcRxIndRingCount)) { |
| 7098 | /* IpaUcRxIndRingCount should be power of 2 */ |
| 7099 | hdd_err("Round down IpaUcRxIndRingCount %d to nearest power of 2", |
| 7100 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 7101 | hdd_ctx->config->IpaUcRxIndRingCount = |
| 7102 | rounddown_pow_of_two( |
| 7103 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 7104 | if (!hdd_ctx->config->IpaUcRxIndRingCount) { |
| 7105 | hdd_err("Failed to round down IpaUcRxIndRingCount"); |
| 7106 | return -EINVAL; |
| 7107 | } |
| 7108 | hdd_err("IpaUcRxIndRingCount rounded down to %d", |
| 7109 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 7110 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7111 | cds_cfg->uc_rxind_ringcount = |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 7112 | hdd_ctx->config->IpaUcRxIndRingCount; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7113 | cds_cfg->uc_tx_partition_base = |
| 7114 | hdd_ctx->config->IpaUcTxPartitionBase; |
| 7115 | cds_cfg->max_scan = hdd_ctx->config->max_scan_count; |
| 7116 | |
| 7117 | cds_cfg->ip_tcp_udp_checksum_offload = |
| 7118 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 7119 | cds_cfg->enable_rxthread = hdd_ctx->enableRxThread; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7120 | cds_cfg->ce_classify_enabled = |
| 7121 | hdd_ctx->config->ce_classify_enabled; |
Dustin Brown | d3fc9ee | 2016-09-14 13:57:27 -0700 | [diff] [blame] | 7122 | cds_cfg->bpf_packet_filter_enable = |
| 7123 | hdd_ctx->config->bpf_packet_filter_enable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7124 | cds_cfg->tx_chain_mask_cck = hdd_ctx->config->tx_chain_mask_cck; |
| 7125 | cds_cfg->self_gen_frm_pwr = hdd_ctx->config->self_gen_frm_pwr; |
| 7126 | cds_cfg->max_station = hdd_ctx->config->maxNumberOfPeers; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 7127 | cds_cfg->sub_20_channel_width = WLAN_SUB_20_CH_WIDTH_NONE; |
Manjunathappa Prakash | fff753c | 2016-09-01 19:34:56 -0700 | [diff] [blame] | 7128 | cds_cfg->flow_steering_enabled = hdd_ctx->config->flow_steering_enable; |
Naveen Rawat | 91df30a | 2016-10-12 21:26:18 -0700 | [diff] [blame] | 7129 | cds_cfg->self_recovery_enabled = hdd_ctx->config->enableSelfRecovery; |
Sandeep Puligilla | afa5289 | 2016-10-26 19:03:16 -0700 | [diff] [blame] | 7130 | cds_cfg->fw_timeout_crash = hdd_ctx->config->fw_timeout_crash; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7131 | |
| 7132 | hdd_ra_populate_cds_config(cds_cfg, hdd_ctx); |
| 7133 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
| 7134 | hdd_nan_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 7135 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7136 | cds_init_ini_config(cds_cfg); |
| 7137 | return 0; |
| 7138 | } |
| 7139 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7140 | /** |
| 7141 | * hdd_init_thermal_info - Initialize thermal level |
| 7142 | * @hdd_ctx: HDD context |
| 7143 | * |
| 7144 | * Initialize thermal level at SME layer and set the thermal level callback |
| 7145 | * which would be called when a configured thermal threshold is hit. |
| 7146 | * |
| 7147 | * Return: 0 on success and errno on failure |
| 7148 | */ |
| 7149 | static int hdd_init_thermal_info(hdd_context_t *hdd_ctx) |
| 7150 | { |
| 7151 | tSmeThermalParams thermal_param; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7152 | QDF_STATUS status; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7153 | |
| 7154 | thermal_param.smeThermalMgmtEnabled = |
| 7155 | hdd_ctx->config->thermalMitigationEnable; |
| 7156 | thermal_param.smeThrottlePeriod = hdd_ctx->config->throttlePeriod; |
| 7157 | |
Poddar, Siddarth | 8390502 | 2016-04-16 17:56:08 -0700 | [diff] [blame] | 7158 | thermal_param.sme_throttle_duty_cycle_tbl[0] = |
| 7159 | hdd_ctx->config->throttle_dutycycle_level0; |
| 7160 | thermal_param.sme_throttle_duty_cycle_tbl[1] = |
| 7161 | hdd_ctx->config->throttle_dutycycle_level1; |
| 7162 | thermal_param.sme_throttle_duty_cycle_tbl[2] = |
| 7163 | hdd_ctx->config->throttle_dutycycle_level2; |
| 7164 | thermal_param.sme_throttle_duty_cycle_tbl[3] = |
| 7165 | hdd_ctx->config->throttle_dutycycle_level3; |
| 7166 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7167 | thermal_param.smeThermalLevels[0].smeMinTempThreshold = |
| 7168 | hdd_ctx->config->thermalTempMinLevel0; |
| 7169 | thermal_param.smeThermalLevels[0].smeMaxTempThreshold = |
| 7170 | hdd_ctx->config->thermalTempMaxLevel0; |
| 7171 | thermal_param.smeThermalLevels[1].smeMinTempThreshold = |
| 7172 | hdd_ctx->config->thermalTempMinLevel1; |
| 7173 | thermal_param.smeThermalLevels[1].smeMaxTempThreshold = |
| 7174 | hdd_ctx->config->thermalTempMaxLevel1; |
| 7175 | thermal_param.smeThermalLevels[2].smeMinTempThreshold = |
| 7176 | hdd_ctx->config->thermalTempMinLevel2; |
| 7177 | thermal_param.smeThermalLevels[2].smeMaxTempThreshold = |
| 7178 | hdd_ctx->config->thermalTempMaxLevel2; |
| 7179 | thermal_param.smeThermalLevels[3].smeMinTempThreshold = |
| 7180 | hdd_ctx->config->thermalTempMinLevel3; |
| 7181 | thermal_param.smeThermalLevels[3].smeMaxTempThreshold = |
| 7182 | hdd_ctx->config->thermalTempMaxLevel3; |
| 7183 | |
| 7184 | status = sme_init_thermal_info(hdd_ctx->hHal, thermal_param); |
| 7185 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7186 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 7187 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7188 | |
| 7189 | sme_add_set_thermal_level_callback(hdd_ctx->hHal, |
| 7190 | hdd_set_thermal_level_cb); |
| 7191 | |
| 7192 | return 0; |
| 7193 | |
| 7194 | } |
| 7195 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7196 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 7197 | /** |
| 7198 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 7199 | * |
| 7200 | * Hold RTNL lock |
| 7201 | * |
| 7202 | * Return: True if held and false otherwise |
| 7203 | */ |
| 7204 | static inline bool hdd_hold_rtnl_lock(void) |
| 7205 | { |
| 7206 | rtnl_lock(); |
| 7207 | return true; |
| 7208 | } |
| 7209 | |
| 7210 | /** |
| 7211 | * hdd_release_rtnl_lock - Release RTNL lock |
| 7212 | * |
| 7213 | * Release RTNL lock |
| 7214 | * |
| 7215 | * Return: None |
| 7216 | */ |
| 7217 | static inline void hdd_release_rtnl_lock(void) |
| 7218 | { |
| 7219 | rtnl_unlock(); |
| 7220 | } |
| 7221 | #else |
| 7222 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 7223 | static inline void hdd_release_rtnl_lock(void) { } |
| 7224 | #endif |
| 7225 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 7226 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7227 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7228 | /* MAX iwpriv command support */ |
| 7229 | #define PKTLOG_SET_BUFF_SIZE 3 |
| 7230 | #define MAX_PKTLOG_SIZE 16 |
| 7231 | |
| 7232 | /** |
| 7233 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 7234 | * @hdd_ctx: hdd context |
| 7235 | * @set_value2: pktlog buffer size value |
| 7236 | * |
| 7237 | * |
| 7238 | * Return: 0 for success or error. |
| 7239 | */ |
| 7240 | static int hdd_pktlog_set_buff_size(hdd_context_t *hdd_ctx, int set_value2) |
| 7241 | { |
| 7242 | struct sir_wifi_start_log start_log = { 0 }; |
| 7243 | QDF_STATUS status; |
| 7244 | |
| 7245 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 7246 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 7247 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 7248 | start_log.user_triggered = 1; |
| 7249 | start_log.size = set_value2; |
| 7250 | |
| 7251 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 7252 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 7253 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 7254 | EXIT(); |
| 7255 | return -EINVAL; |
| 7256 | } |
| 7257 | |
| 7258 | return 0; |
| 7259 | } |
| 7260 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7261 | /** |
| 7262 | * hdd_process_pktlog_command() - process pktlog command |
| 7263 | * @hdd_ctx: hdd context |
| 7264 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7265 | * @set_value2: pktlog buffer size value |
| 7266 | * |
| 7267 | * This function process pktlog command. |
| 7268 | * set_value2 only matters when set_value is 3 (set buff size) |
| 7269 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7270 | * |
| 7271 | * Return: 0 for success or error. |
| 7272 | */ |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7273 | int hdd_process_pktlog_command(hdd_context_t *hdd_ctx, uint32_t set_value, |
| 7274 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7275 | { |
| 7276 | int ret; |
| 7277 | bool enable; |
| 7278 | uint8_t user_triggered = 0; |
| 7279 | |
| 7280 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 7281 | if (0 != ret) |
| 7282 | return ret; |
| 7283 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7284 | hdd_info("set pktlog %d, set size %d", set_value, set_value2); |
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 | if (set_value > PKTLOG_SET_BUFF_SIZE) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7287 | hdd_err("invalid pktlog value %d", set_value); |
| 7288 | return -EINVAL; |
| 7289 | } |
| 7290 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7291 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 7292 | if (set_value2 <= 0) { |
| 7293 | hdd_err("invalid pktlog size %d", set_value2); |
| 7294 | return -EINVAL; |
| 7295 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
| 7296 | hdd_err("Pktlog buff size is too large. max value is 16MB.\n"); |
| 7297 | return -EINVAL; |
| 7298 | } |
| 7299 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
| 7300 | } |
| 7301 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7302 | /* |
| 7303 | * set_value = 0 then disable packetlog |
| 7304 | * set_value = 1 enable packetlog forcefully |
| 7305 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 7306 | * enable packetlog with AUTO type. |
| 7307 | */ |
| 7308 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 7309 | true : false; |
| 7310 | |
| 7311 | if (1 == set_value) { |
| 7312 | enable = true; |
| 7313 | user_triggered = 1; |
| 7314 | } |
| 7315 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7316 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7317 | } |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 7318 | /** |
| 7319 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 7320 | * @hdd_ctx: HDD context |
| 7321 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7322 | * @user_triggered: triggered through iwpriv |
| 7323 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 7324 | * |
| 7325 | * Return: 0 on success; error number otherwise |
| 7326 | */ |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7327 | int hdd_pktlog_enable_disable(hdd_context_t *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7328 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 7329 | { |
| 7330 | struct sir_wifi_start_log start_log; |
| 7331 | QDF_STATUS status; |
| 7332 | |
| 7333 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 7334 | start_log.verbose_level = |
| 7335 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7336 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 7337 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7338 | start_log.size = size; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 7339 | /* |
| 7340 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 7341 | * commands. Host uses this flag to decide whether to send pktlog |
| 7342 | * disable command to fw without sending pktlog enable command |
| 7343 | * previously. For eg, If vendor sends pktlog disable command without |
| 7344 | * sending pktlog enable command, then host discards the packet |
| 7345 | * but for iwpriv command, host will send it to fw. |
| 7346 | */ |
| 7347 | start_log.is_iwpriv_command = 1; |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 7348 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 7349 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 7350 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 7351 | EXIT(); |
| 7352 | return -EINVAL; |
| 7353 | } |
| 7354 | |
| 7355 | return 0; |
| 7356 | } |
| 7357 | #endif /* REMOVE_PKT_LOG */ |
| 7358 | |
| 7359 | |
Chandrasekaran Manishekar | cde33d7 | 2016-04-14 19:03:39 +0530 | [diff] [blame] | 7360 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 7361 | /** |
| 7362 | * hdd_register_for_sap_restart_with_channel_switch() - Register for SAP channel |
| 7363 | * switch without restart |
| 7364 | * |
| 7365 | * Registers callback function to change the operating channel of SAP by using |
| 7366 | * channel switch announcements instead of restarting SAP. |
| 7367 | * |
| 7368 | * Return: QDF_STATUS |
| 7369 | */ |
| 7370 | QDF_STATUS hdd_register_for_sap_restart_with_channel_switch(void) |
| 7371 | { |
| 7372 | QDF_STATUS status; |
| 7373 | |
| 7374 | status = cds_register_sap_restart_channel_switch_cb( |
| 7375 | (void *)hdd_sap_restart_with_channel_switch); |
| 7376 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 7377 | hdd_err("restart cb registration failed"); |
| 7378 | |
| 7379 | return status; |
| 7380 | } |
| 7381 | #endif |
| 7382 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7383 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7384 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 7385 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7386 | * @dev: Device Pointer |
| 7387 | * @num: Number of Valid Mac address |
| 7388 | * |
| 7389 | * Return: Pointer to MAC address buffer |
| 7390 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7391 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 7392 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7393 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7394 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7395 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7396 | |
| 7397 | /** |
| 7398 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 7399 | * @hdd_ctx: HDD Context |
| 7400 | * @num: Number of random mac addresses needed |
| 7401 | * |
| 7402 | * Generate random addresses using bit manipulation on the base mac address |
| 7403 | * |
| 7404 | * Return: None |
| 7405 | */ |
| 7406 | static void hdd_populate_random_mac_addr(hdd_context_t *hdd_ctx, uint32_t num) |
| 7407 | { |
| 7408 | uint32_t start_idx = QDF_MAX_CONCURRENCY_PERSONA - num; |
| 7409 | uint32_t iter; |
| 7410 | struct hdd_config *ini = hdd_ctx->config; |
| 7411 | uint8_t *buf = NULL; |
| 7412 | uint8_t macaddr_b3, tmp_br3; |
| 7413 | uint8_t *src = ini->intfMacAddr[0].bytes; |
| 7414 | |
| 7415 | for (iter = start_idx; iter < QDF_MAX_CONCURRENCY_PERSONA; ++iter) { |
| 7416 | buf = ini->intfMacAddr[iter].bytes; |
| 7417 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 7418 | macaddr_b3 = buf[3]; |
| 7419 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + iter) & |
| 7420 | INTF_MACADDR_MASK; |
| 7421 | macaddr_b3 += tmp_br3; |
| 7422 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 7423 | buf[0] |= 0x02; |
| 7424 | buf[3] = macaddr_b3; |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 7425 | hdd_info(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7426 | } |
| 7427 | } |
| 7428 | |
| 7429 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7430 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7431 | * @hdd_ctx: HDD Context |
| 7432 | * |
| 7433 | * API to get mac addresses from platform driver and update the driver |
| 7434 | * structures and configure FW with the base mac address. |
| 7435 | * Return: int |
| 7436 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7437 | static int hdd_platform_wlan_mac(hdd_context_t *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7438 | { |
| 7439 | uint32_t no_of_mac_addr, iter; |
| 7440 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 7441 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 7442 | uint8_t *addr, *buf; |
| 7443 | struct device *dev = hdd_ctx->parent_dev; |
| 7444 | struct hdd_config *ini = hdd_ctx->config; |
| 7445 | tSirMacAddr mac_addr; |
| 7446 | QDF_STATUS status; |
| 7447 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7448 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7449 | |
| 7450 | if (no_of_mac_addr == 0 || !addr) { |
| 7451 | hdd_warn("Platform Driver Doesn't have wlan mac addresses"); |
| 7452 | return -EINVAL; |
| 7453 | } |
| 7454 | |
| 7455 | if (no_of_mac_addr > max_mac_addr) |
| 7456 | no_of_mac_addr = max_mac_addr; |
| 7457 | |
| 7458 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 7459 | |
| 7460 | for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { |
| 7461 | buf = ini->intfMacAddr[iter].bytes; |
| 7462 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 7463 | hdd_info(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7464 | } |
| 7465 | |
| 7466 | status = sme_set_custom_mac_addr(mac_addr); |
| 7467 | |
| 7468 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 7469 | return -EAGAIN; |
| 7470 | if (no_of_mac_addr < max_mac_addr) |
| 7471 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 7472 | no_of_mac_addr); |
| 7473 | return 0; |
| 7474 | } |
| 7475 | |
| 7476 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 7477 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 7478 | * @hdd_ctx: HDD Context |
| 7479 | * |
| 7480 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 7481 | * will generate its own MAC and update it to FW. |
| 7482 | * |
| 7483 | * Return: 0 for success |
| 7484 | * Non-zero error code for failure |
| 7485 | */ |
| 7486 | static int hdd_update_mac_addr_to_fw(hdd_context_t *hdd_ctx) |
| 7487 | { |
| 7488 | tSirMacAddr customMacAddr; |
| 7489 | QDF_STATUS status; |
| 7490 | |
| 7491 | qdf_mem_copy(&customMacAddr, |
| 7492 | &hdd_ctx->config->intfMacAddr[0].bytes[0], |
| 7493 | sizeof(tSirMacAddr)); |
| 7494 | status = sme_set_custom_mac_addr(customMacAddr); |
| 7495 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 7496 | return -EAGAIN; |
| 7497 | return 0; |
| 7498 | } |
| 7499 | |
| 7500 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7501 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 7502 | * @hdd_ctx: HDD Context |
| 7503 | * |
| 7504 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 7505 | * is provisioned with mac addresses, driver uses it, else it will use |
| 7506 | * wlan_mac.bin to update HW MAC addresses. |
| 7507 | * |
| 7508 | * Return: None |
| 7509 | */ |
| 7510 | static void hdd_initialize_mac_address(hdd_context_t *hdd_ctx) |
| 7511 | { |
| 7512 | QDF_STATUS status; |
| 7513 | int ret; |
| 7514 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7515 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7516 | if (ret == 0) |
| 7517 | return; |
| 7518 | |
| 7519 | hdd_warn("Can't update mac config via platform driver ret:%d", ret); |
| 7520 | |
| 7521 | status = hdd_update_mac_config(hdd_ctx); |
| 7522 | |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 7523 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 7524 | return; |
| 7525 | |
| 7526 | hdd_warn("can't update mac config via wlan_mac.bin, using MAC from ini file or auto-gen"); |
| 7527 | |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 7528 | if (hdd_ctx->update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 7529 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 7530 | if (ret != 0) { |
| 7531 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
| 7532 | QDF_ASSERT(ret); |
| 7533 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 7534 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7535 | } |
| 7536 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7537 | /** |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 7538 | * hdd_tsf_init() - Initialize the TSF synchronization interface |
| 7539 | * @hdd_ctx: HDD global context |
| 7540 | * |
| 7541 | * When TSF synchronization via GPIO is supported by the driver and |
| 7542 | * has been enabled in the configuration file, this function plumbs |
| 7543 | * the GPIO value down to firmware via SME. |
| 7544 | * |
| 7545 | * Return: None |
| 7546 | */ |
| 7547 | #ifdef WLAN_FEATURE_TSF |
| 7548 | static void hdd_tsf_init(hdd_context_t *hdd_ctx) |
| 7549 | { |
| 7550 | QDF_STATUS status; |
| 7551 | |
| 7552 | if (hdd_ctx->config->tsf_gpio_pin == TSF_GPIO_PIN_INVALID) |
| 7553 | return; |
| 7554 | |
| 7555 | status = sme_set_tsf_gpio(hdd_ctx->hHal, |
| 7556 | hdd_ctx->config->tsf_gpio_pin); |
| 7557 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 7558 | hdd_err("Set tsf GPIO failed, status: %d", status); |
| 7559 | } |
| 7560 | #else |
| 7561 | static void hdd_tsf_init(hdd_context_t *hdd_ctx) |
| 7562 | { |
| 7563 | } |
| 7564 | #endif |
| 7565 | |
| 7566 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 7567 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 7568 | * @hdd_ctx: HDD context |
| 7569 | * |
| 7570 | * Pre configurations to be done at lower layer before calling cds enable. |
| 7571 | * |
| 7572 | * Return: 0 on success and errno on failure. |
| 7573 | */ |
| 7574 | static int hdd_pre_enable_configure(hdd_context_t *hdd_ctx) |
| 7575 | { |
| 7576 | int ret; |
| 7577 | QDF_STATUS status; |
| 7578 | tSirRetStatus hal_status; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 7579 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 7580 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 7581 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 7582 | /* |
| 7583 | * Set 802.11p config |
| 7584 | * TODO-OCB: This has been temporarily added here to ensure this |
| 7585 | * parameter is set in CSR when we init the channel list. This should |
| 7586 | * be removed once the 5.9 GHz channels are added to the regulatory |
| 7587 | * domain. |
| 7588 | */ |
| 7589 | hdd_set_dot11p_config(hdd_ctx); |
| 7590 | |
| 7591 | /* |
| 7592 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 7593 | * The cfg download must occur before we update the SME config |
| 7594 | * since the SME config operation must access the cfg database |
| 7595 | */ |
| 7596 | status = hdd_set_sme_config(hdd_ctx); |
| 7597 | |
| 7598 | if (QDF_STATUS_SUCCESS != status) { |
| 7599 | hdd_alert("Failed hdd_set_sme_config: %d", status); |
| 7600 | ret = qdf_status_to_os_return(status); |
| 7601 | goto out; |
| 7602 | } |
| 7603 | |
| 7604 | ret = wma_cli_set_command(0, WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS, |
| 7605 | hdd_ctx->config->tx_chain_mask_1ss, |
| 7606 | PDEV_CMD); |
| 7607 | if (0 != ret) { |
| 7608 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 7609 | goto out; |
| 7610 | } |
| 7611 | |
| 7612 | hdd_program_country_code(hdd_ctx); |
| 7613 | |
| 7614 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 7615 | if (status != QDF_STATUS_SUCCESS) { |
| 7616 | hdd_alert("Failed to init channel list: %d", status); |
| 7617 | ret = qdf_status_to_os_return(status); |
| 7618 | goto out; |
| 7619 | } |
| 7620 | |
| 7621 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 7622 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 7623 | hdd_alert("config update failed"); |
| 7624 | ret = -EINVAL; |
| 7625 | goto out; |
| 7626 | } |
| 7627 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 7628 | /* |
| 7629 | * Set the MAC Address Currently this is used by HAL to add self sta. |
| 7630 | * Remove this once self sta is added as part of session open. |
| 7631 | */ |
| 7632 | hal_status = cfg_set_str(hdd_ctx->hHal, WNI_CFG_STA_ID, |
| 7633 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 7634 | sizeof(hdd_ctx->config->intfMacAddr[0])); |
| 7635 | |
| 7636 | if (!IS_SIR_STATUS_SUCCESS(hal_status)) { |
| 7637 | hdd_err("Failed to set MAC Address. HALStatus is %08d [x%08x]", |
| 7638 | hal_status, hal_status); |
| 7639 | ret = -EINVAL; |
| 7640 | goto out; |
| 7641 | } |
| 7642 | |
| 7643 | hdd_init_channel_avoidance(hdd_ctx); |
| 7644 | |
| 7645 | out: |
| 7646 | return ret; |
| 7647 | } |
| 7648 | |
| 7649 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 7650 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
| 7651 | * @context_ptr - hdd context pointer |
| 7652 | * @event_ptr - event structure pointer |
| 7653 | * |
| 7654 | * This is the p2p listen offload stop event handler, it sends vendor |
| 7655 | * event back to supplicant to notify the stop reason. |
| 7656 | * |
| 7657 | * Return: None |
| 7658 | */ |
| 7659 | static void wlan_hdd_p2p_lo_event_callback(void *context_ptr, |
| 7660 | void *event_ptr) |
| 7661 | { |
| 7662 | hdd_context_t *hdd_ctx = (hdd_context_t *)context_ptr; |
| 7663 | struct sir_p2p_lo_event *evt = event_ptr; |
| 7664 | struct sk_buff *vendor_event; |
| 7665 | |
| 7666 | ENTER(); |
| 7667 | |
| 7668 | if (hdd_ctx == NULL) { |
| 7669 | hdd_err("Invalid HDD context pointer"); |
| 7670 | return; |
| 7671 | } |
| 7672 | |
| 7673 | vendor_event = |
| 7674 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
| 7675 | NULL, sizeof(uint32_t) + NLMSG_HDRLEN, |
| 7676 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 7677 | GFP_KERNEL); |
| 7678 | |
| 7679 | if (!vendor_event) { |
| 7680 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 7681 | return; |
| 7682 | } |
| 7683 | |
| 7684 | if (nla_put_u32(vendor_event, |
| 7685 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 7686 | evt->reason_code)) { |
| 7687 | hdd_err("nla put failed"); |
| 7688 | kfree_skb(vendor_event); |
| 7689 | return; |
| 7690 | } |
| 7691 | |
| 7692 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 7693 | } |
| 7694 | |
| 7695 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 7696 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 7697 | * @hdd_ctx: HDD context |
| 7698 | * |
| 7699 | * This function sends the adaptive dwell time config configuration to the |
| 7700 | * firmware via WMA |
| 7701 | * |
| 7702 | * Return: 0 - success, < 0 - failure |
| 7703 | */ |
| 7704 | static int hdd_adaptive_dwelltime_init(hdd_context_t *hdd_ctx) |
| 7705 | { |
| 7706 | QDF_STATUS status; |
| 7707 | struct adaptive_dwelltime_params dwelltime_params; |
| 7708 | |
| 7709 | dwelltime_params.is_enabled = |
| 7710 | hdd_ctx->config->adaptive_dwell_mode_enabled; |
| 7711 | dwelltime_params.dwelltime_mode = |
| 7712 | hdd_ctx->config->global_adapt_dwelltime_mode; |
| 7713 | dwelltime_params.lpf_weight = |
| 7714 | hdd_ctx->config->adapt_dwell_lpf_weight; |
| 7715 | dwelltime_params.passive_mon_intval = |
| 7716 | hdd_ctx->config->adapt_dwell_passive_mon_intval; |
| 7717 | dwelltime_params.wifi_act_threshold = |
| 7718 | hdd_ctx->config->adapt_dwell_wifi_act_threshold; |
| 7719 | |
| 7720 | status = sme_set_adaptive_dwelltime_config(hdd_ctx->hHal, |
| 7721 | &dwelltime_params); |
| 7722 | |
| 7723 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 7724 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 7725 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 7726 | return -EAGAIN; |
| 7727 | } |
| 7728 | return 0; |
| 7729 | } |
| 7730 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 7731 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 7732 | /** |
| 7733 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 7734 | * @hdd_ctx: HDD context |
| 7735 | * |
| 7736 | * Set auto shutdown callback to get indications from firmware to indicate |
| 7737 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 7738 | * |
| 7739 | * Return: 0 on success and errno on failure. |
| 7740 | */ |
| 7741 | static int hdd_set_auto_shutdown_cb(hdd_context_t *hdd_ctx) |
| 7742 | { |
| 7743 | QDF_STATUS status; |
| 7744 | |
| 7745 | if (!hdd_ctx->config->WlanAutoShutdown) |
| 7746 | return 0; |
| 7747 | |
| 7748 | status = sme_set_auto_shutdown_cb(hdd_ctx->hHal, |
| 7749 | wlan_hdd_auto_shutdown_cb); |
| 7750 | if (status != QDF_STATUS_SUCCESS) |
| 7751 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 7752 | status); |
| 7753 | |
| 7754 | return qdf_status_to_os_return(status); |
| 7755 | } |
| 7756 | #else |
| 7757 | static int hdd_set_auto_shutdown_cb(hdd_context_t *hdd_ctx) |
| 7758 | { |
| 7759 | return 0; |
| 7760 | } |
| 7761 | #endif |
| 7762 | |
| 7763 | /** |
| 7764 | * hdd_features_init() - Init features |
| 7765 | * @hdd_ctx: HDD context |
| 7766 | * @adapter: Primary adapter context |
| 7767 | * |
| 7768 | * Initialize features and their feature context after WLAN firmware is up. |
| 7769 | * |
| 7770 | * Return: 0 on success and errno on failure. |
| 7771 | */ |
| 7772 | static int hdd_features_init(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter) |
| 7773 | { |
| 7774 | tSirTxPowerLimit hddtxlimit; |
| 7775 | QDF_STATUS status; |
| 7776 | int ret; |
| 7777 | |
| 7778 | ENTER(); |
| 7779 | |
| 7780 | ret = hdd_update_country_code(hdd_ctx, adapter); |
| 7781 | if (ret) { |
| 7782 | hdd_err("Failed to update country code: %d", ret); |
| 7783 | goto out; |
| 7784 | } |
| 7785 | |
| 7786 | /* FW capabilities received, Set the Dot11 mode */ |
| 7787 | sme_setdef_dot11mode(hdd_ctx->hHal); |
Kiran Kumar Lokere | 1aa9c9a | 2016-10-05 18:50:59 -0700 | [diff] [blame] | 7788 | sme_set_prefer_80MHz_over_160MHz(hdd_ctx->hHal, |
| 7789 | hdd_ctx->config->sta_prefer_80MHz_over_160MHz); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 7790 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 7791 | |
| 7792 | if (hdd_ctx->config->fIsImpsEnabled) |
| 7793 | hdd_set_idle_ps_config(hdd_ctx, true); |
| 7794 | else |
| 7795 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 7796 | |
| 7797 | if (hdd_lro_init(hdd_ctx)) |
| 7798 | hdd_err("Unable to initialize LRO in fw"); |
| 7799 | |
| 7800 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 7801 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 7802 | |
| 7803 | ret = hdd_init_thermal_info(hdd_ctx); |
| 7804 | if (ret) { |
| 7805 | hdd_err("Error while initializing thermal information"); |
| 7806 | goto deregister_frames; |
| 7807 | } |
| 7808 | |
| 7809 | hddtxlimit.txPower2g = hdd_ctx->config->TxPower2g; |
| 7810 | hddtxlimit.txPower5g = hdd_ctx->config->TxPower5g; |
| 7811 | status = sme_txpower_limit(hdd_ctx->hHal, &hddtxlimit); |
| 7812 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 7813 | hdd_err("Error setting txlimit in sme: %d", status); |
| 7814 | |
| 7815 | hdd_tsf_init(hdd_ctx); |
Padma, Santhosh Kumar | 1472fab | 2016-10-07 13:29:27 +0530 | [diff] [blame] | 7816 | hdd_encrypt_decrypt_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 7817 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 7818 | ret = hdd_register_cb(hdd_ctx); |
| 7819 | if (ret) { |
| 7820 | hdd_err("Failed to register HDD callbacks!"); |
| 7821 | goto deregister_frames; |
| 7822 | } |
| 7823 | |
| 7824 | if (hdd_ctx->config->dual_mac_feature_disable) { |
| 7825 | status = wlan_hdd_disable_all_dual_mac_features(hdd_ctx); |
| 7826 | if (status != QDF_STATUS_SUCCESS) { |
| 7827 | hdd_err("Failed to disable dual mac features"); |
| 7828 | goto deregister_cb; |
| 7829 | } |
| 7830 | } |
| 7831 | |
| 7832 | /* register P2P Listen Offload event callback */ |
| 7833 | if (wma_is_p2p_lo_capable()) |
| 7834 | sme_register_p2p_lo_event(hdd_ctx->hHal, hdd_ctx, |
| 7835 | wlan_hdd_p2p_lo_event_callback); |
| 7836 | |
| 7837 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 7838 | |
| 7839 | if (ret) |
| 7840 | goto deregister_cb; |
| 7841 | |
| 7842 | EXIT(); |
| 7843 | return 0; |
| 7844 | |
| 7845 | deregister_cb: |
| 7846 | hdd_deregister_cb(hdd_ctx); |
| 7847 | deregister_frames: |
| 7848 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 7849 | out: |
| 7850 | return -EINVAL; |
| 7851 | |
| 7852 | } |
| 7853 | |
| 7854 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 7855 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7856 | * hdd_configure_cds() - Configure cds modules |
| 7857 | * @hdd_ctx: HDD context |
| 7858 | * @adapter: Primary adapter context |
| 7859 | * |
| 7860 | * Enable Cds modules after WLAN firmware is up. |
| 7861 | * |
| 7862 | * Return: 0 on success and errno on failure. |
| 7863 | */ |
| 7864 | int hdd_configure_cds(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter) |
| 7865 | { |
| 7866 | int ret; |
| 7867 | QDF_STATUS status; |
| 7868 | /* structure of function pointers to be used by CDS */ |
| 7869 | struct cds_sme_cbacks sme_cbacks; |
| 7870 | |
| 7871 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 7872 | if (ret) { |
| 7873 | hdd_err("Failed to pre-configure cds"); |
| 7874 | goto out; |
| 7875 | } |
| 7876 | |
| 7877 | /* |
| 7878 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 7879 | * else |
| 7880 | */ |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 7881 | status = cds_enable(hdd_ctx->hdd_psoc, hdd_ctx->pcds_context); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7882 | |
| 7883 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 7884 | hdd_alert("cds_enable failed"); |
| 7885 | goto out; |
| 7886 | } |
| 7887 | |
| 7888 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 7889 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 7890 | hdd_alert("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 7891 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7892 | } |
| 7893 | |
| 7894 | ret = hdd_features_init(hdd_ctx, adapter); |
| 7895 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 7896 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7897 | |
| 7898 | sme_cbacks.sme_get_valid_channels = sme_get_cfg_valid_channels; |
| 7899 | sme_cbacks.sme_get_nss_for_vdev = sme_get_vdev_type_nss; |
| 7900 | status = cds_init_policy_mgr(&sme_cbacks); |
| 7901 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 7902 | hdd_err("Policy manager initialization failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 7903 | goto hdd_features_deinit; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7904 | } |
| 7905 | |
| 7906 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 7907 | |
| 7908 | hdd_features_deinit: |
| 7909 | hdd_deregister_cb(hdd_ctx); |
| 7910 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 7911 | cds_disable: |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 7912 | cds_disable(hdd_ctx->hdd_psoc, hdd_ctx->pcds_context); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 7913 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7914 | out: |
| 7915 | return -EINVAL; |
| 7916 | } |
| 7917 | |
| 7918 | /** |
| 7919 | * hdd_deconfigure_cds() -De-Configure cds |
| 7920 | * @hdd_ctx: HDD context |
| 7921 | * |
| 7922 | * Deconfigure Cds modules before WLAN firmware is down. |
| 7923 | * |
| 7924 | * Return: 0 on success and errno on failure. |
| 7925 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 7926 | static int hdd_deconfigure_cds(hdd_context_t *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7927 | { |
| 7928 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 7929 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7930 | |
| 7931 | ENTER(); |
| 7932 | /* De-register the SME callbacks */ |
| 7933 | hdd_deregister_cb(hdd_ctx); |
Padma, Santhosh Kumar | 1472fab | 2016-10-07 13:29:27 +0530 | [diff] [blame] | 7934 | hdd_encrypt_decrypt_deinit(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7935 | |
| 7936 | /* De-init Policy Manager */ |
| 7937 | if (!QDF_IS_STATUS_SUCCESS(cds_deinit_policy_mgr())) { |
| 7938 | hdd_err("Failed to deinit policy manager"); |
| 7939 | /* Proceed and complete the clean up */ |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 7940 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7941 | } |
| 7942 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 7943 | qdf_status = cds_disable(hdd_ctx->hdd_psoc, hdd_ctx->pcds_context); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7944 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 7945 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 7946 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 7947 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7948 | } |
| 7949 | |
| 7950 | EXIT(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 7951 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7952 | } |
| 7953 | |
| 7954 | |
| 7955 | /** |
| 7956 | * hdd_wlan_stop_modules - Single driver state machine for stoping modules |
| 7957 | * @hdd_ctx: HDD context |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7958 | * |
| 7959 | * This function maintains the driver state machine it will be invoked from |
| 7960 | * exit, shutdown and con_mode change handler. Depending on the driver state |
| 7961 | * shall perform the stopping/closing of the modules. |
| 7962 | * |
| 7963 | * Return: 0 for success; non-zero for failure |
| 7964 | */ |
Prashanth Bhatta | 2ac92bd | 2016-10-11 16:08:00 -0700 | [diff] [blame] | 7965 | int hdd_wlan_stop_modules(hdd_context_t *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7966 | { |
| 7967 | void *hif_ctx; |
| 7968 | qdf_device_t qdf_ctx; |
| 7969 | QDF_STATUS qdf_status; |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 7970 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7971 | p_cds_sched_context cds_sched_context = NULL; |
| 7972 | |
| 7973 | ENTER(); |
| 7974 | |
| 7975 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 7976 | if (!qdf_ctx) { |
| 7977 | hdd_err("QDF device context NULL"); |
| 7978 | return -EINVAL; |
| 7979 | } |
| 7980 | |
| 7981 | cds_sched_context = get_cds_sched_ctxt(); |
| 7982 | if (!cds_sched_context) { |
| 7983 | hdd_err("cds scheduler context NULL"); |
| 7984 | return -EINVAL; |
| 7985 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 7986 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 7987 | hdd_ctx->stop_modules_in_progress = true; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7988 | |
| 7989 | hdd_info("Present Driver Status: %d", hdd_ctx->driver_status); |
| 7990 | |
| 7991 | switch (hdd_ctx->driver_status) { |
| 7992 | case DRIVER_MODULES_UNINITIALIZED: |
| 7993 | hdd_info("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 7994 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7995 | case DRIVER_MODULES_CLOSED: |
| 7996 | hdd_info("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 7997 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7998 | case DRIVER_MODULES_ENABLED: |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 7999 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8000 | if (hdd_deconfigure_cds(hdd_ctx)) { |
| 8001 | hdd_alert("Failed to de-configure CDS"); |
| 8002 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8003 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8004 | } |
| 8005 | hdd_info("successfully Disabled the CDS modules!"); |
| 8006 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
| 8007 | break; |
| 8008 | case DRIVER_MODULES_OPENED: |
| 8009 | hdd_info("Closing CDS modules!"); |
| 8010 | break; |
| 8011 | default: |
| 8012 | hdd_err("Trying to stop wlan in a wrong state: %d", |
| 8013 | hdd_ctx->driver_status); |
| 8014 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8015 | ret = -EINVAL; |
| 8016 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8017 | } |
| 8018 | |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 8019 | qdf_status = cds_post_disable(hdd_ctx->pcds_context); |
| 8020 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 8021 | hdd_err("Failed to process post CDS disable Modules! :%d", |
| 8022 | qdf_status); |
| 8023 | ret = -EINVAL; |
| 8024 | QDF_ASSERT(0); |
| 8025 | } |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 8026 | qdf_status = cds_close(hdd_ctx->hdd_psoc, hdd_ctx->pcds_context); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8027 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 8028 | hdd_warn("Failed to stop CDS:%d", qdf_status); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 8029 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8030 | QDF_ASSERT(0); |
| 8031 | } |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 8032 | |
Rajeev Kumar | 3a6c13c | 2017-01-06 13:01:08 -0800 | [diff] [blame] | 8033 | qdf_status = hdd_release_and_destroy_pdev(hdd_ctx); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 8034 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 8035 | hdd_err("Pdev delete failed"); |
| 8036 | |
Rajeev Kumar | 1cba9d0 | 2017-01-06 11:36:14 -0800 | [diff] [blame] | 8037 | qdf_status = hdd_release_and_destroy_psoc(hdd_ctx); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 8038 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 8039 | hdd_err("Psoc delete failed"); |
| 8040 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8041 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 8042 | if (!hif_ctx) { |
| 8043 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8044 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8045 | } |
| 8046 | |
| 8047 | hdd_hif_close(hif_ctx); |
| 8048 | |
| 8049 | ol_cds_free(); |
| 8050 | |
Arunk Khandavalli | 649c009 | 2016-11-22 21:20:43 +0530 | [diff] [blame] | 8051 | if (!cds_is_driver_recovering() && !cds_is_driver_unloading()) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8052 | ret = pld_power_off(qdf_ctx->dev); |
| 8053 | if (ret) |
| 8054 | hdd_err("CNSS power down failed put device into Low power mode:%d", |
| 8055 | ret); |
| 8056 | } |
| 8057 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
| 8058 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8059 | done: |
| 8060 | hdd_ctx->stop_modules_in_progress = false; |
| 8061 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8062 | EXIT(); |
| 8063 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8064 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8065 | |
| 8066 | } |
| 8067 | |
| 8068 | /** |
| 8069 | * hdd_iface_change_callback() - Function invoked when stop modules expires |
| 8070 | * @priv: pointer to hdd context |
| 8071 | * |
| 8072 | * This function is invoked when the timer waiting for the interface change |
| 8073 | * expires, it shall cut-down the power to wlan and stop all the modules. |
| 8074 | * |
| 8075 | * Return: void |
| 8076 | */ |
| 8077 | static void hdd_iface_change_callback(void *priv) |
| 8078 | { |
| 8079 | hdd_context_t *hdd_ctx = (hdd_context_t *) priv; |
| 8080 | int ret; |
| 8081 | int status = wlan_hdd_validate_context(hdd_ctx); |
| 8082 | |
| 8083 | if (status) |
| 8084 | return; |
| 8085 | |
| 8086 | ENTER(); |
| 8087 | hdd_info("Interface change timer expired close the modules!"); |
Prashanth Bhatta | 2ac92bd | 2016-10-11 16:08:00 -0700 | [diff] [blame] | 8088 | ret = hdd_wlan_stop_modules(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8089 | if (ret) |
| 8090 | hdd_alert("Failed to stop modules"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8091 | EXIT(); |
| 8092 | } |
| 8093 | |
| 8094 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 8095 | * hdd_state_info_dump() - prints state information of hdd layer |
| 8096 | * @buf: buffer pointer |
| 8097 | * @size: size of buffer to be filled |
| 8098 | * |
| 8099 | * This function is used to dump state information of hdd layer |
| 8100 | * |
| 8101 | * Return: None |
| 8102 | */ |
| 8103 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 8104 | { |
| 8105 | hdd_context_t *hdd_ctx; |
| 8106 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 8107 | QDF_STATUS status; |
| 8108 | hdd_station_ctx_t *hdd_sta_ctx; |
| 8109 | hdd_adapter_t *adapter; |
| 8110 | uint16_t len = 0; |
| 8111 | char *buf = *buf_ptr; |
| 8112 | |
| 8113 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 8114 | if (!hdd_ctx) { |
| 8115 | hdd_err("Failed to get hdd context "); |
| 8116 | return; |
| 8117 | } |
| 8118 | |
| 8119 | hdd_notice("size of buffer: %d", *size); |
| 8120 | |
| 8121 | len += scnprintf(buf + len, *size - len, |
| 8122 | "\n isWiphySuspended %d", hdd_ctx->isWiphySuspended); |
| 8123 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 8124 | "\n is_scheduler_suspended %d", |
| 8125 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 8126 | |
| 8127 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 8128 | |
| 8129 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 8130 | adapter = adapter_node->pAdapter; |
| 8131 | if (adapter->dev) |
| 8132 | len += scnprintf(buf + len, *size - len, |
| 8133 | "\n device name: %s", adapter->dev->name); |
| 8134 | len += scnprintf(buf + len, *size - len, |
| 8135 | "\n device_mode: %d", adapter->device_mode); |
| 8136 | switch (adapter->device_mode) { |
| 8137 | case QDF_STA_MODE: |
| 8138 | case QDF_P2P_CLIENT_MODE: |
| 8139 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 8140 | len += scnprintf(buf + len, *size - len, |
| 8141 | "\n connState: %d", |
| 8142 | hdd_sta_ctx->conn_info.connState); |
| 8143 | break; |
| 8144 | |
| 8145 | default: |
| 8146 | break; |
| 8147 | } |
| 8148 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 8149 | adapter_node = next; |
| 8150 | } |
| 8151 | |
| 8152 | *size -= len; |
| 8153 | *buf_ptr += len; |
| 8154 | } |
| 8155 | |
| 8156 | /** |
| 8157 | * hdd_register_debug_callback() - registration function for hdd layer |
| 8158 | * to print hdd state information |
| 8159 | * |
| 8160 | * Return: None |
| 8161 | */ |
| 8162 | static void hdd_register_debug_callback(void) |
| 8163 | { |
| 8164 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 8165 | } |
| 8166 | |
| 8167 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8168 | * hdd_wlan_startup() - HDD init function |
| 8169 | * @dev: Pointer to the underlying device |
| 8170 | * |
| 8171 | * This is the driver startup code executed once a WLAN device has been detected |
| 8172 | * |
| 8173 | * Return: 0 for success, < 0 for failure |
| 8174 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8175 | int hdd_wlan_startup(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8176 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8177 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8178 | hdd_adapter_t *adapter = NULL; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8179 | hdd_context_t *hdd_ctx = NULL; |
| 8180 | int ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8181 | void *hif_sc; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8182 | bool rtnl_held; |
Manjeet Singh | e7ecb7c | 2016-09-03 12:34:53 +0530 | [diff] [blame] | 8183 | int set_value; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8184 | |
| 8185 | ENTER(); |
| 8186 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8187 | hdd_ctx = hdd_context_create(dev); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8188 | |
| 8189 | if (IS_ERR(hdd_ctx)) |
| 8190 | return PTR_ERR(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8191 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8192 | qdf_mc_timer_init(&hdd_ctx->iface_change_timer, QDF_TIMER_TYPE_SW, |
| 8193 | hdd_iface_change_callback, (void *)hdd_ctx); |
| 8194 | |
| 8195 | mutex_init(&hdd_ctx->iface_change_lock); |
| 8196 | |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 8197 | ret = hdd_init_netlink_services(hdd_ctx); |
| 8198 | if (ret) |
| 8199 | goto err_hdd_free_context; |
| 8200 | |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 8201 | hdd_green_ap_init(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8202 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8203 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 8204 | if (ret) { |
| 8205 | hdd_alert("Failed to start modules: %d", ret); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 8206 | goto err_exit_nl_srv; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8207 | } |
| 8208 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 8209 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8210 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8211 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 8212 | hdd_notice("Failed to set wow pulse"); |
| 8213 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8214 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8215 | |
| 8216 | if (NULL == hdd_ctx->hHal) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8217 | hdd_alert("HAL context is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8218 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8219 | } |
| 8220 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8221 | ret = hdd_wiphy_init(hdd_ctx); |
| 8222 | if (ret) { |
| 8223 | hdd_alert("Failed to initialize wiphy: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8224 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8225 | } |
| 8226 | |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 8227 | if (hdd_ctx->config->enable_dp_trace) |
| 8228 | qdf_dp_trace_init(); |
| 8229 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8230 | if (hdd_ipa_init(hdd_ctx) == QDF_STATUS_E_FAILURE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8231 | goto err_wiphy_unregister; |
| 8232 | |
Yuanyuan Liu | c98370e | 2016-10-13 11:22:13 -0700 | [diff] [blame] | 8233 | hdd_initialize_mac_address(hdd_ctx); |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 8234 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8235 | rtnl_held = hdd_hold_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8236 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8237 | adapter = hdd_open_interfaces(hdd_ctx, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8238 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8239 | if (IS_ERR(adapter)) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8240 | hdd_alert("Failed to open interface, adapter is NULL"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8241 | ret = PTR_ERR(adapter); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8242 | goto err_ipa_cleanup; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8243 | } |
| 8244 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8245 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
Anurag Chouhan | ce6a405 | 2016-09-14 18:20:42 +0530 | [diff] [blame] | 8246 | if (!hif_sc) { |
| 8247 | hdd_err("HIF context is NULL"); |
| 8248 | goto err_close_adapter; |
| 8249 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8250 | /* |
| 8251 | * target hw version/revision would only be retrieved after firmware |
| 8252 | * donwload |
| 8253 | */ |
| 8254 | hif_get_hw_info(hif_sc, &hdd_ctx->target_hw_version, |
| 8255 | &hdd_ctx->target_hw_revision, |
| 8256 | &hdd_ctx->target_hw_name); |
| 8257 | |
| 8258 | /* Get the wlan hw/fw version */ |
Arun Khandavalli | a96c2c0 | 2016-05-17 19:15:34 +0530 | [diff] [blame] | 8259 | hdd_wlan_get_version(hdd_ctx, NULL, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8260 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8261 | hdd_release_rtnl_lock(); |
| 8262 | rtnl_held = false; |
| 8263 | |
Agrawal Ashish | b2d1a45 | 2016-05-05 12:23:58 +0530 | [diff] [blame] | 8264 | if (hdd_ctx->config->enable_go_cts2self_for_sta) |
| 8265 | sme_set_cts2self_for_p2p_go(hdd_ctx->hHal); |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 8266 | |
| 8267 | wlan_hdd_update_11n_mode(hdd_ctx->config); |
| 8268 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8269 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 8270 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8271 | QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8272 | hdd_skip_acs_scan_timer_handler, |
| 8273 | (void *)hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8274 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8275 | hdd_err("Failed to init ACS Skip timer"); |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 8276 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8277 | #endif |
| 8278 | |
Nitesh Shah | 61c10d9 | 2016-10-19 19:29:15 +0530 | [diff] [blame] | 8279 | qdf_mc_timer_init(&hdd_ctx->tdls_source_timer, |
| 8280 | QDF_TIMER_TYPE_SW, |
| 8281 | wlan_hdd_change_tdls_mode, |
| 8282 | hdd_ctx); |
| 8283 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8284 | hdd_bus_bandwidth_init(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8285 | |
Jeff Johnson | 9afc501 | 2016-09-23 13:56:27 -0700 | [diff] [blame] | 8286 | hdd_lpass_notify_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8287 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 8288 | if (hdd_ctx->rps) |
| 8289 | hdd_set_rps_cpu_mask(hdd_ctx); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 8290 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8291 | |
| 8292 | if (cds_is_packet_log_enabled()) |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8293 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8294 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 8295 | ret = hdd_register_notifiers(hdd_ctx); |
| 8296 | if (ret) |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 8297 | goto err_debugfs_exit; |
| 8298 | |
| 8299 | status = wlansap_global_init(); |
| 8300 | if (QDF_IS_STATUS_ERROR(status)) |
| 8301 | goto err_debugfs_exit; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 8302 | |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 8303 | hdd_runtime_suspend_context_init(hdd_ctx); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 8304 | memdump_init(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 8305 | hdd_driver_memdump_init(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 8306 | |
bings | 612b9c4 | 2016-11-07 10:52:03 +0800 | [diff] [blame] | 8307 | if (hdd_enable_egap(hdd_ctx)) |
| 8308 | hdd_err("enhance green ap is not enabled"); |
| 8309 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8310 | if (hdd_ctx->config->fIsImpsEnabled) |
| 8311 | hdd_set_idle_ps_config(hdd_ctx, true); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 8312 | |
Manjeet Singh | e7ecb7c | 2016-09-03 12:34:53 +0530 | [diff] [blame] | 8313 | if (hdd_ctx->config->sifs_burst_duration) { |
| 8314 | set_value = (SIFS_BURST_DUR_MULTIPLIER) * |
| 8315 | hdd_ctx->config->sifs_burst_duration; |
| 8316 | |
| 8317 | if ((set_value > 0) && (set_value <= SIFS_BURST_DUR_MAX)) |
| 8318 | wma_cli_set_command(0, (int)WMI_PDEV_PARAM_BURST_DUR, |
| 8319 | set_value, PDEV_CMD); |
| 8320 | } |
| 8321 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8322 | qdf_mc_timer_start(&hdd_ctx->iface_change_timer, |
| 8323 | hdd_ctx->config->iface_change_wait_time * 5000); |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 8324 | |
| 8325 | if (hdd_ctx->config->goptimize_chan_avoid_event) { |
| 8326 | status = sme_enable_disable_chanavoidind_event( |
| 8327 | hdd_ctx->hHal, 0); |
| 8328 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8329 | hdd_err("Failed to disable Chan Avoidance Indication"); |
| 8330 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8331 | goto success; |
| 8332 | |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 8333 | err_debugfs_exit: |
| 8334 | hdd_debugfs_exit(adapter); |
Anurag Chouhan | ce6a405 | 2016-09-14 18:20:42 +0530 | [diff] [blame] | 8335 | |
| 8336 | err_close_adapter: |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8337 | hdd_close_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8338 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 8339 | if (rtnl_held) |
| 8340 | hdd_release_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8341 | |
Anurag Chouhan | ce6a405 | 2016-09-14 18:20:42 +0530 | [diff] [blame] | 8342 | err_ipa_cleanup: |
| 8343 | hdd_ipa_cleanup(hdd_ctx); |
Yun Park | 6a46ad8 | 2016-01-04 16:48:19 -0800 | [diff] [blame] | 8344 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8345 | err_wiphy_unregister: |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8346 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8347 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8348 | err_stop_modules: |
Prashanth Bhatta | 2ac92bd | 2016-10-11 16:08:00 -0700 | [diff] [blame] | 8349 | hdd_wlan_stop_modules(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8350 | |
| 8351 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8352 | status = cds_sched_close(hdd_ctx->pcds_context); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8353 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8354 | hdd_alert("Failed to close CDS Scheduler"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 8355 | QDF_ASSERT(QDF_IS_STATUS_SUCCESS(status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8356 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8357 | |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 8358 | err_exit_nl_srv: |
Houston Hoffman | 47a4a05 | 2016-11-14 23:22:44 -0800 | [diff] [blame] | 8359 | hdd_green_ap_deinit(hdd_ctx); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 8360 | hdd_exit_netlink_services(hdd_ctx); |
| 8361 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8362 | cds_deinit_ini_config(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8363 | err_hdd_free_context: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8364 | qdf_mc_timer_destroy(&hdd_ctx->iface_change_timer); |
| 8365 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8366 | hdd_context_destroy(hdd_ctx); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 8367 | QDF_BUG(1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8368 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8369 | return -EIO; |
| 8370 | |
| 8371 | success: |
| 8372 | EXIT(); |
| 8373 | return 0; |
| 8374 | } |
| 8375 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8376 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8377 | * hdd_wlan_update_target_info() - update target type info |
| 8378 | * @hdd_ctx: HDD context |
| 8379 | * @context: hif context |
| 8380 | * |
| 8381 | * Update target info received from firmware in hdd context |
| 8382 | * Return:None |
| 8383 | */ |
| 8384 | |
| 8385 | void hdd_wlan_update_target_info(hdd_context_t *hdd_ctx, void *context) |
| 8386 | { |
| 8387 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 8388 | |
| 8389 | if (!tgt_info) { |
| 8390 | hdd_err("Target info is Null"); |
| 8391 | return; |
| 8392 | } |
| 8393 | |
| 8394 | hdd_ctx->target_type = tgt_info->target_type; |
| 8395 | } |
| 8396 | |
| 8397 | /** |
| 8398 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 8399 | * @hdd_ctx: HDD context |
| 8400 | * |
| 8401 | * Register the HDD callbacks to CDS/SME. |
| 8402 | * |
| 8403 | * Return: 0 for success or Error code for failure |
| 8404 | */ |
| 8405 | int hdd_register_cb(hdd_context_t *hdd_ctx) |
| 8406 | { |
| 8407 | QDF_STATUS status; |
| 8408 | int ret = 0; |
| 8409 | |
| 8410 | ENTER(); |
| 8411 | |
| 8412 | sme_register11d_scan_done_callback(hdd_ctx->hHal, hdd_11d_scan_done); |
| 8413 | |
| 8414 | sme_register_oem_data_rsp_callback(hdd_ctx->hHal, |
| 8415 | hdd_send_oem_data_rsp_msg); |
| 8416 | |
| 8417 | status = sme_fw_mem_dump_register_cb(hdd_ctx->hHal, |
| 8418 | wlan_hdd_cfg80211_fw_mem_dump_cb); |
| 8419 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8420 | hdd_err("Failed to register memdump callback"); |
| 8421 | ret = -EINVAL; |
| 8422 | return ret; |
| 8423 | } |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 8424 | sme_register_mgmt_frame_ind_callback(hdd_ctx->hHal, |
| 8425 | hdd_indicate_mgmt_frame); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 8426 | sme_set_tsfcb(hdd_ctx->hHal, hdd_get_tsf_cb, hdd_ctx); |
| 8427 | sme_nan_register_callback(hdd_ctx->hHal, |
| 8428 | wlan_hdd_cfg80211_nan_callback); |
| 8429 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 8430 | wlan_hdd_cfg80211_stats_ext_callback); |
| 8431 | |
| 8432 | sme_ext_scan_register_callback(hdd_ctx->hHal, |
| 8433 | wlan_hdd_cfg80211_extscan_callback); |
| 8434 | |
| 8435 | status = cds_register_sap_restart_channel_switch_cb( |
| 8436 | (void *)hdd_sap_restart_with_channel_switch); |
| 8437 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8438 | hdd_err("restart cb registration failed"); |
| 8439 | ret = -EINVAL; |
| 8440 | return ret; |
| 8441 | } |
| 8442 | |
| 8443 | sme_set_rssi_threshold_breached_cb(hdd_ctx->hHal, |
| 8444 | hdd_rssi_threshold_breached); |
| 8445 | |
| 8446 | status = sme_bpf_offload_register_callback(hdd_ctx->hHal, |
| 8447 | hdd_get_bpf_offload_cb); |
| 8448 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8449 | hdd_err("set bpf offload callback failed"); |
| 8450 | ret = -EINVAL; |
| 8451 | return ret; |
| 8452 | } |
| 8453 | |
| 8454 | sme_set_link_layer_stats_ind_cb(hdd_ctx->hHal, |
| 8455 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 8456 | |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 8457 | status = sme_set_lost_link_info_cb(hdd_ctx->hHal, |
| 8458 | hdd_lost_link_info_cb); |
| 8459 | /* print error and not block the startup process */ |
| 8460 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8461 | hdd_err("set lost link info callback failed"); |
| 8462 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 8463 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 8464 | |
| 8465 | EXIT(); |
| 8466 | |
| 8467 | return ret; |
| 8468 | } |
| 8469 | |
| 8470 | /** |
| 8471 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 8472 | * @hdd_ctx: HDD context |
| 8473 | * |
| 8474 | * De-Register the HDD callbacks to CDS/SME. |
| 8475 | * |
| 8476 | * Return: void |
| 8477 | */ |
| 8478 | void hdd_deregister_cb(hdd_context_t *hdd_ctx) |
| 8479 | { |
| 8480 | QDF_STATUS status; |
| 8481 | |
| 8482 | ENTER(); |
| 8483 | |
| 8484 | status = sme_deregister_for_dcc_stats_event(hdd_ctx->hHal); |
| 8485 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8486 | hdd_err("De-register of dcc stats callback failed: %d", |
| 8487 | status); |
| 8488 | |
| 8489 | sme_reset_link_layer_stats_ind_cb(hdd_ctx->hHal); |
| 8490 | status = sme_bpf_offload_deregister_callback(hdd_ctx->hHal); |
| 8491 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8492 | hdd_err("De-register bpf offload callback failed: %d", |
| 8493 | status); |
| 8494 | sme_reset_rssi_threshold_breached_cb(hdd_ctx->hHal); |
| 8495 | |
| 8496 | status = cds_deregister_sap_restart_channel_switch_cb(); |
| 8497 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8498 | hdd_err("De-register restart cb registration failed: %d", |
| 8499 | status); |
| 8500 | |
| 8501 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 8502 | wlan_hdd_cfg80211_stats_ext_callback); |
| 8503 | |
| 8504 | sme_nan_deregister_callback(hdd_ctx->hHal); |
| 8505 | status = sme_reset_tsfcb(hdd_ctx->hHal); |
| 8506 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8507 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 8508 | status); |
| 8509 | status = sme_fw_mem_dump_unregister_cb(hdd_ctx->hHal); |
| 8510 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8511 | hdd_err("Failed to de-register the fw mem dump callback: %d", |
| 8512 | status); |
| 8513 | |
| 8514 | sme_deregister_oem_data_rsp_callback(hdd_ctx->hHal); |
| 8515 | sme_deregister11d_scan_done_callback(hdd_ctx->hHal); |
| 8516 | |
| 8517 | EXIT(); |
| 8518 | } |
| 8519 | |
| 8520 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8521 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
| 8522 | * @adapter: Pointer to the HDD |
| 8523 | * @enable: bool value |
| 8524 | * |
| 8525 | * This to take counter measure to handle deauth req from HDD |
| 8526 | * |
| 8527 | * Return: None |
| 8528 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8529 | QDF_STATUS hdd_softap_sta_deauth(hdd_adapter_t *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8530 | struct tagCsrDelStaParams *pDelStaParams) |
| 8531 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8532 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8533 | |
| 8534 | ENTER(); |
| 8535 | |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8536 | hdd_notice("hdd_softap_sta_deauth:(%p, false)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8537 | (WLAN_HDD_GET_CTX(adapter))->pcds_context); |
| 8538 | |
| 8539 | /* Ignore request to deauth bcmc station */ |
| 8540 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8541 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8542 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8543 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8544 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 8545 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8546 | |
| 8547 | EXIT(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8548 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8549 | } |
| 8550 | |
| 8551 | /** |
| 8552 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
| 8553 | * @adapter: Pointer to the HDD |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 8554 | * @p_del_sta_params: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8555 | * |
| 8556 | * This to take counter measure to handle deauth req from HDD |
| 8557 | * |
| 8558 | * Return: None |
| 8559 | */ |
| 8560 | void hdd_softap_sta_disassoc(hdd_adapter_t *adapter, |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 8561 | struct tagCsrDelStaParams *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8562 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8563 | ENTER(); |
| 8564 | |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8565 | hdd_err("hdd_softap_sta_disassoc:(%p, false)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8566 | (WLAN_HDD_GET_CTX(adapter))->pcds_context); |
| 8567 | |
| 8568 | /* Ignore request to disassoc bcmc station */ |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 8569 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8570 | return; |
| 8571 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8572 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 8573 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8574 | } |
| 8575 | |
| 8576 | void hdd_softap_tkip_mic_fail_counter_measure(hdd_adapter_t *adapter, |
| 8577 | bool enable) |
| 8578 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8579 | ENTER(); |
| 8580 | |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8581 | hdd_err("hdd_softap_tkip_mic_fail_counter_measure:(%p, false)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8582 | (WLAN_HDD_GET_CTX(adapter))->pcds_context); |
| 8583 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8584 | wlansap_set_counter_measure(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 8585 | (bool) enable); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8586 | } |
| 8587 | |
| 8588 | /** |
| 8589 | * hdd_issta_p2p_clientconnected() - check if sta or p2p client is connected |
| 8590 | * @hdd_ctx: HDD Context |
| 8591 | * |
| 8592 | * API to find if there is any STA or P2P-Client is connected |
| 8593 | * |
| 8594 | * Return: true if connected; false otherwise |
| 8595 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8596 | QDF_STATUS hdd_issta_p2p_clientconnected(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8597 | { |
| 8598 | return sme_is_sta_p2p_client_connected(hdd_ctx->hHal); |
| 8599 | } |
| 8600 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8601 | /** |
| 8602 | * wlan_hdd_disable_roaming() - disable roaming on all STAs except the input one |
| 8603 | * @adapter: HDD adapter pointer |
| 8604 | * |
| 8605 | * This function loop through each adapter and disable roaming on each STA |
| 8606 | * device mode except the input adapter. |
| 8607 | * |
| 8608 | * Note: On the input adapter roaming is not enabled yet hence no need to |
| 8609 | * disable. |
| 8610 | * |
| 8611 | * Return: None |
| 8612 | */ |
| 8613 | void wlan_hdd_disable_roaming(hdd_adapter_t *adapter) |
| 8614 | { |
| 8615 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8616 | hdd_adapter_t *adapterIdx = NULL; |
| 8617 | hdd_adapter_list_node_t *adapterNode = NULL; |
| 8618 | hdd_adapter_list_node_t *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8619 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8620 | |
| 8621 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
| 8622 | hdd_ctx->config->isRoamOffloadScanEnabled && |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8623 | QDF_STA_MODE == adapter->device_mode && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8624 | cds_is_sta_active_connection_exists()) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8625 | hdd_notice("Connect received on STA sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8626 | adapter->sessionId); |
| 8627 | /* |
| 8628 | * Loop through adapter and disable roaming for each STA device |
| 8629 | * mode except the input adapter. |
| 8630 | */ |
| 8631 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 8632 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8633 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8634 | adapterIdx = adapterNode->pAdapter; |
| 8635 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8636 | if (QDF_STA_MODE == adapterIdx->device_mode |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8637 | && adapter->sessionId != adapterIdx->sessionId) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8638 | hdd_notice("Disable Roaming on sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8639 | adapterIdx->sessionId); |
| 8640 | sme_stop_roaming(WLAN_HDD_GET_HAL_CTX |
| 8641 | (adapterIdx), |
| 8642 | adapterIdx->sessionId, 0); |
| 8643 | } |
| 8644 | |
| 8645 | status = hdd_get_next_adapter(hdd_ctx, |
| 8646 | adapterNode, |
| 8647 | &pNext); |
| 8648 | adapterNode = pNext; |
| 8649 | } |
| 8650 | } |
| 8651 | } |
| 8652 | |
| 8653 | /** |
| 8654 | * wlan_hdd_enable_roaming() - enable roaming on all STAs except the input one |
| 8655 | * @adapter: HDD adapter pointer |
| 8656 | * |
| 8657 | * This function loop through each adapter and enable roaming on each STA |
| 8658 | * device mode except the input adapter. |
| 8659 | * Note: On the input adapter no need to enable roaming because link got |
| 8660 | * disconnected on this. |
| 8661 | * |
| 8662 | * Return: None |
| 8663 | */ |
| 8664 | void wlan_hdd_enable_roaming(hdd_adapter_t *adapter) |
| 8665 | { |
| 8666 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8667 | hdd_adapter_t *adapterIdx = NULL; |
| 8668 | hdd_adapter_list_node_t *adapterNode = NULL; |
| 8669 | hdd_adapter_list_node_t *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8670 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8671 | |
| 8672 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
| 8673 | hdd_ctx->config->isRoamOffloadScanEnabled && |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8674 | QDF_STA_MODE == adapter->device_mode && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8675 | cds_is_sta_active_connection_exists()) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8676 | hdd_notice("Disconnect received on STA sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8677 | adapter->sessionId); |
| 8678 | /* |
| 8679 | * Loop through adapter and enable roaming for each STA device |
| 8680 | * mode except the input adapter. |
| 8681 | */ |
| 8682 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 8683 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8684 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8685 | adapterIdx = adapterNode->pAdapter; |
| 8686 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8687 | if (QDF_STA_MODE == adapterIdx->device_mode |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8688 | && adapter->sessionId != adapterIdx->sessionId) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8689 | hdd_notice("Enabling Roaming on sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8690 | adapterIdx->sessionId); |
| 8691 | sme_start_roaming(WLAN_HDD_GET_HAL_CTX |
| 8692 | (adapterIdx), |
| 8693 | adapterIdx->sessionId, |
| 8694 | REASON_CONNECT); |
| 8695 | } |
| 8696 | |
| 8697 | status = hdd_get_next_adapter(hdd_ctx, |
| 8698 | adapterNode, |
| 8699 | &pNext); |
| 8700 | adapterNode = pNext; |
| 8701 | } |
| 8702 | } |
| 8703 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8704 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 8705 | 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] | 8706 | { |
| 8707 | struct sk_buff *skb; |
| 8708 | struct nlmsghdr *nlh; |
| 8709 | tAniMsgHdr *ani_hdr; |
| 8710 | void *nl_data = NULL; |
| 8711 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 8712 | struct radio_index_tlv *radio_info; |
| 8713 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8714 | |
| 8715 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 8716 | flags = GFP_ATOMIC; |
| 8717 | |
| 8718 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 8719 | |
| 8720 | if (skb == NULL) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8721 | hdd_err("alloc_skb failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8722 | return; |
| 8723 | } |
| 8724 | |
| 8725 | nlh = (struct nlmsghdr *)skb->data; |
| 8726 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 8727 | nlh->nlmsg_flags = 0; |
| 8728 | nlh->nlmsg_seq = 0; |
| 8729 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 8730 | |
| 8731 | ani_hdr = NLMSG_DATA(nlh); |
| 8732 | ani_hdr->type = type; |
| 8733 | |
| 8734 | switch (type) { |
| 8735 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 8736 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8737 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8738 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 8739 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8740 | ani_hdr->length = 0; |
| 8741 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
| 8742 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr))); |
| 8743 | break; |
| 8744 | case WLAN_SVC_WLAN_STATUS_IND: |
| 8745 | case WLAN_SVC_WLAN_VERSION_IND: |
| 8746 | case WLAN_SVC_DFS_CAC_START_IND: |
| 8747 | case WLAN_SVC_DFS_CAC_END_IND: |
| 8748 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 8749 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 8750 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 8751 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 8752 | case WLAN_SVC_RPS_ENABLE_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8753 | ani_hdr->length = len; |
| 8754 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 8755 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 8756 | memcpy(nl_data, data, len); |
| 8757 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len)); |
| 8758 | break; |
| 8759 | |
| 8760 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8761 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8762 | type); |
| 8763 | kfree_skb(skb); |
| 8764 | return; |
| 8765 | } |
| 8766 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 8767 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame^] | 8768 | * Add radio index at the end of the svc event in TLV format |
| 8769 | * to maintain the backward compatibility with userspace |
| 8770 | * applications. |
| 8771 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 8772 | |
| 8773 | tlv_len = 0; |
| 8774 | |
| 8775 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 8776 | < WLAN_NL_MAX_PAYLOAD) { |
| 8777 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 8778 | sizeof(*ani_hdr) + len); |
| 8779 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 8780 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 8781 | radio_info->radio = radio; |
| 8782 | tlv_len = sizeof(*radio_info); |
| 8783 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO, |
| 8784 | "Added radio index tlv - radio index %d", |
| 8785 | radio_info->radio); |
| 8786 | } |
| 8787 | |
| 8788 | nlh->nlmsg_len += tlv_len; |
| 8789 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 8790 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8791 | nl_srv_bcast(skb); |
| 8792 | |
| 8793 | return; |
| 8794 | } |
| 8795 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8796 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 8797 | void wlan_hdd_auto_shutdown_cb(void) |
| 8798 | { |
Mahesh Kumar Kalikot Veetil | d214d55 | 2016-09-14 15:15:49 -0700 | [diff] [blame] | 8799 | hdd_context_t *hdd_ctx = cds_get_global_context(); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 8800 | |
| 8801 | if (!hdd_ctx) |
| 8802 | return; |
| 8803 | |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 8804 | hdd_err("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 8805 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 8806 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8807 | } |
| 8808 | |
| 8809 | void wlan_hdd_auto_shutdown_enable(hdd_context_t *hdd_ctx, bool enable) |
| 8810 | { |
| 8811 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8812 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8813 | hdd_adapter_t *adapter; |
| 8814 | bool ap_connected = false, sta_connected = false; |
| 8815 | tHalHandle hal_handle; |
| 8816 | |
| 8817 | hal_handle = hdd_ctx->hHal; |
| 8818 | if (hal_handle == NULL) |
| 8819 | return; |
| 8820 | |
| 8821 | if (hdd_ctx->config->WlanAutoShutdown == 0) |
| 8822 | return; |
| 8823 | |
| 8824 | if (enable == false) { |
| 8825 | if (sme_set_auto_shutdown_timer(hal_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8826 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 8827 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8828 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 8829 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 8830 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8831 | return; |
| 8832 | } |
| 8833 | |
| 8834 | /* To enable shutdown timer check conncurrency */ |
| 8835 | if (cds_concurrent_open_sessions_running()) { |
| 8836 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 8837 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8838 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8839 | adapter = adapterNode->pAdapter; |
| 8840 | if (adapter |
| 8841 | && adapter->device_mode == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8842 | QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8843 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 8844 | conn_info.connState == |
| 8845 | eConnectionState_Associated) { |
| 8846 | sta_connected = true; |
| 8847 | break; |
| 8848 | } |
| 8849 | } |
| 8850 | if (adapter |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8851 | && adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8852 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
| 8853 | bApActive == true) { |
| 8854 | ap_connected = true; |
| 8855 | break; |
| 8856 | } |
| 8857 | } |
| 8858 | status = hdd_get_next_adapter(hdd_ctx, |
| 8859 | adapterNode, |
| 8860 | &pNext); |
| 8861 | adapterNode = pNext; |
| 8862 | } |
| 8863 | } |
| 8864 | |
| 8865 | if (ap_connected == true || sta_connected == true) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 8866 | hdd_notice("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8867 | return; |
| 8868 | } else { |
| 8869 | if (sme_set_auto_shutdown_timer(hal_handle, |
| 8870 | hdd_ctx->config-> |
| 8871 | WlanAutoShutdown) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8872 | != QDF_STATUS_SUCCESS) |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 8873 | hdd_err("Failed to start wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8874 | else |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 8875 | hdd_notice("Auto Shutdown timer for %d seconds enabled", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8876 | hdd_ctx->config->WlanAutoShutdown); |
| 8877 | |
| 8878 | } |
| 8879 | } |
| 8880 | #endif |
| 8881 | |
| 8882 | hdd_adapter_t *hdd_get_con_sap_adapter(hdd_adapter_t *this_sap_adapter, |
| 8883 | bool check_start_bss) |
| 8884 | { |
| 8885 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
| 8886 | hdd_adapter_t *adapter, *con_sap_adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8887 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8888 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 8889 | |
| 8890 | con_sap_adapter = NULL; |
| 8891 | |
| 8892 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8893 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8894 | adapter = adapterNode->pAdapter; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8895 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 8896 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8897 | adapter != this_sap_adapter) { |
| 8898 | if (check_start_bss) { |
| 8899 | if (test_bit(SOFTAP_BSS_STARTED, |
| 8900 | &adapter->event_flags)) { |
| 8901 | con_sap_adapter = adapter; |
| 8902 | break; |
| 8903 | } |
| 8904 | } else { |
| 8905 | con_sap_adapter = adapter; |
| 8906 | break; |
| 8907 | } |
| 8908 | } |
| 8909 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 8910 | adapterNode = pNext; |
| 8911 | } |
| 8912 | |
| 8913 | return con_sap_adapter; |
| 8914 | } |
| 8915 | |
| 8916 | #ifdef MSM_PLATFORM |
| 8917 | void hdd_start_bus_bw_compute_timer(hdd_adapter_t *adapter) |
| 8918 | { |
| 8919 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8920 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 8921 | if (hdd_ctx->bus_bw_timer_started) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8922 | return; |
| 8923 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 8924 | hdd_ctx->bus_bw_timer_started = true; |
| 8925 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8926 | hdd_ctx->config->busBandwidthComputeInterval); |
| 8927 | } |
| 8928 | |
| 8929 | void hdd_stop_bus_bw_compute_timer(hdd_adapter_t *adapter) |
| 8930 | { |
| 8931 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8932 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8933 | bool can_stop = true; |
| 8934 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8935 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 8936 | if (!hdd_ctx->bus_bw_timer_started) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8937 | /* trying to stop timer, when not running is not good */ |
Srinivas Girigowda | 0ee9644 | 2016-08-17 19:10:56 -0700 | [diff] [blame] | 8938 | hdd_info("bus band width compute timer is not running"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8939 | return; |
| 8940 | } |
| 8941 | |
| 8942 | if (cds_concurrent_open_sessions_running()) { |
| 8943 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 8944 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8945 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8946 | adapter = adapterNode->pAdapter; |
| 8947 | if (adapter |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8948 | && (adapter->device_mode == QDF_STA_MODE |
| 8949 | || adapter->device_mode == QDF_P2P_CLIENT_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8950 | && WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 8951 | conn_info.connState == |
| 8952 | eConnectionState_Associated) { |
| 8953 | can_stop = false; |
| 8954 | break; |
| 8955 | } |
| 8956 | if (adapter |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8957 | && (adapter->device_mode == QDF_SAP_MODE |
| 8958 | || adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8959 | && WLAN_HDD_GET_AP_CTX_PTR(adapter)->bApActive == |
| 8960 | true) { |
| 8961 | can_stop = false; |
| 8962 | break; |
| 8963 | } |
| 8964 | status = hdd_get_next_adapter(hdd_ctx, |
| 8965 | adapterNode, |
| 8966 | &pNext); |
| 8967 | adapterNode = pNext; |
| 8968 | } |
| 8969 | } |
| 8970 | |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 8971 | if (can_stop == true) { |
Chris Guo | c0c95bf | 2016-11-10 14:28:25 +0800 | [diff] [blame] | 8972 | /* reset the ipa perf level */ |
| 8973 | hdd_ipa_set_perf_level(hdd_ctx, 0, 0); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 8974 | qdf_timer_stop(&hdd_ctx->bus_bw_timer); |
| 8975 | hdd_ctx->bus_bw_timer_started = false; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 8976 | hdd_reset_tcp_delack(hdd_ctx); |
| 8977 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8978 | } |
| 8979 | #endif |
| 8980 | |
| 8981 | /** |
| 8982 | * wlan_hdd_check_custom_con_channel_rules() - This function checks the sap's |
| 8983 | * and sta's operating channel. |
| 8984 | * @sta_adapter: Describe the first argument to foobar. |
| 8985 | * @ap_adapter: Describe the second argument to foobar. |
| 8986 | * @roam_profile: Roam profile of AP to which STA wants to connect. |
| 8987 | * @concurrent_chnl_same: If both SAP and STA channels are same then |
| 8988 | * set this flag to true else false. |
| 8989 | * |
| 8990 | * This function checks the sap's operating channel and sta's operating channel. |
| 8991 | * if both are same then it will return false else it will restart the sap in |
| 8992 | * sta's channel and return true. |
| 8993 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8994 | * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8995 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8996 | 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] | 8997 | hdd_adapter_t *ap_adapter, |
| 8998 | tCsrRoamProfile *roam_profile, |
| 8999 | tScanResultHandle *scan_cache, |
| 9000 | bool *concurrent_chnl_same) |
| 9001 | { |
| 9002 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 9003 | uint8_t channel_id; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9004 | QDF_STATUS status; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9005 | enum tQDF_ADAPTER_MODE device_mode = ap_adapter->device_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9006 | *concurrent_chnl_same = true; |
| 9007 | |
| 9008 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 9009 | status = |
| 9010 | sme_get_ap_channel_from_scan_cache(WLAN_HDD_GET_HAL_CTX(sta_adapter), |
| 9011 | roam_profile, |
| 9012 | scan_cache, |
| 9013 | &channel_id); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9014 | if ((QDF_STATUS_SUCCESS == status)) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9015 | if ((QDF_SAP_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9016 | (channel_id < SIR_11A_CHANNEL_BEGIN)) { |
| 9017 | if (hdd_ap_ctx->operatingChannel != channel_id) { |
| 9018 | *concurrent_chnl_same = false; |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9019 | hdd_info("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9020 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9021 | } else if ((QDF_P2P_GO_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9022 | (channel_id >= SIR_11A_CHANNEL_BEGIN)) { |
| 9023 | if (hdd_ap_ctx->operatingChannel != channel_id) { |
| 9024 | *concurrent_chnl_same = false; |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9025 | hdd_info("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9026 | } |
| 9027 | } |
| 9028 | } else { |
| 9029 | /* |
| 9030 | * Lets handle worst case scenario here, Scan cache lookup is |
| 9031 | * failed so we have to stop the SAP to avoid any channel |
| 9032 | * discrepancy between SAP's channel and STA's channel. |
| 9033 | * Return the status as failure so caller function could know |
| 9034 | * that scan look up is failed. |
| 9035 | */ |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9036 | hdd_err("Finding AP from scan cache failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9037 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9038 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9039 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9040 | } |
| 9041 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9042 | /** |
| 9043 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 9044 | * @ap_adapter: SAP adapter |
| 9045 | * |
| 9046 | * This function will process the stopping of sap adapter. |
| 9047 | * |
| 9048 | * Return: None |
| 9049 | */ |
| 9050 | void wlan_hdd_stop_sap(hdd_adapter_t *ap_adapter) |
| 9051 | { |
| 9052 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 9053 | hdd_hostapd_state_t *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 9054 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9055 | hdd_context_t *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9056 | |
| 9057 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9058 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9059 | return; |
| 9060 | } |
| 9061 | |
| 9062 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 9063 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 9064 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9065 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 9066 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9067 | mutex_lock(&hdd_ctx->sap_lock); |
| 9068 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 9069 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9070 | hdd_cleanup_actionframe(hdd_ctx, ap_adapter); |
| 9071 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9072 | hdd_info("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 9073 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9074 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9075 | sapContext)) { |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 9076 | qdf_status = qdf_wait_single_event(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 9077 | qdf_stop_bss_event, |
| 9078 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 9079 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9080 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9081 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9082 | return; |
| 9083 | } |
| 9084 | } |
| 9085 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | 4adb368 | 2016-01-07 15:07:12 -0800 | [diff] [blame] | 9086 | cds_decr_session_set_pcl(ap_adapter->device_mode, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9087 | ap_adapter->sessionId); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9088 | hdd_info("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9089 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9090 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9091 | } |
| 9092 | mutex_unlock(&hdd_ctx->sap_lock); |
| 9093 | return; |
| 9094 | } |
| 9095 | |
| 9096 | /** |
| 9097 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 9098 | * @ap_adapter: SAP adapter |
| 9099 | * |
| 9100 | * This function will process the starting of sap adapter. |
| 9101 | * |
| 9102 | * Return: None |
| 9103 | */ |
| 9104 | void wlan_hdd_start_sap(hdd_adapter_t *ap_adapter) |
| 9105 | { |
| 9106 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 9107 | hdd_hostapd_state_t *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 9108 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9109 | hdd_context_t *hdd_ctx; |
| 9110 | tsap_Config_t *sap_config; |
| 9111 | |
| 9112 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9113 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9114 | return; |
| 9115 | } |
| 9116 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9117 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 9118 | hdd_err("SoftAp role has not been enabled"); |
| 9119 | return; |
| 9120 | } |
| 9121 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9122 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 9123 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 9124 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 9125 | sap_config = &ap_adapter->sessionCtx.ap.sapConfig; |
| 9126 | |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 9127 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9128 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 9129 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9130 | mutex_lock(&hdd_ctx->sap_lock); |
| 9131 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 9132 | goto end; |
| 9133 | |
| 9134 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9135 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9136 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
| 9137 | goto end; |
| 9138 | } |
| 9139 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 9140 | qdf_event_reset(&hostapd_state->qdf_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9141 | if (wlansap_start_bss(hdd_ap_ctx->sapContext, hdd_hostapd_sap_event_cb, |
| 9142 | &hdd_ap_ctx->sapConfig, |
| 9143 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9144 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9145 | goto end; |
| 9146 | |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9147 | hdd_info("Waiting for SAP to start"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 9148 | qdf_status = qdf_wait_single_event(&hostapd_state->qdf_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 9149 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 9150 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9151 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9152 | goto end; |
| 9153 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9154 | hdd_info("SAP Start Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9155 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Krunal Soni | b37bb35 | 2016-12-20 14:12:21 -0800 | [diff] [blame] | 9156 | if (hostapd_state->bssState == BSS_START) |
| 9157 | cds_incr_active_session(ap_adapter->device_mode, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9158 | ap_adapter->sessionId); |
| 9159 | hostapd_state->bCommit = true; |
| 9160 | |
| 9161 | end: |
| 9162 | mutex_unlock(&hdd_ctx->sap_lock); |
| 9163 | return; |
| 9164 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9165 | |
| 9166 | /** |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 9167 | * wlan_hdd_soc_set_antenna_mode_cb() - Callback for set dual |
| 9168 | * mac scan config |
| 9169 | * @status: Status of set antenna mode |
| 9170 | * |
| 9171 | * Callback on setting the dual mac configuration |
| 9172 | * |
| 9173 | * Return: None |
| 9174 | */ |
| 9175 | void wlan_hdd_soc_set_antenna_mode_cb( |
| 9176 | enum set_antenna_mode_status status) |
| 9177 | { |
| 9178 | hdd_context_t *hdd_ctx; |
| 9179 | |
| 9180 | hdd_info("Status: %d", status); |
| 9181 | |
| 9182 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 9183 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 9184 | return; |
| 9185 | |
| 9186 | /* Signal the completion of set dual mac config */ |
| 9187 | complete(&hdd_ctx->set_antenna_mode_cmpl); |
| 9188 | } |
| 9189 | |
| 9190 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9191 | * hdd_get_fw_version() - Get FW version |
| 9192 | * @hdd_ctx: pointer to HDD context. |
| 9193 | * @major_spid: FW version - major spid. |
| 9194 | * @minor_spid: FW version - minor spid |
| 9195 | * @ssid: FW version - ssid |
| 9196 | * @crmid: FW version - crmid |
| 9197 | * |
| 9198 | * This function is called to get the firmware build version stored |
| 9199 | * as part of the HDD context |
| 9200 | * |
| 9201 | * Return: None |
| 9202 | */ |
| 9203 | void hdd_get_fw_version(hdd_context_t *hdd_ctx, |
| 9204 | uint32_t *major_spid, uint32_t *minor_spid, |
| 9205 | uint32_t *siid, uint32_t *crmid) |
| 9206 | { |
| 9207 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 9208 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 9209 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 9210 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 9211 | } |
| 9212 | |
| 9213 | #ifdef QCA_CONFIG_SMP |
| 9214 | /** |
| 9215 | * wlan_hdd_get_cpu() - get cpu_index |
| 9216 | * |
| 9217 | * Return: cpu_index |
| 9218 | */ |
| 9219 | int wlan_hdd_get_cpu(void) |
| 9220 | { |
| 9221 | int cpu_index = get_cpu(); |
| 9222 | put_cpu(); |
| 9223 | return cpu_index; |
| 9224 | } |
| 9225 | #endif |
| 9226 | |
| 9227 | /** |
| 9228 | * hdd_get_fwpath() - get framework path |
| 9229 | * |
| 9230 | * This function is used to get the string written by |
| 9231 | * userspace to start the wlan driver |
| 9232 | * |
| 9233 | * Return: string |
| 9234 | */ |
| 9235 | const char *hdd_get_fwpath(void) |
| 9236 | { |
| 9237 | return fwpath.string; |
| 9238 | } |
| 9239 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9240 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9241 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9242 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9243 | * This function initilizes CDS global context with the help of cds_init. This |
| 9244 | * has to be the first function called after probe to get a valid global |
| 9245 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9246 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9247 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9248 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9249 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9250 | { |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9251 | v_CONTEXT_t p_cds_context = NULL; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9252 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9253 | |
| 9254 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9255 | wlan_logging_sock_init_svc(); |
| 9256 | #endif |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9257 | p_cds_context = cds_init(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9258 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9259 | if (p_cds_context == NULL) { |
| 9260 | hdd_alert("Failed to allocate CDS context"); |
| 9261 | ret = -ENOMEM; |
| 9262 | goto err_out; |
| 9263 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9264 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9265 | hdd_trace_init(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 9266 | hdd_register_debug_callback(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9267 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9268 | err_out: |
| 9269 | return ret; |
| 9270 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9271 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9272 | /** |
| 9273 | * hdd_deinit() - Deinitialize Driver |
| 9274 | * |
| 9275 | * This function frees CDS global context with the help of cds_deinit. This |
| 9276 | * has to be the last function call in remove callback to free the global |
| 9277 | * context. |
| 9278 | */ |
| 9279 | void hdd_deinit(void) |
| 9280 | { |
| 9281 | cds_deinit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9282 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9283 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9284 | wlan_logging_sock_deinit_svc(); |
| 9285 | #endif |
| 9286 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9287 | |
| 9288 | #ifdef QCA_WIFI_3_0_ADRASTEA |
| 9289 | #define HDD_WLAN_START_WAIT_TIME (3600 * 1000) |
| 9290 | #else |
| 9291 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
| 9292 | #endif |
| 9293 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9294 | /** |
| 9295 | * __hdd_module_init - Module init helper |
| 9296 | * |
| 9297 | * Module init helper function used by both module and static driver. |
| 9298 | * |
| 9299 | * Return: 0 for success, errno on failure |
| 9300 | */ |
| 9301 | static int __hdd_module_init(void) |
| 9302 | { |
| 9303 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9304 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9305 | pr_err("%s: Loading driver v%s\n", WLAN_MODULE_NAME, |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9306 | QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9307 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 9308 | pld_init(); |
| 9309 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 9310 | ret = hdd_init(); |
| 9311 | if (ret) { |
| 9312 | pr_err("hdd_init failed %x\n", ret); |
| 9313 | goto err_hdd_init; |
| 9314 | } |
| 9315 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 9316 | dispatcher_init(); |
| 9317 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 9318 | qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9319 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9320 | hdd_set_conparam((uint32_t) con_mode); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9321 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9322 | ret = wlan_hdd_register_driver(); |
| 9323 | if (ret) { |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 9324 | pr_err("%s: driver load failure, err %d\n", WLAN_MODULE_NAME, |
| 9325 | ret); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9326 | goto out; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9327 | } |
| 9328 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 9329 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9330 | |
| 9331 | return 0; |
| 9332 | out: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 9333 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 9334 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 9335 | hdd_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 9336 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 9337 | err_hdd_init: |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 9338 | pld_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 9339 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9340 | return ret; |
| 9341 | } |
| 9342 | |
| 9343 | /** |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 9344 | * hdd_wait_for_recovery_completion() - Wait for cds recovery completion |
| 9345 | * |
| 9346 | * Block the unloading of the driver until the cds recovery is completed |
| 9347 | * |
| 9348 | * Return: None |
| 9349 | */ |
| 9350 | static void hdd_wait_for_recovery_completion(void) |
| 9351 | { |
| 9352 | int retry = 0; |
| 9353 | |
| 9354 | /* Wait for recovery to complete */ |
| 9355 | while (cds_is_driver_recovering()) { |
| 9356 | hdd_alert("Recovery in progress; wait here!!!"); |
| 9357 | msleep(1000); |
| 9358 | if (retry++ == HDD_MOD_EXIT_SSR_MAX_RETRIES) { |
| 9359 | hdd_alert("SSR never completed, fatal error"); |
| 9360 | QDF_BUG(0); |
| 9361 | } |
| 9362 | } |
| 9363 | } |
| 9364 | |
| 9365 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9366 | * __hdd_module_exit - Module exit helper |
| 9367 | * |
| 9368 | * Module exit helper function used by both module and static driver. |
| 9369 | */ |
| 9370 | static void __hdd_module_exit(void) |
| 9371 | { |
| 9372 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 9373 | QWLAN_VERSIONSTR); |
| 9374 | |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 9375 | hdd_wait_for_recovery_completion(); |
| 9376 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9377 | wlan_hdd_unregister_driver(); |
| 9378 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 9379 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9380 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 9381 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 9382 | hdd_deinit(); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 9383 | pld_deinit(); |
| 9384 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9385 | return; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9386 | } |
| 9387 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9388 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9389 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9390 | * wlan_boot_cb() - Wlan boot callback |
| 9391 | * @kobj: object whose directory we're creating the link in. |
| 9392 | * @attr: attribute the user is interacting with |
| 9393 | * @buff: the buffer containing the user data |
| 9394 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9395 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9396 | * This callback is invoked when the fs is ready to start the |
| 9397 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9398 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9399 | * 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] | 9400 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9401 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 9402 | struct kobj_attribute *attr, |
| 9403 | const char *buf, |
| 9404 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9405 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9406 | |
| 9407 | int ret = 0; |
| 9408 | |
| 9409 | if (wlan_loader->loaded_state) { |
| 9410 | pr_info("Wlan driver already initialized"); |
| 9411 | return 0; |
| 9412 | } |
| 9413 | |
| 9414 | |
| 9415 | pr_err("%s: Loading driver v%s\n", WLAN_MODULE_NAME, |
| 9416 | QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
| 9417 | |
| 9418 | if (__hdd_module_init()) { |
| 9419 | pr_err("%s: Failed to register handler\n", __func__); |
| 9420 | ret = -EINVAL; |
| 9421 | } else |
| 9422 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
| 9423 | |
| 9424 | return count; |
| 9425 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9426 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9427 | |
| 9428 | /** |
| 9429 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 9430 | * ready |
| 9431 | * |
| 9432 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 9433 | * when the filesystem is ready. |
| 9434 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 9435 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9436 | */ |
| 9437 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9438 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9439 | int ret = -EINVAL; |
| 9440 | |
| 9441 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
| 9442 | if (!wlan_loader) { |
| 9443 | pr_err("%s: memory alloc failed\n", __func__); |
| 9444 | ret = -ENOMEM; |
| 9445 | return ret; |
| 9446 | } |
| 9447 | |
| 9448 | wlan_loader->boot_wlan_obj = NULL; |
| 9449 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 9450 | GFP_KERNEL); |
| 9451 | if (!wlan_loader->attr_group) { |
| 9452 | pr_err("%s: malloc attr_group failed\n", __func__); |
| 9453 | ret = -ENOMEM; |
| 9454 | goto error_return; |
| 9455 | } |
| 9456 | |
| 9457 | wlan_loader->loaded_state = 0; |
| 9458 | wlan_loader->attr_group->attrs = attrs; |
| 9459 | |
| 9460 | wlan_loader->boot_wlan_obj = kobject_create_and_add("boot_wlan", |
| 9461 | kernel_kobj); |
| 9462 | if (!wlan_loader->boot_wlan_obj) { |
| 9463 | pr_err("%s: sysfs create and add failed\n", __func__); |
| 9464 | ret = -ENOMEM; |
| 9465 | goto error_return; |
| 9466 | } |
| 9467 | |
| 9468 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 9469 | wlan_loader->attr_group); |
| 9470 | if (ret) { |
| 9471 | pr_err("%s: sysfs create group failed %d\n", __func__, ret); |
| 9472 | goto error_return; |
| 9473 | } |
| 9474 | |
| 9475 | return 0; |
| 9476 | |
| 9477 | error_return: |
| 9478 | |
| 9479 | if (wlan_loader->boot_wlan_obj) { |
| 9480 | kobject_del(wlan_loader->boot_wlan_obj); |
| 9481 | wlan_loader->boot_wlan_obj = NULL; |
| 9482 | } |
| 9483 | |
| 9484 | return ret; |
| 9485 | } |
| 9486 | |
| 9487 | /** |
| 9488 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 9489 | * |
| 9490 | * Return: 0 on success or errno on failure |
| 9491 | */ |
| 9492 | static int wlan_deinit_sysfs(void) |
| 9493 | { |
| 9494 | |
| 9495 | if (!wlan_loader) { |
| 9496 | hdd_alert("wlan loader context is Null!"); |
| 9497 | return -EINVAL; |
| 9498 | } |
| 9499 | |
| 9500 | if (wlan_loader->boot_wlan_obj) { |
| 9501 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 9502 | wlan_loader->attr_group); |
| 9503 | kobject_del(wlan_loader->boot_wlan_obj); |
| 9504 | wlan_loader->boot_wlan_obj = NULL; |
| 9505 | } |
| 9506 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9507 | return 0; |
| 9508 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9509 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9510 | #endif |
| 9511 | |
| 9512 | #ifdef MODULE |
| 9513 | /** |
| 9514 | * __hdd_module_init - Module init helper |
| 9515 | * |
| 9516 | * Module init helper function used by both module and static driver. |
| 9517 | * |
| 9518 | * Return: 0 for success, errno on failure |
| 9519 | */ |
| 9520 | static int hdd_module_init(void) |
| 9521 | { |
| 9522 | int ret = 0; |
| 9523 | |
| 9524 | pr_err("%s: Loading driver v%s\n", WLAN_MODULE_NAME, |
| 9525 | QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
| 9526 | |
| 9527 | if (__hdd_module_init()) { |
| 9528 | pr_err("%s: Failed to register handler\n", __func__); |
| 9529 | ret = -EINVAL; |
| 9530 | } |
| 9531 | |
| 9532 | return ret; |
| 9533 | } |
| 9534 | #else |
| 9535 | static int __init hdd_module_init(void) |
| 9536 | { |
| 9537 | int ret = -EINVAL; |
| 9538 | |
| 9539 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 9540 | if (ret) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9541 | pr_err("Failed to create sysfs entry for loading wlan"); |
| 9542 | |
| 9543 | return ret; |
| 9544 | } |
| 9545 | #endif |
| 9546 | |
| 9547 | |
| 9548 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9549 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9550 | * hdd_module_exit() - Exit function |
| 9551 | * |
| 9552 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 9553 | * |
| 9554 | * Return: None |
| 9555 | */ |
| 9556 | static void __exit hdd_module_exit(void) |
| 9557 | { |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9558 | __hdd_module_exit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9559 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9560 | #else |
| 9561 | static void __exit hdd_module_exit(void) |
| 9562 | { |
| 9563 | __hdd_module_exit(); |
| 9564 | wlan_deinit_sysfs(); |
| 9565 | } |
| 9566 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9567 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9568 | static int fwpath_changed_handler(const char *kmessage, struct kernel_param *kp) |
| 9569 | { |
| 9570 | return param_set_copystring(kmessage, kp); |
| 9571 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9572 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9573 | /** |
| 9574 | * is_con_mode_valid() check con mode is valid or not |
| 9575 | * @mode: global con mode |
| 9576 | * |
| 9577 | * Return: TRUE on success FALSE on failure |
| 9578 | */ |
| 9579 | static bool is_con_mode_valid(enum tQDF_GLOBAL_CON_MODE mode) |
| 9580 | { |
| 9581 | switch (mode) { |
| 9582 | case QDF_GLOBAL_MONITOR_MODE: |
| 9583 | case QDF_GLOBAL_FTM_MODE: |
| 9584 | case QDF_GLOBAL_EPPING_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9585 | case QDF_GLOBAL_MISSION_MODE: |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9586 | return true; |
| 9587 | default: |
| 9588 | return false; |
| 9589 | } |
| 9590 | } |
| 9591 | |
| 9592 | /** |
| 9593 | * hdd_get_adpter_mode() - returns adapter mode based on global con mode |
| 9594 | * @mode: global con mode |
| 9595 | * |
| 9596 | * Return: adapter mode |
| 9597 | */ |
| 9598 | static enum tQDF_ADAPTER_MODE hdd_get_adpter_mode( |
| 9599 | enum tQDF_GLOBAL_CON_MODE mode) |
| 9600 | { |
| 9601 | |
| 9602 | switch (mode) { |
| 9603 | case QDF_GLOBAL_MISSION_MODE: |
| 9604 | return QDF_STA_MODE; |
| 9605 | case QDF_GLOBAL_MONITOR_MODE: |
| 9606 | return QDF_MONITOR_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9607 | case QDF_GLOBAL_EPPING_MODE: |
| 9608 | return QDF_EPPING_MODE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9609 | case QDF_GLOBAL_FTM_MODE: |
| 9610 | return QDF_FTM_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9611 | case QDF_GLOBAL_QVIT_MODE: |
| 9612 | return QDF_QVIT_MODE; |
| 9613 | default: |
| 9614 | return QDF_MAX_NO_OF_MODE; |
| 9615 | } |
| 9616 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9617 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9618 | static void hdd_cleanup_present_mode(hdd_context_t *hdd_ctx, |
| 9619 | enum tQDF_GLOBAL_CON_MODE curr_mode) |
| 9620 | { |
| 9621 | switch (curr_mode) { |
| 9622 | case QDF_GLOBAL_MISSION_MODE: |
| 9623 | case QDF_GLOBAL_MONITOR_MODE: |
| 9624 | case QDF_GLOBAL_FTM_MODE: |
| 9625 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
| 9626 | hdd_stop_all_adapters(hdd_ctx); |
| 9627 | hdd_deinit_all_adapters(hdd_ctx, false); |
| 9628 | hdd_close_all_adapters(hdd_ctx, false); |
| 9629 | break; |
| 9630 | case QDF_GLOBAL_EPPING_MODE: |
| 9631 | epping_disable(); |
| 9632 | epping_close(); |
| 9633 | break; |
| 9634 | default: |
| 9635 | return; |
| 9636 | } |
| 9637 | } |
| 9638 | |
| 9639 | static int hdd_register_req_mode(hdd_context_t *hdd_ctx, |
| 9640 | enum tQDF_GLOBAL_CON_MODE mode) |
| 9641 | { |
| 9642 | hdd_adapter_t *adapter; |
| 9643 | int ret = 0; |
| 9644 | bool rtnl_held; |
| 9645 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 9646 | QDF_STATUS status; |
| 9647 | |
| 9648 | if (!qdf_dev) { |
| 9649 | hdd_err("qdf device context is Null return!"); |
| 9650 | return -EINVAL; |
| 9651 | } |
| 9652 | |
| 9653 | rtnl_held = hdd_hold_rtnl_lock(); |
| 9654 | switch (mode) { |
| 9655 | case QDF_GLOBAL_MISSION_MODE: |
| 9656 | adapter = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 9657 | if (IS_ERR(adapter)) { |
| 9658 | hdd_alert("Failed to open interface, adapter is NULL"); |
| 9659 | ret = -EINVAL; |
| 9660 | } |
| 9661 | break; |
| 9662 | case QDF_GLOBAL_FTM_MODE: |
| 9663 | adapter = hdd_open_adapter(hdd_ctx, QDF_FTM_MODE, "wlan%d", |
| 9664 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 9665 | NET_NAME_UNKNOWN, rtnl_held); |
| 9666 | if (adapter == NULL) |
| 9667 | ret = -EINVAL; |
| 9668 | break; |
| 9669 | case QDF_GLOBAL_MONITOR_MODE: |
| 9670 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
| 9671 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 9672 | NET_NAME_UNKNOWN, rtnl_held); |
| 9673 | if (adapter == NULL) |
| 9674 | ret = -EINVAL; |
| 9675 | break; |
| 9676 | case QDF_GLOBAL_EPPING_MODE: |
| 9677 | status = epping_open(); |
| 9678 | if (status != QDF_STATUS_SUCCESS) { |
| 9679 | hdd_err("Failed to open in eeping mode: %d", status); |
| 9680 | ret = -EINVAL; |
| 9681 | break; |
| 9682 | } |
| 9683 | ret = epping_enable(qdf_dev->dev); |
| 9684 | if (ret) { |
| 9685 | hdd_err("Failed to enable in epping mode : %d", ret); |
| 9686 | epping_close(); |
| 9687 | } |
| 9688 | break; |
| 9689 | default: |
| 9690 | hdd_info("Mode not supported"); |
| 9691 | ret = -ENOTSUPP; |
| 9692 | break; |
| 9693 | } |
| 9694 | hdd_release_rtnl_lock(); |
| 9695 | rtnl_held = false; |
| 9696 | return ret; |
| 9697 | } |
| 9698 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9699 | /** |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 9700 | * __con_mode_handler() - Handles module param con_mode change |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9701 | * @kmessage: con mode name on which driver to be bring up |
| 9702 | * @kp: The associated kernel parameter |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 9703 | * @hdd_ctx: Pointer to the global HDD context |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9704 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9705 | * This function is invoked when user updates con mode using sys entry, |
| 9706 | * to initialize and bring-up driver in that specific mode. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9707 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9708 | * Return - 0 on success and failure code on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9709 | */ |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9710 | static int __con_mode_handler(const char *kmessage, struct kernel_param *kp, |
| 9711 | hdd_context_t *hdd_ctx) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9712 | { |
| 9713 | int ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9714 | hdd_adapter_t *adapter; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9715 | enum tQDF_GLOBAL_CON_MODE curr_mode; |
| 9716 | enum tQDF_ADAPTER_MODE adapter_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9717 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 9718 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9719 | if (ret) |
| 9720 | return ret; |
| 9721 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9722 | cds_set_load_in_progress(true); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9723 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9724 | hdd_info("con_mode handler: %s", kmessage); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9725 | ret = param_set_int(kmessage, kp); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9726 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9727 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9728 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9729 | if (!(is_con_mode_valid(con_mode))) { |
| 9730 | hdd_err("invlaid con_mode %d", con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9731 | ret = -EINVAL; |
| 9732 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9733 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9734 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9735 | curr_mode = hdd_get_conparam(); |
| 9736 | if (curr_mode == con_mode) { |
| 9737 | hdd_err("curr mode: %d is same as user triggered mode %d", |
| 9738 | curr_mode, con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9739 | ret = 0; |
| 9740 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9741 | } |
| 9742 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9743 | /* Cleanup present mode before switching to new mode */ |
| 9744 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 9745 | |
Prashanth Bhatta | 2ac92bd | 2016-10-11 16:08:00 -0700 | [diff] [blame] | 9746 | ret = hdd_wlan_stop_modules(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9747 | if (ret) { |
| 9748 | hdd_err("Stop wlan modules failed"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9749 | goto reset_flags; |
| 9750 | } |
| 9751 | |
| 9752 | hdd_set_conparam(con_mode); |
| 9753 | |
| 9754 | /* Register for new con_mode & then kick_start modules again */ |
| 9755 | ret = hdd_register_req_mode(hdd_ctx, con_mode); |
| 9756 | if (ret) { |
| 9757 | hdd_err("Failed to register for new mode"); |
| 9758 | goto reset_flags; |
| 9759 | } |
| 9760 | |
| 9761 | adapter_mode = hdd_get_adpter_mode(con_mode); |
| 9762 | if (adapter_mode == QDF_MAX_NO_OF_MODE) { |
| 9763 | hdd_err("invalid adapter"); |
| 9764 | ret = -EINVAL; |
| 9765 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9766 | } |
| 9767 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9768 | adapter = hdd_get_adapter(hdd_ctx, adapter_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9769 | if (!adapter) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9770 | hdd_err("Failed to get adapter:%d", adapter_mode); |
| 9771 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9772 | } |
| 9773 | |
| 9774 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 9775 | if (ret) { |
| 9776 | hdd_err("Start wlan modules failed: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9777 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9778 | } |
| 9779 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9780 | if (con_mode == QDF_GLOBAL_MONITOR_MODE || |
| 9781 | con_mode == QDF_GLOBAL_FTM_MODE) { |
| 9782 | if (hdd_start_adapter(adapter)) { |
| 9783 | hdd_err("Failed to start %s adapter", kmessage); |
| 9784 | ret = -EINVAL; |
| 9785 | goto reset_flags; |
| 9786 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9787 | } |
| 9788 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9789 | hdd_info("Mode successfully changed to %s", kmessage); |
| 9790 | ret = 0; |
| 9791 | |
| 9792 | reset_flags: |
| 9793 | cds_set_load_in_progress(false); |
| 9794 | return ret; |
| 9795 | } |
| 9796 | |
| 9797 | |
| 9798 | static int con_mode_handler(const char *kmessage, struct kernel_param *kp) |
| 9799 | { |
| 9800 | int ret; |
| 9801 | hdd_context_t *hdd_ctx; |
| 9802 | |
| 9803 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 9804 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9805 | if (ret) |
| 9806 | return ret; |
| 9807 | |
| 9808 | cds_ssr_protect(__func__); |
| 9809 | ret = __con_mode_handler(kmessage, kp, hdd_ctx); |
| 9810 | cds_ssr_unprotect(__func__); |
| 9811 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9812 | return ret; |
| 9813 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9814 | |
| 9815 | /** |
| 9816 | * hdd_get_conparam() - driver exit point |
| 9817 | * |
| 9818 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 9819 | * |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9820 | * Return: enum tQDF_GLOBAL_CON_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9821 | */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9822 | enum tQDF_GLOBAL_CON_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9823 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9824 | return (enum tQDF_GLOBAL_CON_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9825 | } |
| 9826 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 9827 | void hdd_set_conparam(uint32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9828 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 9829 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9830 | } |
| 9831 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 9832 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 9833 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 9834 | * @hdd_ctx: HDD context |
| 9835 | * |
| 9836 | * Cleans up the pre cac interface, if it exists |
| 9837 | * |
| 9838 | * Return: None |
| 9839 | */ |
| 9840 | void hdd_clean_up_pre_cac_interface(hdd_context_t *hdd_ctx) |
| 9841 | { |
| 9842 | uint8_t session_id; |
| 9843 | QDF_STATUS status; |
| 9844 | struct hdd_adapter_s *precac_adapter; |
| 9845 | |
| 9846 | status = wlan_sap_get_pre_cac_vdev_id(hdd_ctx->hHal, &session_id); |
| 9847 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9848 | hdd_err("failed to get pre cac vdev id"); |
| 9849 | return; |
| 9850 | } |
| 9851 | |
| 9852 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, session_id); |
| 9853 | if (!precac_adapter) { |
| 9854 | hdd_err("invalid pre cac adapater"); |
| 9855 | return; |
| 9856 | } |
| 9857 | |
| 9858 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 9859 | wlan_hdd_sap_pre_cac_failure, |
| 9860 | (void *)precac_adapter); |
| 9861 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 9862 | |
| 9863 | } |
| 9864 | |
| 9865 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9866 | * hdd_update_ol_config - API to update ol configuration parameters |
| 9867 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 9868 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 9869 | * Return: void |
| 9870 | */ |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9871 | static void hdd_update_ol_config(hdd_context_t *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 9872 | { |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9873 | struct ol_config_info cfg; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 9874 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 9875 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9876 | if (!ol_ctx) |
| 9877 | return; |
| 9878 | |
| 9879 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
| 9880 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 9881 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 9882 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 9883 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9884 | |
| 9885 | ol_init_ini_config(ol_ctx, &cfg); |
| 9886 | } |
| 9887 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 9888 | #ifdef FEATURE_RUNTIME_PM |
| 9889 | /** |
| 9890 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 9891 | * @hdd_ctx: hdd context |
| 9892 | * @cfg: pointer to the configuration memory being populated |
| 9893 | * |
| 9894 | * Return: void |
| 9895 | */ |
| 9896 | static void hdd_populate_runtime_cfg(hdd_context_t *hdd_ctx, |
| 9897 | struct hif_config_info *cfg) |
| 9898 | { |
| 9899 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
| 9900 | cfg->runtime_pm_delay = hdd_ctx->config->runtime_pm_delay; |
| 9901 | } |
| 9902 | #else |
| 9903 | static void hdd_populate_runtime_cfg(hdd_context_t *hdd_ctx, |
| 9904 | struct hif_config_info *cfg) |
| 9905 | { |
| 9906 | } |
| 9907 | #endif |
| 9908 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9909 | /** |
| 9910 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 9911 | * @hdd_ctx: HDD Context |
| 9912 | * |
| 9913 | * Return: void |
| 9914 | */ |
| 9915 | static void hdd_update_hif_config(hdd_context_t *hdd_ctx) |
| 9916 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 9917 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9918 | struct hif_config_info cfg; |
| 9919 | |
| 9920 | if (!scn) |
| 9921 | return; |
| 9922 | |
| 9923 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 9924 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9925 | hif_init_ini_config(scn, &cfg); |
| 9926 | } |
| 9927 | |
| 9928 | /** |
| 9929 | * hdd_update_config() - Initialize driver per module ini parameters |
| 9930 | * @hdd_ctx: HDD Context |
| 9931 | * |
| 9932 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9933 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9934 | */ |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9935 | int hdd_update_config(hdd_context_t *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9936 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9937 | int ret; |
| 9938 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9939 | hdd_update_ol_config(hdd_ctx); |
| 9940 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9941 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 9942 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 9943 | else |
| 9944 | ret = hdd_update_cds_config(hdd_ctx); |
| 9945 | |
| 9946 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 9947 | } |
| 9948 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 9949 | /** |
| 9950 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 9951 | * @mode : cfg80211 DFS mode |
| 9952 | * |
| 9953 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 9954 | */ |
| 9955 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 9956 | { |
| 9957 | switch (mode) { |
| 9958 | case DFS_MODE_ENABLE: |
| 9959 | return ACS_DFS_MODE_ENABLE; |
| 9960 | break; |
| 9961 | case DFS_MODE_DISABLE: |
| 9962 | return ACS_DFS_MODE_DISABLE; |
| 9963 | break; |
| 9964 | case DFS_MODE_DEPRIORITIZE: |
| 9965 | return ACS_DFS_MODE_DEPRIORITIZE; |
| 9966 | break; |
| 9967 | default: |
| 9968 | hdd_err("ACS dfs mode is NONE"); |
| 9969 | return ACS_DFS_MODE_NONE; |
| 9970 | } |
| 9971 | } |
| 9972 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 9973 | /** |
| 9974 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 9975 | * @hddctx: pointer to hdd context |
| 9976 | * @set_value: enable/disable |
| 9977 | * |
| 9978 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 9979 | * Host(even though it is duplicate). When Host send vendor command |
| 9980 | * disable,FW doesn't perform any action. Whenever any change in |
| 9981 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 9982 | * |
| 9983 | * return - 0 on success, appropriate error values on failure. |
| 9984 | */ |
| 9985 | int hdd_enable_disable_ca_event(hdd_context_t *hddctx, uint8_t set_value) |
| 9986 | { |
| 9987 | QDF_STATUS status; |
| 9988 | |
| 9989 | if (0 != wlan_hdd_validate_context(hddctx)) { |
| 9990 | return -EAGAIN; |
| 9991 | } |
| 9992 | |
| 9993 | if (!hddctx->config->goptimize_chan_avoid_event) { |
| 9994 | hdd_warn("goptimize_chan_avoid_event ini param disabled"); |
| 9995 | return -EINVAL; |
| 9996 | } |
| 9997 | |
| 9998 | status = sme_enable_disable_chanavoidind_event(hddctx->hHal, set_value); |
| 9999 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10000 | hdd_err("Failed to send chan avoid command to SME"); |
| 10001 | return -EINVAL; |
| 10002 | } |
| 10003 | return 0; |
| 10004 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 10005 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 10006 | /** |
| 10007 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 10008 | * @value: value to set |
| 10009 | * |
| 10010 | * This function will set the passed value to roaming in progress flag. |
| 10011 | * |
| 10012 | * Return: None |
| 10013 | */ |
| 10014 | void hdd_set_roaming_in_progress(bool value) |
| 10015 | { |
| 10016 | hdd_context_t *hdd_ctx; |
| 10017 | |
| 10018 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10019 | if (!hdd_ctx) { |
| 10020 | hdd_err("HDD context is NULL"); |
| 10021 | return; |
| 10022 | } |
| 10023 | |
| 10024 | hdd_ctx->roaming_in_progress = value; |
| 10025 | hdd_info("Roaming in Progress set to %d", value); |
| 10026 | } |
| 10027 | |
| 10028 | /** |
| 10029 | * hdd_is_roaming_in_progress() - check if roaming is in progress |
| 10030 | * @hdd_ctx - HDD context |
| 10031 | * |
| 10032 | * Return: true if roaming is in progress else false |
| 10033 | */ |
| 10034 | bool hdd_is_roaming_in_progress(void) |
| 10035 | { |
| 10036 | hdd_context_t *hdd_ctx; |
| 10037 | |
| 10038 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10039 | if (!hdd_ctx) { |
| 10040 | hdd_err("HDD context is NULL"); |
| 10041 | return false; |
| 10042 | } |
| 10043 | return hdd_ctx->roaming_in_progress; |
| 10044 | } |
| 10045 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10046 | /* Register the module init/exit functions */ |
| 10047 | module_init(hdd_module_init); |
| 10048 | module_exit(hdd_module_exit); |
| 10049 | |
| 10050 | MODULE_LICENSE("Dual BSD/GPL"); |
| 10051 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 10052 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 10053 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10054 | module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode, |
| 10055 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10056 | |
| 10057 | module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath, |
| 10058 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 10059 | |
| 10060 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 10061 | |
| 10062 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 10063 | |
| 10064 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |