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> |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 109 | #include <wlan_objmgr_cmn.h> |
| 110 | #include <wlan_objmgr_global_obj.h> |
| 111 | #include <wlan_objmgr_psoc_obj.h> |
| 112 | #include <wlan_objmgr_pdev_obj.h> |
| 113 | #include <wlan_objmgr_vdev_obj.h> |
| 114 | #include <wlan_objmgr_peer_obj.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 115 | |
| 116 | #ifdef MODULE |
| 117 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 118 | #else |
| 119 | #define WLAN_MODULE_NAME "wlan" |
| 120 | #endif |
| 121 | |
| 122 | #ifdef TIMER_MANAGER |
| 123 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 124 | #else |
| 125 | #define TIMER_MANAGER_STR "" |
| 126 | #endif |
| 127 | |
| 128 | #ifdef MEMORY_DEBUG |
| 129 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 130 | #else |
| 131 | #define MEMORY_DEBUG_STR "" |
| 132 | #endif |
| 133 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 134 | #ifndef MODULE |
| 135 | static struct gwlan_loader *wlan_loader; |
| 136 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 137 | struct kobj_attribute *attr, |
| 138 | const char *buf, size_t count); |
| 139 | struct gwlan_loader { |
| 140 | bool loaded_state; |
| 141 | struct kobject *boot_wlan_obj; |
| 142 | struct attribute_group *attr_group; |
| 143 | }; |
| 144 | |
| 145 | static struct kobj_attribute wlan_boot_attribute = |
| 146 | __ATTR(boot_wlan, 0220, NULL, wlan_boot_cb); |
| 147 | |
| 148 | static struct attribute *attrs[] = { |
| 149 | &wlan_boot_attribute.attr, |
| 150 | NULL, |
| 151 | }; |
| 152 | |
| 153 | #define MODULE_INITIALIZED 1 |
| 154 | #endif |
| 155 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 156 | /* the Android framework expects this param even though we don't use it */ |
| 157 | #define BUF_LEN 20 |
| 158 | static char fwpath_buffer[BUF_LEN]; |
| 159 | static struct kparam_string fwpath = { |
| 160 | .string = fwpath_buffer, |
| 161 | .maxlen = BUF_LEN, |
| 162 | }; |
| 163 | |
| 164 | static char *country_code; |
| 165 | static int enable_11d = -1; |
| 166 | static int enable_dfs_chan_scan = -1; |
| 167 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 168 | /* |
| 169 | * spinlock for synchronizing asynchronous request/response |
| 170 | * (full description of use in wlan_hdd_main.h) |
| 171 | */ |
| 172 | DEFINE_SPINLOCK(hdd_context_lock); |
| 173 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 174 | #define WLAN_NLINK_CESIUM 30 |
| 175 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 176 | static qdf_wake_lock_t wlan_wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 177 | |
| 178 | #define WOW_MAX_FILTER_LISTS 1 |
| 179 | #define WOW_MAX_FILTERS_PER_LIST 4 |
| 180 | #define WOW_MIN_PATTERN_SIZE 6 |
| 181 | #define WOW_MAX_PATTERN_SIZE 64 |
| 182 | |
| 183 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 184 | static const struct wiphy_wowlan_support wowlan_support_reg_init = { |
| 185 | .flags = WIPHY_WOWLAN_ANY | |
| 186 | WIPHY_WOWLAN_MAGIC_PKT | |
| 187 | WIPHY_WOWLAN_DISCONNECT | |
| 188 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 189 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 190 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 191 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 192 | WIPHY_WOWLAN_RFKILL_RELEASE, |
| 193 | .n_patterns = WOW_MAX_FILTER_LISTS * WOW_MAX_FILTERS_PER_LIST, |
| 194 | .pattern_min_len = WOW_MIN_PATTERN_SIZE, |
| 195 | .pattern_max_len = WOW_MAX_PATTERN_SIZE, |
| 196 | }; |
| 197 | #endif |
| 198 | |
| 199 | /* internal function declaration */ |
| 200 | |
| 201 | struct sock *cesium_nl_srv_sock; |
| 202 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 203 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 204 | void wlan_hdd_auto_shutdown_cb(void); |
| 205 | #endif |
| 206 | |
| 207 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 208 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
| 209 | * @hdd_ctx: pointer to hdd_context_t |
| 210 | * |
| 211 | * Return: none |
| 212 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 213 | static void hdd_set_rps_cpu_mask(hdd_context_t *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 214 | { |
| 215 | hdd_adapter_t *adapter; |
| 216 | hdd_adapter_list_node_t *adapter_node, *next; |
| 217 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 218 | |
| 219 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 220 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 221 | adapter = adapter_node->pAdapter; |
| 222 | if (NULL != adapter) |
| 223 | hdd_send_rps_ind(adapter); |
| 224 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 225 | adapter_node = next; |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 230 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 231 | * @vdev_id: vdev_id |
| 232 | * @action: action type |
| 233 | * @reason: reason type |
| 234 | * |
| 235 | * Return: none |
| 236 | */ |
| 237 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 238 | enum netif_action_type action, enum netif_reason_type reason) |
| 239 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 240 | hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 241 | hdd_adapter_t *adapter; |
| 242 | |
| 243 | if (!hdd_ctx) { |
| 244 | hdd_err("hdd ctx is NULL"); |
| 245 | return; |
| 246 | } |
| 247 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 248 | |
| 249 | wlan_hdd_netif_queue_control(adapter, action, reason); |
| 250 | return; |
| 251 | } |
| 252 | |
| 253 | /* |
| 254 | * Store WLAN driver version info in a global variable such that crash debugger |
| 255 | * can extract it from driver debug symbol and crashdump for post processing |
| 256 | */ |
| 257 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR; |
| 258 | |
| 259 | /** |
| 260 | * hdd_device_mode_to_string() - return string conversion of device mode |
| 261 | * @device_mode: device mode |
| 262 | * |
| 263 | * This utility function helps log string conversion of device mode. |
| 264 | * |
| 265 | * Return: string conversion of device mode, if match found; |
| 266 | * "Unknown" otherwise. |
| 267 | */ |
| 268 | const char *hdd_device_mode_to_string(uint8_t device_mode) |
| 269 | { |
| 270 | switch (device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 271 | CASE_RETURN_STRING(QDF_STA_MODE); |
| 272 | CASE_RETURN_STRING(QDF_SAP_MODE); |
| 273 | CASE_RETURN_STRING(QDF_P2P_CLIENT_MODE); |
| 274 | CASE_RETURN_STRING(QDF_P2P_GO_MODE); |
| 275 | CASE_RETURN_STRING(QDF_FTM_MODE); |
| 276 | CASE_RETURN_STRING(QDF_IBSS_MODE); |
| 277 | CASE_RETURN_STRING(QDF_P2P_DEVICE_MODE); |
| 278 | CASE_RETURN_STRING(QDF_OCB_MODE); |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 279 | CASE_RETURN_STRING(QDF_NDI_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 280 | default: |
| 281 | return "Unknown"; |
| 282 | } |
| 283 | } |
| 284 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 285 | /** |
| 286 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 287 | * @adapter: HDD adapter |
| 288 | * @chan_number: Channel number |
| 289 | * @chan_bw: Bandwidth |
| 290 | * |
| 291 | * Checks if the given bandwidth is valid for the given channel number. |
| 292 | * |
| 293 | * Return: 0 for success, non-zero for failure |
| 294 | */ |
| 295 | int hdd_validate_channel_and_bandwidth(hdd_adapter_t *adapter, |
| 296 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 297 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 298 | { |
| 299 | uint8_t chan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 300 | uint32_t len = WNI_CFG_VALID_CHANNEL_LIST_LEN, i; |
| 301 | bool found = false; |
| 302 | tHalHandle hal; |
| 303 | |
| 304 | hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 305 | if (!hal) { |
| 306 | hdd_err("Invalid HAL context"); |
| 307 | return -EINVAL; |
| 308 | } |
| 309 | |
| 310 | if (0 != sme_cfg_get_str(hal, WNI_CFG_VALID_CHANNEL_LIST, chan, &len)) { |
| 311 | hdd_err("No valid channel list"); |
| 312 | return -EOPNOTSUPP; |
| 313 | } |
| 314 | |
| 315 | for (i = 0; i < len; i++) { |
| 316 | if (chan[i] == chan_number) { |
| 317 | found = true; |
| 318 | break; |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | if (found == false) { |
| 323 | hdd_err("Channel not in driver's valid channel list"); |
| 324 | return -EOPNOTSUPP; |
| 325 | } |
| 326 | |
| 327 | if ((!CDS_IS_CHANNEL_24GHZ(chan_number)) && |
| 328 | (!CDS_IS_CHANNEL_5GHZ(chan_number))) { |
| 329 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 330 | return -EINVAL; |
| 331 | } |
| 332 | |
| 333 | if (CDS_IS_CHANNEL_24GHZ(chan_number)) { |
| 334 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 335 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 336 | return -EINVAL; |
| 337 | } |
| 338 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 339 | (chan_bw != CH_WIDTH_MAX)) { |
| 340 | hdd_err("Only BW20 possible on channel 14"); |
| 341 | return -EINVAL; |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | if (CDS_IS_CHANNEL_5GHZ(chan_number)) { |
| 346 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 347 | (chan_bw != CH_WIDTH_MAX)) { |
| 348 | hdd_err("Only BW20 possible on channel 165"); |
| 349 | return -EINVAL; |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | return 0; |
| 354 | } |
| 355 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 356 | static int __hdd_netdev_notifier_call(struct notifier_block *nb, |
| 357 | unsigned long state, void *data) |
| 358 | { |
| 359 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 360 | struct netdev_notifier_info *dev_notif_info = data; |
| 361 | struct net_device *dev = dev_notif_info->dev; |
| 362 | #else |
| 363 | struct net_device *dev = data; |
| 364 | #endif |
| 365 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 366 | hdd_context_t *hdd_ctx; |
| 367 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 368 | ENTER_DEV(dev); |
| 369 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 370 | /* Make sure that this callback corresponds to our device. */ |
| 371 | if ((strncmp(dev->name, "wlan", 4)) && (strncmp(dev->name, "p2p", 3))) |
| 372 | return NOTIFY_DONE; |
| 373 | |
Samuel Ahn | c9c48ca | 2016-09-19 15:46:36 +0530 | [diff] [blame] | 374 | if ((adapter->magic != WLAN_HDD_ADAPTER_MAGIC) || |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 375 | (adapter->dev != dev)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 376 | hdd_err("device adapter is not matching!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 377 | return NOTIFY_DONE; |
| 378 | } |
| 379 | |
| 380 | if (!dev->ieee80211_ptr) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 381 | hdd_err("ieee80211_ptr is NULL!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 382 | return NOTIFY_DONE; |
| 383 | } |
| 384 | |
| 385 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 386 | if (NULL == hdd_ctx) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 387 | hdd_alert("HDD Context Null Pointer"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 388 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 389 | return NOTIFY_DONE; |
| 390 | } |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 391 | if (cds_is_driver_recovering()) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 392 | return NOTIFY_DONE; |
| 393 | |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 394 | hdd_notice("%s New Net Device State = %lu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 395 | dev->name, state); |
| 396 | |
| 397 | switch (state) { |
| 398 | case NETDEV_REGISTER: |
| 399 | break; |
| 400 | |
| 401 | case NETDEV_UNREGISTER: |
| 402 | break; |
| 403 | |
| 404 | case NETDEV_UP: |
| 405 | sme_ch_avoid_update_req(hdd_ctx->hHal); |
| 406 | break; |
| 407 | |
| 408 | case NETDEV_DOWN: |
| 409 | break; |
| 410 | |
| 411 | case NETDEV_CHANGE: |
| 412 | if (true == adapter->isLinkUpSvcNeeded) |
| 413 | complete(&adapter->linkup_event_var); |
| 414 | break; |
| 415 | |
| 416 | case NETDEV_GOING_DOWN: |
| 417 | if (adapter->scan_info.mScanPending != false) { |
| 418 | unsigned long rc; |
| 419 | INIT_COMPLETION(adapter->scan_info. |
| 420 | abortscan_event_var); |
| 421 | hdd_abort_mac_scan(adapter->pHddCtx, |
| 422 | adapter->sessionId, |
| 423 | eCSR_SCAN_ABORT_DEFAULT); |
| 424 | rc = wait_for_completion_timeout( |
| 425 | &adapter->scan_info.abortscan_event_var, |
| 426 | msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN)); |
| 427 | if (!rc) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 428 | hdd_err("Timeout occurred while waiting for abortscan"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 429 | } |
| 430 | } else { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 431 | hdd_notice("Scan is not Pending from user"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 432 | } |
| 433 | break; |
| 434 | |
| 435 | default: |
| 436 | break; |
| 437 | } |
| 438 | |
| 439 | return NOTIFY_DONE; |
| 440 | } |
| 441 | |
| 442 | /** |
| 443 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 444 | * @nb: pointer to notifier block |
| 445 | * @state: state |
| 446 | * @ndev: ndev pointer |
| 447 | * |
| 448 | * Return: 0 on success, error number otherwise. |
| 449 | */ |
| 450 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 451 | unsigned long state, |
| 452 | void *ndev) |
| 453 | { |
| 454 | int ret; |
| 455 | |
| 456 | cds_ssr_protect(__func__); |
| 457 | ret = __hdd_netdev_notifier_call(nb, state, ndev); |
| 458 | cds_ssr_unprotect(__func__); |
| 459 | |
| 460 | return ret; |
| 461 | } |
| 462 | |
| 463 | struct notifier_block hdd_netdev_notifier = { |
| 464 | .notifier_call = hdd_netdev_notifier_call, |
| 465 | }; |
| 466 | |
| 467 | /* variable to hold the insmod parameters */ |
| 468 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 469 | |
| 470 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 471 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 472 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 473 | /** |
| 474 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 475 | * @ch_width: NL channel width |
| 476 | * |
| 477 | * Converts the NL channel width to the driver's internal representation |
| 478 | * |
| 479 | * Return: Converted channel width. In case of non matching NL channel width, |
| 480 | * CH_WIDTH_MAX will be returned. |
| 481 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 482 | 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] | 483 | { |
| 484 | switch (ch_width) { |
| 485 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 486 | case NL80211_CHAN_WIDTH_20: |
| 487 | return CH_WIDTH_20MHZ; |
| 488 | case NL80211_CHAN_WIDTH_40: |
| 489 | return CH_WIDTH_40MHZ; |
| 490 | break; |
| 491 | case NL80211_CHAN_WIDTH_80: |
| 492 | return CH_WIDTH_80MHZ; |
| 493 | case NL80211_CHAN_WIDTH_80P80: |
| 494 | return CH_WIDTH_80P80MHZ; |
| 495 | case NL80211_CHAN_WIDTH_160: |
| 496 | return CH_WIDTH_160MHZ; |
| 497 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 498 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 499 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 500 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 501 | default: |
| 502 | hdd_err("Invalid channel width %d, setting to default", |
| 503 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 504 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 505 | } |
| 506 | } |
| 507 | |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 508 | /* wlan_hdd_find_opclass() - Find operating class for a channel |
| 509 | * @hal: handler to HAL |
| 510 | * @channel: channel id |
| 511 | * @bw_offset: bandwidth offset |
| 512 | * |
| 513 | * Function invokes sme api to find the operating class |
| 514 | * |
| 515 | * Return: operating class |
| 516 | */ |
| 517 | uint8_t wlan_hdd_find_opclass(tHalHandle hal, uint8_t channel, |
| 518 | uint8_t bw_offset) |
| 519 | { |
| 520 | uint8_t opclass = 0; |
| 521 | |
| 522 | sme_get_opclass(hal, channel, bw_offset, &opclass); |
| 523 | return opclass; |
| 524 | } |
| 525 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 526 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 527 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 528 | * @moduleId: Module whose trace level is being configured |
| 529 | * @bitmask: Bitmask of log levels to be enabled |
| 530 | * |
| 531 | * Called immediately after the cfg.ini is read in order to configure |
| 532 | * the desired trace levels. |
| 533 | * |
| 534 | * Return: None |
| 535 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 536 | 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] | 537 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 538 | QDF_TRACE_LEVEL level; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 539 | |
| 540 | /* |
| 541 | * if the bitmask is the default value, then a bitmask was not |
| 542 | * specified in cfg.ini, so leave the logging level alone (it |
| 543 | * will remain at the "compiled in" default value) |
| 544 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 545 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 546 | return; |
| 547 | } |
| 548 | |
| 549 | /* a mask was specified. start by disabling all logging */ |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 550 | qdf_trace_set_value(moduleId, QDF_TRACE_LEVEL_NONE, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 551 | |
| 552 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 553 | level = QDF_TRACE_LEVEL_FATAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 554 | while (0 != bitmask) { |
| 555 | if (bitmask & 1) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 556 | qdf_trace_set_value(moduleId, level, 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 557 | } |
| 558 | level++; |
| 559 | bitmask >>= 1; |
| 560 | } |
| 561 | } |
| 562 | |
| 563 | /** |
| 564 | * wlan_hdd_validate_context() - check the HDD context |
| 565 | * @hdd_ctx: HDD context pointer |
| 566 | * |
| 567 | * Return: 0 if the context is valid. Error code otherwise |
| 568 | */ |
| 569 | int wlan_hdd_validate_context(hdd_context_t *hdd_ctx) |
| 570 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 571 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 572 | hdd_err("%pS HDD context is Null", (void *)_RET_IP_); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 573 | return -ENODEV; |
| 574 | } |
| 575 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 576 | if (cds_is_driver_recovering()) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 577 | hdd_err("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
| 578 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 579 | return -EAGAIN; |
| 580 | } |
| 581 | |
Rajeev Kumar | fec3dbe | 2016-01-19 15:23:52 -0800 | [diff] [blame] | 582 | if (cds_is_load_or_unload_in_progress()) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 583 | hdd_err("%pS Unloading/Loading in Progress. Ignore!!!: 0x%x", |
| 584 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 585 | return -EAGAIN; |
| 586 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 587 | |
| 588 | if (hdd_ctx->start_modules_in_progress || |
| 589 | hdd_ctx->stop_modules_in_progress) { |
| 590 | hdd_err("%pS Start/Stop Modules in progress. Ignore!!!", |
| 591 | (void *)_RET_IP_); |
| 592 | return -EAGAIN; |
| 593 | } |
| 594 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 595 | return 0; |
| 596 | } |
| 597 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 598 | /** |
| 599 | * hdd_set_ibss_power_save_params() - update IBSS Power Save params to WMA. |
| 600 | * @hdd_adapter_t Hdd adapter. |
| 601 | * |
| 602 | * This function sets the IBSS power save config parameters to WMA |
| 603 | * which will send it to firmware if FW supports IBSS power save |
| 604 | * before vdev start. |
| 605 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 606 | * 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] | 607 | * on failure. |
| 608 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 609 | QDF_STATUS hdd_set_ibss_power_save_params(hdd_adapter_t *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 610 | { |
| 611 | int ret; |
| 612 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 613 | |
| 614 | if (hdd_ctx == NULL) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 615 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 616 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 617 | } |
| 618 | |
| 619 | ret = wma_cli_set_command(adapter->sessionId, |
| 620 | WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE, |
| 621 | hdd_ctx->config->ibssATIMWinSize, |
| 622 | VDEV_CMD); |
| 623 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 624 | hdd_err("WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 625 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 626 | } |
| 627 | |
| 628 | ret = wma_cli_set_command(adapter->sessionId, |
| 629 | WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED, |
| 630 | hdd_ctx->config->isIbssPowerSaveAllowed, |
| 631 | VDEV_CMD); |
| 632 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 633 | hdd_err("WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED failed %d", |
| 634 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 635 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 636 | } |
| 637 | |
| 638 | ret = wma_cli_set_command(adapter->sessionId, |
| 639 | WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED, |
| 640 | hdd_ctx->config-> |
| 641 | isIbssPowerCollapseAllowed, VDEV_CMD); |
| 642 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 643 | hdd_err("WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED failed %d", |
| 644 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 645 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 646 | } |
| 647 | |
| 648 | ret = wma_cli_set_command(adapter->sessionId, |
| 649 | WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX, |
| 650 | hdd_ctx->config->isIbssAwakeOnTxRx, |
| 651 | VDEV_CMD); |
| 652 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 653 | 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] | 654 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 655 | } |
| 656 | |
| 657 | ret = wma_cli_set_command(adapter->sessionId, |
| 658 | WMA_VDEV_IBSS_SET_INACTIVITY_TIME, |
| 659 | hdd_ctx->config->ibssInactivityCount, |
| 660 | VDEV_CMD); |
| 661 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 662 | hdd_err("WMA_VDEV_IBSS_SET_INACTIVITY_TIME failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 663 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 664 | } |
| 665 | |
| 666 | ret = wma_cli_set_command(adapter->sessionId, |
| 667 | WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME, |
| 668 | hdd_ctx->config->ibssTxSpEndInactivityTime, |
| 669 | VDEV_CMD); |
| 670 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 671 | hdd_err("WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME failed %d", |
| 672 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 673 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 674 | } |
| 675 | |
| 676 | ret = wma_cli_set_command(adapter->sessionId, |
| 677 | WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS, |
| 678 | hdd_ctx->config->ibssPsWarmupTime, |
| 679 | VDEV_CMD); |
| 680 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 681 | hdd_err("WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS failed %d", |
| 682 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 683 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | ret = wma_cli_set_command(adapter->sessionId, |
| 687 | WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW, |
| 688 | hdd_ctx->config->ibssPs1RxChainInAtimEnable, |
| 689 | VDEV_CMD); |
| 690 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 691 | hdd_err("WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW failed %d", |
| 692 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 693 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 694 | } |
| 695 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 696 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 697 | } |
| 698 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 699 | #define INTF_MACADDR_MASK 0x7 |
| 700 | |
| 701 | /** |
| 702 | * hdd_update_macaddr() - update mac address |
| 703 | * @config: hdd configuration |
| 704 | * @hw_macaddr: mac address |
| 705 | * |
| 706 | * Mac address for multiple virtual interface is found as following |
| 707 | * i) The mac address of the first interface is just the actual hw mac address. |
| 708 | * ii) MSM 3 or 4 bits of byte5 of the actual mac address are used to |
| 709 | * define the mac address for the remaining interfaces and locally |
| 710 | * admistered bit is set. INTF_MACADDR_MASK is based on the number of |
| 711 | * supported virtual interfaces, right now this is 0x07 (meaning 8 |
| 712 | * interface). |
| 713 | * Byte[3] of second interface will be hw_macaddr[3](bit5..7) + 1, |
| 714 | * for third interface it will be hw_macaddr[3](bit5..7) + 2, etc. |
| 715 | * |
| 716 | * Return: None |
| 717 | */ |
| 718 | void hdd_update_macaddr(struct hdd_config *config, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 719 | struct qdf_mac_addr hw_macaddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 720 | { |
| 721 | int8_t i; |
| 722 | uint8_t macaddr_b3, tmp_br3; |
| 723 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 724 | qdf_mem_copy(config->intfMacAddr[0].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 725 | QDF_MAC_ADDR_SIZE); |
| 726 | for (i = 1; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 727 | qdf_mem_copy(config->intfMacAddr[i].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 728 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 729 | macaddr_b3 = config->intfMacAddr[i].bytes[3]; |
| 730 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 731 | INTF_MACADDR_MASK; |
| 732 | macaddr_b3 += tmp_br3; |
| 733 | |
| 734 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 735 | * mac address range before collision |
| 736 | */ |
| 737 | macaddr_b3 ^= (1 << 7); |
| 738 | |
| 739 | /* Set locally administered bit */ |
| 740 | config->intfMacAddr[i].bytes[0] |= 0x02; |
| 741 | config->intfMacAddr[i].bytes[3] = macaddr_b3; |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 742 | hdd_notice("config->intfMacAddr[%d]: " |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 743 | MAC_ADDRESS_STR, i, |
| 744 | MAC_ADDR_ARRAY(config->intfMacAddr[i].bytes)); |
| 745 | } |
| 746 | } |
| 747 | |
| 748 | static void hdd_update_tgt_services(hdd_context_t *hdd_ctx, |
| 749 | struct wma_tgt_services *cfg) |
| 750 | { |
| 751 | struct hdd_config *config = hdd_ctx->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 752 | |
| 753 | /* Set up UAPSD */ |
| 754 | config->apUapsdEnabled &= cfg->uapsd; |
| 755 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 756 | /* 11AC mode support */ |
| 757 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 758 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 759 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 760 | |
| 761 | /* ARP offload: override user setting if invalid */ |
| 762 | config->fhostArpOffload &= cfg->arp_offload; |
| 763 | |
| 764 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 765 | /* PNO offload */ |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 766 | hdd_info("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 767 | if (cfg->pno_offload) |
| 768 | config->PnoOffload = true; |
| 769 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 770 | #ifdef FEATURE_WLAN_TDLS |
| 771 | config->fEnableTDLSSupport &= cfg->en_tdls; |
Manjeet Singh | fdd2ac7 | 2016-09-02 18:11:43 +0530 | [diff] [blame] | 772 | config->fEnableTDLSOffChannel = config->fEnableTDLSOffChannel && |
| 773 | cfg->en_tdls_offchan; |
| 774 | config->fEnableTDLSBufferSta = config->fEnableTDLSBufferSta && |
| 775 | cfg->en_tdls_uapsd_buf_sta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 776 | if (config->fTDLSUapsdMask && cfg->en_tdls_uapsd_sleep_sta) { |
| 777 | config->fEnableTDLSSleepSta = true; |
| 778 | } else { |
| 779 | config->fEnableTDLSSleepSta = false; |
| 780 | } |
| 781 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 782 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 783 | config->isRoamOffloadEnabled &= cfg->en_roam_offload; |
| 784 | #endif |
Krishna Kumaar Natarajan | 052c6e6 | 2015-09-28 15:32:55 -0700 | [diff] [blame] | 785 | sme_update_tgt_services(hdd_ctx->hHal, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 786 | |
| 787 | } |
| 788 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 789 | /** |
| 790 | * hdd_update_vdev_nss() - sets the vdev nss |
| 791 | * @hdd_ctx: HDD context |
| 792 | * |
| 793 | * Sets the Nss per vdev type based on INI |
| 794 | * |
| 795 | * Return: None |
| 796 | */ |
| 797 | static void hdd_update_vdev_nss(hdd_context_t *hdd_ctx) |
| 798 | { |
| 799 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 800 | uint8_t max_supp_nss = 1; |
| 801 | |
| 802 | if (cfg_ini->enable2x2) |
| 803 | max_supp_nss = 2; |
| 804 | |
| 805 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
| 806 | cfg_ini->vdev_type_nss_2g, eCSR_BAND_24); |
| 807 | |
| 808 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
| 809 | cfg_ini->vdev_type_nss_5g, eCSR_BAND_5G); |
| 810 | } |
| 811 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 812 | static void hdd_update_tgt_ht_cap(hdd_context_t *hdd_ctx, |
| 813 | struct wma_tgt_ht_cap *cfg) |
| 814 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 815 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 816 | uint32_t value, val32; |
| 817 | uint16_t val16; |
| 818 | struct hdd_config *pconfig = hdd_ctx->config; |
| 819 | tSirMacHTCapabilityInfo *phtCapInfo; |
| 820 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
| 821 | uint8_t enable_tx_stbc; |
| 822 | |
| 823 | /* check and update RX STBC */ |
| 824 | if (pconfig->enableRxSTBC && !cfg->ht_rx_stbc) |
| 825 | pconfig->enableRxSTBC = cfg->ht_rx_stbc; |
| 826 | |
| 827 | /* get the MPDU density */ |
| 828 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, &value); |
| 829 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 830 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 831 | hdd_err("could not get MPDU DENSITY"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 832 | value = 0; |
| 833 | } |
| 834 | |
| 835 | /* |
| 836 | * MPDU density: |
| 837 | * override user's setting if value is larger |
| 838 | * than the one supported by target |
| 839 | */ |
| 840 | if (value > cfg->mpdu_density) { |
| 841 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, |
| 842 | cfg->mpdu_density); |
| 843 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 844 | if (status == QDF_STATUS_E_FAILURE) |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 845 | hdd_alert("could not set MPDU DENSITY to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 846 | } |
| 847 | |
| 848 | /* get the HT capability info */ |
| 849 | 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] | 850 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 851 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 852 | return; |
| 853 | } |
| 854 | val16 = (uint16_t) val32; |
| 855 | phtCapInfo = (tSirMacHTCapabilityInfo *) &val16; |
| 856 | |
| 857 | /* Set the LDPC capability */ |
| 858 | phtCapInfo->advCodingCap = cfg->ht_rx_ldpc; |
| 859 | |
| 860 | if (pconfig->ShortGI20MhzEnable && !cfg->ht_sgi_20) |
| 861 | pconfig->ShortGI20MhzEnable = cfg->ht_sgi_20; |
| 862 | |
| 863 | if (pconfig->ShortGI40MhzEnable && !cfg->ht_sgi_40) |
| 864 | pconfig->ShortGI40MhzEnable = cfg->ht_sgi_40; |
| 865 | |
| 866 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 867 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 868 | |
| 869 | enable_tx_stbc = pconfig->enableTxSTBC; |
| 870 | |
| 871 | if (pconfig->enable2x2 && (cfg->num_rf_chains == 2)) { |
| 872 | pconfig->enable2x2 = 1; |
| 873 | } else { |
| 874 | pconfig->enable2x2 = 0; |
| 875 | enable_tx_stbc = 0; |
| 876 | |
| 877 | /* 1x1 */ |
| 878 | /* Update Rx Highest Long GI data Rate */ |
| 879 | if (sme_cfg_set_int(hdd_ctx->hHal, |
| 880 | WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 881 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 882 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 883 | 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] | 884 | } |
| 885 | |
| 886 | /* Update Tx Highest Long GI data Rate */ |
| 887 | if (sme_cfg_set_int |
| 888 | (hdd_ctx->hHal, |
| 889 | WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 890 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 891 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 892 | hdd_err("VHT_TX_HIGHEST_SUPP_RATE_1_1 to CCM fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 893 | } |
| 894 | } |
| 895 | if (!(cfg->ht_tx_stbc && pconfig->enable2x2)) |
| 896 | enable_tx_stbc = 0; |
| 897 | phtCapInfo->txSTBC = enable_tx_stbc; |
| 898 | |
| 899 | val32 = val16; |
| 900 | 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] | 901 | if (status != QDF_STATUS_SUCCESS) |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 902 | hdd_alert("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 903 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
| 904 | value = SIZE_OF_SUPPORTED_MCS_SET; |
| 905 | 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] | 906 | &value) == QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 907 | hdd_notice("Read MCS rate set"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 908 | |
| 909 | if (pconfig->enable2x2) { |
| 910 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 911 | mcs_set[value] = |
| 912 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 913 | |
| 914 | status = |
| 915 | sme_cfg_set_str(hdd_ctx->hHal, |
| 916 | WNI_CFG_SUPPORTED_MCS_SET, |
| 917 | mcs_set, |
| 918 | SIZE_OF_SUPPORTED_MCS_SET); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 919 | if (status == QDF_STATUS_E_FAILURE) |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 920 | hdd_alert("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 921 | } |
| 922 | } |
| 923 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 924 | } |
| 925 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 926 | static void hdd_update_tgt_vht_cap(hdd_context_t *hdd_ctx, |
| 927 | struct wma_tgt_vht_cap *cfg) |
| 928 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 929 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 930 | uint32_t value = 0; |
| 931 | struct hdd_config *pconfig = hdd_ctx->config; |
| 932 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 933 | struct ieee80211_supported_band *band_5g = |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 934 | wiphy->bands[NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 935 | uint32_t temp = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 936 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 937 | if (!band_5g) { |
| 938 | hdd_info("5GHz band disabled, skipping capability population"); |
| 939 | return; |
| 940 | } |
| 941 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 942 | /* Get the current MPDU length */ |
| 943 | status = |
| 944 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 945 | &value); |
| 946 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 947 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 948 | hdd_err("could not get MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 949 | value = 0; |
| 950 | } |
| 951 | |
| 952 | /* |
| 953 | * VHT max MPDU length: |
| 954 | * override if user configured value is too high |
| 955 | * that the target cannot support |
| 956 | */ |
| 957 | if (value > cfg->vht_max_mpdu) { |
| 958 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 959 | WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 960 | cfg->vht_max_mpdu); |
| 961 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 962 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 963 | hdd_alert("could not set VHT MAX MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 964 | } |
| 965 | } |
| 966 | |
| 967 | /* Get the current supported chan width */ |
| 968 | status = sme_cfg_get_int(hdd_ctx->hHal, |
| 969 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 970 | &value); |
| 971 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 972 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 973 | hdd_err("could not get MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 974 | value = 0; |
| 975 | } |
| 976 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 977 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, &temp); |
| 978 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 979 | |
| 980 | if (pconfig->enable2x2) |
| 981 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 982 | |
| 983 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, temp) == |
| 984 | QDF_STATUS_E_FAILURE) { |
| 985 | hdd_err("Could not pass VHT_BASIC_MCS_SET to CCM"); |
| 986 | } |
| 987 | |
| 988 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, &temp); |
| 989 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 990 | if (pconfig->enable2x2) |
| 991 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 992 | |
| 993 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, temp) == |
| 994 | QDF_STATUS_E_FAILURE) { |
| 995 | hdd_err("Could not pass WNI_CFG_VHT_RX_MCS_MAP to CCM"); |
| 996 | } |
| 997 | |
| 998 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, &temp); |
| 999 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtTxMCS; |
| 1000 | if (pconfig->enable2x2) |
| 1001 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtTxMCS2x2 << 2); |
| 1002 | |
| 1003 | hdd_info("vhtRxMCS2x2 - %x temp - %u enable2x2 %d", |
| 1004 | pconfig->vhtRxMCS2x2, temp, pconfig->enable2x2); |
| 1005 | |
| 1006 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, temp) == |
| 1007 | QDF_STATUS_E_FAILURE) { |
| 1008 | hdd_err("Could not pass WNI_CFG_VHT_TX_MCS_MAP to CCM"); |
| 1009 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1010 | /* Get the current RX LDPC setting */ |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1011 | 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] | 1012 | &value); |
| 1013 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1014 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1015 | hdd_err("could not get VHT LDPC CODING CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1016 | value = 0; |
| 1017 | } |
| 1018 | |
| 1019 | /* Set the LDPC capability */ |
| 1020 | if (value && !cfg->vht_rx_ldpc) { |
| 1021 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1022 | WNI_CFG_VHT_LDPC_CODING_CAP, |
| 1023 | cfg->vht_rx_ldpc); |
| 1024 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1025 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1026 | hdd_alert("could not set VHT LDPC CODING CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1027 | } |
| 1028 | } |
| 1029 | |
| 1030 | /* Get current GI 80 value */ |
| 1031 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1032 | &value); |
| 1033 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1034 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1035 | hdd_err("could not get SHORT GI 80MHZ"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1036 | value = 0; |
| 1037 | } |
| 1038 | |
| 1039 | /* set the Guard interval 80MHz */ |
| 1040 | if (value && !cfg->vht_short_gi_80) { |
| 1041 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1042 | WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1043 | cfg->vht_short_gi_80); |
| 1044 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1045 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1046 | hdd_alert("could not set SHORT GI 80MHZ to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1047 | } |
| 1048 | } |
| 1049 | |
| 1050 | /* Get current GI 160 value */ |
| 1051 | status = sme_cfg_get_int(hdd_ctx->hHal, |
| 1052 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
| 1053 | &value); |
| 1054 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1055 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1056 | hdd_err("could not get SHORT GI 80 & 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1057 | value = 0; |
| 1058 | } |
| 1059 | |
| 1060 | /* Get VHT TX STBC cap */ |
| 1061 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, &value); |
| 1062 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1063 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1064 | hdd_err("could not get VHT TX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1065 | value = 0; |
| 1066 | } |
| 1067 | |
| 1068 | /* VHT TX STBC cap */ |
| 1069 | if (value && !cfg->vht_tx_stbc) { |
| 1070 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, |
| 1071 | cfg->vht_tx_stbc); |
| 1072 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1073 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1074 | hdd_alert("could not set the VHT TX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1075 | } |
| 1076 | } |
| 1077 | |
| 1078 | /* Get VHT RX STBC cap */ |
| 1079 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, &value); |
| 1080 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1081 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1082 | hdd_err("could not get VHT RX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1083 | value = 0; |
| 1084 | } |
| 1085 | |
| 1086 | /* VHT RX STBC cap */ |
| 1087 | if (value && !cfg->vht_rx_stbc) { |
| 1088 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, |
| 1089 | cfg->vht_rx_stbc); |
| 1090 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1091 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1092 | hdd_alert("could not set the VHT RX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1093 | } |
| 1094 | } |
| 1095 | |
| 1096 | /* Get VHT SU Beamformer cap */ |
| 1097 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1098 | &value); |
| 1099 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1100 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1101 | hdd_err("could not get VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1102 | value = 0; |
| 1103 | } |
| 1104 | |
| 1105 | /* set VHT SU Beamformer cap */ |
| 1106 | if (value && !cfg->vht_su_bformer) { |
| 1107 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1108 | WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1109 | cfg->vht_su_bformer); |
| 1110 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1111 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1112 | hdd_alert("could not set VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1113 | } |
| 1114 | } |
| 1115 | |
| 1116 | /* check and update SU BEAMFORMEE capabality */ |
| 1117 | if (pconfig->enableTxBF && !cfg->vht_su_bformee) |
| 1118 | pconfig->enableTxBF = cfg->vht_su_bformee; |
| 1119 | |
| 1120 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1121 | WNI_CFG_VHT_SU_BEAMFORMEE_CAP, |
| 1122 | pconfig->enableTxBF); |
| 1123 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1124 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1125 | hdd_alert("could not set VHT SU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1126 | } |
| 1127 | |
| 1128 | /* Get VHT MU Beamformer cap */ |
| 1129 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1130 | &value); |
| 1131 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1132 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1133 | hdd_err("could not get VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1134 | value = 0; |
| 1135 | } |
| 1136 | |
| 1137 | /* set VHT MU Beamformer cap */ |
| 1138 | if (value && !cfg->vht_mu_bformer) { |
| 1139 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1140 | WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1141 | cfg->vht_mu_bformer); |
| 1142 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1143 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1144 | hdd_alert("could not set the VHT MU BEAMFORMER CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1145 | } |
| 1146 | } |
| 1147 | |
| 1148 | /* Get VHT MU Beamformee cap */ |
| 1149 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1150 | &value); |
| 1151 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1152 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1153 | hdd_err("could not get VHT MU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1154 | value = 0; |
| 1155 | } |
| 1156 | |
| 1157 | /* set VHT MU Beamformee cap */ |
| 1158 | if (value && !cfg->vht_mu_bformee) { |
| 1159 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1160 | WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1161 | cfg->vht_mu_bformee); |
| 1162 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1163 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1164 | hdd_alert("could not set VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1165 | } |
| 1166 | } |
| 1167 | |
| 1168 | /* Get VHT MAX AMPDU Len exp */ |
| 1169 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1170 | &value); |
| 1171 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1172 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1173 | hdd_err("could not get VHT AMPDU LEN"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1174 | value = 0; |
| 1175 | } |
| 1176 | |
| 1177 | /* |
| 1178 | * VHT max AMPDU len exp: |
| 1179 | * override if user configured value is too high |
| 1180 | * that the target cannot support. |
| 1181 | * Even though Rome publish ampdu_len=7, it can |
| 1182 | * only support 4 because of some h/w bug. |
| 1183 | */ |
| 1184 | |
| 1185 | if (value > cfg->vht_max_ampdu_len_exp) { |
| 1186 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1187 | WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1188 | cfg->vht_max_ampdu_len_exp); |
| 1189 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1190 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1191 | hdd_alert("could not set the VHT AMPDU LEN EXP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1192 | } |
| 1193 | } |
| 1194 | |
| 1195 | /* Get VHT TXOP PS CAP */ |
| 1196 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, &value); |
| 1197 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1198 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1199 | hdd_err("could not get VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1200 | value = 0; |
| 1201 | } |
| 1202 | |
| 1203 | /* set VHT TXOP PS cap */ |
| 1204 | if (value && !cfg->vht_txop_ps) { |
| 1205 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, |
| 1206 | cfg->vht_txop_ps); |
| 1207 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1208 | if (status == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1209 | hdd_alert("could not set the VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1210 | } |
| 1211 | } |
| 1212 | |
| 1213 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1214 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1215 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1216 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1217 | else |
| 1218 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1219 | |
| 1220 | |
Amar Singhal | 90aaa6a | 2016-03-01 16:53:37 -0800 | [diff] [blame] | 1221 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1222 | band_5g->vht_cap.cap |= |
| 1223 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Amar Singhal | 90aaa6a | 2016-03-01 16:53:37 -0800 | [diff] [blame] | 1224 | else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1225 | band_5g->vht_cap.cap |= |
| 1226 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1227 | |
| 1228 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) |
| 1229 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1230 | |
| 1231 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1232 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1233 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1234 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1235 | |
| 1236 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1237 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1238 | |
| 1239 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1240 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1241 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1242 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1243 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1244 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1245 | |
| 1246 | band_5g->vht_cap.cap |= |
| 1247 | (cfg->vht_max_ampdu_len_exp << |
| 1248 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1249 | |
| 1250 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1251 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1252 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1253 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1254 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1255 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1256 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1257 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1258 | |
| 1259 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1260 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1261 | |
| 1262 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1263 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1264 | /** |
| 1265 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1266 | * @hdd_ctx: Pointer to the HDD context |
| 1267 | * |
| 1268 | * Auto-generate mac address using device serial number. |
| 1269 | * Keep the first 3 bytes of OUI as before and replace |
| 1270 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1271 | * |
| 1272 | * Return: 0 for success |
| 1273 | * Non zero failure code for errors |
| 1274 | */ |
| 1275 | static int hdd_generate_macaddr_auto(hdd_context_t *hdd_ctx) |
| 1276 | { |
| 1277 | unsigned int serialno = 0; |
| 1278 | struct qdf_mac_addr mac_addr = { |
| 1279 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1280 | }; |
| 1281 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1282 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1283 | if (serialno == 0) |
| 1284 | return -EINVAL; |
| 1285 | |
| 1286 | serialno &= 0x00ffffff; |
| 1287 | |
| 1288 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1289 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1290 | mac_addr.bytes[5] = serialno & 0xff; |
| 1291 | |
| 1292 | hdd_update_macaddr(hdd_ctx->config, mac_addr); |
| 1293 | return 0; |
| 1294 | } |
| 1295 | |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1296 | /** |
| 1297 | * hdd_update_ra_rate_limit() - Update RA rate limit from target |
| 1298 | * configuration to cfg_ini in HDD |
| 1299 | * @hdd_ctx: Pointer to hdd_ctx |
| 1300 | * @cfg: target configuration |
| 1301 | * |
| 1302 | * Return: None |
| 1303 | */ |
| 1304 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 1305 | static void hdd_update_ra_rate_limit(hdd_context_t *hdd_ctx, |
| 1306 | struct wma_tgt_cfg *cfg) |
| 1307 | { |
| 1308 | hdd_ctx->config->IsRArateLimitEnabled = cfg->is_ra_rate_limit_enabled; |
| 1309 | } |
| 1310 | #else |
| 1311 | static void hdd_update_ra_rate_limit(hdd_context_t *hdd_ctx, |
| 1312 | struct wma_tgt_cfg *cfg) |
| 1313 | { |
| 1314 | } |
| 1315 | #endif |
| 1316 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1317 | void hdd_update_tgt_cfg(void *context, void *param) |
| 1318 | { |
| 1319 | hdd_context_t *hdd_ctx = (hdd_context_t *) context; |
| 1320 | struct wma_tgt_cfg *cfg = param; |
| 1321 | uint8_t temp_band_cap; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1322 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1323 | QDF_STATUS qdf_status; |
| 1324 | |
| 1325 | qdf_status = hdd_create_and_store_pdev(hdd_ctx); |
| 1326 | if (QDF_IS_STATUS_ERROR(qdf_status)) { |
| 1327 | hdd_err("Pdev creation fails!"); |
| 1328 | QDF_BUG(0); |
| 1329 | } |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1330 | |
| 1331 | if (cds_cfg) { |
| 1332 | if (hdd_ctx->config->enable_sub_20_channel_width != |
| 1333 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
| 1334 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1335 | cds_cfg->sub_20_channel_width = |
| 1336 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1337 | } else { |
| 1338 | cds_cfg->sub_20_channel_width = |
| 1339 | hdd_ctx->config->enable_sub_20_channel_width; |
| 1340 | } |
| 1341 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1342 | |
| 1343 | /* first store the INI band capability */ |
| 1344 | temp_band_cap = hdd_ctx->config->nBandCapability; |
| 1345 | |
| 1346 | hdd_ctx->config->nBandCapability = cfg->band_cap; |
| 1347 | |
| 1348 | /* now overwrite the target band capability with INI |
| 1349 | setting if INI setting is a subset */ |
| 1350 | |
| 1351 | if ((hdd_ctx->config->nBandCapability == eCSR_BAND_ALL) && |
| 1352 | (temp_band_cap != eCSR_BAND_ALL)) |
| 1353 | hdd_ctx->config->nBandCapability = temp_band_cap; |
| 1354 | else if ((hdd_ctx->config->nBandCapability != eCSR_BAND_ALL) && |
| 1355 | (temp_band_cap != eCSR_BAND_ALL) && |
| 1356 | (hdd_ctx->config->nBandCapability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1357 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1358 | } |
| 1359 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 1360 | if (!cds_is_driver_recovering()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1361 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 1362 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 1363 | } |
| 1364 | |
| 1365 | /* This can be extended to other configurations like ht, vht cap... */ |
| 1366 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 1367 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1368 | hdd_update_macaddr(hdd_ctx->config, cfg->hw_macaddr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1369 | hdd_ctx->update_mac_addr_to_fw = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1370 | } else { |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1371 | static struct qdf_mac_addr default_mac_addr = { |
| 1372 | {0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF} |
| 1373 | }; |
| 1374 | if (qdf_is_macaddr_equal(&hdd_ctx->config->intfMacAddr[0], |
| 1375 | &default_mac_addr)) { |
| 1376 | if (hdd_generate_macaddr_auto(hdd_ctx) != 0) |
| 1377 | hdd_err("Fail to auto-generate MAC, using MAC from ini file " |
| 1378 | MAC_ADDRESS_STR, |
| 1379 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1380 | intfMacAddr[0].bytes)); |
| 1381 | } else { |
| 1382 | hdd_err("Invalid MAC passed from target, using MAC from ini file " |
| 1383 | MAC_ADDRESS_STR, |
| 1384 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1385 | intfMacAddr[0].bytes)); |
| 1386 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1387 | hdd_ctx->update_mac_addr_to_fw = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1388 | } |
| 1389 | |
| 1390 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 1391 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1392 | |
| 1393 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 1394 | |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 1395 | hdd_lpass_target_config(hdd_ctx, cfg); |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 1396 | hdd_green_ap_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1397 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1398 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 1399 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 1400 | |
| 1401 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 1402 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1403 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1404 | |
| 1405 | hdd_update_vdev_nss(hdd_ctx); |
| 1406 | |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1407 | hdd_ctx->config->fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 1408 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1409 | hdd_info("fine_time_meas_cap: 0x%x", |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1410 | hdd_ctx->config->fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1411 | |
| 1412 | hdd_ctx->current_antenna_mode = |
| 1413 | (hdd_ctx->config->enable2x2 == 0x01) ? |
| 1414 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 1415 | hdd_info("Init current antenna mode: %d", |
| 1416 | hdd_ctx->current_antenna_mode); |
| 1417 | |
Rajeev Kumar | dd3bc60 | 2016-08-16 14:21:05 -0700 | [diff] [blame] | 1418 | hdd_info("Target BPF %d Host BPF %d", |
| 1419 | cfg->bpf_enabled, hdd_ctx->config->bpf_packet_filter_enable); |
| 1420 | hdd_ctx->bpf_enabled = (cfg->bpf_enabled && |
| 1421 | hdd_ctx->config->bpf_packet_filter_enable); |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1422 | hdd_update_ra_rate_limit(hdd_ctx, cfg); |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1423 | |
Arun Khandavalli | d454d42 | 2016-08-17 12:47:05 +0530 | [diff] [blame] | 1424 | /* |
| 1425 | * If BPF is enabled, maxWowFilters set to WMA_STA_WOW_DEFAULT_PTRN_MAX |
| 1426 | * because we need atleast WMA_STA_WOW_DEFAULT_PTRN_MAX free slots to |
| 1427 | * configure the STA mode wow pattern. |
| 1428 | */ |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1429 | if (hdd_ctx->bpf_enabled) |
Arun Khandavalli | d454d42 | 2016-08-17 12:47:05 +0530 | [diff] [blame] | 1430 | hdd_ctx->config->maxWoWFilters = WMA_STA_WOW_DEFAULT_PTRN_MAX; |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1431 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 1432 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 1433 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 1434 | /* Configure NAN datapath features */ |
| 1435 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1436 | } |
| 1437 | |
| 1438 | /** |
| 1439 | * hdd_dfs_indicate_radar() - handle radar detection on current SAP channel |
| 1440 | * @context: HDD context pointer |
| 1441 | * @param: HDD radar indication pointer |
| 1442 | * |
Sandeep Puligilla | a8d4eec | 2016-06-30 15:13:11 -0700 | [diff] [blame] | 1443 | * This function is invoked in atomic context when a radar |
| 1444 | * is found on the SAP current operating channel and Data Tx |
| 1445 | * from netif has to be stopped to honor the DFS regulations. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1446 | * Actions: Stop the netif Tx queues,Indicate Radar present |
| 1447 | * in HDD context for future usage. |
| 1448 | * |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1449 | * Return: true to allow radar indication to host else false |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1450 | */ |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1451 | bool hdd_dfs_indicate_radar(void *context, void *param) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1452 | { |
| 1453 | hdd_context_t *hdd_ctx = (hdd_context_t *) context; |
| 1454 | struct wma_dfs_radar_ind *hdd_radar_event = |
| 1455 | (struct wma_dfs_radar_ind *)param; |
| 1456 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 1457 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1458 | QDF_STATUS status; |
Manishekar Chandrasekaran | 11ecd55 | 2016-08-31 12:44:05 +0530 | [diff] [blame] | 1459 | hdd_ap_ctx_t *ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1460 | |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1461 | if (!hdd_ctx || !hdd_radar_event || |
| 1462 | hdd_ctx->config->disableDFSChSwitch) |
| 1463 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1464 | |
| 1465 | if (true == hdd_radar_event->dfs_radar_status) { |
Arif Hussain | 2a7c1f3 | 2016-07-18 14:24:36 -0700 | [diff] [blame] | 1466 | if (qdf_atomic_inc_return(&hdd_ctx->dfs_radar_found) > 1) { |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1467 | /* |
| 1468 | * Application already triggered channel switch |
| 1469 | * on current channel, so return here. |
| 1470 | */ |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1471 | return false; |
| 1472 | } |
| 1473 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1474 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1475 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1476 | adapter = adapterNode->pAdapter; |
Manishekar Chandrasekaran | 11ecd55 | 2016-08-31 12:44:05 +0530 | [diff] [blame] | 1477 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 1478 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 1479 | QDF_P2P_GO_MODE == adapter->device_mode) && |
| 1480 | (CHANNEL_STATE_DFS == |
| 1481 | cds_get_channel_state(ap_ctx->operatingChannel))) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1482 | WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
| 1483 | dfs_cac_block_tx = true; |
Manishekar Chandrasekaran | 11ecd55 | 2016-08-31 12:44:05 +0530 | [diff] [blame] | 1484 | hdd_info("tx blocked for session:%d", |
| 1485 | adapter->sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1486 | } |
| 1487 | |
| 1488 | status = hdd_get_next_adapter(hdd_ctx, |
| 1489 | adapterNode, |
| 1490 | &pNext); |
| 1491 | adapterNode = pNext; |
| 1492 | } |
| 1493 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1494 | |
| 1495 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1496 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1497 | |
| 1498 | /** |
| 1499 | * hdd_is_valid_mac_address() - validate MAC address |
| 1500 | * @pMacAddr: Pointer to the input MAC address |
| 1501 | * |
| 1502 | * This function validates whether the given MAC address is valid or not |
| 1503 | * Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 1504 | * where X is the hexa decimal digit character and separated by ':' |
| 1505 | * This algorithm works even if MAC address is not separated by ':' |
| 1506 | * |
| 1507 | * This code checks given input string mac contains exactly 12 hexadecimal |
| 1508 | * digits and a separator colon : appears in the input string only after |
| 1509 | * an even number of hex digits. |
| 1510 | * |
| 1511 | * Return: 1 for valid and 0 for invalid |
| 1512 | */ |
| 1513 | bool hdd_is_valid_mac_address(const uint8_t *pMacAddr) |
| 1514 | { |
| 1515 | int xdigit = 0; |
| 1516 | int separator = 0; |
| 1517 | while (*pMacAddr) { |
| 1518 | if (isxdigit(*pMacAddr)) { |
| 1519 | xdigit++; |
| 1520 | } else if (':' == *pMacAddr) { |
| 1521 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 1522 | break; |
| 1523 | |
| 1524 | ++separator; |
| 1525 | } else { |
| 1526 | /* Invalid MAC found */ |
| 1527 | return 0; |
| 1528 | } |
| 1529 | ++pMacAddr; |
| 1530 | } |
| 1531 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 1532 | } |
| 1533 | |
| 1534 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 1535 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 1536 | * @dev: Handle to struct net_device to be updated. |
| 1537 | * |
| 1538 | * Return: None |
| 1539 | */ |
| 1540 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 1541 | { |
| 1542 | dev->header_ops = NULL; |
| 1543 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 1544 | dev->hard_header_len = ETH_HLEN; |
| 1545 | dev->mtu = ETH_DATA_LEN; |
| 1546 | dev->addr_len = ETH_ALEN; |
| 1547 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 1548 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 1549 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 1550 | |
| 1551 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 1552 | } |
| 1553 | |
| 1554 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1555 | * __hdd__mon_open() - HDD Open function |
| 1556 | * @dev: Pointer to net_device structure |
| 1557 | * |
| 1558 | * This is called in response to ifconfig up |
| 1559 | * |
| 1560 | * Return: 0 for success; non-zero for failure |
| 1561 | */ |
| 1562 | static int __hdd_mon_open(struct net_device *dev) |
| 1563 | { |
| 1564 | int ret; |
| 1565 | |
| 1566 | ENTER_DEV(dev); |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 1567 | hdd_mon_mode_ether_setup(dev); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1568 | ret = hdd_set_mon_rx_cb(dev); |
| 1569 | return ret; |
| 1570 | } |
| 1571 | |
| 1572 | /** |
| 1573 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 1574 | * @dev: Pointer to net_device structure |
| 1575 | * |
| 1576 | * This is called in response to ifconfig up |
| 1577 | * |
| 1578 | * Return: 0 for success; non-zero for failure |
| 1579 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 1580 | static int hdd_mon_open(struct net_device *dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1581 | { |
| 1582 | int ret; |
| 1583 | |
| 1584 | cds_ssr_protect(__func__); |
| 1585 | ret = __hdd_mon_open(dev); |
| 1586 | cds_ssr_unprotect(__func__); |
| 1587 | |
| 1588 | return ret; |
| 1589 | } |
| 1590 | |
| 1591 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1592 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 1593 | * @adapter: pointer to HDD adapter |
| 1594 | * |
| 1595 | * This function is called to start the device specific adapter for |
| 1596 | * the mode passed in the adapter's device_mode. |
| 1597 | * |
| 1598 | * Return: 0 for success; non-zero for failure |
| 1599 | */ |
| 1600 | int hdd_start_adapter(hdd_adapter_t *adapter) |
| 1601 | { |
| 1602 | |
| 1603 | int ret; |
| 1604 | enum tQDF_ADAPTER_MODE device_mode = adapter->device_mode; |
| 1605 | |
| 1606 | ENTER_DEV(adapter->dev); |
| 1607 | hdd_info("Start_adapter for mode : %d", adapter->device_mode); |
| 1608 | |
| 1609 | switch (device_mode) { |
| 1610 | case QDF_P2P_CLIENT_MODE: |
| 1611 | case QDF_P2P_DEVICE_MODE: |
| 1612 | case QDF_OCB_MODE: |
| 1613 | case QDF_STA_MODE: |
| 1614 | case QDF_MONITOR_MODE: |
| 1615 | ret = hdd_start_station_adapter(adapter); |
| 1616 | if (ret) |
| 1617 | goto err_start_adapter; |
| 1618 | break; |
| 1619 | case QDF_P2P_GO_MODE: |
| 1620 | case QDF_SAP_MODE: |
| 1621 | ret = hdd_start_ap_adapter(adapter); |
| 1622 | if (ret) |
| 1623 | goto err_start_adapter; |
| 1624 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 1625 | case QDF_IBSS_MODE: |
| 1626 | /* |
| 1627 | * For IBSS interface is initialized as part of |
| 1628 | * hdd_init_station_mode() |
| 1629 | */ |
| 1630 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1631 | case QDF_FTM_MODE: |
| 1632 | ret = hdd_start_ftm_adapter(adapter); |
| 1633 | if (ret) |
| 1634 | goto err_start_adapter; |
| 1635 | break; |
| 1636 | default: |
| 1637 | hdd_err("Invalid session type %d", device_mode); |
| 1638 | QDF_ASSERT(0); |
| 1639 | goto err_start_adapter; |
| 1640 | } |
| 1641 | if (hdd_set_fw_params(adapter)) |
| 1642 | hdd_err("Failed to set the FW params for the adapter!"); |
| 1643 | |
| 1644 | /* |
| 1645 | * Action frame registered in one adapter which will |
| 1646 | * applicable to all interfaces |
| 1647 | */ |
| 1648 | wlan_hdd_cfg80211_register_frames(adapter); |
| 1649 | EXIT(); |
| 1650 | return 0; |
| 1651 | err_start_adapter: |
| 1652 | return -EINVAL; |
| 1653 | } |
| 1654 | |
| 1655 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 1656 | * hdd_enable_power_management() - API to Enable Power Management |
| 1657 | * |
| 1658 | * API invokes Bus Interface Layer power management functionality |
| 1659 | * |
| 1660 | * Return: None |
| 1661 | */ |
| 1662 | static void hdd_enable_power_management(void) |
| 1663 | { |
| 1664 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 1665 | |
| 1666 | if (!hif_ctx) { |
| 1667 | hdd_err("Bus Interface Context is Invalid"); |
| 1668 | return; |
| 1669 | } |
| 1670 | |
| 1671 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 1672 | } |
| 1673 | |
| 1674 | /** |
| 1675 | * hdd_disable_power_management() - API to disable Power Management |
| 1676 | * |
| 1677 | * API disable Bus Interface Layer Power management functionality |
| 1678 | * |
| 1679 | * Return: None |
| 1680 | */ |
| 1681 | static void hdd_disable_power_management(void) |
| 1682 | { |
| 1683 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 1684 | |
| 1685 | if (!hif_ctx) { |
| 1686 | hdd_err("Bus Interface Context is Invalid"); |
| 1687 | return; |
| 1688 | } |
| 1689 | |
| 1690 | hif_disable_power_management(hif_ctx); |
| 1691 | } |
| 1692 | |
| 1693 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1694 | * hdd_wlan_start_modules() - Single driver state machine for starting modules |
| 1695 | * @hdd_ctx: HDD context |
| 1696 | * @adapter: HDD adapter |
| 1697 | * @reinit: flag to indicate from SSR or normal path |
| 1698 | * |
| 1699 | * This function maintains the driver state machine it will be invoked from |
| 1700 | * startup, reinit and change interface. Depending on the driver state shall |
| 1701 | * perform the opening of the modules. |
| 1702 | * |
| 1703 | * Return: 0 for success; non-zero for failure |
| 1704 | */ |
| 1705 | int hdd_wlan_start_modules(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, |
| 1706 | bool reinit) |
| 1707 | { |
| 1708 | int ret; |
| 1709 | qdf_device_t qdf_dev; |
| 1710 | QDF_STATUS status; |
| 1711 | p_cds_contextType p_cds_context; |
| 1712 | bool unint = false; |
| 1713 | void *hif_ctx; |
| 1714 | |
| 1715 | ENTER(); |
| 1716 | |
| 1717 | p_cds_context = cds_get_global_context(); |
| 1718 | if (!p_cds_context) { |
| 1719 | hdd_err("Global Context is NULL"); |
| 1720 | QDF_ASSERT(0); |
| 1721 | return -EINVAL; |
| 1722 | } |
| 1723 | |
| 1724 | hdd_info("start modules called in state! :%d reinit: %d", |
| 1725 | hdd_ctx->driver_status, reinit); |
| 1726 | |
| 1727 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 1728 | if (!qdf_dev) { |
| 1729 | hdd_err("QDF Device Context is Invalid return"); |
| 1730 | return -EINVAL; |
| 1731 | } |
| 1732 | |
| 1733 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 1734 | hdd_ctx->start_modules_in_progress = true; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1735 | |
| 1736 | if (QDF_TIMER_STATE_RUNNING == |
| 1737 | qdf_mc_timer_get_current_state(&hdd_ctx->iface_change_timer)) { |
| 1738 | |
| 1739 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 1740 | hdd_info("Interface change Timer running Stop timer"); |
| 1741 | qdf_mc_timer_stop(&hdd_ctx->iface_change_timer); |
| 1742 | } |
| 1743 | |
| 1744 | switch (hdd_ctx->driver_status) { |
| 1745 | case DRIVER_MODULES_UNINITIALIZED: |
| 1746 | unint = true; |
| 1747 | /* Fall through dont add break here */ |
| 1748 | case DRIVER_MODULES_CLOSED: |
| 1749 | if (!reinit && !unint) { |
| 1750 | ret = pld_power_on(qdf_dev->dev); |
| 1751 | if (ret) { |
| 1752 | hdd_err("Failed to Powerup the device: %d", ret); |
| 1753 | goto release_lock; |
| 1754 | } |
| 1755 | } |
| 1756 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 1757 | qdf_dev->bus_type, |
| 1758 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 1759 | HIF_ENABLE_TYPE_PROBE); |
| 1760 | if (ret) { |
| 1761 | hdd_err("Failed to open hif: %d", ret); |
| 1762 | goto power_down; |
| 1763 | } |
| 1764 | |
| 1765 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 1766 | if (!hif_ctx) { |
| 1767 | hdd_err("hif context is null!!"); |
| 1768 | goto power_down; |
| 1769 | } |
| 1770 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1771 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 1772 | if (status != QDF_STATUS_SUCCESS) { |
| 1773 | hdd_err("No Memory to Create BMI Context :%d", status); |
| 1774 | goto hif_close; |
| 1775 | } |
| 1776 | |
Arun Khandavalli | f624663 | 2016-08-17 17:43:06 +0530 | [diff] [blame] | 1777 | ret = hdd_update_config(hdd_ctx); |
| 1778 | if (ret) { |
| 1779 | hdd_err("Failed to update configuration :%d", ret); |
| 1780 | goto ol_cds_free; |
| 1781 | } |
| 1782 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1783 | status = hdd_create_and_store_psoc(hdd_ctx, DEFAULT_PSOC_ID); |
| 1784 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1785 | hdd_err("Psoc creation fails!"); |
| 1786 | goto ol_cds_free; |
| 1787 | } |
| 1788 | |
| 1789 | status = cds_open(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1790 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 1791 | hdd_err("Failed to Open CDS: %d", status); |
| 1792 | goto ol_cds_free; |
| 1793 | } |
| 1794 | |
| 1795 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
| 1796 | |
| 1797 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
| 1798 | |
| 1799 | status = cds_pre_enable(hdd_ctx->pcds_context); |
| 1800 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 1801 | hdd_err("Failed to pre-enable CDS: %d", status); |
| 1802 | goto close; |
| 1803 | } |
| 1804 | |
| 1805 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 1806 | sme_register_ftm_msg_processor(hdd_ctx->hHal, |
| 1807 | hdd_ftm_mc_process_msg); |
| 1808 | break; |
| 1809 | } |
| 1810 | if (unint) { |
| 1811 | hdd_info("In phase-1 initialization don't enable modules"); |
| 1812 | break; |
| 1813 | } |
| 1814 | /* Fall through dont add break here */ |
| 1815 | case DRIVER_MODULES_OPENED: |
| 1816 | if (!adapter) { |
| 1817 | hdd_alert("adapter is Null"); |
| 1818 | goto close; |
| 1819 | } |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 1820 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 1821 | hdd_err("in ftm mode, no need to configure cds modules"); |
| 1822 | break; |
| 1823 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1824 | if (hdd_configure_cds(hdd_ctx, adapter)) { |
| 1825 | hdd_err("Failed to Enable cds modules"); |
| 1826 | goto close; |
| 1827 | } |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 1828 | hdd_enable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1829 | hdd_info("Driver Modules Successfully Enabled"); |
| 1830 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
| 1831 | break; |
| 1832 | case DRIVER_MODULES_ENABLED: |
| 1833 | hdd_info("Driver modules already Enabled"); |
| 1834 | break; |
| 1835 | default: |
| 1836 | hdd_err("WLAN start invoked in wrong state! :%d\n", |
| 1837 | hdd_ctx->driver_status); |
| 1838 | goto release_lock; |
| 1839 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 1840 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1841 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 1842 | EXIT(); |
| 1843 | return 0; |
| 1844 | |
| 1845 | close: |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1846 | cds_close(hdd_ctx->hdd_psoc, p_cds_context); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1847 | |
| 1848 | ol_cds_free: |
| 1849 | ol_cds_free(); |
| 1850 | |
| 1851 | hif_close: |
| 1852 | hdd_hif_close(p_cds_context->pHIFContext); |
| 1853 | power_down: |
| 1854 | if (!reinit && !unint) |
| 1855 | pld_power_off(qdf_dev->dev); |
| 1856 | release_lock: |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 1857 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1858 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 1859 | EXIT(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1860 | return -EINVAL; |
| 1861 | } |
| 1862 | |
| 1863 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1864 | * __hdd_open() - HDD Open function |
| 1865 | * @dev: Pointer to net_device structure |
| 1866 | * |
| 1867 | * This is called in response to ifconfig up |
| 1868 | * |
| 1869 | * Return: 0 for success; non-zero for failure |
| 1870 | */ |
| 1871 | static int __hdd_open(struct net_device *dev) |
| 1872 | { |
| 1873 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1874 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 1875 | int ret; |
| 1876 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 1877 | ENTER_DEV(dev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1878 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1879 | adapter->sessionId, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1880 | |
| 1881 | ret = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 1882 | if (ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1883 | return ret; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 1884 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1885 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1886 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 1887 | if (ret) { |
| 1888 | hdd_err("Failed to start WLAN modules return"); |
| 1889 | return -ret; |
| 1890 | } |
| 1891 | |
| 1892 | |
| 1893 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 1894 | ret = hdd_start_adapter(adapter); |
| 1895 | if (ret) { |
| 1896 | hdd_err("Failed to start adapter :%d", |
| 1897 | adapter->device_mode); |
| 1898 | return ret; |
| 1899 | } |
| 1900 | } |
| 1901 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1902 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 1903 | if (hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1904 | hdd_info("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1905 | /* Enable TX queues only when we are connected */ |
| 1906 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1907 | WLAN_START_ALL_NETIF_QUEUE, |
| 1908 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1909 | } |
| 1910 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 1911 | /* Enable carrier and transmit queues for NDI */ |
| 1912 | if (WLAN_HDD_IS_NDI(adapter)) { |
| 1913 | hdd_notice("Enabling Tx Queues"); |
| 1914 | wlan_hdd_netif_queue_control(adapter, |
| 1915 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 1916 | WLAN_CONTROL_PATH); |
| 1917 | } |
| 1918 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1919 | return ret; |
| 1920 | } |
| 1921 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1922 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1923 | /** |
| 1924 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 1925 | * @dev: Pointer to net_device structure |
| 1926 | * |
| 1927 | * This is called in response to ifconfig up |
| 1928 | * |
| 1929 | * Return: 0 for success; non-zero for failure |
| 1930 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 1931 | static int hdd_open(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1932 | { |
| 1933 | int ret; |
| 1934 | |
| 1935 | cds_ssr_protect(__func__); |
| 1936 | ret = __hdd_open(dev); |
| 1937 | cds_ssr_unprotect(__func__); |
| 1938 | |
| 1939 | return ret; |
| 1940 | } |
| 1941 | |
| 1942 | /** |
| 1943 | * __hdd_stop() - HDD stop function |
| 1944 | * @dev: Pointer to net_device structure |
| 1945 | * |
| 1946 | * This is called in response to ifconfig down |
| 1947 | * |
| 1948 | * Return: 0 for success; non-zero for failure |
| 1949 | */ |
| 1950 | static int __hdd_stop(struct net_device *dev) |
| 1951 | { |
| 1952 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1953 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1954 | hdd_adapter_list_node_t *adapternode = NULL, *next = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1955 | int ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1956 | bool close_modules = true; |
| 1957 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1958 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 1959 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1960 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1961 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1962 | adapter->sessionId, adapter->device_mode)); |
| 1963 | |
| 1964 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 1965 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1966 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1967 | |
| 1968 | /* Nothing to be done if the interface is not opened */ |
| 1969 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 1970 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1971 | return -ENODEV; |
| 1972 | } |
| 1973 | |
| 1974 | /* Make sure the interface is marked as closed */ |
| 1975 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 1976 | hdd_notice("Disabling OS Tx queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1977 | |
| 1978 | /* |
| 1979 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 1980 | * be called on that interface |
| 1981 | */ |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 1982 | hdd_notice("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1983 | wlan_hdd_netif_queue_control(adapter, WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 1984 | WLAN_CONTROL_PATH); |
| 1985 | |
| 1986 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 1987 | * NAN data interface is different in some sense. The traffic on NDI is |
| 1988 | * bursty in nature and depends on the need to transfer. The service |
| 1989 | * layer may down the interface after the usage and up again when |
| 1990 | * required. In some sense, the NDI is expected to be available |
| 1991 | * (like SAP) iface until NDI delete request is issued by the service |
| 1992 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 1993 | * interface (NDI). |
| 1994 | */ |
| 1995 | if (WLAN_HDD_IS_NDI(adapter)) |
| 1996 | return 0; |
| 1997 | |
| 1998 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1999 | * The interface is marked as down for outside world (aka kernel) |
| 2000 | * But the driver is pretty much alive inside. The driver needs to |
| 2001 | * tear down the existing connection on the netdev (session) |
| 2002 | * cleanup the data pipes and wait until the control plane is stabilized |
| 2003 | * for this interface. The call also needs to wait until the above |
| 2004 | * mentioned actions are completed before returning to the caller. |
| 2005 | * Notice that the hdd_stop_adapter is requested not to close the session |
| 2006 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 2007 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2008 | hdd_stop_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2009 | |
| 2010 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 2011 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 2012 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2013 | |
| 2014 | /* |
| 2015 | * Find if any iface is up. If any iface is up then can't put device to |
| 2016 | * sleep/power save mode |
| 2017 | */ |
| 2018 | status = hdd_get_front_adapter(hdd_ctx, &adapternode); |
| 2019 | while ((NULL != adapternode) && (QDF_STATUS_SUCCESS == status)) { |
| 2020 | if (test_bit(DEVICE_IFACE_OPENED, |
| 2021 | &adapternode->pAdapter->event_flags)) { |
| 2022 | hdd_info("Still other ifaces are up cannot close modules"); |
| 2023 | close_modules = false; |
| 2024 | break; |
| 2025 | } |
| 2026 | status = hdd_get_next_adapter(hdd_ctx, adapternode, &next); |
| 2027 | adapternode = next; |
| 2028 | |
| 2029 | } |
| 2030 | |
| 2031 | if (close_modules) { |
| 2032 | hdd_info("Closing all modules from the hdd_stop"); |
| 2033 | qdf_mc_timer_start(&hdd_ctx->iface_change_timer, |
| 2034 | hdd_ctx->config->iface_change_wait_time |
| 2035 | * 50000); |
| 2036 | } |
| 2037 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2038 | EXIT(); |
| 2039 | return 0; |
| 2040 | } |
| 2041 | |
| 2042 | /** |
| 2043 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 2044 | * @dev: pointer to net_device structure |
| 2045 | * |
| 2046 | * This is called in response to ifconfig down |
| 2047 | * |
| 2048 | * Return: 0 for success and error number for failure |
| 2049 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2050 | static int hdd_stop(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2051 | { |
| 2052 | int ret; |
| 2053 | |
| 2054 | cds_ssr_protect(__func__); |
| 2055 | ret = __hdd_stop(dev); |
| 2056 | cds_ssr_unprotect(__func__); |
| 2057 | |
| 2058 | return ret; |
| 2059 | } |
| 2060 | |
| 2061 | /** |
| 2062 | * __hdd_uninit() - HDD uninit function |
| 2063 | * @dev: Pointer to net_device structure |
| 2064 | * |
| 2065 | * This is called during the netdev unregister to uninitialize all data |
| 2066 | * associated with the device |
| 2067 | * |
| 2068 | * Return: None |
| 2069 | */ |
| 2070 | static void __hdd_uninit(struct net_device *dev) |
| 2071 | { |
| 2072 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2073 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2074 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2075 | |
| 2076 | do { |
| 2077 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2078 | hdd_alert("Invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2079 | break; |
| 2080 | } |
| 2081 | |
| 2082 | if (NULL == adapter->pHddCtx) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2083 | hdd_alert("NULL hdd_ctx"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2084 | break; |
| 2085 | } |
| 2086 | |
| 2087 | if (dev != adapter->dev) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2088 | hdd_alert("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2089 | /* |
| 2090 | * we haven't validated all cases so let this go for |
| 2091 | * now |
| 2092 | */ |
| 2093 | } |
| 2094 | |
| 2095 | hdd_deinit_adapter(adapter->pHddCtx, adapter, true); |
| 2096 | |
| 2097 | /* after uninit our adapter structure will no longer be valid */ |
| 2098 | adapter->dev = NULL; |
| 2099 | adapter->magic = 0; |
| 2100 | } while (0); |
| 2101 | |
| 2102 | EXIT(); |
| 2103 | } |
| 2104 | |
| 2105 | /** |
| 2106 | * hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 2107 | * @dev: pointer to net_device structure |
| 2108 | * |
| 2109 | * This is called during the netdev unregister to uninitialize all data |
| 2110 | * associated with the device |
| 2111 | * |
| 2112 | * Return: none |
| 2113 | */ |
| 2114 | static void hdd_uninit(struct net_device *dev) |
| 2115 | { |
| 2116 | cds_ssr_protect(__func__); |
| 2117 | __hdd_uninit(dev); |
| 2118 | cds_ssr_unprotect(__func__); |
| 2119 | } |
| 2120 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2121 | static int hdd_open_cesium_nl_sock(void) |
| 2122 | { |
| 2123 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 2124 | struct netlink_kernel_cfg cfg = { |
| 2125 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 2126 | .input = NULL |
| 2127 | }; |
| 2128 | #endif |
| 2129 | int ret = 0; |
| 2130 | |
| 2131 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 2132 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 2133 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 2134 | THIS_MODULE, |
| 2135 | #endif |
| 2136 | &cfg); |
| 2137 | #else |
| 2138 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 2139 | WLAN_NLINK_MCAST_GRP_ID, |
| 2140 | NULL, NULL, THIS_MODULE); |
| 2141 | #endif |
| 2142 | |
| 2143 | if (cesium_nl_srv_sock == NULL) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2144 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2145 | ret = -ECONNREFUSED; |
| 2146 | } |
| 2147 | |
| 2148 | return ret; |
| 2149 | } |
| 2150 | |
| 2151 | static void hdd_close_cesium_nl_sock(void) |
| 2152 | { |
| 2153 | if (NULL != cesium_nl_srv_sock) { |
| 2154 | netlink_kernel_release(cesium_nl_srv_sock); |
| 2155 | cesium_nl_srv_sock = NULL; |
| 2156 | } |
| 2157 | } |
| 2158 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2159 | /** |
| 2160 | * __hdd_set_mac_address() - set the user specified mac address |
| 2161 | * @dev: Pointer to the net device. |
| 2162 | * @addr: Pointer to the sockaddr. |
| 2163 | * |
| 2164 | * This function sets the user specified mac address using |
| 2165 | * the command ifconfig wlanX hw ether <mac adress>. |
| 2166 | * |
| 2167 | * Return: 0 for success, non zero for failure |
| 2168 | */ |
| 2169 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 2170 | { |
| 2171 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2172 | hdd_context_t *hdd_ctx; |
| 2173 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2174 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2175 | int ret; |
| 2176 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2177 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2178 | |
| 2179 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2180 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2181 | if (0 != ret) |
| 2182 | return ret; |
| 2183 | |
| 2184 | memcpy(&adapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN); |
| 2185 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 2186 | |
| 2187 | EXIT(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2188 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2189 | } |
| 2190 | |
| 2191 | /** |
| 2192 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
| 2193 | * function from SSR |
| 2194 | * @dev: pointer to net_device structure |
| 2195 | * @addr: Pointer to the sockaddr |
| 2196 | * |
| 2197 | * This function sets the user specified mac address using |
| 2198 | * the command ifconfig wlanX hw ether <mac adress>. |
| 2199 | * |
| 2200 | * Return: 0 for success. |
| 2201 | */ |
| 2202 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 2203 | { |
| 2204 | int ret; |
| 2205 | |
| 2206 | cds_ssr_protect(__func__); |
| 2207 | ret = __hdd_set_mac_address(dev, addr); |
| 2208 | cds_ssr_unprotect(__func__); |
| 2209 | |
| 2210 | return ret; |
| 2211 | } |
| 2212 | |
| 2213 | uint8_t *wlan_hdd_get_intf_addr(hdd_context_t *hdd_ctx) |
| 2214 | { |
| 2215 | int i; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2216 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2217 | if (0 == ((hdd_ctx->config->intfAddrMask) & (1 << i))) |
| 2218 | break; |
| 2219 | } |
| 2220 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2221 | if (QDF_MAX_CONCURRENCY_PERSONA == i) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2222 | return NULL; |
| 2223 | |
| 2224 | hdd_ctx->config->intfAddrMask |= (1 << i); |
| 2225 | return &hdd_ctx->config->intfMacAddr[i].bytes[0]; |
| 2226 | } |
| 2227 | |
| 2228 | void wlan_hdd_release_intf_addr(hdd_context_t *hdd_ctx, uint8_t *releaseAddr) |
| 2229 | { |
| 2230 | int i; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2231 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2232 | if (!memcmp(releaseAddr, |
| 2233 | &hdd_ctx->config->intfMacAddr[i].bytes[0], |
| 2234 | 6)) { |
| 2235 | hdd_ctx->config->intfAddrMask &= ~(1 << i); |
| 2236 | break; |
| 2237 | } |
| 2238 | } |
| 2239 | return; |
| 2240 | } |
| 2241 | |
| 2242 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 2243 | /** |
| 2244 | * __hdd_set_multicast_list() - set the multicast address list |
| 2245 | * @dev: Pointer to the WLAN device. |
| 2246 | * @skb: Pointer to OS packet (sk_buff). |
| 2247 | * |
| 2248 | * This funciton sets the multicast address list. |
| 2249 | * |
| 2250 | * Return: None |
| 2251 | */ |
| 2252 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 2253 | { |
| 2254 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2255 | int mc_count; |
| 2256 | int i = 0, status; |
| 2257 | struct netdev_hw_addr *ha; |
| 2258 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2259 | static const uint8_t ipv6_router_solicitation[] |
| 2260 | = {0x33, 0x33, 0x00, 0x00, 0x00, 0x02}; |
| 2261 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2262 | ENTER_DEV(dev); |
| 2263 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2264 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 2265 | return; |
| 2266 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2267 | status = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 2268 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2269 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2270 | |
| 2271 | if (dev->flags & IFF_ALLMULTI) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2272 | hdd_notice("allow all multicast frames"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2273 | adapter->mc_addr_list.mc_cnt = 0; |
| 2274 | } else { |
| 2275 | mc_count = netdev_mc_count(dev); |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 2276 | hdd_notice("mc_count : %u", mc_count); |
| 2277 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2278 | if (mc_count > WLAN_HDD_MAX_MC_ADDR_LIST) { |
Dustin Brown | 6126946 | 2016-09-19 13:25:45 -0700 | [diff] [blame] | 2279 | hdd_notice("Exceeded max MC filter addresses (%d). Allowing all MC frames by disabling MC address filtering", |
| 2280 | WLAN_HDD_MAX_MC_ADDR_LIST); |
| 2281 | wlan_hdd_set_mc_addr_list(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2282 | adapter->mc_addr_list.mc_cnt = 0; |
| 2283 | return; |
| 2284 | } |
| 2285 | |
| 2286 | adapter->mc_addr_list.mc_cnt = mc_count; |
| 2287 | |
| 2288 | netdev_for_each_mc_addr(ha, dev) { |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 2289 | hdd_notice("ha_addr[%d] "MAC_ADDRESS_STR, |
| 2290 | i, MAC_ADDR_ARRAY(ha->addr)); |
| 2291 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2292 | if (i == mc_count) |
| 2293 | break; |
| 2294 | /* |
| 2295 | * Skip following addresses: |
| 2296 | * 1)IPv6 router solicitation address |
| 2297 | * 2)Any other address pattern if its set during |
| 2298 | * RXFILTER REMOVE driver command based on |
| 2299 | * addr_filter_pattern |
| 2300 | */ |
| 2301 | if ((!memcmp(ha->addr, ipv6_router_solicitation, |
| 2302 | ETH_ALEN)) || |
| 2303 | (adapter->addr_filter_pattern && (!memcmp(ha->addr, |
| 2304 | &adapter->addr_filter_pattern, 1)))) { |
Srinivas Girigowda | f2599dd | 2015-11-16 18:20:46 -0800 | [diff] [blame] | 2305 | hdd_info("MC/BC filtering Skip addr ="MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2306 | MAC_ADDR_ARRAY(ha->addr)); |
| 2307 | adapter->mc_addr_list.mc_cnt--; |
| 2308 | continue; |
| 2309 | } |
| 2310 | |
| 2311 | memset(&(adapter->mc_addr_list.addr[i][0]), 0, |
| 2312 | ETH_ALEN); |
| 2313 | memcpy(&(adapter->mc_addr_list.addr[i][0]), ha->addr, |
| 2314 | ETH_ALEN); |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2315 | hdd_notice("mlist[%d] = " MAC_ADDRESS_STR, i, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2316 | MAC_ADDR_ARRAY(adapter->mc_addr_list.addr[i])); |
| 2317 | i++; |
| 2318 | } |
| 2319 | } |
| 2320 | if (hdd_ctx->config->active_mode_offload) { |
| 2321 | hdd_info("enable mc filtering"); |
| 2322 | wlan_hdd_set_mc_addr_list(adapter, true); |
| 2323 | } else { |
| 2324 | hdd_info("skip mc filtering enable it during cfg80211 suspend"); |
| 2325 | } |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 2326 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2327 | return; |
| 2328 | } |
| 2329 | |
| 2330 | /** |
| 2331 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
| 2332 | * @dev: pointer to net_device |
| 2333 | * |
| 2334 | * Return: none |
| 2335 | */ |
| 2336 | static void hdd_set_multicast_list(struct net_device *dev) |
| 2337 | { |
| 2338 | cds_ssr_protect(__func__); |
| 2339 | __hdd_set_multicast_list(dev); |
| 2340 | cds_ssr_unprotect(__func__); |
| 2341 | } |
| 2342 | #endif |
| 2343 | |
| 2344 | /** |
| 2345 | * hdd_select_queue() - used by Linux OS to decide which queue to use first |
| 2346 | * @dev: Pointer to the WLAN device. |
| 2347 | * @skb: Pointer to OS packet (sk_buff). |
| 2348 | * |
| 2349 | * This function is registered with the Linux OS for network |
| 2350 | * core to decide which queue to use first. |
| 2351 | * |
| 2352 | * Return: ac, Queue Index/access category corresponding to UP in IP header |
| 2353 | */ |
| 2354 | static uint16_t hdd_select_queue(struct net_device *dev, struct sk_buff *skb |
| 2355 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) |
| 2356 | , void *accel_priv |
| 2357 | #endif |
| 2358 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 2359 | , select_queue_fallback_t fallback |
| 2360 | #endif |
| 2361 | ) |
| 2362 | { |
| 2363 | return hdd_wmm_select_queue(dev, skb); |
| 2364 | } |
| 2365 | |
| 2366 | static struct net_device_ops wlan_drv_ops = { |
| 2367 | .ndo_open = hdd_open, |
| 2368 | .ndo_stop = hdd_stop, |
| 2369 | .ndo_uninit = hdd_uninit, |
| 2370 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 2371 | .ndo_tx_timeout = hdd_tx_timeout, |
| 2372 | .ndo_get_stats = hdd_get_stats, |
| 2373 | .ndo_do_ioctl = hdd_ioctl, |
| 2374 | .ndo_set_mac_address = hdd_set_mac_address, |
| 2375 | .ndo_select_queue = hdd_select_queue, |
| 2376 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2377 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2378 | #endif |
| 2379 | }; |
| 2380 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2381 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
| 2382 | static struct net_device_ops wlan_mon_drv_ops = { |
| 2383 | .ndo_open = hdd_mon_open, |
| 2384 | .ndo_stop = hdd_stop, |
| 2385 | .ndo_get_stats = hdd_get_stats, |
| 2386 | }; |
| 2387 | |
| 2388 | /** |
| 2389 | * hdd_set_station_ops() - update net_device ops for monitor mode |
| 2390 | * @pWlanDev: Handle to struct net_device to be updated. |
| 2391 | * Return: None |
| 2392 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2393 | void hdd_set_station_ops(struct net_device *pWlanDev) |
| 2394 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2395 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
| 2396 | pWlanDev->netdev_ops = &wlan_mon_drv_ops; |
| 2397 | else |
| 2398 | pWlanDev->netdev_ops = &wlan_drv_ops; |
| 2399 | } |
| 2400 | |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 2401 | #ifdef FEATURE_RUNTIME_PM |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 2402 | /** |
| 2403 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 2404 | * @hdd_ctx: HDD context |
| 2405 | * |
| 2406 | * Return: None |
| 2407 | */ |
| 2408 | static void hdd_runtime_suspend_context_init(hdd_context_t *hdd_ctx) |
| 2409 | { |
| 2410 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 2411 | |
| 2412 | ctx->scan = qdf_runtime_lock_init("scan"); |
Komal Seelam | aa75f26 | 2016-09-29 12:32:13 +0530 | [diff] [blame] | 2413 | ctx->roc = qdf_runtime_lock_init("roc"); |
Komal Seelam | 81cb166 | 2016-09-29 12:39:08 +0530 | [diff] [blame] | 2414 | ctx->dfs = qdf_runtime_lock_init("dfs"); |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 2415 | } |
| 2416 | |
| 2417 | /** |
| 2418 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 2419 | * @hdd_ctx: HDD Context |
| 2420 | * |
| 2421 | * Return: None |
| 2422 | */ |
| 2423 | static void hdd_runtime_suspend_context_deinit(hdd_context_t *hdd_ctx) |
| 2424 | { |
| 2425 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 2426 | |
| 2427 | qdf_runtime_lock_deinit(ctx->scan); |
| 2428 | ctx->scan = NULL; |
Komal Seelam | aa75f26 | 2016-09-29 12:32:13 +0530 | [diff] [blame] | 2429 | qdf_runtime_lock_deinit(ctx->roc); |
| 2430 | ctx->roc = NULL; |
Komal Seelam | 81cb166 | 2016-09-29 12:39:08 +0530 | [diff] [blame] | 2431 | qdf_runtime_lock_deinit(ctx->dfs); |
| 2432 | ctx->dfs = NULL; |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 2433 | } |
| 2434 | |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 2435 | static void hdd_adapter_runtime_suspend_init(hdd_adapter_t *adapter) |
| 2436 | { |
| 2437 | struct hdd_connect_pm_context *ctx = &adapter->connect_rpm_ctx; |
| 2438 | |
| 2439 | ctx->connect = qdf_runtime_lock_init("connect"); |
| 2440 | } |
| 2441 | |
| 2442 | static void hdd_adapter_runtime_suspend_denit(hdd_adapter_t *adapter) |
| 2443 | { |
| 2444 | struct hdd_connect_pm_context *ctx = &adapter->connect_rpm_ctx; |
| 2445 | |
| 2446 | qdf_runtime_lock_deinit(ctx->connect); |
| 2447 | ctx->connect = NULL; |
| 2448 | } |
| 2449 | #else /* FEATURE_RUNTIME_PM */ |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 2450 | static void hdd_runtime_suspend_context_init(hdd_context_t *hdd_ctx) {} |
| 2451 | static void hdd_runtime_suspend_context_deinit(hdd_context_t *hdd_ctx) {} |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 2452 | static inline void hdd_adapter_runtime_suspend_init(hdd_adapter_t *adapter) {} |
| 2453 | static inline void hdd_adapter_runtime_suspend_denit(hdd_adapter_t *adapter) {} |
| 2454 | #endif /* FEATURE_RUNTIME_PM */ |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2455 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 2456 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 2457 | * @hdd_ctx: global hdd context |
| 2458 | * @macAddr: mac address to assign to the interface |
| 2459 | * @name: User-visible name of the interface |
| 2460 | * |
| 2461 | * hdd adapter pointer would point to the netdev->priv space, this function |
| 2462 | * would retrive the pointer, and setup the hdd adapter configuration. |
| 2463 | * |
| 2464 | * Return: the pointer to hdd adapter, otherwise NULL |
| 2465 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2466 | static hdd_adapter_t *hdd_alloc_station_adapter(hdd_context_t *hdd_ctx, |
| 2467 | tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 2468 | unsigned char name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2469 | const char *name) |
| 2470 | { |
| 2471 | struct net_device *pWlanDev = NULL; |
| 2472 | hdd_adapter_t *adapter = NULL; |
| 2473 | /* |
| 2474 | * cfg80211 initialization and registration.... |
| 2475 | */ |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 2476 | pWlanDev = alloc_netdev_mq(sizeof(hdd_adapter_t), name, |
| 2477 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
| 2478 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2479 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2480 | (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam() ? |
| 2481 | hdd_mon_mode_ether_setup : ether_setup), |
| 2482 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2483 | |
| 2484 | if (pWlanDev != NULL) { |
| 2485 | |
| 2486 | /* Save the pointer to the net_device in the HDD adapter */ |
| 2487 | adapter = (hdd_adapter_t *) netdev_priv(pWlanDev); |
| 2488 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2489 | qdf_mem_zero(adapter, sizeof(hdd_adapter_t)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2490 | |
| 2491 | adapter->dev = pWlanDev; |
| 2492 | adapter->pHddCtx = hdd_ctx; |
| 2493 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Arun Khandavalli | 9ad88f0 | 2016-09-01 19:03:37 +0530 | [diff] [blame] | 2494 | adapter->sessionId = HDD_SESSION_ID_INVALID; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2495 | |
| 2496 | init_completion(&adapter->session_open_comp_var); |
| 2497 | init_completion(&adapter->session_close_comp_var); |
| 2498 | init_completion(&adapter->disconnect_comp_var); |
| 2499 | init_completion(&adapter->linkup_event_var); |
| 2500 | init_completion(&adapter->cancel_rem_on_chan_var); |
| 2501 | init_completion(&adapter->rem_on_chan_ready_event); |
| 2502 | init_completion(&adapter->sta_authorized_event); |
| 2503 | init_completion(&adapter->offchannel_tx_event); |
| 2504 | init_completion(&adapter->tx_action_cnf_event); |
| 2505 | #ifdef FEATURE_WLAN_TDLS |
| 2506 | init_completion(&adapter->tdls_add_station_comp); |
| 2507 | init_completion(&adapter->tdls_del_station_comp); |
| 2508 | init_completion(&adapter->tdls_mgmt_comp); |
| 2509 | init_completion(&adapter->tdls_link_establish_req_comp); |
| 2510 | #endif |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2511 | init_completion(&adapter->ibss_peer_info_comp); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2512 | init_completion(&adapter->change_country_code); |
| 2513 | |
| 2514 | |
| 2515 | init_completion(&adapter->scan_info.abortscan_event_var); |
| 2516 | |
| 2517 | adapter->offloads_configured = false; |
| 2518 | adapter->isLinkUpSvcNeeded = false; |
| 2519 | adapter->higherDtimTransition = true; |
| 2520 | /* Init the net_device structure */ |
| 2521 | strlcpy(pWlanDev->name, name, IFNAMSIZ); |
| 2522 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2523 | qdf_mem_copy(pWlanDev->dev_addr, (void *)macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2524 | sizeof(tSirMacAddr)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2525 | qdf_mem_copy(adapter->macAddressCurrent.bytes, macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2526 | sizeof(tSirMacAddr)); |
| 2527 | pWlanDev->watchdog_timeo = HDD_TX_TIMEOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2528 | |
| 2529 | if (hdd_ctx->config->enable_ip_tcp_udp_checksum_offload) |
| 2530 | pWlanDev->features |= |
| 2531 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
| 2532 | pWlanDev->features |= NETIF_F_RXCSUM; |
| 2533 | |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 2534 | hdd_set_tso_flags(hdd_ctx, pWlanDev); |
| 2535 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2536 | hdd_set_station_ops(adapter->dev); |
| 2537 | |
| 2538 | pWlanDev->destructor = free_netdev; |
| 2539 | pWlanDev->ieee80211_ptr = &adapter->wdev; |
Mohit Khanna | ee9e80f | 2015-11-10 11:32:49 -0800 | [diff] [blame] | 2540 | pWlanDev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2541 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
| 2542 | adapter->wdev.netdev = pWlanDev; |
| 2543 | /* set pWlanDev's parent to underlying device */ |
| 2544 | SET_NETDEV_DEV(pWlanDev, hdd_ctx->parent_dev); |
| 2545 | hdd_wmm_init(adapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 2546 | hdd_adapter_runtime_suspend_init(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2547 | spin_lock_init(&adapter->pause_map_lock); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 2548 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2549 | } |
| 2550 | |
| 2551 | return adapter; |
| 2552 | } |
| 2553 | |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2554 | static QDF_STATUS hdd_register_interface(hdd_adapter_t *adapter, |
| 2555 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2556 | { |
| 2557 | struct net_device *pWlanDev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2558 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 2559 | if (rtnl_held) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2560 | if (strnchr(pWlanDev->name, strlen(pWlanDev->name), '%')) { |
| 2561 | if (dev_alloc_name(pWlanDev, pWlanDev->name) < 0) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2562 | hdd_err("Failed:dev_alloc_name"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2563 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2564 | } |
| 2565 | } |
| 2566 | if (register_netdevice(pWlanDev)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2567 | hdd_err("Failed:register_netdev"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2568 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2569 | } |
| 2570 | } else { |
| 2571 | if (register_netdev(pWlanDev)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2572 | hdd_err("Failed:register_netdev"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2573 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2574 | } |
| 2575 | } |
| 2576 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 2577 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2578 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2579 | } |
| 2580 | |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 2581 | QDF_STATUS hdd_sme_close_session_callback(void *pContext) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2582 | { |
| 2583 | hdd_adapter_t *adapter = pContext; |
| 2584 | |
| 2585 | if (NULL == adapter) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2586 | hdd_alert("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2587 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2588 | } |
| 2589 | |
| 2590 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2591 | hdd_alert("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2592 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2593 | } |
| 2594 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 2595 | /* |
| 2596 | * For NAN Data interface, the close session results in the final |
| 2597 | * indication to the userspace |
| 2598 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 2599 | if (adapter->device_mode == QDF_NDI_MODE) |
| 2600 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 2601 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2602 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 2603 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2604 | /* |
| 2605 | * We can be blocked while waiting for scheduled work to be |
| 2606 | * flushed, and the adapter structure can potentially be freed, in |
| 2607 | * which case the magic will have been reset. So make sure the |
| 2608 | * magic is still good, and hence the adapter structure is still |
| 2609 | * valid, before signaling completion |
| 2610 | */ |
| 2611 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
| 2612 | complete(&adapter->session_close_comp_var); |
| 2613 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2614 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2615 | } |
| 2616 | |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 2617 | /** |
| 2618 | * hdd_check_and_init_tdls() - check and init TDLS operation for desired mode |
| 2619 | * @adapter: pointer to device adapter |
| 2620 | * @type: type of interface |
| 2621 | * |
| 2622 | * This routine will check the mode of adapter and if it is required then it |
| 2623 | * will initialize the TDLS operations |
| 2624 | * |
| 2625 | * Return: QDF_STATUS |
| 2626 | */ |
| 2627 | #ifdef FEATURE_WLAN_TDLS |
| 2628 | static QDF_STATUS hdd_check_and_init_tdls(hdd_adapter_t *adapter, uint32_t type) |
| 2629 | { |
| 2630 | if (QDF_IBSS_MODE != type) { |
| 2631 | if (0 != wlan_hdd_tdls_init(adapter)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2632 | hdd_err("wlan_hdd_tdls_init failed"); |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 2633 | return QDF_STATUS_E_FAILURE; |
| 2634 | } |
| 2635 | set_bit(TDLS_INIT_DONE, &adapter->event_flags); |
| 2636 | } |
| 2637 | return QDF_STATUS_SUCCESS; |
| 2638 | } |
| 2639 | #else |
| 2640 | static QDF_STATUS hdd_check_and_init_tdls(hdd_adapter_t *adapter, uint32_t type) |
| 2641 | { |
| 2642 | return QDF_STATUS_SUCCESS; |
| 2643 | } |
| 2644 | #endif |
| 2645 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2646 | QDF_STATUS hdd_init_station_mode(hdd_adapter_t *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2647 | { |
| 2648 | struct net_device *pWlanDev = adapter->dev; |
| 2649 | hdd_station_ctx_t *pHddStaCtx = &adapter->sessionCtx.station; |
| 2650 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2651 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2652 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2653 | uint32_t type, subType; |
| 2654 | unsigned long rc; |
| 2655 | int ret_val; |
| 2656 | |
| 2657 | INIT_COMPLETION(adapter->session_open_comp_var); |
| 2658 | sme_set_curr_device_mode(hdd_ctx->hHal, adapter->device_mode); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 2659 | 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] | 2660 | status = cds_get_vdev_types(adapter->device_mode, &type, &subType); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2661 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2662 | hdd_err("failed to get vdev type"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2663 | goto error_sme_open; |
| 2664 | } |
| 2665 | /* Open a SME session for future operation */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2666 | qdf_ret_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2667 | sme_open_session(hdd_ctx->hHal, hdd_sme_roam_callback, adapter, |
| 2668 | (uint8_t *) &adapter->macAddressCurrent, |
| 2669 | &adapter->sessionId, type, subType); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2670 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2671 | hdd_alert("sme_open_session() failed, status code %08d [x%08x]", |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2672 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2673 | status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2674 | goto error_sme_open; |
| 2675 | } |
| 2676 | /* Block on a completion variable. Can't wait forever though. */ |
| 2677 | rc = wait_for_completion_timeout( |
| 2678 | &adapter->session_open_comp_var, |
| 2679 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
| 2680 | if (!rc) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2681 | hdd_alert("Session is not opened within timeout period code %ld", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2682 | rc); |
Sandeep Puligilla | e806599 | 2016-11-14 00:23:43 -0800 | [diff] [blame] | 2683 | adapter->sessionId = HDD_SESSION_ID_INVALID; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2684 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2685 | } |
| 2686 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2687 | status = hdd_create_and_store_vdev(hdd_ctx->hdd_pdev, adapter); |
| 2688 | if (QDF_IS_STATUS_ERROR(status)) |
| 2689 | goto error_vdev_create; |
| 2690 | |
Naveen Rawat | a410c5a | 2016-09-19 14:22:33 -0700 | [diff] [blame] | 2691 | sme_set_vdev_ies_per_band(hdd_ctx->hHal, adapter->sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2692 | /* Register wireless extensions */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2693 | qdf_ret_status = hdd_register_wext(pWlanDev); |
| 2694 | if (QDF_STATUS_SUCCESS != qdf_ret_status) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2695 | hdd_alert("hdd_register_wext() failed, status code %08d [x%08x]", |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2696 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2697 | status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2698 | goto error_register_wext; |
| 2699 | } |
| 2700 | /* Set the Connection State to Not Connected */ |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2701 | hdd_notice("Set HDD connState to eConnectionState_NotConnected"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2702 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 2703 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame^] | 2704 | /* set fast roaming capability in sme session */ |
| 2705 | status = sme_config_fast_roaming(hdd_ctx->hHal, adapter->sessionId, |
| 2706 | adapter->fast_roaming_allowed); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2707 | /* Set the default operation channel */ |
| 2708 | pHddStaCtx->conn_info.operationChannel = |
| 2709 | hdd_ctx->config->OperatingChannel; |
| 2710 | |
| 2711 | /* Make the default Auth Type as OPEN */ |
| 2712 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 2713 | |
| 2714 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2715 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2716 | hdd_alert("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2717 | status, status); |
| 2718 | goto error_init_txrx; |
| 2719 | } |
| 2720 | |
| 2721 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 2722 | |
| 2723 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2724 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2725 | hdd_alert("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2726 | status, status); |
| 2727 | goto error_wmm_init; |
| 2728 | } |
| 2729 | |
| 2730 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 2731 | |
| 2732 | ret_val = wma_cli_set_command(adapter->sessionId, |
| 2733 | WMI_PDEV_PARAM_BURST_ENABLE, |
| 2734 | hdd_ctx->config->enableSifsBurst, |
| 2735 | PDEV_CMD); |
| 2736 | |
| 2737 | if (0 != ret_val) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2738 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2739 | ret_val); |
| 2740 | } |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 2741 | status = hdd_check_and_init_tdls(adapter, type); |
| 2742 | if (status != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2743 | goto error_tdls_init; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2744 | |
Himanshu Agarwal | 3d95b90 | 2016-08-24 16:27:03 +0530 | [diff] [blame] | 2745 | status = hdd_lro_enable(hdd_ctx, adapter); |
| 2746 | if (status != QDF_STATUS_SUCCESS) |
| 2747 | goto error_lro_enable; |
| 2748 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2749 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2750 | |
Himanshu Agarwal | 3d95b90 | 2016-08-24 16:27:03 +0530 | [diff] [blame] | 2751 | error_lro_enable: |
| 2752 | wlan_hdd_tdls_exit(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2753 | error_tdls_init: |
| 2754 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 2755 | hdd_wmm_adapter_close(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2756 | error_wmm_init: |
| 2757 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 2758 | hdd_deinit_tx_rx(adapter); |
| 2759 | error_init_txrx: |
| 2760 | hdd_unregister_wext(pWlanDev); |
| 2761 | error_register_wext: |
Rajeev Kumar | ba77885 | 2017-01-06 13:23:04 -0800 | [diff] [blame] | 2762 | status = hdd_release_and_destroy_vdev(adapter); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2763 | if (QDF_IS_STATUS_ERROR(status)) |
| 2764 | hdd_err("vdev delete failed"); |
| 2765 | error_vdev_create: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2766 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2767 | INIT_COMPLETION(adapter->session_close_comp_var); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2768 | if (QDF_STATUS_SUCCESS == sme_close_session(hdd_ctx->hHal, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2769 | adapter->sessionId, |
| 2770 | hdd_sme_close_session_callback, |
| 2771 | adapter)) { |
| 2772 | unsigned long rc; |
| 2773 | |
| 2774 | /* |
| 2775 | * Block on a completion variable. |
| 2776 | * Can't wait forever though. |
| 2777 | */ |
| 2778 | rc = wait_for_completion_timeout( |
| 2779 | &adapter->session_close_comp_var, |
| 2780 | msecs_to_jiffies |
| 2781 | (WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
| 2782 | if (rc <= 0) |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2783 | hdd_err("Session is not opened within timeout period code %ld", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2784 | rc); |
| 2785 | } |
| 2786 | } |
| 2787 | error_sme_open: |
| 2788 | return status; |
| 2789 | } |
| 2790 | |
| 2791 | void hdd_cleanup_actionframe(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter) |
| 2792 | { |
| 2793 | hdd_cfg80211_state_t *cfgState; |
| 2794 | |
| 2795 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR(adapter); |
| 2796 | |
| 2797 | if (NULL != cfgState->buf) { |
| 2798 | unsigned long rc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2799 | rc = wait_for_completion_timeout( |
| 2800 | &adapter->tx_action_cnf_event, |
| 2801 | msecs_to_jiffies(ACTION_FRAME_TX_TIMEOUT)); |
| 2802 | if (!rc) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 2803 | hdd_err("HDD Wait for Action Confirmation Failed!!"); |
Masti, Narayanraddi | f8f6e7e | 2015-08-25 10:22:46 +0530 | [diff] [blame] | 2804 | /* |
| 2805 | * Inform tx status as FAILURE to upper layer and free |
| 2806 | * cfgState->buf |
| 2807 | */ |
| 2808 | hdd_send_action_cnf(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2809 | } |
| 2810 | } |
| 2811 | return; |
| 2812 | } |
| 2813 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2814 | /** |
| 2815 | * hdd_station_adapter_deinit() - De-initialize the station adapter |
| 2816 | * @hdd_ctx: global hdd context |
| 2817 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2818 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 2819 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2820 | * |
| 2821 | * This function De-initializes the STA/P2P/OCB adapter. |
| 2822 | * |
| 2823 | * Return: None. |
| 2824 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2825 | static void hdd_station_adapter_deinit(hdd_context_t *hdd_ctx, |
| 2826 | hdd_adapter_t *adapter, |
| 2827 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2828 | { |
| 2829 | ENTER_DEV(adapter->dev); |
| 2830 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 2831 | if (adapter->dev) { |
| 2832 | if (rtnl_held) |
| 2833 | adapter->dev->wireless_handlers = NULL; |
| 2834 | else { |
| 2835 | rtnl_lock(); |
| 2836 | adapter->dev->wireless_handlers = NULL; |
| 2837 | rtnl_unlock(); |
| 2838 | } |
| 2839 | } |
| 2840 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2841 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 2842 | hdd_deinit_tx_rx(adapter); |
| 2843 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 2844 | } |
| 2845 | |
| 2846 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 2847 | hdd_wmm_adapter_close(adapter); |
| 2848 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 2849 | } |
| 2850 | |
| 2851 | hdd_cleanup_actionframe(hdd_ctx, adapter); |
| 2852 | wlan_hdd_tdls_exit(adapter); |
| 2853 | |
| 2854 | EXIT(); |
| 2855 | } |
| 2856 | |
| 2857 | /** |
| 2858 | * hdd_ap_adapter_deinit() - De-initialize the ap adapter |
| 2859 | * @hdd_ctx: global hdd context |
| 2860 | * @adapter: HDD adapter |
| 2861 | * @rtnl_held: the rtnl lock hold flag |
| 2862 | * This function De-initializes the AP/P2PGo adapter. |
| 2863 | * |
| 2864 | * Return: None. |
| 2865 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2866 | static void hdd_ap_adapter_deinit(hdd_context_t *hdd_ctx, |
| 2867 | hdd_adapter_t *adapter, |
| 2868 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2869 | { |
| 2870 | ENTER_DEV(adapter->dev); |
| 2871 | |
| 2872 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 2873 | hdd_wmm_adapter_close(adapter); |
| 2874 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 2875 | } |
Liangwei Dong | 8baf7c8 | 2016-10-11 01:26:59 -0400 | [diff] [blame] | 2876 | wlan_hdd_undo_acs(adapter); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2877 | |
| 2878 | hdd_cleanup_actionframe(hdd_ctx, adapter); |
| 2879 | |
| 2880 | hdd_unregister_hostapd(adapter, rtnl_held); |
| 2881 | |
| 2882 | EXIT(); |
| 2883 | } |
| 2884 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2885 | void hdd_deinit_adapter(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, |
| 2886 | bool rtnl_held) |
| 2887 | { |
| 2888 | ENTER(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2889 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2890 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 2891 | case QDF_STA_MODE: |
| 2892 | case QDF_P2P_CLIENT_MODE: |
| 2893 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2894 | { |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 2895 | hdd_station_adapter_deinit(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2896 | break; |
| 2897 | } |
| 2898 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 2899 | case QDF_SAP_MODE: |
| 2900 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2901 | { |
| 2902 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 2903 | hdd_ap_adapter_deinit(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2904 | break; |
| 2905 | } |
| 2906 | |
| 2907 | default: |
| 2908 | break; |
| 2909 | } |
| 2910 | |
| 2911 | EXIT(); |
| 2912 | } |
| 2913 | |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2914 | static void hdd_cleanup_adapter(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, |
| 2915 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2916 | { |
| 2917 | struct net_device *pWlanDev = NULL; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2918 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2919 | |
| 2920 | if (adapter) |
| 2921 | pWlanDev = adapter->dev; |
| 2922 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 2923 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2924 | return; |
| 2925 | } |
| 2926 | |
Rajeev Kumar | ba77885 | 2017-01-06 13:23:04 -0800 | [diff] [blame] | 2927 | qdf_status = hdd_release_and_destroy_vdev(adapter); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2928 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 2929 | hdd_err("vdev delete failed"); |
| 2930 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 2931 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 2932 | |
| 2933 | if (adapter->scan_info.default_scan_ies) { |
| 2934 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 2935 | adapter->scan_info.default_scan_ies = NULL; |
| 2936 | } |
| 2937 | |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 2938 | hdd_adapter_runtime_suspend_denit(adapter); |
| 2939 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2940 | /* |
| 2941 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 2942 | * the driver is almost closed and cannot handle either control |
| 2943 | * messages or data. However, unregister_netdevice() call above will |
| 2944 | * eventually invoke hdd_stop (ndo_close) driver callback, which attempts |
| 2945 | * to close the active connections (basically excites control path) which |
| 2946 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 2947 | * the interface is closed and restricts any operations on that |
| 2948 | */ |
| 2949 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2950 | |
| 2951 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
| 2952 | if (rtnl_held) { |
| 2953 | unregister_netdevice(pWlanDev); |
| 2954 | } else { |
| 2955 | unregister_netdev(pWlanDev); |
| 2956 | } |
| 2957 | /* |
| 2958 | * Note that the adapter is no longer valid at this point |
| 2959 | * since the memory has been reclaimed |
| 2960 | */ |
| 2961 | } |
| 2962 | } |
| 2963 | |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2964 | static QDF_STATUS hdd_check_for_existing_macaddr(hdd_context_t *hdd_ctx, |
| 2965 | tSirMacAddr macAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2966 | { |
| 2967 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 2968 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2969 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2970 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2971 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2972 | adapter = adapterNode->pAdapter; |
| 2973 | if (adapter |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2974 | && !qdf_mem_cmp(adapter->macAddressCurrent.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2975 | macAddr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2976 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2977 | } |
| 2978 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 2979 | adapterNode = pNext; |
| 2980 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2981 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2982 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 2983 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 2984 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 2985 | /** |
| 2986 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 2987 | * @hdd_ctx: HDD Context |
| 2988 | * @adapter: HDD Adapter |
| 2989 | * |
| 2990 | * This function set the FW Debug log level based on the INI. |
| 2991 | * |
| 2992 | * Return: None |
| 2993 | */ |
| 2994 | static void hdd_set_fw_log_params(hdd_context_t *hdd_ctx, |
| 2995 | hdd_adapter_t *adapter) |
| 2996 | { |
| 2997 | uint8_t count = 0, numentries = 0, |
| 2998 | moduleloglevel[FW_MODULE_LOG_LEVEL_STRING_LENGTH]; |
| 2999 | uint32_t value = 0; |
| 3000 | int ret; |
| 3001 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3002 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 3003 | (!hdd_ctx->config->enable_fw_log)) { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3004 | hdd_info("enable_fw_log not enabled in INI or in FTM mode return"); |
| 3005 | return; |
| 3006 | } |
| 3007 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3008 | /* Enable FW logs based on INI configuration */ |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3009 | hdd_ctx->fw_log_settings.dl_type = |
| 3010 | hdd_ctx->config->enableFwLogType; |
| 3011 | ret = wma_cli_set_command(adapter->sessionId, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3012 | WMI_DBGLOG_TYPE, |
| 3013 | hdd_ctx->config->enableFwLogType, |
| 3014 | DBG_CMD); |
| 3015 | if (ret != 0) |
| 3016 | hdd_err("Failed to enable FW log type ret %d", |
| 3017 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3018 | |
| 3019 | hdd_ctx->fw_log_settings.dl_loglevel = |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3020 | hdd_ctx->config->enableFwLogLevel; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3021 | ret = wma_cli_set_command(adapter->sessionId, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3022 | WMI_DBGLOG_LOG_LEVEL, |
| 3023 | hdd_ctx->config->enableFwLogLevel, |
| 3024 | DBG_CMD); |
| 3025 | if (ret != 0) |
| 3026 | hdd_err("Failed to enable FW log level ret %d", |
| 3027 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3028 | |
| 3029 | hdd_string_to_u8_array( |
| 3030 | hdd_ctx->config->enableFwModuleLogLevel, |
| 3031 | moduleloglevel, |
| 3032 | &numentries, |
| 3033 | FW_MODULE_LOG_LEVEL_STRING_LENGTH); |
| 3034 | |
| 3035 | while (count < numentries) { |
| 3036 | /* |
| 3037 | * FW module log level input string looks like |
| 3038 | * below: |
| 3039 | * gFwDebugModuleLoglevel=<FW Module ID>, |
| 3040 | * <Log Level>,... |
| 3041 | * For example: |
| 3042 | * gFwDebugModuleLoglevel= |
| 3043 | * 1,0,2,1,3,2,4,3,5,4,6,5,7,6 |
| 3044 | * Above input string means : |
| 3045 | * For FW module ID 1 enable log level 0 |
| 3046 | * For FW module ID 2 enable log level 1 |
| 3047 | * For FW module ID 3 enable log level 2 |
| 3048 | * For FW module ID 4 enable log level 3 |
| 3049 | * For FW module ID 5 enable log level 4 |
| 3050 | * For FW module ID 6 enable log level 5 |
| 3051 | * For FW module ID 7 enable log level 6 |
| 3052 | */ |
| 3053 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3054 | /* FW expects WMI command value = |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3055 | * Module ID * 10 + Module Log level |
| 3056 | */ |
| 3057 | value = ((moduleloglevel[count] * 10) + |
| 3058 | moduleloglevel[count + 1]); |
| 3059 | ret = wma_cli_set_command(adapter->sessionId, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3060 | WMI_DBGLOG_MOD_LOG_LEVEL, |
| 3061 | value, DBG_CMD); |
| 3062 | if (ret != 0) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3063 | hdd_err("Failed to enable FW module log level %d ret %d", |
| 3064 | value, ret); |
| 3065 | |
| 3066 | count += 2; |
| 3067 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3068 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3069 | } |
| 3070 | #else |
| 3071 | static void hdd_set_fw_log_params(hdd_context_t *hdd_ctx, |
| 3072 | hdd_adapter_t *adapter) |
| 3073 | { |
| 3074 | } |
| 3075 | |
| 3076 | #endif |
| 3077 | |
| 3078 | /** |
| 3079 | * hdd_set_fw_params() - Set parameters to firmware |
| 3080 | * @adapter: HDD adapter |
| 3081 | * |
| 3082 | * This function Sets various parameters to fw once the |
| 3083 | * adapter is started. |
| 3084 | * |
| 3085 | * Return: 0 on success or errno on failure |
| 3086 | */ |
| 3087 | int hdd_set_fw_params(hdd_adapter_t *adapter) |
| 3088 | { |
| 3089 | int ret; |
| 3090 | hdd_context_t *hdd_ctx; |
| 3091 | |
| 3092 | ENTER_DEV(adapter->dev); |
| 3093 | |
| 3094 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3095 | if (!hdd_ctx) |
| 3096 | return -EINVAL; |
| 3097 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3098 | if ((cds_get_conparam() != QDF_GLOBAL_FTM_MODE) && |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3099 | (!hdd_ctx->config->enable2x2)) { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3100 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 3101 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3102 | /* |
| 3103 | * Disable DTIM 1 chain Rx when in 1x1, |
| 3104 | * we are passing two value |
| 3105 | * as param_id << 29 | param_value. |
| 3106 | * Below param_value = 0(disable) |
| 3107 | */ |
| 3108 | ret = wma_cli_set_command(adapter->sessionId, |
| 3109 | WMI_STA_SMPS_PARAM_CMDID, |
| 3110 | HDD_DTIM_1CHAIN_RX_ID << |
| 3111 | HDD_SMPS_PARAM_VALUE_S, |
| 3112 | VDEV_CMD); |
| 3113 | if (ret) { |
| 3114 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 3115 | goto error; |
| 3116 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3117 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3118 | ret = wma_cli_set_command(adapter->sessionId, |
| 3119 | WMI_PDEV_PARAM_TX_CHAIN_MASK, |
| 3120 | hdd_ctx->config->txchainmask1x1, |
| 3121 | PDEV_CMD); |
| 3122 | if (ret) { |
| 3123 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK set failed %d", |
| 3124 | ret); |
| 3125 | goto error; |
| 3126 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3127 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3128 | ret = wma_cli_set_command(adapter->sessionId, |
| 3129 | WMI_PDEV_PARAM_RX_CHAIN_MASK, |
| 3130 | hdd_ctx->config->rxchainmask1x1, |
| 3131 | PDEV_CMD); |
| 3132 | if (ret) { |
| 3133 | hdd_err("WMI_PDEV_PARAM_RX_CHAIN_MASK set failed %d", |
| 3134 | ret); |
| 3135 | goto error; |
| 3136 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3137 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 3138 | #undef HDD_SMPS_PARAM_VALUE_S |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3139 | } else { |
| 3140 | hdd_info("FTM Mode or 2x2 mode - Do not set 1x1 params"); |
| 3141 | } |
| 3142 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3143 | if (QDF_GLOBAL_FTM_MODE != cds_get_conparam()) { |
| 3144 | ret = wma_cli_set_command(adapter->sessionId, |
| 3145 | WMI_PDEV_PARAM_HYST_EN, |
| 3146 | hdd_ctx->config->enableMemDeepSleep, |
| 3147 | PDEV_CMD); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3148 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3149 | if (ret) { |
| 3150 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", |
| 3151 | ret); |
| 3152 | goto error; |
| 3153 | } |
Rajeev Kumar Sirasanagandla | 2dab3ec | 2016-10-18 16:10:15 +0530 | [diff] [blame] | 3154 | |
| 3155 | ret = wma_cli_set_command(adapter->sessionId, |
| 3156 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
| 3157 | hdd_ctx->config->rts_profile, |
| 3158 | VDEV_CMD); |
| 3159 | if (ret) { |
| 3160 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 3161 | goto error; |
| 3162 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3163 | } |
| 3164 | |
| 3165 | hdd_set_fw_log_params(hdd_ctx, adapter); |
| 3166 | |
| 3167 | EXIT(); |
| 3168 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3169 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3170 | error: |
| 3171 | return -EINVAL; |
| 3172 | } |
| 3173 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3174 | /** |
| 3175 | * hdd_open_adapter() - open and setup the hdd adatper |
| 3176 | * @hdd_ctx: global hdd context |
| 3177 | * @session_type: type of the interface to be created |
| 3178 | * @iface_name: User-visible name of the interface |
| 3179 | * @macAddr: MAC address to assign to the interface |
| 3180 | * @name_assign_type: the name of assign type of the netdev |
| 3181 | * @rtnl_held: the rtnl lock hold flag |
| 3182 | * |
| 3183 | * This function open and setup the hdd adpater according to the device |
| 3184 | * type request, assign the name, the mac address assigned, and then prepared |
| 3185 | * the hdd related parameters, queue, lock and ready to start. |
| 3186 | * |
| 3187 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 3188 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3189 | hdd_adapter_t *hdd_open_adapter(hdd_context_t *hdd_ctx, uint8_t session_type, |
| 3190 | const char *iface_name, tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3191 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3192 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3193 | { |
| 3194 | hdd_adapter_t *adapter = NULL; |
| 3195 | hdd_adapter_list_node_t *pHddAdapterNode = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3196 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3197 | hdd_cfg80211_state_t *cfgState; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3198 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3199 | hdd_info("iface(%s) type(%d)", iface_name, session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3200 | |
| 3201 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 3202 | /* |
| 3203 | * Max limit reached on the number of vdevs configured by the |
| 3204 | * host. Return error |
| 3205 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3206 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 3207 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3208 | return NULL; |
| 3209 | } |
| 3210 | |
| 3211 | if (macAddr == NULL) { |
| 3212 | /* Not received valid macAddr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3213 | 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] | 3214 | return NULL; |
| 3215 | } |
| 3216 | status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3217 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3218 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 3219 | " already exists", |
| 3220 | MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3221 | return NULL; |
| 3222 | } |
| 3223 | |
| 3224 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3225 | case QDF_STA_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3226 | /* Reset locally administered bit if the device mode is STA */ |
| 3227 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr); |
| 3228 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3229 | case QDF_P2P_CLIENT_MODE: |
| 3230 | case QDF_P2P_DEVICE_MODE: |
| 3231 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 3232 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3233 | case QDF_MONITOR_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3234 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 3235 | name_assign_type, |
| 3236 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3237 | |
| 3238 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3239 | hdd_err("failed to allocate adapter for session %d", |
| 3240 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3241 | return NULL; |
| 3242 | } |
| 3243 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3244 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3245 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3246 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3247 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3248 | else if (QDF_MONITOR_MODE == session_type) |
| 3249 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3250 | else |
| 3251 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 3252 | |
| 3253 | adapter->device_mode = session_type; |
| 3254 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3255 | if (QDF_NDI_MODE == session_type) { |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 3256 | status = hdd_init_nan_data_mode(adapter); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3257 | if (QDF_STATUS_SUCCESS != status) |
| 3258 | goto err_free_netdev; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3259 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3260 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3261 | /* |
| 3262 | * Workqueue which gets scheduled in IPv4 notification |
| 3263 | * callback |
| 3264 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3265 | INIT_WORK(&adapter->ipv4NotifierWorkQueue, |
| 3266 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3267 | |
| 3268 | #ifdef WLAN_NS_OFFLOAD |
| 3269 | /* |
| 3270 | * Workqueue which gets scheduled in IPv6 |
| 3271 | * notification callback. |
| 3272 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3273 | INIT_WORK(&adapter->ipv6NotifierWorkQueue, |
| 3274 | hdd_ipv6_notifier_work_queue); |
| 3275 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3276 | status = hdd_register_interface(adapter, rtnl_held); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3277 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3278 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 3279 | goto err_free_netdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3280 | } |
| 3281 | |
| 3282 | /* Stop the Interface TX queue. */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3283 | hdd_info("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3284 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3285 | WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 3286 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3287 | break; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3288 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3289 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3290 | case QDF_P2P_GO_MODE: |
| 3291 | case QDF_SAP_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3292 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr, |
| 3293 | name_assign_type, |
| 3294 | (uint8_t *) iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3295 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3296 | hdd_alert("failed to allocate adapter for session %d", |
| 3297 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3298 | return NULL; |
| 3299 | } |
| 3300 | |
| 3301 | adapter->wdev.iftype = |
| 3302 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3303 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3304 | NL80211_IFTYPE_P2P_GO; |
| 3305 | adapter->device_mode = session_type; |
| 3306 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3307 | status = hdd_register_hostapd(adapter, rtnl_held); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3308 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3309 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
| 3310 | goto err_free_netdev; |
| 3311 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3312 | hdd_info("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3313 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3314 | WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 3315 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3316 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3317 | case QDF_FTM_MODE: |
| 3318 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 3319 | name_assign_type, |
| 3320 | "wlan0"); |
| 3321 | if (NULL == adapter) { |
| 3322 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 3323 | return NULL; |
| 3324 | } |
| 3325 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 3326 | adapter->device_mode = session_type; |
| 3327 | status = hdd_register_interface(adapter, rtnl_held); |
| 3328 | if (QDF_STATUS_SUCCESS != status) { |
| 3329 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
| 3330 | goto err_free_netdev; |
| 3331 | } |
| 3332 | /* Stop the Interface TX queue. */ |
| 3333 | hdd_info("Disabling queues"); |
| 3334 | wlan_hdd_netif_queue_control(adapter, |
| 3335 | WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 3336 | WLAN_CONTROL_PATH); |
| 3337 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3338 | default: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3339 | hdd_alert("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3340 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3341 | return NULL; |
| 3342 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3343 | |
| 3344 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR(adapter); |
| 3345 | mutex_init(&cfgState->remain_on_chan_ctx_lock); |
| 3346 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3347 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3348 | /* Add it to the hdd's session list. */ |
| 3349 | pHddAdapterNode = |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3350 | qdf_mem_malloc(sizeof(hdd_adapter_list_node_t)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3351 | if (NULL == pHddAdapterNode) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3352 | status = QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3353 | } else { |
| 3354 | pHddAdapterNode->pAdapter = adapter; |
| 3355 | status = hdd_add_adapter_back(hdd_ctx, pHddAdapterNode); |
| 3356 | } |
| 3357 | } |
| 3358 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3359 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3360 | if (NULL != adapter) { |
| 3361 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 3362 | adapter = NULL; |
| 3363 | } |
| 3364 | if (NULL != pHddAdapterNode) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3365 | qdf_mem_free(pHddAdapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3366 | } |
| 3367 | return NULL; |
| 3368 | } |
| 3369 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3370 | if (QDF_STATUS_SUCCESS == status) { |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 3371 | cds_set_concurrency_mode(session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3372 | |
| 3373 | /* Initialize the WoWL service */ |
| 3374 | if (!hdd_init_wowl(adapter)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3375 | hdd_alert("hdd_init_wowl failed"); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 3376 | goto err_close_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3377 | } |
| 3378 | |
| 3379 | /* Adapter successfully added. Increment the vdev count */ |
| 3380 | hdd_ctx->current_intf_count++; |
| 3381 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3382 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3383 | hdd_ctx->current_intf_count); |
| 3384 | |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 3385 | cds_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3386 | } |
| 3387 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 3388 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
| 3389 | hdd_err("Interface %s wow debug_fs init failed", iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3390 | |
| 3391 | return adapter; |
| 3392 | |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 3393 | err_close_adapter: |
| 3394 | hdd_close_adapter(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3395 | err_free_netdev: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3396 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->macAddressCurrent.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 3397 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3398 | |
| 3399 | return NULL; |
| 3400 | } |
| 3401 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3402 | 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] | 3403 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3404 | { |
| 3405 | hdd_adapter_list_node_t *adapterNode, *pCurrent, *pNext; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3406 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3407 | |
| 3408 | status = hdd_get_front_adapter(hdd_ctx, &pCurrent); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3409 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3410 | hdd_warn("adapter list empty %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3411 | status); |
| 3412 | return status; |
| 3413 | } |
| 3414 | |
| 3415 | while (pCurrent->pAdapter != adapter) { |
| 3416 | status = hdd_get_next_adapter(hdd_ctx, pCurrent, &pNext); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3417 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3418 | break; |
| 3419 | |
| 3420 | pCurrent = pNext; |
| 3421 | } |
| 3422 | adapterNode = pCurrent; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3423 | if (QDF_STATUS_SUCCESS == status) { |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 3424 | cds_clear_concurrency_mode(adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3425 | hdd_cleanup_adapter(hdd_ctx, adapterNode->pAdapter, rtnl_held); |
| 3426 | |
| 3427 | hdd_remove_adapter(hdd_ctx, adapterNode); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3428 | qdf_mem_free(adapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3429 | adapterNode = NULL; |
| 3430 | |
| 3431 | /* Adapter removed. Decrement vdev count */ |
| 3432 | if (hdd_ctx->current_intf_count != 0) |
| 3433 | hdd_ctx->current_intf_count--; |
| 3434 | |
| 3435 | /* Fw will take care incase of concurrency */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3436 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3437 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3438 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3439 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3440 | } |
| 3441 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3442 | /** |
| 3443 | * hdd_close_all_adapters - Close all open adapters |
| 3444 | * @hdd_ctx: Hdd context |
| 3445 | * rtnl_held: True if RTNL lock held |
| 3446 | * |
| 3447 | * Close all open adapters. |
| 3448 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3449 | * Return: QDF status code |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3450 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3451 | 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] | 3452 | { |
| 3453 | hdd_adapter_list_node_t *pHddAdapterNode; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3454 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3455 | |
| 3456 | ENTER(); |
| 3457 | |
| 3458 | do { |
| 3459 | status = hdd_remove_front_adapter(hdd_ctx, &pHddAdapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3460 | if (pHddAdapterNode && QDF_STATUS_SUCCESS == status) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3461 | wlan_hdd_release_intf_addr(hdd_ctx, |
| 3462 | pHddAdapterNode->pAdapter->macAddressCurrent.bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3463 | hdd_cleanup_adapter(hdd_ctx, pHddAdapterNode->pAdapter, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3464 | rtnl_held); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3465 | qdf_mem_free(pHddAdapterNode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3466 | /* Adapter removed. Decrement vdev count */ |
| 3467 | if (hdd_ctx->current_intf_count != 0) |
| 3468 | hdd_ctx->current_intf_count--; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3469 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3470 | } while (NULL != pHddAdapterNode && QDF_STATUS_E_EMPTY != status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3471 | |
| 3472 | EXIT(); |
| 3473 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3474 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3475 | } |
| 3476 | |
| 3477 | void wlan_hdd_reset_prob_rspies(hdd_adapter_t *pHostapdAdapter) |
| 3478 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3479 | struct qdf_mac_addr *bssid = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3480 | tSirUpdateIE updateIE; |
| 3481 | switch (pHostapdAdapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3482 | case QDF_STA_MODE: |
| 3483 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3484 | { |
| 3485 | hdd_station_ctx_t *pHddStaCtx = |
| 3486 | WLAN_HDD_GET_STATION_CTX_PTR(pHostapdAdapter); |
Srinivas Girigowda | 8b98396 | 2015-11-18 22:14:34 -0800 | [diff] [blame] | 3487 | bssid = &pHddStaCtx->conn_info.bssId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3488 | break; |
| 3489 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3490 | case QDF_SAP_MODE: |
| 3491 | case QDF_P2P_GO_MODE: |
| 3492 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3493 | { |
Srinivas Girigowda | 8b98396 | 2015-11-18 22:14:34 -0800 | [diff] [blame] | 3494 | bssid = &pHostapdAdapter->macAddressCurrent; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3495 | break; |
| 3496 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3497 | case QDF_FTM_MODE: |
| 3498 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3499 | default: |
| 3500 | /* |
| 3501 | * wlan_hdd_reset_prob_rspies should not have been called |
| 3502 | * for these kind of devices |
| 3503 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3504 | hdd_err("Unexpected request for the current device type %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3505 | pHostapdAdapter->device_mode); |
| 3506 | return; |
| 3507 | } |
| 3508 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 3509 | qdf_copy_macaddr(&updateIE.bssid, bssid); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3510 | updateIE.smeSessionId = pHostapdAdapter->sessionId; |
| 3511 | updateIE.ieBufferlength = 0; |
| 3512 | updateIE.pAdditionIEBuffer = NULL; |
| 3513 | updateIE.append = true; |
| 3514 | updateIE.notify = false; |
| 3515 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(pHostapdAdapter), |
| 3516 | &updateIE, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3517 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3518 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3519 | } |
| 3520 | } |
| 3521 | |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 3522 | /** |
| 3523 | * hdd_wait_for_sme_close_sesion() - Close and wait for SME session close |
| 3524 | * @hdd_ctx: HDD context which is already NULL validated |
| 3525 | * @adapter: HDD adapter which is already NULL validated |
| 3526 | * |
| 3527 | * Close the SME session and wait for its completion, if needed. |
| 3528 | * |
| 3529 | * Return: None |
| 3530 | */ |
| 3531 | static void hdd_wait_for_sme_close_sesion(hdd_context_t *hdd_ctx, |
| 3532 | hdd_adapter_t *adapter) |
| 3533 | { |
| 3534 | unsigned long rc; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 3535 | QDF_STATUS qdf_status; |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 3536 | |
| 3537 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 3538 | hdd_err("session is not opened:%d", adapter->sessionId); |
| 3539 | return; |
| 3540 | } |
| 3541 | |
| 3542 | INIT_COMPLETION(adapter->session_close_comp_var); |
| 3543 | if (QDF_STATUS_SUCCESS == |
| 3544 | sme_close_session(hdd_ctx->hHal, adapter->sessionId, |
| 3545 | hdd_sme_close_session_callback, |
| 3546 | adapter)) { |
| 3547 | /* |
| 3548 | * Block on a completion variable. Can't wait |
| 3549 | * forever though. |
| 3550 | */ |
| 3551 | rc = wait_for_completion_timeout( |
| 3552 | &adapter->session_close_comp_var, |
| 3553 | msecs_to_jiffies |
| 3554 | (WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
Sandeep Puligilla | ada7292 | 2016-09-29 19:31:21 -0700 | [diff] [blame] | 3555 | if (!rc) { |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 3556 | hdd_err("failure waiting for session_close_comp_var"); |
Sandeep Puligilla | ada7292 | 2016-09-29 19:31:21 -0700 | [diff] [blame] | 3557 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3558 | hdd_ndp_session_end_handler(adapter); |
| 3559 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Hanumanth Reddy Pothula | 3370212 | 2016-10-07 17:27:04 +0530 | [diff] [blame] | 3560 | return; |
Sandeep Puligilla | ada7292 | 2016-09-29 19:31:21 -0700 | [diff] [blame] | 3561 | } |
Rajeev Kumar | ba77885 | 2017-01-06 13:23:04 -0800 | [diff] [blame] | 3562 | qdf_status = hdd_release_and_destroy_vdev(adapter); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 3563 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 3564 | hdd_err("vdev delete failed"); |
| 3565 | |
Hanumanth Reddy Pothula | 3370212 | 2016-10-07 17:27:04 +0530 | [diff] [blame] | 3566 | adapter->sessionId = HDD_SESSION_ID_INVALID; |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 3567 | } |
| 3568 | } |
| 3569 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3570 | 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] | 3571 | const bool bCloseSession) |
| 3572 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3573 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3574 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(adapter); |
| 3575 | union iwreq_data wrqu; |
| 3576 | tSirUpdateIE updateIE; |
| 3577 | unsigned long rc; |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 3578 | hdd_scaninfo_t *scan_info = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3579 | |
| 3580 | ENTER(); |
| 3581 | |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 3582 | scan_info = &adapter->scan_info; |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3583 | hdd_notice("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3584 | wlan_hdd_netif_queue_control(adapter, WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 3585 | WLAN_CONTROL_PATH); |
| 3586 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3587 | case QDF_STA_MODE: |
| 3588 | case QDF_P2P_CLIENT_MODE: |
| 3589 | case QDF_IBSS_MODE: |
| 3590 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3591 | case QDF_NDI_MODE: |
| 3592 | if ((QDF_NDI_MODE == adapter->device_mode) || |
| 3593 | hdd_conn_is_connected( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3594 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)) || |
| 3595 | hdd_is_connecting( |
| 3596 | WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3597 | INIT_COMPLETION(adapter->disconnect_comp_var); |
| 3598 | /* |
| 3599 | * For NDI do not use pWextState from sta_ctx, if needed |
| 3600 | * extract from ndi_ctx. |
| 3601 | */ |
| 3602 | if (QDF_NDI_MODE == adapter->device_mode) |
| 3603 | qdf_ret_status = sme_roam_disconnect( |
| 3604 | hdd_ctx->hHal, |
| 3605 | adapter->sessionId, |
| 3606 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
| 3607 | else if (pWextState->roamProfile.BSSType == |
| 3608 | eCSR_BSS_TYPE_START_IBSS) |
| 3609 | qdf_ret_status = sme_roam_disconnect( |
| 3610 | hdd_ctx->hHal, |
| 3611 | adapter->sessionId, |
| 3612 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3613 | else |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3614 | qdf_ret_status = sme_roam_disconnect( |
| 3615 | hdd_ctx->hHal, |
| 3616 | adapter->sessionId, |
| 3617 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3618 | /* success implies disconnect command got queued up successfully */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3619 | if (qdf_ret_status == QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3620 | rc = wait_for_completion_timeout( |
| 3621 | &adapter->disconnect_comp_var, |
| 3622 | msecs_to_jiffies |
| 3623 | (WLAN_WAIT_TIME_DISCONNECT)); |
| 3624 | if (!rc) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3625 | hdd_err("wait on disconnect_comp_var failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3626 | } |
| 3627 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3628 | hdd_err("failed to post disconnect event to SME"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3629 | } |
| 3630 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 3631 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 3632 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 3633 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 3634 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 3635 | } |
| 3636 | if (scan_info != NULL && scan_info->mScanPending) { |
Mahesh A Saptasagar | ebb47fa | 2016-07-21 18:11:38 +0530 | [diff] [blame] | 3637 | wlan_hdd_scan_abort(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3638 | } |
Himanshu Agarwal | 3d95b90 | 2016-08-24 16:27:03 +0530 | [diff] [blame] | 3639 | hdd_lro_disable(hdd_ctx, adapter); |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 3640 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3641 | |
| 3642 | #ifdef WLAN_OPEN_SOURCE |
| 3643 | cancel_work_sync(&adapter->ipv4NotifierWorkQueue); |
| 3644 | #endif |
| 3645 | |
| 3646 | hdd_deregister_tx_flow_control(adapter); |
| 3647 | |
| 3648 | #ifdef WLAN_NS_OFFLOAD |
| 3649 | #ifdef WLAN_OPEN_SOURCE |
| 3650 | cancel_work_sync(&adapter->ipv6NotifierWorkQueue); |
| 3651 | #endif |
| 3652 | #endif |
| 3653 | |
| 3654 | /* |
| 3655 | * It is possible that the caller of this function does not |
| 3656 | * wish to close the session |
| 3657 | */ |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 3658 | if (true == bCloseSession) |
| 3659 | hdd_wait_for_sme_close_sesion(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3660 | break; |
| 3661 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3662 | case QDF_SAP_MODE: |
| 3663 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3664 | if (hdd_ctx->config->conc_custom_rule1 && |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3665 | (QDF_SAP_MODE == adapter->device_mode)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3666 | /* |
| 3667 | * Before stopping the sap adapter, lets make sure there |
| 3668 | * is no sap restart work pending. |
| 3669 | */ |
| 3670 | cds_flush_work(&hdd_ctx->sap_start_work); |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3671 | hdd_info("Canceled the pending SAP restart work"); |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 3672 | cds_change_sap_restart_required_status(false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3673 | } |
| 3674 | /* Any softap specific cleanup here... */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3675 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3676 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 3677 | |
| 3678 | hdd_deregister_tx_flow_control(adapter); |
| 3679 | |
| 3680 | mutex_lock(&hdd_ctx->sap_lock); |
| 3681 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3682 | QDF_STATUS status; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 3683 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3684 | |
| 3685 | /* Stop Bss. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3686 | status = wlansap_stop_bss( |
| 3687 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3688 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3689 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3690 | hdd_hostapd_state_t *hostapd_state = |
| 3691 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 3692 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3693 | qdf_stop_bss_event); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 3694 | qdf_status = |
| 3695 | qdf_wait_single_event(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3696 | qdf_stop_bss_event, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3697 | BSS_WAIT_TIMEOUT); |
| 3698 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 3699 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3700 | hdd_err("failure waiting for wlansap_stop_bss %d", |
| 3701 | qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3702 | } |
| 3703 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3704 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3705 | } |
| 3706 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 3707 | cds_decr_session_set_pcl( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3708 | adapter->device_mode, |
| 3709 | adapter->sessionId); |
| 3710 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 3711 | qdf_copy_macaddr(&updateIE.bssid, |
Srinivas Girigowda | 8b98396 | 2015-11-18 22:14:34 -0800 | [diff] [blame] | 3712 | &adapter->macAddressCurrent); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3713 | updateIE.smeSessionId = adapter->sessionId; |
| 3714 | updateIE.ieBufferlength = 0; |
| 3715 | updateIE.pAdditionIEBuffer = NULL; |
| 3716 | updateIE.append = false; |
| 3717 | updateIE.notify = false; |
| 3718 | /* Probe bcn reset */ |
| 3719 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 3720 | &updateIE, eUPDATE_IE_PROBE_BCN) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3721 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3722 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3723 | } |
| 3724 | /* Assoc resp reset */ |
| 3725 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 3726 | &updateIE, |
| 3727 | eUPDATE_IE_ASSOC_RESP) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3728 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3729 | hdd_err("Could not pass on ASSOC_RSP data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3730 | } |
| 3731 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 3732 | wlan_hdd_reset_prob_rspies(adapter); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 3733 | qdf_mem_free(adapter->sessionCtx.ap.beacon); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3734 | adapter->sessionCtx.ap.beacon = NULL; |
| 3735 | } |
| 3736 | mutex_unlock(&hdd_ctx->sap_lock); |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 3737 | if (true == bCloseSession) |
| 3738 | hdd_wait_for_sme_close_sesion(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3739 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3740 | case QDF_OCB_MODE: |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 3741 | cdp_peer_clear(cds_get_context(QDF_MODULE_ID_SOC), |
| 3742 | cds_get_context(QDF_MODULE_ID_TXRX), |
| 3743 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.staId[0]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3744 | break; |
| 3745 | default: |
| 3746 | break; |
| 3747 | } |
| 3748 | |
| 3749 | EXIT(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3750 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3751 | } |
| 3752 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 3753 | /** |
| 3754 | * hdd_deinit_all_adapters - deinit all adapters |
| 3755 | * @hdd_ctx: HDD context |
| 3756 | * @rtnl_held: True if RTNL lock held |
| 3757 | * |
| 3758 | */ |
| 3759 | void hdd_deinit_all_adapters(hdd_context_t *hdd_ctx, bool rtnl_held) |
| 3760 | { |
| 3761 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 3762 | QDF_STATUS status; |
| 3763 | hdd_adapter_t *adapter; |
| 3764 | |
| 3765 | ENTER(); |
| 3766 | |
| 3767 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 3768 | |
| 3769 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 3770 | adapter = adapter_node->pAdapter; |
| 3771 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
| 3772 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 3773 | adapter_node = next; |
| 3774 | } |
| 3775 | |
| 3776 | EXIT(); |
| 3777 | } |
| 3778 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3779 | QDF_STATUS hdd_stop_all_adapters(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3780 | { |
| 3781 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3782 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3783 | hdd_adapter_t *adapter; |
| 3784 | |
| 3785 | ENTER(); |
| 3786 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 3787 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 3788 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3789 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 3790 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3791 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3792 | adapter = adapterNode->pAdapter; |
| 3793 | hdd_stop_adapter(hdd_ctx, adapter, true); |
| 3794 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 3795 | adapterNode = pNext; |
| 3796 | } |
| 3797 | |
| 3798 | EXIT(); |
| 3799 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3800 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3801 | } |
| 3802 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3803 | QDF_STATUS hdd_reset_all_adapters(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3804 | { |
| 3805 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3806 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3807 | hdd_adapter_t *adapter; |
| 3808 | |
| 3809 | ENTER(); |
| 3810 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 3811 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 3812 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3813 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 3814 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3815 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3816 | adapter = adapterNode->pAdapter; |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3817 | hdd_notice("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3818 | wlan_hdd_netif_queue_control(adapter, |
| 3819 | WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 3820 | WLAN_CONTROL_PATH); |
| 3821 | |
| 3822 | adapter->sessionCtx.station.hdd_ReassocScenario = false; |
| 3823 | |
| 3824 | hdd_deinit_tx_rx(adapter); |
Tushnim Bhattacharyya | 4adb368 | 2016-01-07 15:07:12 -0800 | [diff] [blame] | 3825 | cds_decr_session_set_pcl(adapter->device_mode, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3826 | adapter->sessionId); |
| 3827 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 3828 | hdd_wmm_adapter_close(adapter); |
| 3829 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3830 | } |
| 3831 | |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 3832 | /* |
| 3833 | * If adapter is SAP, set session ID to invalid since SAP |
| 3834 | * session will be cleanup during SSR. |
| 3835 | */ |
| 3836 | if (adapter->device_mode == QDF_SAP_MODE) |
| 3837 | wlansap_set_invalid_session( |
| 3838 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 3839 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3840 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 3841 | adapterNode = pNext; |
| 3842 | } |
| 3843 | |
| 3844 | EXIT(); |
| 3845 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3846 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3847 | } |
| 3848 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3849 | /** |
| 3850 | * hdd_is_interface_up()- Checkfor interface up before ssr |
| 3851 | * @hdd_ctx: HDD context |
| 3852 | * |
| 3853 | * check if there are any wlan interfaces before SSR accordingly start |
| 3854 | * the interface. |
| 3855 | * |
| 3856 | * Return: 0 if interface was opened else false |
| 3857 | */ |
| 3858 | static bool hdd_is_interface_up(hdd_adapter_t *adapter) |
| 3859 | { |
| 3860 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 3861 | return true; |
| 3862 | else |
| 3863 | return false; |
| 3864 | } |
| 3865 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3866 | #if defined CFG80211_CONNECT_BSS |
| 3867 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
| 3868 | && !defined(WITH_BACKPORTS) && !defined(IEEE80211_PRIVACY) |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3869 | static |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3870 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 3871 | struct ieee80211_channel *channel, |
| 3872 | const u8 *bssid, const u8 *ssid, |
| 3873 | size_t ssid_len) |
| 3874 | { |
| 3875 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 3876 | ssid, ssid_len, |
| 3877 | WLAN_CAPABILITY_ESS, |
| 3878 | WLAN_CAPABILITY_ESS); |
| 3879 | } |
| 3880 | #else |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3881 | static |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3882 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 3883 | struct ieee80211_channel *channel, |
| 3884 | const u8 *bssid, const u8 *ssid, |
| 3885 | size_t ssid_len) |
| 3886 | { |
| 3887 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 3888 | ssid, ssid_len, |
| 3889 | IEEE80211_BSS_TYPE_ESS, |
| 3890 | IEEE80211_PRIVACY_ANY); |
| 3891 | } |
| 3892 | #endif |
| 3893 | #endif |
| 3894 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 3895 | #if defined CFG80211_CONNECT_BSS |
| 3896 | /** |
| 3897 | * hdd_connect_bss() - API to send connection status to supplicant |
| 3898 | * @dev: network device |
| 3899 | * @bssid: bssid to which we want to associate |
| 3900 | * @req_ie: Request Information Element |
| 3901 | * @req_ie_len: len of the req IE |
| 3902 | * @resp_ie: Response IE |
| 3903 | * @resp_ie_len: len of ht response IE |
| 3904 | * @status: status |
| 3905 | * @gfp: Kernel Flag |
| 3906 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 3907 | * |
| 3908 | * The API is a wrapper to send connection status to supplicant |
| 3909 | * |
| 3910 | * Return: Void |
| 3911 | */ |
| 3912 | #if defined CFG80211_CONNECT_TIMEOUT |
| 3913 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 3914 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 3915 | size_t req_ie_len, const u8 *resp_ie, |
| 3916 | size_t resp_ie_len, int status, gfp_t gfp, |
| 3917 | bool connect_timeout) |
| 3918 | { |
| 3919 | if (connect_timeout) |
| 3920 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 3921 | else |
| 3922 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 3923 | resp_ie, resp_ie_len, status, gfp); |
| 3924 | } |
| 3925 | #else |
| 3926 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 3927 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 3928 | size_t req_ie_len, const u8 *resp_ie, |
| 3929 | size_t resp_ie_len, int status, gfp_t gfp, |
| 3930 | bool connect_timeout) |
| 3931 | { |
| 3932 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 3933 | resp_ie, resp_ie_len, status, gfp); |
| 3934 | } |
| 3935 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3936 | |
| 3937 | /** |
| 3938 | * hdd_connect_result() - API to send connection status to supplicant |
| 3939 | * @dev: network device |
| 3940 | * @bssid: bssid to which we want to associate |
| 3941 | * @roam_info: information about connected bss |
| 3942 | * @req_ie: Request Information Element |
| 3943 | * @req_ie_len: len of the req IE |
| 3944 | * @resp_ie: Response IE |
| 3945 | * @resp_ie_len: len of ht response IE |
| 3946 | * @status: status |
| 3947 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 3948 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3949 | * |
| 3950 | * The API is a wrapper to send connection status to supplicant |
| 3951 | * and allow runtime suspend |
| 3952 | * |
| 3953 | * Return: Void |
| 3954 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3955 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
| 3956 | tCsrRoamInfo *roam_info, const u8 *req_ie, |
| 3957 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 3958 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 3959 | bool connect_timeout) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3960 | { |
| 3961 | hdd_adapter_t *padapter = (hdd_adapter_t *) netdev_priv(dev); |
| 3962 | struct cfg80211_bss *bss = NULL; |
| 3963 | |
| 3964 | if (WLAN_STATUS_SUCCESS == status) { |
| 3965 | struct ieee80211_channel *chan; |
| 3966 | int freq; |
| 3967 | int chan_no = roam_info->pBssDesc->channelId; |
| 3968 | |
| 3969 | if (chan_no <= 14) |
| 3970 | freq = ieee80211_channel_to_frequency(chan_no, |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 3971 | NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3972 | else |
| 3973 | freq = ieee80211_channel_to_frequency(chan_no, |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 3974 | NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3975 | |
| 3976 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
| 3977 | bss = hdd_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
| 3978 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 3979 | roam_info->u.pConnectedProfile->SSID.length); |
| 3980 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3981 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 3982 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 3983 | req_ie_len, resp_ie, resp_ie_len, |
| 3984 | status, gfp, connect_timeout); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3985 | |
| 3986 | qdf_runtime_pm_allow_suspend(padapter->connect_rpm_ctx.connect); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3987 | } |
| 3988 | #else |
| 3989 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
| 3990 | tCsrRoamInfo *roam_info, const u8 *req_ie, |
| 3991 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 3992 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 3993 | bool connect_timeout) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3994 | { |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3995 | hdd_adapter_t *padapter = (hdd_adapter_t *) netdev_priv(dev); |
| 3996 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 3997 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 3998 | resp_ie, resp_ie_len, status, gfp); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3999 | qdf_runtime_pm_allow_suspend(padapter->connect_rpm_ctx.connect); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4000 | } |
| 4001 | #endif |
| 4002 | |
| 4003 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4004 | QDF_STATUS hdd_start_all_adapters(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4005 | { |
| 4006 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4007 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4008 | hdd_adapter_t *adapter; |
| 4009 | #ifndef MSM_PLATFORM |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4010 | struct qdf_mac_addr bcastMac = QDF_MAC_ADDR_BROADCAST_INITIALIZER; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4011 | #endif |
| 4012 | eConnectionState connState; |
| 4013 | |
| 4014 | ENTER(); |
| 4015 | |
| 4016 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4017 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4018 | adapter = adapterNode->pAdapter; |
| 4019 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4020 | if (!hdd_is_interface_up(adapter)) |
Hanumanth Reddy Pothula | c1c4d2b | 2016-09-22 15:45:16 +0530 | [diff] [blame] | 4021 | goto get_adapter; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4022 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4023 | hdd_wmm_init(adapter); |
| 4024 | |
| 4025 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4026 | case QDF_STA_MODE: |
| 4027 | case QDF_P2P_CLIENT_MODE: |
| 4028 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4029 | |
| 4030 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 4031 | ->conn_info.connState; |
| 4032 | |
| 4033 | hdd_init_station_mode(adapter); |
| 4034 | /* Open the gates for HDD to receive Wext commands */ |
| 4035 | adapter->isLinkUpSvcNeeded = false; |
| 4036 | adapter->scan_info.mScanPending = false; |
| 4037 | |
| 4038 | /* Indicate disconnect event to supplicant if associated previously */ |
| 4039 | if (eConnectionState_Associated == connState || |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 4040 | eConnectionState_IbssConnected == connState || |
| 4041 | eConnectionState_NotConnected == connState || |
| 4042 | eConnectionState_IbssDisconnected == connState || |
| 4043 | eConnectionState_Disconnecting == connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4044 | union iwreq_data wrqu; |
| 4045 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 4046 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 4047 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 4048 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 4049 | &wrqu, NULL); |
| 4050 | adapter->sessionCtx.station. |
| 4051 | hdd_ReassocScenario = false; |
| 4052 | |
| 4053 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 4054 | wlan_hdd_cfg80211_indicate_disconnect( |
| 4055 | adapter->dev, false, |
| 4056 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4057 | } else if (eConnectionState_Connecting == connState) { |
| 4058 | /* |
| 4059 | * Indicate connect failure to supplicant if we were in the |
| 4060 | * process of connecting |
| 4061 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4062 | hdd_connect_result(adapter->dev, NULL, NULL, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4063 | NULL, 0, NULL, 0, |
| 4064 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4065 | GFP_KERNEL, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4066 | } |
| 4067 | |
| 4068 | hdd_register_tx_flow_control(adapter, |
| 4069 | hdd_tx_resume_timer_expired_handler, |
| 4070 | hdd_tx_resume_cb); |
| 4071 | |
| 4072 | break; |
| 4073 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4074 | case QDF_SAP_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4075 | /* softAP can handle SSR */ |
| 4076 | break; |
| 4077 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4078 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4079 | #ifdef MSM_PLATFORM |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4080 | hdd_err("[SSR] send stop ap to supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4081 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 4082 | #else |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4083 | hdd_err("[SSR] send restart supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4084 | /* event supplicant to restart */ |
| 4085 | cfg80211_del_sta(adapter->dev, |
| 4086 | (const u8 *)&bcastMac.bytes[0], |
| 4087 | GFP_KERNEL); |
| 4088 | #endif |
| 4089 | break; |
| 4090 | |
| 4091 | default: |
| 4092 | break; |
| 4093 | } |
Hanumanth Reddy Pothula | c1c4d2b | 2016-09-22 15:45:16 +0530 | [diff] [blame] | 4094 | get_adapter: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4095 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4096 | adapterNode = pNext; |
| 4097 | } |
| 4098 | |
| 4099 | EXIT(); |
| 4100 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4101 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4102 | } |
| 4103 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4104 | QDF_STATUS hdd_get_front_adapter(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4105 | hdd_adapter_list_node_t **padapterNode) |
| 4106 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4107 | QDF_STATUS status; |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4108 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4109 | status = qdf_list_peek_front(&hdd_ctx->hddAdapters, |
| 4110 | (qdf_list_node_t **) padapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4111 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4112 | return status; |
| 4113 | } |
| 4114 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4115 | QDF_STATUS hdd_get_next_adapter(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4116 | hdd_adapter_list_node_t *adapterNode, |
| 4117 | hdd_adapter_list_node_t **pNextAdapterNode) |
| 4118 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4119 | QDF_STATUS status; |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4120 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4121 | status = qdf_list_peek_next(&hdd_ctx->hddAdapters, |
| 4122 | (qdf_list_node_t *) adapterNode, |
| 4123 | (qdf_list_node_t **) pNextAdapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4124 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4125 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4126 | return status; |
| 4127 | } |
| 4128 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4129 | QDF_STATUS hdd_remove_adapter(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4130 | hdd_adapter_list_node_t *adapterNode) |
| 4131 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4132 | QDF_STATUS status; |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4133 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4134 | status = qdf_list_remove_node(&hdd_ctx->hddAdapters, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4135 | &adapterNode->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4136 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4137 | return status; |
| 4138 | } |
| 4139 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4140 | QDF_STATUS hdd_remove_front_adapter(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4141 | hdd_adapter_list_node_t **padapterNode) |
| 4142 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4143 | QDF_STATUS status; |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4144 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4145 | status = qdf_list_remove_front(&hdd_ctx->hddAdapters, |
| 4146 | (qdf_list_node_t **) padapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4147 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4148 | return status; |
| 4149 | } |
| 4150 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4151 | QDF_STATUS hdd_add_adapter_back(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4152 | hdd_adapter_list_node_t *adapterNode) |
| 4153 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4154 | QDF_STATUS status; |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4155 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4156 | status = qdf_list_insert_back(&hdd_ctx->hddAdapters, |
| 4157 | (qdf_list_node_t *) adapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4158 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4159 | return status; |
| 4160 | } |
| 4161 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4162 | QDF_STATUS hdd_add_adapter_front(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4163 | hdd_adapter_list_node_t *adapterNode) |
| 4164 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4165 | QDF_STATUS status; |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4166 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 4167 | status = qdf_list_insert_front(&hdd_ctx->hddAdapters, |
| 4168 | (qdf_list_node_t *) adapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 4169 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4170 | return status; |
| 4171 | } |
| 4172 | |
| 4173 | hdd_adapter_t *hdd_get_adapter_by_macaddr(hdd_context_t *hdd_ctx, |
| 4174 | tSirMacAddr macAddr) |
| 4175 | { |
| 4176 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 4177 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4178 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4179 | |
| 4180 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4181 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4182 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4183 | adapter = adapterNode->pAdapter; |
| 4184 | |
| 4185 | if (adapter |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4186 | && !qdf_mem_cmp(adapter->macAddressCurrent.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4187 | macAddr, sizeof(tSirMacAddr))) { |
| 4188 | return adapter; |
| 4189 | } |
| 4190 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4191 | adapterNode = pNext; |
| 4192 | } |
| 4193 | |
| 4194 | return NULL; |
| 4195 | |
| 4196 | } |
| 4197 | |
| 4198 | hdd_adapter_t *hdd_get_adapter_by_vdev(hdd_context_t *hdd_ctx, |
| 4199 | uint32_t vdev_id) |
| 4200 | { |
| 4201 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 4202 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4203 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4204 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4205 | qdf_status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4206 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4207 | while ((NULL != adapterNode) && (QDF_STATUS_SUCCESS == qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4208 | adapter = adapterNode->pAdapter; |
| 4209 | |
| 4210 | if (adapter->sessionId == vdev_id) |
| 4211 | return adapter; |
| 4212 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4213 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4214 | hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4215 | adapterNode = pNext; |
| 4216 | } |
| 4217 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4218 | hdd_err("vdev_id %d does not exist with host", vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4219 | |
| 4220 | return NULL; |
| 4221 | } |
| 4222 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 4223 | /** |
| 4224 | * hdd_get_adapter_by_sme_session_id() - Return adapter with |
| 4225 | * the sessionid |
| 4226 | * @hdd_ctx: hdd context. |
| 4227 | * @sme_session_id: sme session is for the adapter to get. |
| 4228 | * |
| 4229 | * This function is used to get the adapter with provided session id |
| 4230 | * |
| 4231 | * Return: adapter pointer if found |
| 4232 | * |
| 4233 | */ |
| 4234 | hdd_adapter_t *hdd_get_adapter_by_sme_session_id(hdd_context_t *hdd_ctx, |
| 4235 | uint32_t sme_session_id) |
| 4236 | { |
| 4237 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 4238 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4239 | QDF_STATUS qdf_status; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 4240 | |
| 4241 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4242 | qdf_status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 4243 | |
| 4244 | while ((NULL != adapter_node) && |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4245 | (QDF_STATUS_SUCCESS == qdf_status)) { |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 4246 | adapter = adapter_node->pAdapter; |
| 4247 | |
| 4248 | if (adapter && |
| 4249 | adapter->sessionId == sme_session_id) |
| 4250 | return adapter; |
| 4251 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4252 | qdf_status = |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 4253 | hdd_get_next_adapter(hdd_ctx, |
| 4254 | adapter_node, &next); |
| 4255 | adapter_node = next; |
| 4256 | } |
| 4257 | return NULL; |
| 4258 | } |
| 4259 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4260 | /** |
| 4261 | * hdd_get_adapter() - to get adapter matching the mode |
| 4262 | * @hdd_ctx: hdd context |
| 4263 | * @mode: adapter mode |
| 4264 | * |
| 4265 | * This routine will return the pointer to adapter matching |
| 4266 | * with the passed mode. |
| 4267 | * |
| 4268 | * Return: pointer to adapter or null |
| 4269 | */ |
| 4270 | hdd_adapter_t *hdd_get_adapter(hdd_context_t *hdd_ctx, |
| 4271 | enum tQDF_ADAPTER_MODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4272 | { |
| 4273 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 4274 | hdd_adapter_t *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4275 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4276 | |
| 4277 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4278 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4279 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4280 | adapter = adapterNode->pAdapter; |
| 4281 | |
| 4282 | if (adapter && (mode == adapter->device_mode)) |
| 4283 | return adapter; |
| 4284 | |
| 4285 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4286 | adapterNode = pNext; |
| 4287 | } |
| 4288 | |
| 4289 | return NULL; |
| 4290 | |
| 4291 | } |
| 4292 | |
| 4293 | /** |
| 4294 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 4295 | * @hdd_ctx: Pointer to the HDD context. |
| 4296 | * @mode: Device mode for which operating channel is required. |
| 4297 | * Suported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4298 | * QDF_STA_MODE, |
| 4299 | * QDF_P2P_CLIENT_MODE, |
| 4300 | * QDF_SAP_MODE, |
| 4301 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4302 | * |
| 4303 | * This API returns the operating channel of the requested device mode |
| 4304 | * |
| 4305 | * Return: channel number. "0" id the requested device is not found OR it is |
| 4306 | * not connected. |
| 4307 | */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4308 | uint8_t hdd_get_operating_channel(hdd_context_t *hdd_ctx, |
| 4309 | enum tQDF_ADAPTER_MODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4310 | { |
| 4311 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4312 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4313 | hdd_adapter_t *adapter; |
| 4314 | uint8_t operatingChannel = 0; |
| 4315 | |
| 4316 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4317 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4318 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4319 | adapter = adapterNode->pAdapter; |
| 4320 | |
| 4321 | if (mode == adapter->device_mode) { |
| 4322 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4323 | case QDF_STA_MODE: |
| 4324 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4325 | if (hdd_conn_is_connected |
| 4326 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 4327 | (adapter))) { |
| 4328 | operatingChannel = |
| 4329 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 4330 | (adapter))->conn_info. |
| 4331 | operationChannel; |
| 4332 | } |
| 4333 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4334 | case QDF_SAP_MODE: |
| 4335 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4336 | /* softap connection info */ |
| 4337 | if (test_bit |
| 4338 | (SOFTAP_BSS_STARTED, |
| 4339 | &adapter->event_flags)) |
| 4340 | operatingChannel = |
| 4341 | (WLAN_HDD_GET_AP_CTX_PTR |
| 4342 | (adapter))->operatingChannel; |
| 4343 | break; |
| 4344 | default: |
| 4345 | break; |
| 4346 | } |
| 4347 | |
| 4348 | break; /* Found the device of interest. break the loop */ |
| 4349 | } |
| 4350 | |
| 4351 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4352 | adapterNode = pNext; |
| 4353 | } |
| 4354 | return operatingChannel; |
| 4355 | } |
| 4356 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4357 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(hdd_context_t * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4358 | hdd_ctx) |
| 4359 | { |
| 4360 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4361 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4362 | hdd_adapter_t *adapter; |
| 4363 | |
| 4364 | ENTER(); |
| 4365 | |
| 4366 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4367 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4368 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4369 | adapter = adapterNode->pAdapter; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4370 | if ((adapter->device_mode == QDF_STA_MODE) || |
| 4371 | (adapter->device_mode == QDF_P2P_CLIENT_MODE) || |
| 4372 | (adapter->device_mode == QDF_IBSS_MODE) || |
| 4373 | (adapter->device_mode == QDF_P2P_DEVICE_MODE) || |
| 4374 | (adapter->device_mode == QDF_SAP_MODE) || |
| 4375 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4376 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 4377 | hdd_unregister_wext(adapter->dev); |
| 4378 | } |
| 4379 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4380 | adapterNode = pNext; |
| 4381 | } |
| 4382 | |
| 4383 | EXIT(); |
| 4384 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4385 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4386 | } |
| 4387 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4388 | 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] | 4389 | { |
| 4390 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4391 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4392 | hdd_adapter_t *adapter; |
| 4393 | |
| 4394 | ENTER(); |
| 4395 | |
| 4396 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4397 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4398 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4399 | adapter = adapterNode->pAdapter; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4400 | if ((adapter->device_mode == QDF_STA_MODE) || |
| 4401 | (adapter->device_mode == QDF_P2P_CLIENT_MODE) || |
| 4402 | (adapter->device_mode == QDF_IBSS_MODE) || |
| 4403 | (adapter->device_mode == QDF_P2P_DEVICE_MODE) || |
| 4404 | (adapter->device_mode == QDF_SAP_MODE) || |
| 4405 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4406 | hdd_abort_mac_scan(hdd_ctx, adapter->sessionId, |
| 4407 | eCSR_SCAN_ABORT_DEFAULT); |
| 4408 | } |
| 4409 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4410 | adapterNode = pNext; |
| 4411 | } |
| 4412 | |
| 4413 | EXIT(); |
| 4414 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4415 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4416 | } |
| 4417 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 4418 | /** |
| 4419 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 4420 | * adapters |
| 4421 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 4422 | * |
| 4423 | * return: QDF_STATUS_SUCCESS |
| 4424 | */ |
| 4425 | static QDF_STATUS hdd_abort_sched_scan_all_adapters(hdd_context_t *hdd_ctx) |
| 4426 | { |
| 4427 | hdd_adapter_list_node_t *adapter_node = NULL, *next_node = NULL; |
| 4428 | QDF_STATUS status; |
| 4429 | hdd_adapter_t *adapter; |
| 4430 | int err; |
| 4431 | |
| 4432 | ENTER(); |
| 4433 | |
| 4434 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 4435 | |
| 4436 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 4437 | adapter = adapter_node->pAdapter; |
| 4438 | if ((adapter->device_mode == QDF_STA_MODE) || |
| 4439 | (adapter->device_mode == QDF_P2P_CLIENT_MODE) || |
| 4440 | (adapter->device_mode == QDF_IBSS_MODE) || |
| 4441 | (adapter->device_mode == QDF_P2P_DEVICE_MODE) || |
| 4442 | (adapter->device_mode == QDF_SAP_MODE) || |
| 4443 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
| 4444 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 4445 | if (err) |
| 4446 | hdd_err("Unable to stop scheduled scan"); |
| 4447 | } |
| 4448 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next_node); |
| 4449 | adapter_node = next_node; |
| 4450 | } |
| 4451 | |
| 4452 | EXIT(); |
| 4453 | |
| 4454 | return QDF_STATUS_SUCCESS; |
| 4455 | } |
| 4456 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4457 | #ifdef WLAN_NS_OFFLOAD |
| 4458 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4459 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4460 | * @hdd_ctx: Pointer to hdd context |
| 4461 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4462 | * Unregister for IPv6 address change notifications. |
| 4463 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4464 | * Return: None |
| 4465 | */ |
| 4466 | static void hdd_wlan_unregister_ip6_notifier(hdd_context_t *hdd_ctx) |
| 4467 | { |
| 4468 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
| 4469 | |
| 4470 | return; |
| 4471 | } |
| 4472 | |
| 4473 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4474 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4475 | * @hdd_ctx: Pointer to hdd context |
| 4476 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4477 | * Register for IPv6 address change notifications. |
| 4478 | * |
| 4479 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4480 | */ |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4481 | static int hdd_wlan_register_ip6_notifier(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4482 | { |
| 4483 | int ret; |
| 4484 | |
| 4485 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 4486 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4487 | if (ret) { |
| 4488 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 4489 | goto out; |
| 4490 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4491 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4492 | hdd_info("Registered IPv6 notifier"); |
| 4493 | out: |
| 4494 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4495 | } |
| 4496 | #else |
| 4497 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4498 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4499 | * @hdd_ctx: Pointer to hdd context |
| 4500 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4501 | * Unregister for IPv6 address change notifications. |
| 4502 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4503 | * Return: None |
| 4504 | */ |
| 4505 | static void hdd_wlan_unregister_ip6_notifier(hdd_context_t *hdd_ctx) |
| 4506 | { |
| 4507 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4508 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4509 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4510 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4511 | * @hdd_ctx: Pointer to hdd context |
| 4512 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4513 | * Register for IPv6 address change notifications. |
| 4514 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4515 | * Return: None |
| 4516 | */ |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4517 | static int hdd_wlan_register_ip6_notifier(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4518 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4519 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4520 | } |
| 4521 | #endif |
| 4522 | |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 4523 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 4524 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4525 | * hdd_logging_sock_activate_svc() - Activate logging |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 4526 | * @hdd_ctx: HDD context |
| 4527 | * |
| 4528 | * Activates the logging service |
| 4529 | * |
| 4530 | * Return: Zero in case of success, negative value otherwise |
| 4531 | */ |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4532 | static int hdd_logging_sock_activate_svc(hdd_context_t *hdd_ctx) |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 4533 | { |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4534 | int ret; |
| 4535 | struct hdd_config *config = hdd_ctx->config; |
| 4536 | |
| 4537 | if (!config->wlanLoggingEnable) |
| 4538 | return 0; |
| 4539 | |
| 4540 | ret = wlan_logging_sock_activate_svc(config->wlanLoggingFEToConsole, |
| 4541 | config->wlanLoggingNumBuf); |
| 4542 | if (ret) |
| 4543 | hdd_err("wlan_logging_sock_activate_svc failed: %d", ret); |
| 4544 | return ret; |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 4545 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4546 | |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 4547 | /** |
| 4548 | * wlan_hdd_logging_sock_deactivate_svc() - Deactivate logging |
| 4549 | * @hdd_ctx: HDD context |
| 4550 | * |
| 4551 | * Deactivates the logging service |
| 4552 | * |
| 4553 | * Return: 0 on deactivating the logging service |
| 4554 | */ |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4555 | static int hdd_logging_sock_deactivate_svc(hdd_context_t *hdd_ctx) |
Chandrasekaran, Manishekar | 3cc29cb | 2016-01-16 17:28:11 +0530 | [diff] [blame] | 4556 | { |
| 4557 | if (hdd_ctx && hdd_ctx->config->wlanLoggingEnable) |
| 4558 | return wlan_logging_sock_deactivate_svc(); |
| 4559 | |
| 4560 | return 0; |
| 4561 | } |
| 4562 | #else |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4563 | 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] | 4564 | { |
| 4565 | return 0; |
| 4566 | } |
| 4567 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4568 | 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] | 4569 | { |
| 4570 | return 0; |
| 4571 | } |
| 4572 | #endif |
| 4573 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4574 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4575 | * hdd_register_notifiers - Register netdev notifiers. |
| 4576 | * @hdd_ctx: HDD context |
| 4577 | * |
| 4578 | * Register netdev notifiers like IPv4 and IPv6. |
| 4579 | * |
| 4580 | * Return: 0 on success and errno on failure |
| 4581 | */ |
| 4582 | static int hdd_register_notifiers(hdd_context_t *hdd_ctx) |
| 4583 | { |
| 4584 | int ret; |
| 4585 | |
| 4586 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 4587 | if (ret) { |
| 4588 | hdd_err("register_netdevice_notifier failed: %d", ret); |
| 4589 | goto out; |
| 4590 | } |
| 4591 | |
| 4592 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 4593 | if (ret) |
| 4594 | goto unregister_notifier; |
| 4595 | |
| 4596 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 4597 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 4598 | if (ret) { |
| 4599 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 4600 | goto unregister_ip6_notifier; |
| 4601 | } |
| 4602 | |
| 4603 | return 0; |
| 4604 | |
| 4605 | unregister_ip6_notifier: |
| 4606 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 4607 | unregister_notifier: |
| 4608 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 4609 | out: |
| 4610 | return ret; |
| 4611 | |
| 4612 | } |
| 4613 | |
| 4614 | /** |
| 4615 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 4616 | * @hdd_ctx: HDD context |
| 4617 | * |
| 4618 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 4619 | * |
| 4620 | * Return: None. |
| 4621 | */ |
| 4622 | static void hdd_unregister_notifiers(hdd_context_t *hdd_ctx) |
| 4623 | { |
| 4624 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 4625 | |
| 4626 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 4627 | |
| 4628 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 4629 | } |
| 4630 | |
| 4631 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4632 | * hdd_exit_netlink_services - Exit netlink services |
| 4633 | * @hdd_ctx: HDD context |
| 4634 | * |
| 4635 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 4636 | * nl service. |
| 4637 | * |
| 4638 | * Return: None. |
| 4639 | */ |
| 4640 | static void hdd_exit_netlink_services(hdd_context_t *hdd_ctx) |
| 4641 | { |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4642 | hdd_close_cesium_nl_sock(); |
| 4643 | |
| 4644 | ptt_sock_deactivate_svc(); |
| 4645 | |
| 4646 | nl_srv_exit(); |
| 4647 | } |
| 4648 | |
| 4649 | /** |
| 4650 | * hdd_init_netlink_services- Init netlink services |
| 4651 | * @hdd_ctx: HDD context |
| 4652 | * |
| 4653 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 4654 | * nl service. |
| 4655 | * |
| 4656 | * Return: 0 on success and errno on failure. |
| 4657 | */ |
| 4658 | static int hdd_init_netlink_services(hdd_context_t *hdd_ctx) |
| 4659 | { |
| 4660 | int ret; |
| 4661 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 4662 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4663 | if (ret) { |
| 4664 | hdd_alert("nl_srv_init failed: %d", ret); |
| 4665 | goto out; |
| 4666 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 4667 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4668 | |
| 4669 | ret = oem_activate_service(hdd_ctx); |
| 4670 | if (ret) { |
| 4671 | hdd_alert("oem_activate_service failed: %d", ret); |
| 4672 | goto err_nl_srv; |
| 4673 | } |
| 4674 | |
| 4675 | ret = ptt_sock_activate_svc(); |
| 4676 | if (ret) { |
| 4677 | hdd_alert("ptt_sock_activate_svc failed: %d", ret); |
| 4678 | goto err_nl_srv; |
| 4679 | } |
| 4680 | |
| 4681 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 4682 | if (ret) |
| 4683 | hdd_warn("hdd_open_cesium_nl_sock failed"); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4684 | |
| 4685 | ret = cnss_diag_activate_service(); |
| 4686 | if (ret) { |
| 4687 | hdd_alert("cnss_diag_activate_service failed: %d", ret); |
| 4688 | goto err_close_cesium; |
| 4689 | } |
| 4690 | |
| 4691 | return 0; |
| 4692 | |
| 4693 | err_close_cesium: |
| 4694 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4695 | ptt_sock_deactivate_svc(); |
| 4696 | err_nl_srv: |
| 4697 | nl_srv_exit(); |
| 4698 | out: |
| 4699 | return ret; |
| 4700 | } |
| 4701 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 4702 | /** |
| 4703 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 4704 | * @hdd_ctx: HDD context. |
| 4705 | * |
| 4706 | * Destroy RX wakelock. |
| 4707 | * |
| 4708 | * Return: None. |
| 4709 | */ |
| 4710 | static void hdd_rx_wake_lock_destroy(hdd_context_t *hdd_ctx) |
| 4711 | { |
| 4712 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 4713 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 4714 | |
| 4715 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 4716 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 4717 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4718 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 4719 | * Create RX wakelock. |
| 4720 | * |
| 4721 | * Return: None. |
| 4722 | */ |
| 4723 | static void hdd_rx_wake_lock_create(hdd_context_t *hdd_ctx) |
| 4724 | { |
| 4725 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 4726 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 4727 | |
| 4728 | /** |
| 4729 | * hdd_roc_context_init() - Init ROC context |
| 4730 | * @hdd_ctx: HDD context. |
| 4731 | * |
| 4732 | * Initialize ROC context. |
| 4733 | * |
| 4734 | * Return: 0 on success and errno on failure. |
| 4735 | */ |
| 4736 | static int hdd_roc_context_init(hdd_context_t *hdd_ctx) |
| 4737 | { |
| 4738 | qdf_spinlock_create(&hdd_ctx->hdd_roc_req_q_lock); |
| 4739 | qdf_list_create(&hdd_ctx->hdd_roc_req_q, MAX_ROC_REQ_QUEUE_ENTRY); |
| 4740 | |
| 4741 | INIT_DELAYED_WORK(&hdd_ctx->roc_req_work, wlan_hdd_roc_request_dequeue); |
| 4742 | |
| 4743 | return 0; |
| 4744 | } |
| 4745 | |
| 4746 | /** |
| 4747 | * hdd_roc_context_destroy() - Destroy ROC context |
| 4748 | * @hdd_ctx: HDD context. |
| 4749 | * |
| 4750 | * Destroy roc list and flush the pending roc work. |
| 4751 | * |
| 4752 | * Return: None. |
| 4753 | */ |
| 4754 | static void hdd_roc_context_destroy(hdd_context_t *hdd_ctx) |
| 4755 | { |
| 4756 | flush_delayed_work(&hdd_ctx->roc_req_work); |
| 4757 | qdf_list_destroy(&hdd_ctx->hdd_roc_req_q); |
| 4758 | } |
| 4759 | |
| 4760 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 4761 | * hdd_context_deinit() - Deinitialize HDD context |
| 4762 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 4763 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 4764 | * Deinitialize HDD context along with all the feature specific contexts but |
| 4765 | * do not free hdd context itself. Caller of this API is supposed to free |
| 4766 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4767 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 4768 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4769 | */ |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 4770 | static int hdd_context_deinit(hdd_context_t *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4771 | { |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 4772 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4773 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 4774 | hdd_roc_context_destroy(hdd_ctx); |
| 4775 | |
| 4776 | hdd_sap_context_destroy(hdd_ctx); |
| 4777 | |
| 4778 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 4779 | |
| 4780 | hdd_tdls_context_destroy(hdd_ctx); |
| 4781 | |
| 4782 | hdd_scan_context_destroy(hdd_ctx); |
| 4783 | |
| 4784 | qdf_list_destroy(&hdd_ctx->hddAdapters); |
| 4785 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 4786 | return 0; |
| 4787 | } |
| 4788 | |
| 4789 | /** |
| 4790 | * hdd_context_destroy() - Destroy HDD context |
| 4791 | * @hdd_ctx: HDD context to be destroyed. |
| 4792 | * |
| 4793 | * Free config and HDD context as well as destroy all the resources. |
| 4794 | * |
| 4795 | * Return: None |
| 4796 | */ |
| 4797 | static void hdd_context_destroy(hdd_context_t *hdd_ctx) |
| 4798 | { |
| 4799 | if (QDF_GLOBAL_FTM_MODE != hdd_get_conparam()) |
| 4800 | hdd_logging_sock_deactivate_svc(hdd_ctx); |
| 4801 | |
| 4802 | hdd_context_deinit(hdd_ctx); |
| 4803 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4804 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 4805 | hdd_ctx->config = NULL; |
| 4806 | |
| 4807 | wiphy_free(hdd_ctx->wiphy); |
| 4808 | } |
| 4809 | |
| 4810 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4811 | * hdd_wlan_exit() - HDD WLAN exit function |
| 4812 | * @hdd_ctx: Pointer to the HDD Context |
| 4813 | * |
| 4814 | * This is the driver exit point (invoked during rmmod) |
| 4815 | * |
| 4816 | * Return: None |
| 4817 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4818 | static void hdd_wlan_exit(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4819 | { |
| 4820 | v_CONTEXT_t p_cds_context = hdd_ctx->pcds_context; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4821 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4822 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4823 | int driver_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4824 | |
| 4825 | ENTER(); |
| 4826 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4827 | if (QDF_TIMER_STATE_RUNNING == |
| 4828 | qdf_mc_timer_get_current_state(&hdd_ctx->iface_change_timer)) { |
| 4829 | hdd_info("Stpp interface change timer"); |
| 4830 | qdf_mc_timer_stop(&hdd_ctx->iface_change_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4831 | } |
| 4832 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4833 | if (!QDF_IS_STATUS_SUCCESS |
| 4834 | (qdf_mc_timer_destroy(&hdd_ctx->iface_change_timer))) |
| 4835 | hdd_err("Cannot delete interface change timer"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 4836 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4837 | |
| 4838 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4839 | |
Nitesh Shah | 61c10d9 | 2016-10-19 19:29:15 +0530 | [diff] [blame] | 4840 | qdf_mc_timer_destroy(&hdd_ctx->tdls_source_timer); |
| 4841 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 4842 | hdd_bus_bandwidth_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4843 | |
| 4844 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 4845 | if (QDF_TIMER_STATE_RUNNING == |
| 4846 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 4847 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4848 | } |
| 4849 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4850 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 4851 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4852 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4853 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 4854 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 4855 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 4856 | hdd_ctx->last_acs_channel_list = NULL; |
| 4857 | hdd_ctx->num_of_channels = 0; |
| 4858 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4859 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4860 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4861 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 4862 | driver_status = hdd_ctx->driver_status; |
| 4863 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 4864 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4865 | /* |
| 4866 | * Powersave Offload Case |
| 4867 | * Disable Idle Power Save Mode |
| 4868 | */ |
| 4869 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 4870 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4871 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 4872 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 4873 | /* |
| 4874 | * Cancel any outstanding scan requests. We are about to close |
| 4875 | * all of our adapters, but an adapter structure is what SME |
| 4876 | * passes back to our callback function. Hence if there |
| 4877 | * are any outstanding scan requests then there is a |
| 4878 | * race condition between when the adapter is closed and |
| 4879 | * when the callback is invoked. We try to resolve that |
| 4880 | * race condition here by canceling any outstanding scans |
| 4881 | * before we close the adapters. |
| 4882 | * Note that the scans may be cancelled in an asynchronous |
| 4883 | * manner, so ideally there needs to be some kind of |
| 4884 | * synchronization. Rather than introduce a new |
| 4885 | * synchronization here, we will utilize the fact that we are |
| 4886 | * about to Request Full Power, and since that is synchronized, |
| 4887 | * the expectation is that by the time Request Full Power has |
| 4888 | * completed, all scans will be cancelled |
| 4889 | */ |
| 4890 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 4891 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4892 | hdd_stop_all_adapters(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4893 | } |
| 4894 | |
| 4895 | /* |
| 4896 | * Close the scheduler before calling cds_close to make sure no thread |
| 4897 | * is scheduled after the each module close is called i.e after all the |
| 4898 | * data structures are freed. |
| 4899 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4900 | qdf_status = cds_sched_close(p_cds_context); |
| 4901 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4902 | hdd_alert("Failed to close CDS Scheduler"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4903 | QDF_ASSERT(QDF_IS_STATUS_SUCCESS(qdf_status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4904 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4905 | |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 4906 | hdd_wlan_stop_modules(hdd_ctx); |
| 4907 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 4908 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
| 4909 | qdf_spinlock_destroy(&hdd_ctx->sta_update_info_lock); |
| 4910 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
| 4911 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4912 | /* |
| 4913 | * Close CDS |
| 4914 | * This frees pMac(HAL) context. There should not be any call |
| 4915 | * that requires pMac access after this. |
| 4916 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4917 | |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 4918 | hdd_green_ap_deinit(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4919 | |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 4920 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4921 | hdd_close_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4922 | |
| 4923 | hdd_ipa_cleanup(hdd_ctx); |
| 4924 | |
| 4925 | /* Free up RoC request queue and flush workqueue */ |
| 4926 | cds_flush_work(&hdd_ctx->roc_req_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4927 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 4928 | wlansap_global_deinit(); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 4929 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
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) |
| 5419 | static void hdd_bus_bw_compute_cbk(void *priv) |
| 5420 | { |
| 5421 | hdd_context_t *hdd_ctx = (hdd_context_t *) priv; |
| 5422 | hdd_adapter_t *adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 5423 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 5424 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 5425 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5426 | uint64_t total_tx = 0, total_rx = 0; |
| 5427 | hdd_adapter_list_node_t *adapterNode = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5428 | QDF_STATUS status = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 5429 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5430 | bool connected = false; |
| 5431 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 5432 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 5433 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 5434 | return; |
| 5435 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5436 | for (status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5437 | NULL != adapterNode && QDF_STATUS_SUCCESS == status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5438 | status = |
| 5439 | hdd_get_next_adapter(hdd_ctx, adapterNode, &adapterNode)) { |
| 5440 | |
| 5441 | if (adapterNode->pAdapter == NULL) |
| 5442 | continue; |
| 5443 | adapter = adapterNode->pAdapter; |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 5444 | /* |
| 5445 | * Validate magic so we don't end up accessing |
| 5446 | * an invalid adapter. |
| 5447 | */ |
| 5448 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 5449 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5450 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5451 | if ((adapter->device_mode == QDF_STA_MODE || |
| 5452 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5453 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.connState |
| 5454 | != eConnectionState_Associated) { |
| 5455 | |
| 5456 | continue; |
| 5457 | } |
| 5458 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5459 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 5460 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5461 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->bApActive == false) { |
| 5462 | |
| 5463 | continue; |
| 5464 | } |
| 5465 | |
| 5466 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 5467 | adapter->prev_tx_packets); |
| 5468 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 5469 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 5470 | |
| 5471 | if (adapter->device_mode == QDF_SAP_MODE || |
| 5472 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 5473 | adapter->device_mode == QDF_IBSS_MODE) { |
| 5474 | |
| 5475 | ret = ol_get_intra_bss_fwd_pkts_count( |
| 5476 | adapter->sessionId, |
| 5477 | &fwd_tx_packets, &fwd_rx_packets); |
| 5478 | if (ret == A_OK) { |
| 5479 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 5480 | fwd_tx_packets, |
| 5481 | adapter->prev_fwd_tx_packets); |
| 5482 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 5483 | fwd_tx_packets, |
| 5484 | adapter->prev_fwd_rx_packets); |
| 5485 | } |
| 5486 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5487 | |
| 5488 | total_rx += adapter->stats.rx_packets; |
| 5489 | total_tx += adapter->stats.tx_packets; |
| 5490 | |
| 5491 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 5492 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 5493 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 5494 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 5495 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5496 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 5497 | connected = true; |
| 5498 | } |
| 5499 | |
| 5500 | hdd_ctx->hdd_txrx_hist[hdd_ctx->hdd_txrx_hist_idx].total_rx = total_rx; |
| 5501 | hdd_ctx->hdd_txrx_hist[hdd_ctx->hdd_txrx_hist_idx].total_tx = total_tx; |
| 5502 | hdd_ctx->hdd_txrx_hist[hdd_ctx->hdd_txrx_hist_idx].interval_rx = |
| 5503 | rx_packets; |
| 5504 | hdd_ctx->hdd_txrx_hist[hdd_ctx->hdd_txrx_hist_idx].interval_tx = |
| 5505 | tx_packets; |
| 5506 | |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 5507 | /* add intra bss forwarded tx and rx packets */ |
| 5508 | tx_packets += fwd_tx_packets_diff; |
| 5509 | rx_packets += fwd_rx_packets_diff; |
| 5510 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5511 | hdd_ipa_uc_stat_query(hdd_ctx, &ipa_tx_packets, &ipa_rx_packets); |
| 5512 | tx_packets += (uint64_t)ipa_tx_packets; |
| 5513 | rx_packets += (uint64_t)ipa_rx_packets; |
| 5514 | |
| 5515 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5516 | hdd_err("bus bandwidth timer running in disconnected state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5517 | return; |
| 5518 | } |
| 5519 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5520 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5521 | |
| 5522 | hdd_ipa_set_perf_level(hdd_ctx, tx_packets, rx_packets); |
| 5523 | hdd_ipa_uc_stat_request(adapter, 2); |
| 5524 | |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 5525 | qdf_mc_timer_start(&hdd_ctx->bus_bw_timer, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5526 | hdd_ctx->config->busBandwidthComputeInterval); |
| 5527 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 5528 | |
| 5529 | int hdd_bus_bandwidth_init(hdd_context_t *hdd_ctx) |
| 5530 | { |
| 5531 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
| 5532 | |
| 5533 | qdf_mc_timer_init(&hdd_ctx->bus_bw_timer, |
| 5534 | QDF_TIMER_TYPE_SW, |
| 5535 | hdd_bus_bw_compute_cbk, (void *)hdd_ctx); |
| 5536 | |
| 5537 | return 0; |
| 5538 | } |
| 5539 | |
| 5540 | void hdd_bus_bandwidth_destroy(hdd_context_t *hdd_ctx) |
| 5541 | { |
| 5542 | if (qdf_mc_timer_get_current_state(&hdd_ctx->bus_bw_timer) == |
| 5543 | QDF_TIMER_STATE_RUNNING) |
| 5544 | hdd_reset_tcp_delack(hdd_ctx); |
| 5545 | |
| 5546 | qdf_mc_timer_destroy(&hdd_ctx->bus_bw_timer); |
| 5547 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5548 | #endif |
| 5549 | |
| 5550 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 5551 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 5552 | * @hdd_ctx: hdd context |
| 5553 | * |
| 5554 | * Return: 0 for success or error code |
| 5555 | */ |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 5556 | 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] | 5557 | { |
| 5558 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 5559 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
| 5560 | if (hdd_ctx->hdd_txrx_hist == NULL) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5561 | hdd_err("Failed malloc for hdd_txrx_hist"); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 5562 | return -ENOMEM; |
| 5563 | } |
| 5564 | return 0; |
| 5565 | } |
| 5566 | |
| 5567 | /** |
| 5568 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 5569 | * @hdd_ctx: hdd context |
| 5570 | * |
| 5571 | * Return: none |
| 5572 | */ |
| 5573 | void wlan_hdd_deinit_tx_rx_histogram(hdd_context_t *hdd_ctx) |
| 5574 | { |
| 5575 | if (hdd_ctx->hdd_txrx_hist) { |
| 5576 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 5577 | hdd_ctx->hdd_txrx_hist = NULL; |
| 5578 | } |
| 5579 | } |
| 5580 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5581 | static uint8_t *convert_level_to_string(uint32_t level) |
| 5582 | { |
| 5583 | switch (level) { |
| 5584 | /* initialize the wlan sub system */ |
| 5585 | case WLAN_SVC_TP_NONE: |
| 5586 | return "NONE"; |
| 5587 | case WLAN_SVC_TP_LOW: |
| 5588 | return "LOW"; |
| 5589 | case WLAN_SVC_TP_MEDIUM: |
| 5590 | return "MED"; |
| 5591 | case WLAN_SVC_TP_HIGH: |
| 5592 | return "HIGH"; |
| 5593 | default: |
| 5594 | return "INVAL"; |
| 5595 | } |
| 5596 | } |
| 5597 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 5598 | |
| 5599 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5600 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 5601 | * @hdd_ctx: hdd context |
| 5602 | * |
| 5603 | * Return: none |
| 5604 | */ |
| 5605 | void wlan_hdd_display_tx_rx_histogram(hdd_context_t *hdd_ctx) |
| 5606 | { |
| 5607 | int i; |
| 5608 | |
| 5609 | #ifdef MSM_PLATFORM |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5610 | hdd_err("BW compute Interval: %dms", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5611 | hdd_ctx->config->busBandwidthComputeInterval); |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5612 | 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] | 5613 | hdd_ctx->config->busBandwidthHighThreshold, |
| 5614 | hdd_ctx->config->busBandwidthMediumThreshold, |
| 5615 | hdd_ctx->config->busBandwidthLowThreshold); |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5616 | hdd_err("Enable TCP DEL ACK: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5617 | hdd_ctx->config->enable_tcp_delack); |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5618 | hdd_err("TCP DEL High TH: %d TCP DEL Low TH: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5619 | hdd_ctx->config->tcpDelackThresholdHigh, |
| 5620 | hdd_ctx->config->tcpDelackThresholdLow); |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5621 | 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] | 5622 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5623 | #endif |
| 5624 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5625 | hdd_err("Total entries: %d Current index: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5626 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
| 5627 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5628 | 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] | 5629 | |
| 5630 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5631 | hdd_err("%d: %llu, %llu, %llu, %llu, %s, %s, %s", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5632 | i, hdd_ctx->hdd_txrx_hist[i].total_rx, |
| 5633 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
| 5634 | hdd_ctx->hdd_txrx_hist[i].total_tx, |
| 5635 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5636 | convert_level_to_string( |
| 5637 | hdd_ctx->hdd_txrx_hist[i].next_vote_level), |
| 5638 | convert_level_to_string( |
| 5639 | hdd_ctx->hdd_txrx_hist[i].next_rx_level), |
| 5640 | convert_level_to_string( |
| 5641 | hdd_ctx->hdd_txrx_hist[i].next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5642 | } |
| 5643 | return; |
| 5644 | } |
| 5645 | |
| 5646 | /** |
| 5647 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 5648 | * @hdd_ctx: hdd context |
| 5649 | * |
| 5650 | * Return: none |
| 5651 | */ |
| 5652 | void wlan_hdd_clear_tx_rx_histogram(hdd_context_t *hdd_ctx) |
| 5653 | { |
| 5654 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 5655 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 5656 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5657 | } |
| 5658 | |
| 5659 | /** |
| 5660 | * wlan_hdd_display_netif_queue_history() - display netif queue operation history |
| 5661 | * @pHddCtx: hdd context |
| 5662 | * |
| 5663 | * Return: none |
| 5664 | */ |
| 5665 | void wlan_hdd_display_netif_queue_history(hdd_context_t *hdd_ctx) |
| 5666 | { |
| 5667 | |
| 5668 | hdd_adapter_t *adapter = NULL; |
| 5669 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5670 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5671 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5672 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5673 | |
| 5674 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5675 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5676 | adapter = adapter_node->pAdapter; |
| 5677 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5678 | hdd_err("\nNetif queue operation statistics:"); |
| 5679 | hdd_err("Session_id %d device mode %d", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 5680 | adapter->sessionId, adapter->device_mode); |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5681 | hdd_err("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 5682 | curr_time = qdf_system_ticks(); |
| 5683 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5684 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 5685 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5686 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 5687 | unpause = adapter->total_unpause_time; |
| 5688 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5689 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 5690 | pause = adapter->total_pause_time; |
| 5691 | } |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5692 | hdd_err("Total: %ums Pause: %ums Unpause: %ums", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 5693 | qdf_system_ticks_to_msecs(total), |
| 5694 | qdf_system_ticks_to_msecs(pause), |
| 5695 | qdf_system_ticks_to_msecs(unpause)); |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5696 | hdd_err("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5697 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5698 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 5699 | qdf_time_t pause_delta = 0; |
| 5700 | |
| 5701 | if (adapter->pause_map & (1 << i)) |
| 5702 | pause_delta = delta; |
| 5703 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5704 | hdd_err("%s: %d: %d: %ums", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5705 | hdd_reason_type_to_string(i), |
| 5706 | adapter->queue_oper_stats[i].pause_count, |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5707 | adapter->queue_oper_stats[i].unpause_count, |
| 5708 | qdf_system_ticks_to_msecs( |
| 5709 | adapter->queue_oper_stats[i].total_pause_time + |
| 5710 | pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5711 | } |
| 5712 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5713 | hdd_err("\nNetif queue operation history:"); |
| 5714 | hdd_err("Total entries: %d current index %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 5715 | WLAN_HDD_MAX_HISTORY_ENTRY, adapter->history_index); |
| 5716 | |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5717 | hdd_err("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5718 | |
| 5719 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 5720 | hdd_err("%d: %u: %s: %s: %x", |
Anurag Chouhan | 50220ce | 2016-02-18 20:11:33 +0530 | [diff] [blame] | 5721 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5722 | adapter->queue_oper_history[i].time), |
| 5723 | hdd_action_type_to_string( |
| 5724 | adapter->queue_oper_history[i].netif_action), |
| 5725 | hdd_reason_type_to_string( |
| 5726 | adapter->queue_oper_history[i].netif_reason), |
| 5727 | adapter->queue_oper_history[i].pause_map); |
| 5728 | } |
| 5729 | |
| 5730 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 5731 | adapter_node = next; |
| 5732 | } |
| 5733 | |
| 5734 | |
| 5735 | } |
| 5736 | |
| 5737 | /** |
| 5738 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 5739 | * @hdd_ctx: hdd context |
| 5740 | * |
| 5741 | * Return: none |
| 5742 | */ |
| 5743 | void wlan_hdd_clear_netif_queue_history(hdd_context_t *hdd_ctx) |
| 5744 | { |
| 5745 | hdd_adapter_t *adapter = NULL; |
| 5746 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5747 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5748 | |
| 5749 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5750 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5751 | adapter = adapter_node->pAdapter; |
| 5752 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5753 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5754 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5755 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5756 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 5757 | adapter->history_index = 0; |
| 5758 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 5759 | adapter->total_pause_time = 0; |
| 5760 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5761 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 5762 | adapter_node = next; |
| 5763 | } |
| 5764 | } |
| 5765 | |
| 5766 | /** |
| 5767 | * hdd_11d_scan_done() - callback for 11d scan completion of flushing results |
| 5768 | * @halHandle: Hal handle |
| 5769 | * @pContext: Pointer to the context |
| 5770 | * @sessionId: Session ID |
| 5771 | * @scanId: Scan ID |
| 5772 | * @status: Status |
| 5773 | * |
| 5774 | * This is the callback to be executed when 11d scan is completed to flush out |
| 5775 | * the scan results |
| 5776 | * |
| 5777 | * 11d scan is done during driver load and is a passive scan on all |
| 5778 | * channels supported by the device, 11d scans may find some APs on |
| 5779 | * frequencies which are forbidden to be used in the regulatory domain |
| 5780 | * the device is operating in. If these APs are notified to the supplicant |
| 5781 | * it may try to connect to these APs, thus flush out all the scan results |
| 5782 | * which are present in SME after 11d scan is done. |
| 5783 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5784 | * Return: QDF_STATUS_SUCCESS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5785 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5786 | static QDF_STATUS hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5787 | uint8_t sessionId, uint32_t scanId, |
| 5788 | eCsrScanStatus status) |
| 5789 | { |
| 5790 | ENTER(); |
| 5791 | |
| 5792 | sme_scan_flush_result(halHandle); |
| 5793 | |
| 5794 | EXIT(); |
| 5795 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5796 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5797 | } |
| 5798 | |
| 5799 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 5800 | /** |
| 5801 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 5802 | * @hdd_ctx: hdd global context |
| 5803 | * |
| 5804 | * Return: none |
| 5805 | */ |
| 5806 | static void hdd_init_offloaded_packets_ctx(hdd_context_t *hdd_ctx) |
| 5807 | { |
| 5808 | uint8_t i; |
| 5809 | |
| 5810 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 5811 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 5812 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 5813 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 5814 | } |
| 5815 | } |
| 5816 | #else |
| 5817 | static void hdd_init_offloaded_packets_ctx(hdd_context_t *hdd_ctx) |
| 5818 | { |
| 5819 | } |
| 5820 | #endif |
| 5821 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 5822 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 5823 | /** |
| 5824 | * wlan_hdd_set_wow_pulse() - call SME to send wmi cmd of wow pulse |
| 5825 | * @phddctx: hdd_context_t structure pointer |
| 5826 | * @enable: enable or disable this behaviour |
| 5827 | * |
| 5828 | * Return: int |
| 5829 | */ |
| 5830 | static int wlan_hdd_set_wow_pulse(hdd_context_t *phddctx, bool enable) |
| 5831 | { |
| 5832 | struct hdd_config *pcfg_ini = phddctx->config; |
| 5833 | struct wow_pulse_mode wow_pulse_set_info; |
| 5834 | QDF_STATUS status; |
| 5835 | |
| 5836 | hdd_notice("wow pulse enable flag is %d", enable); |
| 5837 | |
| 5838 | if (false == phddctx->config->wow_pulse_support) |
| 5839 | return 0; |
| 5840 | |
| 5841 | /* prepare the request to send to SME */ |
| 5842 | if (enable == true) { |
| 5843 | wow_pulse_set_info.wow_pulse_enable = true; |
| 5844 | wow_pulse_set_info.wow_pulse_pin = |
| 5845 | pcfg_ini->wow_pulse_pin; |
| 5846 | wow_pulse_set_info.wow_pulse_interval_low = |
| 5847 | pcfg_ini->wow_pulse_interval_low; |
| 5848 | wow_pulse_set_info.wow_pulse_interval_high = |
| 5849 | pcfg_ini->wow_pulse_interval_high; |
| 5850 | } else { |
| 5851 | wow_pulse_set_info.wow_pulse_enable = false; |
| 5852 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 5853 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 5854 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 5855 | } |
| 5856 | hdd_notice("enable %d pin %d low %d high %d", |
| 5857 | wow_pulse_set_info.wow_pulse_enable, |
| 5858 | wow_pulse_set_info.wow_pulse_pin, |
| 5859 | wow_pulse_set_info.wow_pulse_interval_low, |
| 5860 | wow_pulse_set_info.wow_pulse_interval_high); |
| 5861 | |
| 5862 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 5863 | if (QDF_STATUS_E_FAILURE == status) { |
| 5864 | hdd_notice("sme_set_wow_pulse failure!"); |
| 5865 | return -EIO; |
| 5866 | } |
| 5867 | hdd_notice("sme_set_wow_pulse success!"); |
| 5868 | return 0; |
| 5869 | } |
| 5870 | #else |
| 5871 | static inline int wlan_hdd_set_wow_pulse(hdd_context_t *phddctx, bool enable) |
| 5872 | { |
| 5873 | return 0; |
| 5874 | } |
| 5875 | #endif |
| 5876 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5877 | #ifdef WLAN_FEATURE_FASTPATH |
| 5878 | /** |
| 5879 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 5880 | * @hdd_cfg: hdd config |
| 5881 | * @context: lower layer context |
| 5882 | * |
| 5883 | * Return: none |
| 5884 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5885 | void hdd_enable_fastpath(struct hdd_config *hdd_cfg, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5886 | void *context) |
| 5887 | { |
| 5888 | if (hdd_cfg->fastpath_enable) |
| 5889 | hif_enable_fastpath(context); |
| 5890 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5891 | #endif |
| 5892 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 5893 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5894 | /** |
| 5895 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 5896 | * @context: hdd context pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5897 | * @level: thermal level |
| 5898 | * |
| 5899 | * Change IPA data path to SW path when the thermal throttle level greater |
| 5900 | * than 0, and restore the original data path when throttle level is 0 |
| 5901 | * |
| 5902 | * Return: none |
| 5903 | */ |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 5904 | 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] | 5905 | { |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 5906 | hdd_context_t *hdd_ctx = context; |
| 5907 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5908 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 5909 | if (level > THROTTLE_LEVEL_0) |
| 5910 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, true); |
| 5911 | else |
| 5912 | /* restore original concurrency mode */ |
| 5913 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, hdd_ctx->mcc_mode); |
| 5914 | } |
| 5915 | |
| 5916 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 5917 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 5918 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 5919 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5920 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 5921 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 5922 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 5923 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5924 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 5925 | * Return: Channel number to restart SAP in case of success. In case of any |
| 5926 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5927 | */ |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 5928 | static uint8_t hdd_get_safe_channel_from_pcl_and_acs_range( |
| 5929 | hdd_adapter_t *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5930 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 5931 | struct sir_pcl_list pcl; |
| 5932 | QDF_STATUS status; |
| 5933 | uint32_t i, j; |
| 5934 | tHalHandle *hal_handle; |
| 5935 | hdd_context_t *hdd_ctx; |
| 5936 | bool found = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5937 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 5938 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 5939 | if (!hdd_ctx) { |
| 5940 | hdd_err("invalid HDD context"); |
| 5941 | return INVALID_CHANNEL_ID; |
| 5942 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5943 | |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 5944 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 5945 | if (!hal_handle) { |
| 5946 | hdd_err("invalid HAL handle"); |
| 5947 | return INVALID_CHANNEL_ID; |
| 5948 | } |
| 5949 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 5950 | status = cds_get_pcl_for_existing_conn(CDS_SAP_MODE, |
| 5951 | pcl.pcl_list, &pcl.pcl_len, |
| 5952 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list)); |
| 5953 | if (QDF_IS_STATUS_ERROR(status)) { |
| 5954 | hdd_err("Get PCL failed"); |
| 5955 | return INVALID_CHANNEL_ID; |
| 5956 | } |
| 5957 | |
| 5958 | if (!pcl.pcl_len) { |
| 5959 | hdd_alert("pcl length is zero. this is not expected"); |
| 5960 | return INVALID_CHANNEL_ID; |
| 5961 | } |
| 5962 | |
| 5963 | hdd_info("start:%d end:%d", |
| 5964 | adapter->sessionCtx.ap.sapConfig.acs_cfg.start_ch, |
| 5965 | adapter->sessionCtx.ap.sapConfig.acs_cfg.end_ch); |
| 5966 | |
| 5967 | /* PCL already takes unsafe channel into account */ |
| 5968 | for (i = 0; i < pcl.pcl_len; i++) { |
| 5969 | hdd_info("chan[%d]:%d", i, pcl.pcl_list[i]); |
| 5970 | if ((pcl.pcl_list[i] >= |
| 5971 | adapter->sessionCtx.ap.sapConfig.acs_cfg.start_ch) && |
| 5972 | (pcl.pcl_list[i] <= |
| 5973 | adapter->sessionCtx.ap.sapConfig.acs_cfg.end_ch)) { |
| 5974 | hdd_info("found PCL safe chan:%d", pcl.pcl_list[i]); |
| 5975 | return pcl.pcl_list[i]; |
| 5976 | } |
| 5977 | } |
| 5978 | |
| 5979 | hdd_info("no safe channel from PCL found in ACS range"); |
| 5980 | |
| 5981 | /* Try for safe channel from all valid channel */ |
| 5982 | pcl.pcl_len = MAX_NUM_CHAN; |
| 5983 | status = sme_get_cfg_valid_channels(hal_handle, pcl.pcl_list, |
| 5984 | &pcl.pcl_len); |
| 5985 | if (QDF_IS_STATUS_ERROR(status)) { |
| 5986 | hdd_err("error in getting valid channel list"); |
| 5987 | return INVALID_CHANNEL_ID; |
| 5988 | } |
| 5989 | |
| 5990 | for (i = 0; i < pcl.pcl_len; i++) { |
| 5991 | hdd_info("chan[%d]:%d", i, pcl.pcl_list[i]); |
| 5992 | found = false; |
| 5993 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 5994 | if (pcl.pcl_list[i] == |
| 5995 | hdd_ctx->unsafe_channel_list[j]) { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 5996 | hdd_info("unsafe chan:%d", pcl.pcl_list[i]); |
| 5997 | found = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5998 | break; |
| 5999 | } |
| 6000 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6001 | |
| 6002 | if (found) |
| 6003 | continue; |
| 6004 | |
| 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 safe chan:%d", pcl.pcl_list[i]); |
| 6010 | return pcl.pcl_list[i]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6011 | } |
| 6012 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6013 | |
| 6014 | return INVALID_CHANNEL_ID; |
| 6015 | } |
| 6016 | |
| 6017 | /** |
| 6018 | * hdd_restart_sap() - Restarts SAP on the given channel |
| 6019 | * @adapter: AP adapter |
| 6020 | * @channel: Channel |
| 6021 | * |
| 6022 | * Restarts the SAP interface by invoking the function which executes the |
| 6023 | * callback to perform channel switch using (E)CSA. |
| 6024 | * |
| 6025 | * Return: None |
| 6026 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 6027 | static void hdd_restart_sap(hdd_adapter_t *adapter, uint8_t channel) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6028 | { |
| 6029 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 6030 | tHalHandle *hal_handle; |
| 6031 | |
| 6032 | if (!adapter) { |
| 6033 | hdd_err("invalid adapter"); |
| 6034 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6035 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6036 | |
| 6037 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 6038 | |
| 6039 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 6040 | if (!hal_handle) { |
| 6041 | hdd_err("invalid HAL handle"); |
| 6042 | return; |
| 6043 | } |
| 6044 | |
| 6045 | hdd_ap_ctx->sapConfig.channel = channel; |
| 6046 | hdd_ap_ctx->sapConfig.ch_params.ch_width = |
| 6047 | hdd_ap_ctx->sapConfig.ch_width_orig; |
| 6048 | |
| 6049 | hdd_info("chan:%d width:%d", |
| 6050 | channel, hdd_ap_ctx->sapConfig.ch_width_orig); |
| 6051 | |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 6052 | cds_set_channel_params(hdd_ap_ctx->sapConfig.channel, |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6053 | hdd_ap_ctx->sapConfig.sec_ch, |
| 6054 | &hdd_ap_ctx->sapConfig.ch_params); |
| 6055 | |
| 6056 | cds_change_sap_channel_with_csa(adapter, hdd_ap_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6057 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6058 | /** |
| 6059 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 6060 | * @hdd_ctx: hdd context pointer |
| 6061 | * |
| 6062 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 6063 | * and if ACS is enabled, driver will ask userspace to restart the |
| 6064 | * sap. User space on LTE coex indication restart driver. |
| 6065 | * |
| 6066 | * Return - none |
| 6067 | */ |
| 6068 | void hdd_unsafe_channel_restart_sap(hdd_context_t *hdd_ctxt) |
| 6069 | { |
| 6070 | QDF_STATUS status; |
| 6071 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 6072 | hdd_adapter_t *adapter_temp; |
| 6073 | uint32_t i; |
| 6074 | bool found = false; |
| 6075 | uint8_t restart_chan; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6076 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6077 | status = hdd_get_front_adapter(hdd_ctxt, &adapter_node); |
| 6078 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 6079 | adapter_temp = adapter_node->pAdapter; |
| 6080 | |
| 6081 | if (!adapter_temp) { |
| 6082 | hdd_err("adapter is NULL, moving to next one"); |
| 6083 | goto next_adapater; |
| 6084 | } |
| 6085 | |
| 6086 | if (!((adapter_temp->device_mode == QDF_SAP_MODE) && |
| 6087 | (adapter_temp->sessionCtx.ap.sapConfig.acs_cfg.acs_mode))) { |
| 6088 | hdd_info("skip device mode:%d acs:%d", |
| 6089 | adapter_temp->device_mode, |
| 6090 | adapter_temp->sessionCtx.ap.sapConfig. |
| 6091 | acs_cfg.acs_mode); |
| 6092 | goto next_adapater; |
| 6093 | } |
| 6094 | |
| 6095 | found = false; |
| 6096 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 6097 | if (adapter_temp->sessionCtx.ap.operatingChannel == |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6098 | hdd_ctxt->unsafe_channel_list[i]) { |
| 6099 | found = true; |
| 6100 | hdd_info("operating ch:%d is unsafe", |
| 6101 | adapter_temp->sessionCtx.ap.operatingChannel); |
| 6102 | break; |
| 6103 | } |
| 6104 | } |
| 6105 | |
| 6106 | if (!found) { |
| 6107 | hdd_info("ch:%d is safe. no need to change channel", |
| 6108 | adapter_temp->sessionCtx.ap.operatingChannel); |
| 6109 | goto next_adapater; |
| 6110 | } |
| 6111 | |
| 6112 | restart_chan = |
| 6113 | hdd_get_safe_channel_from_pcl_and_acs_range( |
| 6114 | adapter_temp); |
| 6115 | if (!restart_chan) { |
| 6116 | hdd_alert("fail to restart SAP"); |
| 6117 | } else { |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 6118 | /* SAP restart due to unsafe channel. While restarting |
| 6119 | * the SAP, make sure to clear acs_channel, channel to |
| 6120 | * reset to 0. Otherwise these settings will override |
| 6121 | * the ACS while restart. |
| 6122 | */ |
| 6123 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
| 6124 | adapter_temp->sessionCtx.ap.sapConfig.channel = |
| 6125 | AUTO_CHANNEL_SELECT; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6126 | hdd_info("sending coex indication"); |
| 6127 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 6128 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
| 6129 | hdd_restart_sap(adapter_temp, restart_chan); |
| 6130 | } |
| 6131 | |
| 6132 | next_adapater: |
| 6133 | status = hdd_get_next_adapter(hdd_ctxt, adapter_node, &next); |
| 6134 | adapter_node = next; |
| 6135 | } |
| 6136 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6137 | /** |
| 6138 | * hdd_ch_avoid_cb() - Avoid notified channels from FW handler |
| 6139 | * @adapter: HDD adapter pointer |
| 6140 | * @indParam: Channel avoid notification parameter |
| 6141 | * |
| 6142 | * Avoid channel notification from FW handler. |
| 6143 | * FW will send un-safe channel list to avoid over wrapping. |
| 6144 | * hostapd should not use notified channel |
| 6145 | * |
| 6146 | * Return: None |
| 6147 | */ |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6148 | void hdd_ch_avoid_cb(void *hdd_context, void *indi_param) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6149 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6150 | hdd_context_t *hdd_ctxt; |
| 6151 | tSirChAvoidIndType *ch_avoid_indi; |
| 6152 | uint8_t range_loop; |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6153 | enum channel_enum channel_loop, start_channel_idx = INVALID_CHANNEL, |
| 6154 | end_channel_idx = INVALID_CHANNEL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6155 | uint16_t start_channel; |
| 6156 | uint16_t end_channel; |
| 6157 | v_CONTEXT_t cds_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6158 | tHddAvoidFreqList hdd_avoid_freq_list; |
| 6159 | uint32_t i; |
| 6160 | |
| 6161 | /* Basic sanity */ |
| 6162 | if (!hdd_context || !indi_param) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6163 | hdd_err("Invalid arguments"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6164 | return; |
| 6165 | } |
| 6166 | |
| 6167 | hdd_ctxt = (hdd_context_t *) hdd_context; |
| 6168 | ch_avoid_indi = (tSirChAvoidIndType *) indi_param; |
| 6169 | cds_context = hdd_ctxt->pcds_context; |
| 6170 | |
| 6171 | /* Make unsafe channel list */ |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6172 | hdd_notice("band count %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6173 | ch_avoid_indi->avoid_range_count); |
| 6174 | |
| 6175 | /* generate vendor specific event */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6176 | qdf_mem_zero((void *)&hdd_avoid_freq_list, sizeof(tHddAvoidFreqList)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6177 | for (i = 0; i < ch_avoid_indi->avoid_range_count; i++) { |
| 6178 | hdd_avoid_freq_list.avoidFreqRange[i].startFreq = |
| 6179 | ch_avoid_indi->avoid_freq_range[i].start_freq; |
| 6180 | hdd_avoid_freq_list.avoidFreqRange[i].endFreq = |
| 6181 | ch_avoid_indi->avoid_freq_range[i].end_freq; |
| 6182 | } |
| 6183 | hdd_avoid_freq_list.avoidFreqRangeCount = |
| 6184 | ch_avoid_indi->avoid_range_count; |
| 6185 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6186 | /* clear existing unsafe channel cache */ |
| 6187 | hdd_ctxt->unsafe_channel_count = 0; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6188 | qdf_mem_zero(hdd_ctxt->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6189 | sizeof(hdd_ctxt->unsafe_channel_list)); |
| 6190 | |
| 6191 | for (range_loop = 0; range_loop < ch_avoid_indi->avoid_range_count; |
| 6192 | range_loop++) { |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6193 | if (hdd_ctxt->unsafe_channel_count >= NUM_CHANNELS) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6194 | hdd_warn("LTE Coex unsafe channel list full"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6195 | break; |
| 6196 | } |
| 6197 | |
| 6198 | start_channel = ieee80211_frequency_to_channel( |
| 6199 | ch_avoid_indi->avoid_freq_range[range_loop].start_freq); |
| 6200 | end_channel = ieee80211_frequency_to_channel( |
| 6201 | ch_avoid_indi->avoid_freq_range[range_loop].end_freq); |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6202 | hdd_notice("start %d : %d, end %d : %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6203 | ch_avoid_indi->avoid_freq_range[range_loop].start_freq, |
| 6204 | start_channel, |
| 6205 | ch_avoid_indi->avoid_freq_range[range_loop].end_freq, |
| 6206 | end_channel); |
| 6207 | |
| 6208 | /* do not process frequency bands that are not mapped to |
| 6209 | * predefined channels |
| 6210 | */ |
| 6211 | if (start_channel == 0 || end_channel == 0) |
| 6212 | continue; |
| 6213 | |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6214 | for (channel_loop = CHAN_ENUM_1; channel_loop <= |
| 6215 | CHAN_ENUM_184; channel_loop++) { |
Amar Singhal | 7a1726a | 2015-10-14 16:28:11 -0700 | [diff] [blame] | 6216 | if (CDS_CHANNEL_FREQ(channel_loop) >= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6217 | ch_avoid_indi->avoid_freq_range[ |
| 6218 | range_loop].start_freq) { |
| 6219 | start_channel_idx = channel_loop; |
| 6220 | break; |
| 6221 | } |
| 6222 | } |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6223 | for (channel_loop = CHAN_ENUM_1; channel_loop <= |
| 6224 | CHAN_ENUM_184; channel_loop++) { |
Amar Singhal | 7a1726a | 2015-10-14 16:28:11 -0700 | [diff] [blame] | 6225 | if (CDS_CHANNEL_FREQ(channel_loop) >= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6226 | ch_avoid_indi->avoid_freq_range[ |
| 6227 | range_loop].end_freq) { |
| 6228 | end_channel_idx = channel_loop; |
Amar Singhal | 7a1726a | 2015-10-14 16:28:11 -0700 | [diff] [blame] | 6229 | if (CDS_CHANNEL_FREQ(channel_loop) > |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6230 | ch_avoid_indi->avoid_freq_range[ |
| 6231 | range_loop].end_freq) |
| 6232 | end_channel_idx--; |
| 6233 | break; |
| 6234 | } |
| 6235 | } |
| 6236 | |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6237 | if (start_channel_idx == INVALID_CHANNEL || |
| 6238 | end_channel_idx == INVALID_CHANNEL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6239 | continue; |
| 6240 | |
| 6241 | for (channel_loop = start_channel_idx; channel_loop <= |
| 6242 | end_channel_idx; channel_loop++) { |
| 6243 | hdd_ctxt->unsafe_channel_list[ |
Amar Singhal | 7a1726a | 2015-10-14 16:28:11 -0700 | [diff] [blame] | 6244 | hdd_ctxt->unsafe_channel_count++] = |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 6245 | CDS_CHANNEL_NUM(channel_loop); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6246 | if (hdd_ctxt->unsafe_channel_count >= |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6247 | NUM_CHANNELS) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6248 | hdd_warn("LTECoex unsafe ch list full"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6249 | break; |
| 6250 | } |
| 6251 | } |
| 6252 | } |
| 6253 | |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6254 | hdd_notice("number of unsafe channels is %d ", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6255 | hdd_ctxt->unsafe_channel_count); |
| 6256 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6257 | if (pld_set_wlan_unsafe_channel(hdd_ctxt->parent_dev, |
| 6258 | hdd_ctxt->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6259 | hdd_ctxt->unsafe_channel_count)) { |
| 6260 | hdd_err("Failed to set unsafe channel"); |
| 6261 | |
| 6262 | /* clear existing unsafe channel cache */ |
| 6263 | hdd_ctxt->unsafe_channel_count = 0; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6264 | qdf_mem_zero(hdd_ctxt->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6265 | sizeof(hdd_ctxt->unsafe_channel_list)); |
| 6266 | |
| 6267 | return; |
| 6268 | } |
| 6269 | |
| 6270 | for (channel_loop = 0; |
| 6271 | channel_loop < hdd_ctxt->unsafe_channel_count; channel_loop++) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6272 | hdd_notice("channel %d is not safe ", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6273 | hdd_ctxt->unsafe_channel_list[channel_loop]); |
| 6274 | } |
| 6275 | |
Kondabattini, Ganesh | cf7b60f | 2016-08-10 16:31:55 +0530 | [diff] [blame] | 6276 | /* |
| 6277 | * first update the unsafe channel list to the platform driver and |
| 6278 | * send the avoid freq event to the application |
| 6279 | */ |
| 6280 | wlan_hdd_send_avoid_freq_event(hdd_ctxt, &hdd_avoid_freq_list); |
| 6281 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6282 | if (!hdd_ctxt->unsafe_channel_count) { |
| 6283 | hdd_info("no unsafe channels - not restarting SAP"); |
| 6284 | return; |
| 6285 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 6286 | hdd_unsafe_channel_restart_sap(hdd_ctxt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6287 | return; |
| 6288 | } |
| 6289 | |
| 6290 | /** |
| 6291 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 6292 | * @hdd_ctx: HDD global context |
| 6293 | * |
| 6294 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6295 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6296 | * down to the lower layers. Then subscribe to subsequent channel |
| 6297 | * avoidance events. |
| 6298 | * |
| 6299 | * Return: None |
| 6300 | */ |
| 6301 | static void hdd_init_channel_avoidance(hdd_context_t *hdd_ctx) |
| 6302 | { |
| 6303 | uint16_t unsafe_channel_count; |
| 6304 | int index; |
| 6305 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6306 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 6307 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6308 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6309 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6310 | |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6311 | hdd_notice("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6312 | hdd_ctx->unsafe_channel_count); |
| 6313 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6314 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 6315 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6316 | |
| 6317 | for (index = 0; index < unsafe_channel_count; index++) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 6318 | hdd_notice("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6319 | hdd_ctx->unsafe_channel_list[index]); |
| 6320 | |
| 6321 | } |
| 6322 | |
| 6323 | /* Plug in avoid channel notification callback */ |
| 6324 | sme_add_ch_avoid_callback(hdd_ctx->hHal, hdd_ch_avoid_cb); |
| 6325 | } |
| 6326 | #else |
| 6327 | static void hdd_init_channel_avoidance(hdd_context_t *hdd_ctx) |
| 6328 | { |
| 6329 | } |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 6330 | 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] | 6331 | { |
| 6332 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6333 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6334 | |
| 6335 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 6336 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 6337 | * user space |
| 6338 | * @frame_ind: Management frame data to be informed. |
| 6339 | * |
| 6340 | * This function is used to indicate management frame to |
| 6341 | * user space |
| 6342 | * |
| 6343 | * Return: None |
| 6344 | * |
| 6345 | */ |
| 6346 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 6347 | { |
| 6348 | hdd_context_t *hdd_ctx = NULL; |
| 6349 | hdd_adapter_t *adapter = NULL; |
| 6350 | void *cds_context = NULL; |
| 6351 | int i; |
| 6352 | |
| 6353 | /* Get the global VOSS context.*/ |
| 6354 | cds_context = cds_get_global_context(); |
| 6355 | if (!cds_context) { |
| 6356 | hdd_err("Global CDS context is Null"); |
| 6357 | return; |
| 6358 | } |
| 6359 | /* Get the HDD context.*/ |
| 6360 | hdd_ctx = (hdd_context_t *)cds_get_context(QDF_MODULE_ID_HDD); |
| 6361 | |
| 6362 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 6363 | return; |
| 6364 | |
| 6365 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
| 6366 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 6367 | adapter = |
| 6368 | hdd_get_adapter_by_sme_session_id(hdd_ctx, i); |
| 6369 | if (adapter) |
| 6370 | break; |
| 6371 | } |
| 6372 | } else { |
| 6373 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 6374 | frame_ind->sessionId); |
| 6375 | } |
| 6376 | |
| 6377 | if ((NULL != adapter) && |
| 6378 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 6379 | __hdd_indicate_mgmt_frame(adapter, |
| 6380 | frame_ind->frame_len, |
| 6381 | frame_ind->frameBuf, |
| 6382 | frame_ind->frameType, |
| 6383 | frame_ind->rxChan, |
| 6384 | frame_ind->rxRssi); |
| 6385 | return; |
| 6386 | } |
| 6387 | |
| 6388 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6389 | * wlan_hdd_disable_all_dual_mac_features() - Disable dual mac features |
| 6390 | * @hdd_ctx: HDD context |
| 6391 | * |
| 6392 | * Disables all the dual mac features like DBS, Agile DFS etc. |
| 6393 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6394 | * Return: QDF_STATUS_SUCCESS on success |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6395 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6396 | static QDF_STATUS wlan_hdd_disable_all_dual_mac_features(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6397 | { |
| 6398 | struct sir_dual_mac_config cfg; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6399 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6400 | |
| 6401 | if (!hdd_ctx) { |
| 6402 | hdd_err("HDD context is NULL"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6403 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6404 | } |
| 6405 | |
| 6406 | cfg.scan_config = 0; |
| 6407 | cfg.fw_mode_config = 0; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 6408 | cfg.set_dual_mac_cb = cds_soc_set_dual_mac_cfg_cb; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6409 | |
| 6410 | hdd_debug("Disabling all dual mac features..."); |
| 6411 | |
| 6412 | status = sme_soc_set_dual_mac_config(hdd_ctx->hHal, cfg); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6413 | if (status != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6414 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 6415 | return status; |
| 6416 | } |
| 6417 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6418 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6419 | } |
| 6420 | |
| 6421 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6422 | * hdd_override_ini_config - Override INI config |
| 6423 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6424 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6425 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6426 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6427 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6428 | */ |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6429 | static void hdd_override_ini_config(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6430 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6431 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6432 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
| 6433 | hdd_ctx->config->enableDFSChnlScan = enable_dfs_chan_scan; |
| 6434 | hdd_notice("Module enable_dfs_chan_scan set to %d", |
| 6435 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6436 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6437 | if (0 == enable_11d || 1 == enable_11d) { |
| 6438 | hdd_ctx->config->Is11dSupportEnabled = enable_11d; |
| 6439 | hdd_notice("Module enable_11d set to %d", enable_11d); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6440 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 6441 | |
| 6442 | if (!hdd_ipa_is_present(hdd_ctx)) |
| 6443 | hdd_ctx->config->IpaConfig = 0; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6444 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6445 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6446 | /** |
| 6447 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 6448 | * @hdd_ctx - HDD context |
| 6449 | * |
| 6450 | * Set trace level for each module based on INI config. |
| 6451 | * |
| 6452 | * Return: None |
| 6453 | */ |
| 6454 | static void hdd_set_trace_level_for_each(hdd_context_t *hdd_ctx) |
| 6455 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6456 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMI, |
| 6457 | hdd_ctx->config->qdf_trace_enable_wdi); |
| 6458 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD, |
| 6459 | hdd_ctx->config->qdf_trace_enable_hdd); |
| 6460 | hdd_qdf_trace_enable(QDF_MODULE_ID_SME, |
| 6461 | hdd_ctx->config->qdf_trace_enable_sme); |
| 6462 | hdd_qdf_trace_enable(QDF_MODULE_ID_PE, |
| 6463 | hdd_ctx->config->qdf_trace_enable_pe); |
| 6464 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMA, |
| 6465 | hdd_ctx->config->qdf_trace_enable_wma); |
| 6466 | hdd_qdf_trace_enable(QDF_MODULE_ID_SYS, |
| 6467 | hdd_ctx->config->qdf_trace_enable_sys); |
| 6468 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF, |
| 6469 | hdd_ctx->config->qdf_trace_enable_qdf); |
| 6470 | hdd_qdf_trace_enable(QDF_MODULE_ID_SAP, |
| 6471 | hdd_ctx->config->qdf_trace_enable_sap); |
| 6472 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SOFTAP, |
| 6473 | hdd_ctx->config->qdf_trace_enable_hdd_sap); |
| 6474 | hdd_qdf_trace_enable(QDF_MODULE_ID_BMI, |
| 6475 | hdd_ctx->config->qdf_trace_enable_bmi); |
| 6476 | hdd_qdf_trace_enable(QDF_MODULE_ID_CFG, |
| 6477 | hdd_ctx->config->qdf_trace_enable_cfg); |
| 6478 | hdd_qdf_trace_enable(QDF_MODULE_ID_EPPING, |
| 6479 | hdd_ctx->config->qdf_trace_enable_epping); |
| 6480 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF_DEVICE, |
| 6481 | hdd_ctx->config->qdf_trace_enable_qdf_devices); |
| 6482 | hdd_qdf_trace_enable(QDF_MODULE_ID_TXRX, |
Bhargav Shah | 480a90f | 2015-06-24 15:10:14 +0530 | [diff] [blame] | 6483 | hdd_ctx->config->cfd_trace_enable_txrx); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6484 | hdd_qdf_trace_enable(QDF_MODULE_ID_HTC, |
| 6485 | hdd_ctx->config->qdf_trace_enable_htc); |
| 6486 | hdd_qdf_trace_enable(QDF_MODULE_ID_HIF, |
| 6487 | hdd_ctx->config->qdf_trace_enable_hif); |
| 6488 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SAP_DATA, |
| 6489 | hdd_ctx->config->qdf_trace_enable_hdd_sap_data); |
| 6490 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_DATA, |
| 6491 | hdd_ctx->config->qdf_trace_enable_hdd_data); |
Bhargav Shah | 480a90f | 2015-06-24 15:10:14 +0530 | [diff] [blame] | 6492 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6493 | hdd_cfg_print(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6494 | } |
| 6495 | |
| 6496 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6497 | * hdd_context_init() - Initialize HDD context |
| 6498 | * @hdd_ctx: HDD context. |
| 6499 | * |
| 6500 | * Initialize HDD context along with all the feature specific contexts. |
| 6501 | * |
| 6502 | * return: 0 on success and errno on failure. |
| 6503 | */ |
| 6504 | static int hdd_context_init(hdd_context_t *hdd_ctx) |
| 6505 | { |
| 6506 | int ret; |
| 6507 | |
| 6508 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 6509 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 6510 | |
| 6511 | hdd_init_ll_stats_ctx(); |
| 6512 | |
| 6513 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 6514 | init_completion(&hdd_ctx->ready_to_suspend); |
| 6515 | |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6516 | hdd_init_bpf_completion(); |
| 6517 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6518 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 6519 | qdf_spinlock_create(&hdd_ctx->sta_update_info_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6520 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 6521 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6522 | qdf_list_create(&hdd_ctx->hddAdapters, MAX_NUMBER_OF_ADAPTERS); |
| 6523 | |
| 6524 | init_completion(&hdd_ctx->set_antenna_mode_cmpl); |
| 6525 | |
| 6526 | ret = hdd_scan_context_init(hdd_ctx); |
| 6527 | if (ret) |
| 6528 | goto list_destroy; |
| 6529 | |
| 6530 | hdd_tdls_context_init(hdd_ctx); |
| 6531 | |
| 6532 | hdd_rx_wake_lock_create(hdd_ctx); |
| 6533 | |
| 6534 | ret = hdd_sap_context_init(hdd_ctx); |
| 6535 | if (ret) |
| 6536 | goto scan_destroy; |
| 6537 | |
| 6538 | ret = hdd_roc_context_init(hdd_ctx); |
| 6539 | if (ret) |
| 6540 | goto sap_destroy; |
| 6541 | |
| 6542 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 6543 | |
| 6544 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 6545 | |
| 6546 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 6547 | hdd_ctx->config); |
| 6548 | if (ret) |
| 6549 | goto roc_destroy; |
| 6550 | |
| 6551 | return 0; |
| 6552 | |
| 6553 | roc_destroy: |
| 6554 | hdd_roc_context_destroy(hdd_ctx); |
| 6555 | |
| 6556 | sap_destroy: |
| 6557 | hdd_sap_context_destroy(hdd_ctx); |
| 6558 | |
| 6559 | scan_destroy: |
| 6560 | hdd_scan_context_destroy(hdd_ctx); |
| 6561 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 6562 | hdd_tdls_context_destroy(hdd_ctx); |
| 6563 | |
| 6564 | list_destroy: |
| 6565 | qdf_list_destroy(&hdd_ctx->hddAdapters); |
| 6566 | return ret; |
| 6567 | } |
| 6568 | |
| 6569 | /** |
| 6570 | * hdd_context_create() - Allocate and inialize HDD context. |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6571 | * @dev: Device Pointer to the underlying device |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6572 | * |
| 6573 | * Allocate and initialize HDD context. HDD context is allocated as part of |
| 6574 | * wiphy allocation and then context is initialized. |
| 6575 | * |
| 6576 | * Return: HDD context on success and ERR_PTR on failure |
| 6577 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 6578 | static hdd_context_t *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6579 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6580 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6581 | int ret = 0; |
| 6582 | hdd_context_t *hdd_ctx; |
| 6583 | v_CONTEXT_t p_cds_context; |
| 6584 | |
| 6585 | ENTER(); |
| 6586 | |
| 6587 | p_cds_context = cds_get_global_context(); |
| 6588 | if (p_cds_context == NULL) { |
| 6589 | hdd_alert("Failed to get CDS global context"); |
| 6590 | ret = -EINVAL; |
| 6591 | goto err_out; |
| 6592 | } |
| 6593 | |
| 6594 | hdd_ctx = hdd_cfg80211_wiphy_alloc(sizeof(hdd_context_t)); |
| 6595 | |
| 6596 | if (hdd_ctx == NULL) { |
| 6597 | ret = -ENOMEM; |
| 6598 | goto err_out; |
| 6599 | } |
| 6600 | |
| 6601 | hdd_ctx->pcds_context = p_cds_context; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6602 | hdd_ctx->parent_dev = dev; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6603 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6604 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6605 | if (hdd_ctx->config == NULL) { |
| 6606 | hdd_alert("Failed to alloc memory for HDD config!"); |
| 6607 | ret = -ENOMEM; |
| 6608 | goto err_free_hdd_context; |
| 6609 | } |
| 6610 | |
| 6611 | /* Read and parse the qcom_cfg.ini file */ |
| 6612 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6613 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6614 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6615 | WLAN_INI_FILE); |
| 6616 | ret = -EINVAL; |
| 6617 | goto err_free_config; |
| 6618 | } |
| 6619 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6620 | hdd_ctx->configuredMcastBcastFilter = |
| 6621 | hdd_ctx->config->mcastBcastFilterSetting; |
| 6622 | |
| 6623 | hdd_notice("Setting configuredMcastBcastFilter: %d", |
| 6624 | hdd_ctx->config->mcastBcastFilterSetting); |
| 6625 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 6626 | if (hdd_ctx->config->fhostNSOffload) |
| 6627 | hdd_ctx->ns_offload_enable = true; |
| 6628 | |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 6629 | cds_set_fatal_event(hdd_ctx->config->enable_fatal_event); |
| 6630 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6631 | hdd_override_ini_config(hdd_ctx); |
| 6632 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6633 | ((cds_context_type *) (p_cds_context))->pHDDContext = (void *)hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6634 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6635 | ret = hdd_context_init(hdd_ctx); |
| 6636 | |
| 6637 | if (ret) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6638 | goto err_free_config; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6639 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6640 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6641 | pld_set_fw_debug_mode(hdd_ctx->parent_dev, |
| 6642 | hdd_ctx->config->enable_fw_log); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6643 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6644 | |
| 6645 | /* Uses to enabled logging after SSR */ |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 6646 | hdd_ctx->fw_log_settings.enable = hdd_ctx->config->enable_fw_log; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6647 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6648 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6649 | goto skip_multicast_logging; |
| 6650 | |
| 6651 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 6652 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 6653 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 6654 | if (ret) |
| 6655 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6656 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6657 | ret = hdd_logging_sock_activate_svc(hdd_ctx); |
| 6658 | if (ret) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6659 | goto err_free_histogram; |
| 6660 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6661 | |
| 6662 | /* |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6663 | * Update QDF trace levels based upon the code. The multicast |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6664 | * levels of the code need not be set when the logger thread |
| 6665 | * is not enabled. |
| 6666 | */ |
| 6667 | if (cds_is_multicast_logging()) |
| 6668 | wlan_logging_set_log_level(); |
| 6669 | |
| 6670 | skip_multicast_logging: |
| 6671 | hdd_set_trace_level_for_each(hdd_ctx); |
| 6672 | |
| 6673 | return hdd_ctx; |
| 6674 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6675 | err_free_histogram: |
| 6676 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 6677 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 6678 | err_deinit_hdd_context: |
| 6679 | hdd_context_deinit(hdd_ctx); |
| 6680 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6681 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6682 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6683 | |
| 6684 | err_free_hdd_context: |
| 6685 | wiphy_free(hdd_ctx->wiphy); |
| 6686 | |
| 6687 | err_out: |
| 6688 | return ERR_PTR(ret); |
| 6689 | } |
| 6690 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6691 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 6692 | /** |
| 6693 | * hdd_open_p2p_interface - Open P2P interface |
| 6694 | * @hdd_ctx: HDD context |
| 6695 | * @rtnl_held: True if RTNL lock held |
| 6696 | * |
| 6697 | * Open P2P interface during probe. This function called to open the P2P |
| 6698 | * interface at probe along with STA interface. |
| 6699 | * |
| 6700 | * Return: 0 on success and errno on failure |
| 6701 | */ |
| 6702 | static int hdd_open_p2p_interface(hdd_context_t *hdd_ctx, bool rtnl_held) |
| 6703 | { |
| 6704 | hdd_adapter_t *adapter; |
| 6705 | uint8_t *p2p_dev_addr; |
| 6706 | |
| 6707 | if (hdd_ctx->config->isP2pDeviceAddrAdministrated && |
| 6708 | !(hdd_ctx->config->intfMacAddr[0].bytes[0] & 0x02)) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6709 | qdf_mem_copy(hdd_ctx->p2pDeviceAddress.bytes, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6710 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 6711 | sizeof(tSirMacAddr)); |
| 6712 | |
| 6713 | /* |
| 6714 | * Generate the P2P Device Address. This consists of |
| 6715 | * the device's primary MAC address with the locally |
| 6716 | * administered bit set. |
| 6717 | */ |
| 6718 | hdd_ctx->p2pDeviceAddress.bytes[0] |= 0x02; |
| 6719 | } else { |
| 6720 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx); |
| 6721 | if (p2p_dev_addr == NULL) { |
| 6722 | hdd_alert("Failed to allocate mac_address for p2p_device"); |
| 6723 | return -ENOSPC; |
| 6724 | } |
| 6725 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6726 | qdf_mem_copy(&hdd_ctx->p2pDeviceAddress.bytes[0], p2p_dev_addr, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6727 | QDF_MAC_ADDR_SIZE); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6728 | } |
| 6729 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6730 | adapter = hdd_open_adapter(hdd_ctx, QDF_P2P_DEVICE_MODE, "p2p%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6731 | &hdd_ctx->p2pDeviceAddress.bytes[0], |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 6732 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6733 | |
| 6734 | if (NULL == adapter) { |
| 6735 | hdd_alert("Failed to do hdd_open_adapter for P2P Device Interface"); |
| 6736 | return -ENOSPC; |
| 6737 | } |
| 6738 | |
| 6739 | return 0; |
| 6740 | } |
| 6741 | #else |
Manishekar Chandrasekaran | c81ba24 | 2016-07-18 17:44:44 +0530 | [diff] [blame] | 6742 | static inline int hdd_open_p2p_interface(hdd_context_t *hdd_ctx, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6743 | bool rtnl_held) |
| 6744 | { |
| 6745 | return 0; |
| 6746 | } |
| 6747 | #endif |
| 6748 | |
| 6749 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 6750 | * hdd_start_station_adapter()- Start the Station Adapter |
| 6751 | * @adapter: HDD adapter |
| 6752 | * |
| 6753 | * This function initializes the adapter for the station mode. |
| 6754 | * |
| 6755 | * Return: 0 on success or errno on failure. |
| 6756 | */ |
| 6757 | int hdd_start_station_adapter(hdd_adapter_t *adapter) |
| 6758 | { |
| 6759 | QDF_STATUS status; |
| 6760 | |
| 6761 | ENTER_DEV(adapter->dev); |
| 6762 | |
| 6763 | status = hdd_init_station_mode(adapter); |
| 6764 | |
| 6765 | if (QDF_STATUS_SUCCESS != status) { |
| 6766 | hdd_err("Error Initializing station mode: %d", status); |
| 6767 | return qdf_status_to_os_return(status); |
| 6768 | } |
| 6769 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6770 | hdd_register_tx_flow_control(adapter, |
| 6771 | hdd_tx_resume_timer_expired_handler, |
| 6772 | hdd_tx_resume_cb); |
| 6773 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 6774 | EXIT(); |
| 6775 | return 0; |
| 6776 | } |
| 6777 | |
| 6778 | /** |
| 6779 | * hdd_start_ap_adapter()- Start AP Adapter |
| 6780 | * @adapter: HDD adapter |
| 6781 | * |
| 6782 | * This function initializes the adapter for the AP mode. |
| 6783 | * |
| 6784 | * Return: 0 on success errno on failure. |
| 6785 | */ |
| 6786 | int hdd_start_ap_adapter(hdd_adapter_t *adapter) |
| 6787 | { |
| 6788 | QDF_STATUS status; |
| 6789 | |
| 6790 | ENTER(); |
| 6791 | |
| 6792 | status = hdd_init_ap_mode(adapter); |
| 6793 | |
| 6794 | if (QDF_STATUS_SUCCESS != status) { |
| 6795 | hdd_err("Error Initializing the AP mode: %d", status); |
| 6796 | return qdf_status_to_os_return(status); |
| 6797 | } |
| 6798 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6799 | hdd_register_tx_flow_control(adapter, |
| 6800 | hdd_softap_tx_resume_timer_expired_handler, |
| 6801 | hdd_softap_tx_resume_cb); |
| 6802 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 6803 | EXIT(); |
| 6804 | return 0; |
| 6805 | } |
| 6806 | |
| 6807 | /** |
| 6808 | * hdd_start_ftm_adapter()- Start FTM adapter |
| 6809 | * @adapter: HDD adapter |
| 6810 | * |
| 6811 | * This function initializes the adapter for the FTM mode. |
| 6812 | * |
| 6813 | * Return: 0 on success or errno on failure. |
| 6814 | */ |
| 6815 | int hdd_start_ftm_adapter(hdd_adapter_t *adapter) |
| 6816 | { |
| 6817 | QDF_STATUS qdf_status; |
| 6818 | |
| 6819 | ENTER_DEV(adapter->dev); |
| 6820 | |
| 6821 | qdf_status = hdd_init_tx_rx(adapter); |
| 6822 | |
| 6823 | if (QDF_STATUS_SUCCESS != qdf_status) { |
| 6824 | hdd_err("Failed to start FTM adapter: %d", qdf_status); |
| 6825 | return qdf_status_to_os_return(qdf_status); |
| 6826 | } |
| 6827 | |
| 6828 | return 0; |
| 6829 | EXIT(); |
| 6830 | } |
| 6831 | |
| 6832 | /** |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6833 | * hdd_open_interfaces - Open all required interfaces |
| 6834 | * hdd_ctx: HDD context |
| 6835 | * rtnl_held: True if RTNL lock is held |
| 6836 | * |
| 6837 | * Open all the interfaces like STA, P2P and OCB based on the configuration. |
| 6838 | * |
| 6839 | * Return: Primary adapter on success and PTR_ERR on failure |
| 6840 | */ |
| 6841 | static hdd_adapter_t *hdd_open_interfaces(hdd_context_t *hdd_ctx, |
| 6842 | bool rtnl_held) |
| 6843 | { |
| 6844 | hdd_adapter_t *adapter = NULL; |
| 6845 | hdd_adapter_t *adapter_11p = NULL; |
| 6846 | int ret; |
| 6847 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6848 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_STANDALONE) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6849 | /* Create only 802.11p interface */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6850 | adapter = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, "wlanocb%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6851 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 6852 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6853 | |
| 6854 | if (adapter == NULL) |
| 6855 | return ERR_PTR(-ENOSPC); |
| 6856 | |
| 6857 | return adapter; |
| 6858 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6859 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, "wlan%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6860 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 6861 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6862 | |
| 6863 | if (adapter == NULL) |
| 6864 | return ERR_PTR(-ENOSPC); |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame^] | 6865 | /* fast roaming is allowed only on first STA, i.e. wlan adapter */ |
| 6866 | adapter->fast_roaming_allowed = true; |
| 6867 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6868 | ret = hdd_open_p2p_interface(hdd_ctx, rtnl_held); |
| 6869 | if (ret) |
| 6870 | goto err_close_adapter; |
| 6871 | |
| 6872 | /* Open 802.11p Interface */ |
| 6873 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_CONCURRENT) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6874 | adapter_11p = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6875 | "wlanocb%d", |
| 6876 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 6877 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6878 | if (adapter_11p == NULL) { |
| 6879 | hdd_err("Failed to open 802.11p interface"); |
| 6880 | goto err_close_adapter; |
| 6881 | } |
| 6882 | } |
| 6883 | |
| 6884 | return adapter; |
| 6885 | |
| 6886 | err_close_adapter: |
| 6887 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
| 6888 | return ERR_PTR(ret); |
| 6889 | } |
| 6890 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 6891 | /** |
| 6892 | * hdd_update_country_code - Update country code |
| 6893 | * @hdd_ctx: HDD context |
| 6894 | * @adapter: Primary adapter context |
| 6895 | * |
| 6896 | * Update country code based on module parameter country_code at SME and wait |
| 6897 | * for the settings to take effect. |
| 6898 | * |
| 6899 | * Return: 0 on success and errno on failure |
| 6900 | */ |
| 6901 | static int hdd_update_country_code(hdd_context_t *hdd_ctx, |
| 6902 | hdd_adapter_t *adapter) |
| 6903 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6904 | QDF_STATUS status; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 6905 | int ret = 0; |
| 6906 | unsigned long rc; |
| 6907 | |
| 6908 | if (country_code == NULL) |
| 6909 | return 0; |
| 6910 | |
| 6911 | INIT_COMPLETION(adapter->change_country_code); |
| 6912 | |
| 6913 | status = sme_change_country_code(hdd_ctx->hHal, |
| 6914 | wlan_hdd_change_country_code_callback, |
| 6915 | country_code, adapter, |
| 6916 | hdd_ctx->pcds_context, eSIR_TRUE, |
| 6917 | eSIR_TRUE); |
| 6918 | |
| 6919 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6920 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 6921 | hdd_err("SME Change Country code from module param fail ret=%d", |
| 6922 | ret); |
| 6923 | return -EINVAL; |
| 6924 | } |
| 6925 | |
| 6926 | rc = wait_for_completion_timeout(&adapter->change_country_code, |
| 6927 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 6928 | if (!rc) { |
| 6929 | hdd_err("SME while setting country code timed out"); |
| 6930 | ret = -ETIMEDOUT; |
| 6931 | } |
| 6932 | |
| 6933 | return ret; |
| 6934 | } |
| 6935 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 6936 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 6937 | /** |
| 6938 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 6939 | * @cds_cfg: CDS Configuration |
| 6940 | * @hdd_ctx: Pointer to hdd context |
| 6941 | * |
| 6942 | * Return: none |
| 6943 | */ |
| 6944 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 6945 | *cds_cfg, |
| 6946 | hdd_context_t *hdd_ctx) |
| 6947 | { |
| 6948 | cds_cfg->tx_flow_stop_queue_th = |
| 6949 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 6950 | cds_cfg->tx_flow_start_queue_offset = |
| 6951 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 6952 | } |
| 6953 | #else |
| 6954 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 6955 | *cds_cfg, |
| 6956 | hdd_context_t *hdd_ctx) |
| 6957 | { |
| 6958 | } |
| 6959 | #endif |
| 6960 | |
| 6961 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 6962 | /** |
| 6963 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 6964 | * @cds_cfg: CDS Configuration |
| 6965 | * @hdd_ctx: Pointer to hdd context |
| 6966 | * |
| 6967 | * Return: none |
| 6968 | */ |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 6969 | 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] | 6970 | hdd_context_t *hdd_ctx) |
| 6971 | { |
| 6972 | cds_cfg->ra_ratelimit_interval = |
| 6973 | hdd_ctx->config->RArateLimitInterval; |
| 6974 | cds_cfg->is_ra_ratelimit_enabled = |
| 6975 | hdd_ctx->config->IsRArateLimitEnabled; |
| 6976 | } |
| 6977 | #else |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 6978 | 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] | 6979 | hdd_context_t *hdd_ctx) |
| 6980 | { |
| 6981 | } |
| 6982 | #endif |
| 6983 | |
| 6984 | /** |
| 6985 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 6986 | * @hdd_ctx: HDD Context |
| 6987 | * |
| 6988 | * Return: 0 for Success, errno on failure |
| 6989 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 6990 | static int hdd_update_cds_config(hdd_context_t *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 6991 | { |
| 6992 | struct cds_config_info *cds_cfg; |
| 6993 | |
| 6994 | cds_cfg = (struct cds_config_info *)qdf_mem_malloc(sizeof(*cds_cfg)); |
| 6995 | if (!cds_cfg) { |
| 6996 | hdd_err("failed to allocate cds config"); |
| 6997 | return -ENOMEM; |
| 6998 | } |
| 6999 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7000 | cds_cfg->driver_type = DRIVER_TYPE_PRODUCTION; |
| 7001 | cds_cfg->powersave_offload_enabled = |
| 7002 | hdd_ctx->config->enablePowersaveOffload; |
| 7003 | cds_cfg->sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 7004 | cds_cfg->sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 7005 | cds_cfg->sta_maxlimod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 7006 | cds_cfg->wow_enable = hdd_ctx->config->wowEnable; |
| 7007 | cds_cfg->max_wow_filters = hdd_ctx->config->maxWoWFilters; |
| 7008 | |
| 7009 | /* Here ol_ini_info is used to store ini status of arp offload |
| 7010 | * ns offload and others. Currently 1st bit is used for arp |
| 7011 | * off load and 2nd bit for ns offload currently, rest bits are unused |
| 7012 | */ |
| 7013 | if (hdd_ctx->config->fhostArpOffload) |
| 7014 | cds_cfg->ol_ini_info = cds_cfg->ol_ini_info | 0x1; |
| 7015 | if (hdd_ctx->config->fhostNSOffload) |
| 7016 | cds_cfg->ol_ini_info = cds_cfg->ol_ini_info | 0x2; |
| 7017 | |
| 7018 | /* |
| 7019 | * Copy the DFS Phyerr Filtering Offload status. |
| 7020 | * This parameter reflects the value of the |
| 7021 | * dfs_phyerr_filter_offload flag as set in the ini. |
| 7022 | */ |
| 7023 | cds_cfg->dfs_phyerr_filter_offload = |
| 7024 | hdd_ctx->config->fDfsPhyerrFilterOffload; |
| 7025 | if (hdd_ctx->config->ssdp) |
| 7026 | cds_cfg->ssdp = hdd_ctx->config->ssdp; |
| 7027 | |
| 7028 | cds_cfg->enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 7029 | cds_cfg->ap_maxoffload_peers = hdd_ctx->config->apMaxOffloadPeers; |
| 7030 | |
| 7031 | cds_cfg->ap_maxoffload_reorderbuffs = |
| 7032 | hdd_ctx->config->apMaxOffloadReorderBuffs; |
| 7033 | |
| 7034 | cds_cfg->ap_disable_intrabss_fwd = |
| 7035 | hdd_ctx->config->apDisableIntraBssFwd; |
| 7036 | |
| 7037 | cds_cfg->dfs_pri_multiplier = |
| 7038 | hdd_ctx->config->dfsRadarPriMultiplier; |
| 7039 | cds_cfg->reorder_offload = |
| 7040 | hdd_ctx->config->reorderOffloadSupport; |
| 7041 | |
| 7042 | /* IPA micro controller data path offload resource config item */ |
| 7043 | cds_cfg->uc_offload_enabled = hdd_ipa_uc_is_enabled(hdd_ctx); |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 7044 | if (!is_power_of_2(hdd_ctx->config->IpaUcTxBufCount)) { |
| 7045 | /* IpaUcTxBufCount should be power of 2 */ |
| 7046 | hdd_err("Round down IpaUcTxBufCount %d to nearest power of 2", |
| 7047 | hdd_ctx->config->IpaUcTxBufCount); |
| 7048 | hdd_ctx->config->IpaUcTxBufCount = |
| 7049 | rounddown_pow_of_two( |
| 7050 | hdd_ctx->config->IpaUcTxBufCount); |
| 7051 | if (!hdd_ctx->config->IpaUcTxBufCount) { |
| 7052 | hdd_err("Failed to round down IpaUcTxBufCount"); |
| 7053 | return -EINVAL; |
| 7054 | } |
| 7055 | hdd_err("IpaUcTxBufCount rounded down to %d", |
| 7056 | hdd_ctx->config->IpaUcTxBufCount); |
| 7057 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7058 | cds_cfg->uc_txbuf_count = hdd_ctx->config->IpaUcTxBufCount; |
| 7059 | cds_cfg->uc_txbuf_size = hdd_ctx->config->IpaUcTxBufSize; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 7060 | if (!is_power_of_2(hdd_ctx->config->IpaUcRxIndRingCount)) { |
| 7061 | /* IpaUcRxIndRingCount should be power of 2 */ |
| 7062 | hdd_err("Round down IpaUcRxIndRingCount %d to nearest power of 2", |
| 7063 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 7064 | hdd_ctx->config->IpaUcRxIndRingCount = |
| 7065 | rounddown_pow_of_two( |
| 7066 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 7067 | if (!hdd_ctx->config->IpaUcRxIndRingCount) { |
| 7068 | hdd_err("Failed to round down IpaUcRxIndRingCount"); |
| 7069 | return -EINVAL; |
| 7070 | } |
| 7071 | hdd_err("IpaUcRxIndRingCount rounded down to %d", |
| 7072 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 7073 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7074 | cds_cfg->uc_rxind_ringcount = |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 7075 | hdd_ctx->config->IpaUcRxIndRingCount; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7076 | cds_cfg->uc_tx_partition_base = |
| 7077 | hdd_ctx->config->IpaUcTxPartitionBase; |
| 7078 | cds_cfg->max_scan = hdd_ctx->config->max_scan_count; |
| 7079 | |
| 7080 | cds_cfg->ip_tcp_udp_checksum_offload = |
| 7081 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 7082 | cds_cfg->enable_rxthread = hdd_ctx->enableRxThread; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7083 | cds_cfg->ce_classify_enabled = |
| 7084 | hdd_ctx->config->ce_classify_enabled; |
Dustin Brown | d3fc9ee | 2016-09-14 13:57:27 -0700 | [diff] [blame] | 7085 | cds_cfg->bpf_packet_filter_enable = |
| 7086 | hdd_ctx->config->bpf_packet_filter_enable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7087 | cds_cfg->tx_chain_mask_cck = hdd_ctx->config->tx_chain_mask_cck; |
| 7088 | cds_cfg->self_gen_frm_pwr = hdd_ctx->config->self_gen_frm_pwr; |
| 7089 | cds_cfg->max_station = hdd_ctx->config->maxNumberOfPeers; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 7090 | cds_cfg->sub_20_channel_width = WLAN_SUB_20_CH_WIDTH_NONE; |
Manjunathappa Prakash | fff753c | 2016-09-01 19:34:56 -0700 | [diff] [blame] | 7091 | cds_cfg->flow_steering_enabled = hdd_ctx->config->flow_steering_enable; |
Naveen Rawat | 91df30a | 2016-10-12 21:26:18 -0700 | [diff] [blame] | 7092 | cds_cfg->self_recovery_enabled = hdd_ctx->config->enableSelfRecovery; |
Sandeep Puligilla | afa5289 | 2016-10-26 19:03:16 -0700 | [diff] [blame] | 7093 | cds_cfg->fw_timeout_crash = hdd_ctx->config->fw_timeout_crash; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7094 | |
| 7095 | hdd_ra_populate_cds_config(cds_cfg, hdd_ctx); |
| 7096 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
| 7097 | hdd_nan_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 7098 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 7099 | cds_init_ini_config(cds_cfg); |
| 7100 | return 0; |
| 7101 | } |
| 7102 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7103 | /** |
| 7104 | * hdd_init_thermal_info - Initialize thermal level |
| 7105 | * @hdd_ctx: HDD context |
| 7106 | * |
| 7107 | * Initialize thermal level at SME layer and set the thermal level callback |
| 7108 | * which would be called when a configured thermal threshold is hit. |
| 7109 | * |
| 7110 | * Return: 0 on success and errno on failure |
| 7111 | */ |
| 7112 | static int hdd_init_thermal_info(hdd_context_t *hdd_ctx) |
| 7113 | { |
| 7114 | tSmeThermalParams thermal_param; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7115 | QDF_STATUS status; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7116 | |
| 7117 | thermal_param.smeThermalMgmtEnabled = |
| 7118 | hdd_ctx->config->thermalMitigationEnable; |
| 7119 | thermal_param.smeThrottlePeriod = hdd_ctx->config->throttlePeriod; |
| 7120 | |
Poddar, Siddarth | 8390502 | 2016-04-16 17:56:08 -0700 | [diff] [blame] | 7121 | thermal_param.sme_throttle_duty_cycle_tbl[0] = |
| 7122 | hdd_ctx->config->throttle_dutycycle_level0; |
| 7123 | thermal_param.sme_throttle_duty_cycle_tbl[1] = |
| 7124 | hdd_ctx->config->throttle_dutycycle_level1; |
| 7125 | thermal_param.sme_throttle_duty_cycle_tbl[2] = |
| 7126 | hdd_ctx->config->throttle_dutycycle_level2; |
| 7127 | thermal_param.sme_throttle_duty_cycle_tbl[3] = |
| 7128 | hdd_ctx->config->throttle_dutycycle_level3; |
| 7129 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7130 | thermal_param.smeThermalLevels[0].smeMinTempThreshold = |
| 7131 | hdd_ctx->config->thermalTempMinLevel0; |
| 7132 | thermal_param.smeThermalLevels[0].smeMaxTempThreshold = |
| 7133 | hdd_ctx->config->thermalTempMaxLevel0; |
| 7134 | thermal_param.smeThermalLevels[1].smeMinTempThreshold = |
| 7135 | hdd_ctx->config->thermalTempMinLevel1; |
| 7136 | thermal_param.smeThermalLevels[1].smeMaxTempThreshold = |
| 7137 | hdd_ctx->config->thermalTempMaxLevel1; |
| 7138 | thermal_param.smeThermalLevels[2].smeMinTempThreshold = |
| 7139 | hdd_ctx->config->thermalTempMinLevel2; |
| 7140 | thermal_param.smeThermalLevels[2].smeMaxTempThreshold = |
| 7141 | hdd_ctx->config->thermalTempMaxLevel2; |
| 7142 | thermal_param.smeThermalLevels[3].smeMinTempThreshold = |
| 7143 | hdd_ctx->config->thermalTempMinLevel3; |
| 7144 | thermal_param.smeThermalLevels[3].smeMaxTempThreshold = |
| 7145 | hdd_ctx->config->thermalTempMaxLevel3; |
| 7146 | |
| 7147 | status = sme_init_thermal_info(hdd_ctx->hHal, thermal_param); |
| 7148 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7149 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 7150 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7151 | |
| 7152 | sme_add_set_thermal_level_callback(hdd_ctx->hHal, |
| 7153 | hdd_set_thermal_level_cb); |
| 7154 | |
| 7155 | return 0; |
| 7156 | |
| 7157 | } |
| 7158 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7159 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 7160 | /** |
| 7161 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 7162 | * |
| 7163 | * Hold RTNL lock |
| 7164 | * |
| 7165 | * Return: True if held and false otherwise |
| 7166 | */ |
| 7167 | static inline bool hdd_hold_rtnl_lock(void) |
| 7168 | { |
| 7169 | rtnl_lock(); |
| 7170 | return true; |
| 7171 | } |
| 7172 | |
| 7173 | /** |
| 7174 | * hdd_release_rtnl_lock - Release RTNL lock |
| 7175 | * |
| 7176 | * Release RTNL lock |
| 7177 | * |
| 7178 | * Return: None |
| 7179 | */ |
| 7180 | static inline void hdd_release_rtnl_lock(void) |
| 7181 | { |
| 7182 | rtnl_unlock(); |
| 7183 | } |
| 7184 | #else |
| 7185 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 7186 | static inline void hdd_release_rtnl_lock(void) { } |
| 7187 | #endif |
| 7188 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 7189 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7190 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7191 | /* MAX iwpriv command support */ |
| 7192 | #define PKTLOG_SET_BUFF_SIZE 3 |
| 7193 | #define MAX_PKTLOG_SIZE 16 |
| 7194 | |
| 7195 | /** |
| 7196 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 7197 | * @hdd_ctx: hdd context |
| 7198 | * @set_value2: pktlog buffer size value |
| 7199 | * |
| 7200 | * |
| 7201 | * Return: 0 for success or error. |
| 7202 | */ |
| 7203 | static int hdd_pktlog_set_buff_size(hdd_context_t *hdd_ctx, int set_value2) |
| 7204 | { |
| 7205 | struct sir_wifi_start_log start_log = { 0 }; |
| 7206 | QDF_STATUS status; |
| 7207 | |
| 7208 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 7209 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 7210 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 7211 | start_log.user_triggered = 1; |
| 7212 | start_log.size = set_value2; |
| 7213 | |
| 7214 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 7215 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 7216 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 7217 | EXIT(); |
| 7218 | return -EINVAL; |
| 7219 | } |
| 7220 | |
| 7221 | return 0; |
| 7222 | } |
| 7223 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7224 | /** |
| 7225 | * hdd_process_pktlog_command() - process pktlog command |
| 7226 | * @hdd_ctx: hdd context |
| 7227 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7228 | * @set_value2: pktlog buffer size value |
| 7229 | * |
| 7230 | * This function process pktlog command. |
| 7231 | * set_value2 only matters when set_value is 3 (set buff size) |
| 7232 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7233 | * |
| 7234 | * Return: 0 for success or error. |
| 7235 | */ |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7236 | int hdd_process_pktlog_command(hdd_context_t *hdd_ctx, uint32_t set_value, |
| 7237 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7238 | { |
| 7239 | int ret; |
| 7240 | bool enable; |
| 7241 | uint8_t user_triggered = 0; |
| 7242 | |
| 7243 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 7244 | if (0 != ret) |
| 7245 | return ret; |
| 7246 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7247 | hdd_info("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7248 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7249 | if (set_value > PKTLOG_SET_BUFF_SIZE) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7250 | hdd_err("invalid pktlog value %d", set_value); |
| 7251 | return -EINVAL; |
| 7252 | } |
| 7253 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7254 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 7255 | if (set_value2 <= 0) { |
| 7256 | hdd_err("invalid pktlog size %d", set_value2); |
| 7257 | return -EINVAL; |
| 7258 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
| 7259 | hdd_err("Pktlog buff size is too large. max value is 16MB.\n"); |
| 7260 | return -EINVAL; |
| 7261 | } |
| 7262 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
| 7263 | } |
| 7264 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7265 | /* |
| 7266 | * set_value = 0 then disable packetlog |
| 7267 | * set_value = 1 enable packetlog forcefully |
| 7268 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 7269 | * enable packetlog with AUTO type. |
| 7270 | */ |
| 7271 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 7272 | true : false; |
| 7273 | |
| 7274 | if (1 == set_value) { |
| 7275 | enable = true; |
| 7276 | user_triggered = 1; |
| 7277 | } |
| 7278 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7279 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7280 | } |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 7281 | /** |
| 7282 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 7283 | * @hdd_ctx: HDD context |
| 7284 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7285 | * @user_triggered: triggered through iwpriv |
| 7286 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 7287 | * |
| 7288 | * Return: 0 on success; error number otherwise |
| 7289 | */ |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7290 | int hdd_pktlog_enable_disable(hdd_context_t *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7291 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 7292 | { |
| 7293 | struct sir_wifi_start_log start_log; |
| 7294 | QDF_STATUS status; |
| 7295 | |
| 7296 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 7297 | start_log.verbose_level = |
| 7298 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 7299 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 7300 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7301 | start_log.size = size; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 7302 | /* |
| 7303 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 7304 | * commands. Host uses this flag to decide whether to send pktlog |
| 7305 | * disable command to fw without sending pktlog enable command |
| 7306 | * previously. For eg, If vendor sends pktlog disable command without |
| 7307 | * sending pktlog enable command, then host discards the packet |
| 7308 | * but for iwpriv command, host will send it to fw. |
| 7309 | */ |
| 7310 | start_log.is_iwpriv_command = 1; |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 7311 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 7312 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 7313 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 7314 | EXIT(); |
| 7315 | return -EINVAL; |
| 7316 | } |
| 7317 | |
| 7318 | return 0; |
| 7319 | } |
| 7320 | #endif /* REMOVE_PKT_LOG */ |
| 7321 | |
| 7322 | |
Chandrasekaran Manishekar | cde33d7 | 2016-04-14 19:03:39 +0530 | [diff] [blame] | 7323 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 7324 | /** |
| 7325 | * hdd_register_for_sap_restart_with_channel_switch() - Register for SAP channel |
| 7326 | * switch without restart |
| 7327 | * |
| 7328 | * Registers callback function to change the operating channel of SAP by using |
| 7329 | * channel switch announcements instead of restarting SAP. |
| 7330 | * |
| 7331 | * Return: QDF_STATUS |
| 7332 | */ |
| 7333 | QDF_STATUS hdd_register_for_sap_restart_with_channel_switch(void) |
| 7334 | { |
| 7335 | QDF_STATUS status; |
| 7336 | |
| 7337 | status = cds_register_sap_restart_channel_switch_cb( |
| 7338 | (void *)hdd_sap_restart_with_channel_switch); |
| 7339 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 7340 | hdd_err("restart cb registration failed"); |
| 7341 | |
| 7342 | return status; |
| 7343 | } |
| 7344 | #endif |
| 7345 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7346 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7347 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 7348 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7349 | * @dev: Device Pointer |
| 7350 | * @num: Number of Valid Mac address |
| 7351 | * |
| 7352 | * Return: Pointer to MAC address buffer |
| 7353 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7354 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 7355 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7356 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7357 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7358 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7359 | |
| 7360 | /** |
| 7361 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 7362 | * @hdd_ctx: HDD Context |
| 7363 | * @num: Number of random mac addresses needed |
| 7364 | * |
| 7365 | * Generate random addresses using bit manipulation on the base mac address |
| 7366 | * |
| 7367 | * Return: None |
| 7368 | */ |
| 7369 | static void hdd_populate_random_mac_addr(hdd_context_t *hdd_ctx, uint32_t num) |
| 7370 | { |
| 7371 | uint32_t start_idx = QDF_MAX_CONCURRENCY_PERSONA - num; |
| 7372 | uint32_t iter; |
| 7373 | struct hdd_config *ini = hdd_ctx->config; |
| 7374 | uint8_t *buf = NULL; |
| 7375 | uint8_t macaddr_b3, tmp_br3; |
| 7376 | uint8_t *src = ini->intfMacAddr[0].bytes; |
| 7377 | |
| 7378 | for (iter = start_idx; iter < QDF_MAX_CONCURRENCY_PERSONA; ++iter) { |
| 7379 | buf = ini->intfMacAddr[iter].bytes; |
| 7380 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 7381 | macaddr_b3 = buf[3]; |
| 7382 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + iter) & |
| 7383 | INTF_MACADDR_MASK; |
| 7384 | macaddr_b3 += tmp_br3; |
| 7385 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 7386 | buf[0] |= 0x02; |
| 7387 | buf[3] = macaddr_b3; |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 7388 | hdd_info(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7389 | } |
| 7390 | } |
| 7391 | |
| 7392 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7393 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7394 | * @hdd_ctx: HDD Context |
| 7395 | * |
| 7396 | * API to get mac addresses from platform driver and update the driver |
| 7397 | * structures and configure FW with the base mac address. |
| 7398 | * Return: int |
| 7399 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7400 | static int hdd_platform_wlan_mac(hdd_context_t *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7401 | { |
| 7402 | uint32_t no_of_mac_addr, iter; |
| 7403 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 7404 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 7405 | uint8_t *addr, *buf; |
| 7406 | struct device *dev = hdd_ctx->parent_dev; |
| 7407 | struct hdd_config *ini = hdd_ctx->config; |
| 7408 | tSirMacAddr mac_addr; |
| 7409 | QDF_STATUS status; |
| 7410 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7411 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7412 | |
| 7413 | if (no_of_mac_addr == 0 || !addr) { |
| 7414 | hdd_warn("Platform Driver Doesn't have wlan mac addresses"); |
| 7415 | return -EINVAL; |
| 7416 | } |
| 7417 | |
| 7418 | if (no_of_mac_addr > max_mac_addr) |
| 7419 | no_of_mac_addr = max_mac_addr; |
| 7420 | |
| 7421 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 7422 | |
| 7423 | for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { |
| 7424 | buf = ini->intfMacAddr[iter].bytes; |
| 7425 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 7426 | hdd_info(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7427 | } |
| 7428 | |
| 7429 | status = sme_set_custom_mac_addr(mac_addr); |
| 7430 | |
| 7431 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 7432 | return -EAGAIN; |
| 7433 | if (no_of_mac_addr < max_mac_addr) |
| 7434 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 7435 | no_of_mac_addr); |
| 7436 | return 0; |
| 7437 | } |
| 7438 | |
| 7439 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 7440 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 7441 | * @hdd_ctx: HDD Context |
| 7442 | * |
| 7443 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 7444 | * will generate its own MAC and update it to FW. |
| 7445 | * |
| 7446 | * Return: 0 for success |
| 7447 | * Non-zero error code for failure |
| 7448 | */ |
| 7449 | static int hdd_update_mac_addr_to_fw(hdd_context_t *hdd_ctx) |
| 7450 | { |
| 7451 | tSirMacAddr customMacAddr; |
| 7452 | QDF_STATUS status; |
| 7453 | |
| 7454 | qdf_mem_copy(&customMacAddr, |
| 7455 | &hdd_ctx->config->intfMacAddr[0].bytes[0], |
| 7456 | sizeof(tSirMacAddr)); |
| 7457 | status = sme_set_custom_mac_addr(customMacAddr); |
| 7458 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 7459 | return -EAGAIN; |
| 7460 | return 0; |
| 7461 | } |
| 7462 | |
| 7463 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7464 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 7465 | * @hdd_ctx: HDD Context |
| 7466 | * |
| 7467 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 7468 | * is provisioned with mac addresses, driver uses it, else it will use |
| 7469 | * wlan_mac.bin to update HW MAC addresses. |
| 7470 | * |
| 7471 | * Return: None |
| 7472 | */ |
| 7473 | static void hdd_initialize_mac_address(hdd_context_t *hdd_ctx) |
| 7474 | { |
| 7475 | QDF_STATUS status; |
| 7476 | int ret; |
| 7477 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 7478 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7479 | if (ret == 0) |
| 7480 | return; |
| 7481 | |
| 7482 | hdd_warn("Can't update mac config via platform driver ret:%d", ret); |
| 7483 | |
| 7484 | status = hdd_update_mac_config(hdd_ctx); |
| 7485 | |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 7486 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 7487 | return; |
| 7488 | |
| 7489 | hdd_warn("can't update mac config via wlan_mac.bin, using MAC from ini file or auto-gen"); |
| 7490 | |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 7491 | if (hdd_ctx->update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 7492 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 7493 | if (ret != 0) { |
| 7494 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
| 7495 | QDF_ASSERT(ret); |
| 7496 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 7497 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 7498 | } |
| 7499 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7500 | /** |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 7501 | * hdd_tsf_init() - Initialize the TSF synchronization interface |
| 7502 | * @hdd_ctx: HDD global context |
| 7503 | * |
| 7504 | * When TSF synchronization via GPIO is supported by the driver and |
| 7505 | * has been enabled in the configuration file, this function plumbs |
| 7506 | * the GPIO value down to firmware via SME. |
| 7507 | * |
| 7508 | * Return: None |
| 7509 | */ |
| 7510 | #ifdef WLAN_FEATURE_TSF |
| 7511 | static void hdd_tsf_init(hdd_context_t *hdd_ctx) |
| 7512 | { |
| 7513 | QDF_STATUS status; |
| 7514 | |
| 7515 | if (hdd_ctx->config->tsf_gpio_pin == TSF_GPIO_PIN_INVALID) |
| 7516 | return; |
| 7517 | |
| 7518 | status = sme_set_tsf_gpio(hdd_ctx->hHal, |
| 7519 | hdd_ctx->config->tsf_gpio_pin); |
| 7520 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 7521 | hdd_err("Set tsf GPIO failed, status: %d", status); |
| 7522 | } |
| 7523 | #else |
| 7524 | static void hdd_tsf_init(hdd_context_t *hdd_ctx) |
| 7525 | { |
| 7526 | } |
| 7527 | #endif |
| 7528 | |
| 7529 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 7530 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 7531 | * @hdd_ctx: HDD context |
| 7532 | * |
| 7533 | * Pre configurations to be done at lower layer before calling cds enable. |
| 7534 | * |
| 7535 | * Return: 0 on success and errno on failure. |
| 7536 | */ |
| 7537 | static int hdd_pre_enable_configure(hdd_context_t *hdd_ctx) |
| 7538 | { |
| 7539 | int ret; |
| 7540 | QDF_STATUS status; |
| 7541 | tSirRetStatus hal_status; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 7542 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 7543 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 7544 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 7545 | /* |
| 7546 | * Set 802.11p config |
| 7547 | * TODO-OCB: This has been temporarily added here to ensure this |
| 7548 | * parameter is set in CSR when we init the channel list. This should |
| 7549 | * be removed once the 5.9 GHz channels are added to the regulatory |
| 7550 | * domain. |
| 7551 | */ |
| 7552 | hdd_set_dot11p_config(hdd_ctx); |
| 7553 | |
| 7554 | /* |
| 7555 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 7556 | * The cfg download must occur before we update the SME config |
| 7557 | * since the SME config operation must access the cfg database |
| 7558 | */ |
| 7559 | status = hdd_set_sme_config(hdd_ctx); |
| 7560 | |
| 7561 | if (QDF_STATUS_SUCCESS != status) { |
| 7562 | hdd_alert("Failed hdd_set_sme_config: %d", status); |
| 7563 | ret = qdf_status_to_os_return(status); |
| 7564 | goto out; |
| 7565 | } |
| 7566 | |
| 7567 | ret = wma_cli_set_command(0, WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS, |
| 7568 | hdd_ctx->config->tx_chain_mask_1ss, |
| 7569 | PDEV_CMD); |
| 7570 | if (0 != ret) { |
| 7571 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 7572 | goto out; |
| 7573 | } |
| 7574 | |
| 7575 | hdd_program_country_code(hdd_ctx); |
| 7576 | |
| 7577 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 7578 | if (status != QDF_STATUS_SUCCESS) { |
| 7579 | hdd_alert("Failed to init channel list: %d", status); |
| 7580 | ret = qdf_status_to_os_return(status); |
| 7581 | goto out; |
| 7582 | } |
| 7583 | |
| 7584 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 7585 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 7586 | hdd_alert("config update failed"); |
| 7587 | ret = -EINVAL; |
| 7588 | goto out; |
| 7589 | } |
| 7590 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 7591 | /* |
| 7592 | * Set the MAC Address Currently this is used by HAL to add self sta. |
| 7593 | * Remove this once self sta is added as part of session open. |
| 7594 | */ |
| 7595 | hal_status = cfg_set_str(hdd_ctx->hHal, WNI_CFG_STA_ID, |
| 7596 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 7597 | sizeof(hdd_ctx->config->intfMacAddr[0])); |
| 7598 | |
| 7599 | if (!IS_SIR_STATUS_SUCCESS(hal_status)) { |
| 7600 | hdd_err("Failed to set MAC Address. HALStatus is %08d [x%08x]", |
| 7601 | hal_status, hal_status); |
| 7602 | ret = -EINVAL; |
| 7603 | goto out; |
| 7604 | } |
| 7605 | |
| 7606 | hdd_init_channel_avoidance(hdd_ctx); |
| 7607 | |
| 7608 | out: |
| 7609 | return ret; |
| 7610 | } |
| 7611 | |
| 7612 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 7613 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
| 7614 | * @context_ptr - hdd context pointer |
| 7615 | * @event_ptr - event structure pointer |
| 7616 | * |
| 7617 | * This is the p2p listen offload stop event handler, it sends vendor |
| 7618 | * event back to supplicant to notify the stop reason. |
| 7619 | * |
| 7620 | * Return: None |
| 7621 | */ |
| 7622 | static void wlan_hdd_p2p_lo_event_callback(void *context_ptr, |
| 7623 | void *event_ptr) |
| 7624 | { |
| 7625 | hdd_context_t *hdd_ctx = (hdd_context_t *)context_ptr; |
| 7626 | struct sir_p2p_lo_event *evt = event_ptr; |
| 7627 | struct sk_buff *vendor_event; |
| 7628 | |
| 7629 | ENTER(); |
| 7630 | |
| 7631 | if (hdd_ctx == NULL) { |
| 7632 | hdd_err("Invalid HDD context pointer"); |
| 7633 | return; |
| 7634 | } |
| 7635 | |
| 7636 | vendor_event = |
| 7637 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
| 7638 | NULL, sizeof(uint32_t) + NLMSG_HDRLEN, |
| 7639 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 7640 | GFP_KERNEL); |
| 7641 | |
| 7642 | if (!vendor_event) { |
| 7643 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 7644 | return; |
| 7645 | } |
| 7646 | |
| 7647 | if (nla_put_u32(vendor_event, |
| 7648 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 7649 | evt->reason_code)) { |
| 7650 | hdd_err("nla put failed"); |
| 7651 | kfree_skb(vendor_event); |
| 7652 | return; |
| 7653 | } |
| 7654 | |
| 7655 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 7656 | } |
| 7657 | |
| 7658 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 7659 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 7660 | * @hdd_ctx: HDD context |
| 7661 | * |
| 7662 | * This function sends the adaptive dwell time config configuration to the |
| 7663 | * firmware via WMA |
| 7664 | * |
| 7665 | * Return: 0 - success, < 0 - failure |
| 7666 | */ |
| 7667 | static int hdd_adaptive_dwelltime_init(hdd_context_t *hdd_ctx) |
| 7668 | { |
| 7669 | QDF_STATUS status; |
| 7670 | struct adaptive_dwelltime_params dwelltime_params; |
| 7671 | |
| 7672 | dwelltime_params.is_enabled = |
| 7673 | hdd_ctx->config->adaptive_dwell_mode_enabled; |
| 7674 | dwelltime_params.dwelltime_mode = |
| 7675 | hdd_ctx->config->global_adapt_dwelltime_mode; |
| 7676 | dwelltime_params.lpf_weight = |
| 7677 | hdd_ctx->config->adapt_dwell_lpf_weight; |
| 7678 | dwelltime_params.passive_mon_intval = |
| 7679 | hdd_ctx->config->adapt_dwell_passive_mon_intval; |
| 7680 | dwelltime_params.wifi_act_threshold = |
| 7681 | hdd_ctx->config->adapt_dwell_wifi_act_threshold; |
| 7682 | |
| 7683 | status = sme_set_adaptive_dwelltime_config(hdd_ctx->hHal, |
| 7684 | &dwelltime_params); |
| 7685 | |
| 7686 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 7687 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 7688 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 7689 | return -EAGAIN; |
| 7690 | } |
| 7691 | return 0; |
| 7692 | } |
| 7693 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 7694 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 7695 | /** |
| 7696 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 7697 | * @hdd_ctx: HDD context |
| 7698 | * |
| 7699 | * Set auto shutdown callback to get indications from firmware to indicate |
| 7700 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 7701 | * |
| 7702 | * Return: 0 on success and errno on failure. |
| 7703 | */ |
| 7704 | static int hdd_set_auto_shutdown_cb(hdd_context_t *hdd_ctx) |
| 7705 | { |
| 7706 | QDF_STATUS status; |
| 7707 | |
| 7708 | if (!hdd_ctx->config->WlanAutoShutdown) |
| 7709 | return 0; |
| 7710 | |
| 7711 | status = sme_set_auto_shutdown_cb(hdd_ctx->hHal, |
| 7712 | wlan_hdd_auto_shutdown_cb); |
| 7713 | if (status != QDF_STATUS_SUCCESS) |
| 7714 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 7715 | status); |
| 7716 | |
| 7717 | return qdf_status_to_os_return(status); |
| 7718 | } |
| 7719 | #else |
| 7720 | static int hdd_set_auto_shutdown_cb(hdd_context_t *hdd_ctx) |
| 7721 | { |
| 7722 | return 0; |
| 7723 | } |
| 7724 | #endif |
| 7725 | |
| 7726 | /** |
| 7727 | * hdd_features_init() - Init features |
| 7728 | * @hdd_ctx: HDD context |
| 7729 | * @adapter: Primary adapter context |
| 7730 | * |
| 7731 | * Initialize features and their feature context after WLAN firmware is up. |
| 7732 | * |
| 7733 | * Return: 0 on success and errno on failure. |
| 7734 | */ |
| 7735 | static int hdd_features_init(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter) |
| 7736 | { |
| 7737 | tSirTxPowerLimit hddtxlimit; |
| 7738 | QDF_STATUS status; |
| 7739 | int ret; |
| 7740 | |
| 7741 | ENTER(); |
| 7742 | |
| 7743 | ret = hdd_update_country_code(hdd_ctx, adapter); |
| 7744 | if (ret) { |
| 7745 | hdd_err("Failed to update country code: %d", ret); |
| 7746 | goto out; |
| 7747 | } |
| 7748 | |
| 7749 | /* FW capabilities received, Set the Dot11 mode */ |
| 7750 | sme_setdef_dot11mode(hdd_ctx->hHal); |
Kiran Kumar Lokere | 1aa9c9a | 2016-10-05 18:50:59 -0700 | [diff] [blame] | 7751 | sme_set_prefer_80MHz_over_160MHz(hdd_ctx->hHal, |
| 7752 | hdd_ctx->config->sta_prefer_80MHz_over_160MHz); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 7753 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 7754 | |
| 7755 | if (hdd_ctx->config->fIsImpsEnabled) |
| 7756 | hdd_set_idle_ps_config(hdd_ctx, true); |
| 7757 | else |
| 7758 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 7759 | |
| 7760 | if (hdd_lro_init(hdd_ctx)) |
| 7761 | hdd_err("Unable to initialize LRO in fw"); |
| 7762 | |
| 7763 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 7764 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 7765 | |
| 7766 | ret = hdd_init_thermal_info(hdd_ctx); |
| 7767 | if (ret) { |
| 7768 | hdd_err("Error while initializing thermal information"); |
| 7769 | goto deregister_frames; |
| 7770 | } |
| 7771 | |
| 7772 | hddtxlimit.txPower2g = hdd_ctx->config->TxPower2g; |
| 7773 | hddtxlimit.txPower5g = hdd_ctx->config->TxPower5g; |
| 7774 | status = sme_txpower_limit(hdd_ctx->hHal, &hddtxlimit); |
| 7775 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 7776 | hdd_err("Error setting txlimit in sme: %d", status); |
| 7777 | |
| 7778 | hdd_tsf_init(hdd_ctx); |
Padma, Santhosh Kumar | 1472fab | 2016-10-07 13:29:27 +0530 | [diff] [blame] | 7779 | hdd_encrypt_decrypt_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 7780 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 7781 | ret = hdd_register_cb(hdd_ctx); |
| 7782 | if (ret) { |
| 7783 | hdd_err("Failed to register HDD callbacks!"); |
| 7784 | goto deregister_frames; |
| 7785 | } |
| 7786 | |
| 7787 | if (hdd_ctx->config->dual_mac_feature_disable) { |
| 7788 | status = wlan_hdd_disable_all_dual_mac_features(hdd_ctx); |
| 7789 | if (status != QDF_STATUS_SUCCESS) { |
| 7790 | hdd_err("Failed to disable dual mac features"); |
| 7791 | goto deregister_cb; |
| 7792 | } |
| 7793 | } |
| 7794 | |
| 7795 | /* register P2P Listen Offload event callback */ |
| 7796 | if (wma_is_p2p_lo_capable()) |
| 7797 | sme_register_p2p_lo_event(hdd_ctx->hHal, hdd_ctx, |
| 7798 | wlan_hdd_p2p_lo_event_callback); |
| 7799 | |
| 7800 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 7801 | |
| 7802 | if (ret) |
| 7803 | goto deregister_cb; |
| 7804 | |
| 7805 | EXIT(); |
| 7806 | return 0; |
| 7807 | |
| 7808 | deregister_cb: |
| 7809 | hdd_deregister_cb(hdd_ctx); |
| 7810 | deregister_frames: |
| 7811 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 7812 | out: |
| 7813 | return -EINVAL; |
| 7814 | |
| 7815 | } |
| 7816 | |
| 7817 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 7818 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7819 | * hdd_configure_cds() - Configure cds modules |
| 7820 | * @hdd_ctx: HDD context |
| 7821 | * @adapter: Primary adapter context |
| 7822 | * |
| 7823 | * Enable Cds modules after WLAN firmware is up. |
| 7824 | * |
| 7825 | * Return: 0 on success and errno on failure. |
| 7826 | */ |
| 7827 | int hdd_configure_cds(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter) |
| 7828 | { |
| 7829 | int ret; |
| 7830 | QDF_STATUS status; |
| 7831 | /* structure of function pointers to be used by CDS */ |
| 7832 | struct cds_sme_cbacks sme_cbacks; |
| 7833 | |
| 7834 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 7835 | if (ret) { |
| 7836 | hdd_err("Failed to pre-configure cds"); |
| 7837 | goto out; |
| 7838 | } |
| 7839 | |
| 7840 | /* |
| 7841 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 7842 | * else |
| 7843 | */ |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 7844 | status = cds_enable(hdd_ctx->hdd_psoc, hdd_ctx->pcds_context); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7845 | |
| 7846 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 7847 | hdd_alert("cds_enable failed"); |
| 7848 | goto out; |
| 7849 | } |
| 7850 | |
| 7851 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 7852 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 7853 | hdd_alert("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 7854 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7855 | } |
| 7856 | |
| 7857 | ret = hdd_features_init(hdd_ctx, adapter); |
| 7858 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 7859 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7860 | |
| 7861 | sme_cbacks.sme_get_valid_channels = sme_get_cfg_valid_channels; |
| 7862 | sme_cbacks.sme_get_nss_for_vdev = sme_get_vdev_type_nss; |
| 7863 | status = cds_init_policy_mgr(&sme_cbacks); |
| 7864 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 7865 | hdd_err("Policy manager initialization failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 7866 | goto hdd_features_deinit; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7867 | } |
| 7868 | |
| 7869 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 7870 | |
| 7871 | hdd_features_deinit: |
| 7872 | hdd_deregister_cb(hdd_ctx); |
| 7873 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 7874 | cds_disable: |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 7875 | cds_disable(hdd_ctx->hdd_psoc, hdd_ctx->pcds_context); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 7876 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7877 | out: |
| 7878 | return -EINVAL; |
| 7879 | } |
| 7880 | |
| 7881 | /** |
| 7882 | * hdd_deconfigure_cds() -De-Configure cds |
| 7883 | * @hdd_ctx: HDD context |
| 7884 | * |
| 7885 | * Deconfigure Cds modules before WLAN firmware is down. |
| 7886 | * |
| 7887 | * Return: 0 on success and errno on failure. |
| 7888 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 7889 | static int hdd_deconfigure_cds(hdd_context_t *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7890 | { |
| 7891 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 7892 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7893 | |
| 7894 | ENTER(); |
| 7895 | /* De-register the SME callbacks */ |
| 7896 | hdd_deregister_cb(hdd_ctx); |
Padma, Santhosh Kumar | 1472fab | 2016-10-07 13:29:27 +0530 | [diff] [blame] | 7897 | hdd_encrypt_decrypt_deinit(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7898 | |
| 7899 | /* De-init Policy Manager */ |
| 7900 | if (!QDF_IS_STATUS_SUCCESS(cds_deinit_policy_mgr())) { |
| 7901 | hdd_err("Failed to deinit policy manager"); |
| 7902 | /* Proceed and complete the clean up */ |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 7903 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7904 | } |
| 7905 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 7906 | qdf_status = cds_disable(hdd_ctx->hdd_psoc, hdd_ctx->pcds_context); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7907 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 7908 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 7909 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 7910 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7911 | } |
| 7912 | |
| 7913 | EXIT(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 7914 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7915 | } |
| 7916 | |
| 7917 | |
| 7918 | /** |
| 7919 | * hdd_wlan_stop_modules - Single driver state machine for stoping modules |
| 7920 | * @hdd_ctx: HDD context |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7921 | * |
| 7922 | * This function maintains the driver state machine it will be invoked from |
| 7923 | * exit, shutdown and con_mode change handler. Depending on the driver state |
| 7924 | * shall perform the stopping/closing of the modules. |
| 7925 | * |
| 7926 | * Return: 0 for success; non-zero for failure |
| 7927 | */ |
Prashanth Bhatta | 2ac92bd | 2016-10-11 16:08:00 -0700 | [diff] [blame] | 7928 | int hdd_wlan_stop_modules(hdd_context_t *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7929 | { |
| 7930 | void *hif_ctx; |
| 7931 | qdf_device_t qdf_ctx; |
| 7932 | QDF_STATUS qdf_status; |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 7933 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7934 | p_cds_sched_context cds_sched_context = NULL; |
| 7935 | |
| 7936 | ENTER(); |
| 7937 | |
| 7938 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 7939 | if (!qdf_ctx) { |
| 7940 | hdd_err("QDF device context NULL"); |
| 7941 | return -EINVAL; |
| 7942 | } |
| 7943 | |
| 7944 | cds_sched_context = get_cds_sched_ctxt(); |
| 7945 | if (!cds_sched_context) { |
| 7946 | hdd_err("cds scheduler context NULL"); |
| 7947 | return -EINVAL; |
| 7948 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 7949 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 7950 | hdd_ctx->stop_modules_in_progress = true; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7951 | |
| 7952 | hdd_info("Present Driver Status: %d", hdd_ctx->driver_status); |
| 7953 | |
| 7954 | switch (hdd_ctx->driver_status) { |
| 7955 | case DRIVER_MODULES_UNINITIALIZED: |
| 7956 | hdd_info("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 7957 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7958 | case DRIVER_MODULES_CLOSED: |
| 7959 | hdd_info("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 7960 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7961 | case DRIVER_MODULES_ENABLED: |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 7962 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7963 | if (hdd_deconfigure_cds(hdd_ctx)) { |
| 7964 | hdd_alert("Failed to de-configure CDS"); |
| 7965 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 7966 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7967 | } |
| 7968 | hdd_info("successfully Disabled the CDS modules!"); |
| 7969 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
| 7970 | break; |
| 7971 | case DRIVER_MODULES_OPENED: |
| 7972 | hdd_info("Closing CDS modules!"); |
| 7973 | break; |
| 7974 | default: |
| 7975 | hdd_err("Trying to stop wlan in a wrong state: %d", |
| 7976 | hdd_ctx->driver_status); |
| 7977 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 7978 | ret = -EINVAL; |
| 7979 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7980 | } |
| 7981 | |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 7982 | qdf_status = cds_post_disable(hdd_ctx->pcds_context); |
| 7983 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 7984 | hdd_err("Failed to process post CDS disable Modules! :%d", |
| 7985 | qdf_status); |
| 7986 | ret = -EINVAL; |
| 7987 | QDF_ASSERT(0); |
| 7988 | } |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 7989 | qdf_status = cds_close(hdd_ctx->hdd_psoc, hdd_ctx->pcds_context); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7990 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 7991 | hdd_warn("Failed to stop CDS:%d", qdf_status); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 7992 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7993 | QDF_ASSERT(0); |
| 7994 | } |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 7995 | |
Rajeev Kumar | 3a6c13c | 2017-01-06 13:01:08 -0800 | [diff] [blame] | 7996 | qdf_status = hdd_release_and_destroy_pdev(hdd_ctx); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 7997 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 7998 | hdd_err("Pdev delete failed"); |
| 7999 | |
Rajeev Kumar | 1cba9d0 | 2017-01-06 11:36:14 -0800 | [diff] [blame] | 8000 | qdf_status = hdd_release_and_destroy_psoc(hdd_ctx); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 8001 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 8002 | hdd_err("Psoc delete failed"); |
| 8003 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8004 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 8005 | if (!hif_ctx) { |
| 8006 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8007 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8008 | } |
| 8009 | |
| 8010 | hdd_hif_close(hif_ctx); |
| 8011 | |
| 8012 | ol_cds_free(); |
| 8013 | |
Arunk Khandavalli | 649c009 | 2016-11-22 21:20:43 +0530 | [diff] [blame] | 8014 | if (!cds_is_driver_recovering() && !cds_is_driver_unloading()) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8015 | ret = pld_power_off(qdf_ctx->dev); |
| 8016 | if (ret) |
| 8017 | hdd_err("CNSS power down failed put device into Low power mode:%d", |
| 8018 | ret); |
| 8019 | } |
| 8020 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
| 8021 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8022 | done: |
| 8023 | hdd_ctx->stop_modules_in_progress = false; |
| 8024 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8025 | EXIT(); |
| 8026 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 8027 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8028 | |
| 8029 | } |
| 8030 | |
| 8031 | /** |
| 8032 | * hdd_iface_change_callback() - Function invoked when stop modules expires |
| 8033 | * @priv: pointer to hdd context |
| 8034 | * |
| 8035 | * This function is invoked when the timer waiting for the interface change |
| 8036 | * expires, it shall cut-down the power to wlan and stop all the modules. |
| 8037 | * |
| 8038 | * Return: void |
| 8039 | */ |
| 8040 | static void hdd_iface_change_callback(void *priv) |
| 8041 | { |
| 8042 | hdd_context_t *hdd_ctx = (hdd_context_t *) priv; |
| 8043 | int ret; |
| 8044 | int status = wlan_hdd_validate_context(hdd_ctx); |
| 8045 | |
| 8046 | if (status) |
| 8047 | return; |
| 8048 | |
| 8049 | ENTER(); |
| 8050 | hdd_info("Interface change timer expired close the modules!"); |
Prashanth Bhatta | 2ac92bd | 2016-10-11 16:08:00 -0700 | [diff] [blame] | 8051 | ret = hdd_wlan_stop_modules(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8052 | if (ret) |
| 8053 | hdd_alert("Failed to stop modules"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8054 | EXIT(); |
| 8055 | } |
| 8056 | |
| 8057 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 8058 | * hdd_state_info_dump() - prints state information of hdd layer |
| 8059 | * @buf: buffer pointer |
| 8060 | * @size: size of buffer to be filled |
| 8061 | * |
| 8062 | * This function is used to dump state information of hdd layer |
| 8063 | * |
| 8064 | * Return: None |
| 8065 | */ |
| 8066 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 8067 | { |
| 8068 | hdd_context_t *hdd_ctx; |
| 8069 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 8070 | QDF_STATUS status; |
| 8071 | hdd_station_ctx_t *hdd_sta_ctx; |
| 8072 | hdd_adapter_t *adapter; |
| 8073 | uint16_t len = 0; |
| 8074 | char *buf = *buf_ptr; |
| 8075 | |
| 8076 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 8077 | if (!hdd_ctx) { |
| 8078 | hdd_err("Failed to get hdd context "); |
| 8079 | return; |
| 8080 | } |
| 8081 | |
| 8082 | hdd_notice("size of buffer: %d", *size); |
| 8083 | |
| 8084 | len += scnprintf(buf + len, *size - len, |
| 8085 | "\n isWiphySuspended %d", hdd_ctx->isWiphySuspended); |
| 8086 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 8087 | "\n is_scheduler_suspended %d", |
| 8088 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 8089 | |
| 8090 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 8091 | |
| 8092 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 8093 | adapter = adapter_node->pAdapter; |
| 8094 | if (adapter->dev) |
| 8095 | len += scnprintf(buf + len, *size - len, |
| 8096 | "\n device name: %s", adapter->dev->name); |
| 8097 | len += scnprintf(buf + len, *size - len, |
| 8098 | "\n device_mode: %d", adapter->device_mode); |
| 8099 | switch (adapter->device_mode) { |
| 8100 | case QDF_STA_MODE: |
| 8101 | case QDF_P2P_CLIENT_MODE: |
| 8102 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 8103 | len += scnprintf(buf + len, *size - len, |
| 8104 | "\n connState: %d", |
| 8105 | hdd_sta_ctx->conn_info.connState); |
| 8106 | break; |
| 8107 | |
| 8108 | default: |
| 8109 | break; |
| 8110 | } |
| 8111 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 8112 | adapter_node = next; |
| 8113 | } |
| 8114 | |
| 8115 | *size -= len; |
| 8116 | *buf_ptr += len; |
| 8117 | } |
| 8118 | |
| 8119 | /** |
| 8120 | * hdd_register_debug_callback() - registration function for hdd layer |
| 8121 | * to print hdd state information |
| 8122 | * |
| 8123 | * Return: None |
| 8124 | */ |
| 8125 | static void hdd_register_debug_callback(void) |
| 8126 | { |
| 8127 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 8128 | } |
| 8129 | |
| 8130 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8131 | * hdd_wlan_startup() - HDD init function |
| 8132 | * @dev: Pointer to the underlying device |
| 8133 | * |
| 8134 | * This is the driver startup code executed once a WLAN device has been detected |
| 8135 | * |
| 8136 | * Return: 0 for success, < 0 for failure |
| 8137 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8138 | int hdd_wlan_startup(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8139 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8140 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8141 | hdd_adapter_t *adapter = NULL; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8142 | hdd_context_t *hdd_ctx = NULL; |
| 8143 | int ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8144 | void *hif_sc; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8145 | bool rtnl_held; |
Manjeet Singh | e7ecb7c | 2016-09-03 12:34:53 +0530 | [diff] [blame] | 8146 | int set_value; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8147 | |
| 8148 | ENTER(); |
| 8149 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8150 | hdd_ctx = hdd_context_create(dev); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8151 | |
| 8152 | if (IS_ERR(hdd_ctx)) |
| 8153 | return PTR_ERR(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8154 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8155 | qdf_mc_timer_init(&hdd_ctx->iface_change_timer, QDF_TIMER_TYPE_SW, |
| 8156 | hdd_iface_change_callback, (void *)hdd_ctx); |
| 8157 | |
| 8158 | mutex_init(&hdd_ctx->iface_change_lock); |
| 8159 | |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 8160 | ret = hdd_init_netlink_services(hdd_ctx); |
| 8161 | if (ret) |
| 8162 | goto err_hdd_free_context; |
| 8163 | |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 8164 | hdd_green_ap_init(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8165 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8166 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 8167 | if (ret) { |
| 8168 | hdd_alert("Failed to start modules: %d", ret); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 8169 | goto err_exit_nl_srv; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8170 | } |
| 8171 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 8172 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8173 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8174 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 8175 | hdd_notice("Failed to set wow pulse"); |
| 8176 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8177 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8178 | |
| 8179 | if (NULL == hdd_ctx->hHal) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8180 | hdd_alert("HAL context is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8181 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8182 | } |
| 8183 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8184 | ret = hdd_wiphy_init(hdd_ctx); |
| 8185 | if (ret) { |
| 8186 | hdd_alert("Failed to initialize wiphy: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8187 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8188 | } |
| 8189 | |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 8190 | if (hdd_ctx->config->enable_dp_trace) |
| 8191 | qdf_dp_trace_init(); |
| 8192 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8193 | if (hdd_ipa_init(hdd_ctx) == QDF_STATUS_E_FAILURE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8194 | goto err_wiphy_unregister; |
| 8195 | |
Yuanyuan Liu | c98370e | 2016-10-13 11:22:13 -0700 | [diff] [blame] | 8196 | hdd_initialize_mac_address(hdd_ctx); |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 8197 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8198 | rtnl_held = hdd_hold_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8199 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8200 | adapter = hdd_open_interfaces(hdd_ctx, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8201 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8202 | if (IS_ERR(adapter)) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8203 | hdd_alert("Failed to open interface, adapter is NULL"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8204 | ret = PTR_ERR(adapter); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8205 | goto err_ipa_cleanup; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8206 | } |
| 8207 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8208 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
Anurag Chouhan | ce6a405 | 2016-09-14 18:20:42 +0530 | [diff] [blame] | 8209 | if (!hif_sc) { |
| 8210 | hdd_err("HIF context is NULL"); |
| 8211 | goto err_close_adapter; |
| 8212 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8213 | /* |
| 8214 | * target hw version/revision would only be retrieved after firmware |
| 8215 | * donwload |
| 8216 | */ |
| 8217 | hif_get_hw_info(hif_sc, &hdd_ctx->target_hw_version, |
| 8218 | &hdd_ctx->target_hw_revision, |
| 8219 | &hdd_ctx->target_hw_name); |
| 8220 | |
| 8221 | /* Get the wlan hw/fw version */ |
Arun Khandavalli | a96c2c0 | 2016-05-17 19:15:34 +0530 | [diff] [blame] | 8222 | hdd_wlan_get_version(hdd_ctx, NULL, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8223 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8224 | hdd_release_rtnl_lock(); |
| 8225 | rtnl_held = false; |
| 8226 | |
Agrawal Ashish | b2d1a45 | 2016-05-05 12:23:58 +0530 | [diff] [blame] | 8227 | if (hdd_ctx->config->enable_go_cts2self_for_sta) |
| 8228 | sme_set_cts2self_for_p2p_go(hdd_ctx->hHal); |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 8229 | |
| 8230 | wlan_hdd_update_11n_mode(hdd_ctx->config); |
| 8231 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8232 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 8233 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8234 | QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8235 | hdd_skip_acs_scan_timer_handler, |
| 8236 | (void *)hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8237 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8238 | hdd_err("Failed to init ACS Skip timer"); |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 8239 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8240 | #endif |
| 8241 | |
Nitesh Shah | 61c10d9 | 2016-10-19 19:29:15 +0530 | [diff] [blame] | 8242 | qdf_mc_timer_init(&hdd_ctx->tdls_source_timer, |
| 8243 | QDF_TIMER_TYPE_SW, |
| 8244 | wlan_hdd_change_tdls_mode, |
| 8245 | hdd_ctx); |
| 8246 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8247 | hdd_bus_bandwidth_init(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8248 | |
Jeff Johnson | 9afc501 | 2016-09-23 13:56:27 -0700 | [diff] [blame] | 8249 | hdd_lpass_notify_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8250 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 8251 | if (hdd_ctx->rps) |
| 8252 | hdd_set_rps_cpu_mask(hdd_ctx); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 8253 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8254 | |
| 8255 | if (cds_is_packet_log_enabled()) |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8256 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8257 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 8258 | ret = hdd_register_notifiers(hdd_ctx); |
| 8259 | if (ret) |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 8260 | goto err_debugfs_exit; |
| 8261 | |
| 8262 | status = wlansap_global_init(); |
| 8263 | if (QDF_IS_STATUS_ERROR(status)) |
| 8264 | goto err_debugfs_exit; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 8265 | |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 8266 | hdd_runtime_suspend_context_init(hdd_ctx); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 8267 | memdump_init(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 8268 | hdd_driver_memdump_init(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 8269 | |
bings | 612b9c4 | 2016-11-07 10:52:03 +0800 | [diff] [blame] | 8270 | if (hdd_enable_egap(hdd_ctx)) |
| 8271 | hdd_err("enhance green ap is not enabled"); |
| 8272 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8273 | if (hdd_ctx->config->fIsImpsEnabled) |
| 8274 | hdd_set_idle_ps_config(hdd_ctx, true); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 8275 | |
Manjeet Singh | e7ecb7c | 2016-09-03 12:34:53 +0530 | [diff] [blame] | 8276 | if (hdd_ctx->config->sifs_burst_duration) { |
| 8277 | set_value = (SIFS_BURST_DUR_MULTIPLIER) * |
| 8278 | hdd_ctx->config->sifs_burst_duration; |
| 8279 | |
| 8280 | if ((set_value > 0) && (set_value <= SIFS_BURST_DUR_MAX)) |
| 8281 | wma_cli_set_command(0, (int)WMI_PDEV_PARAM_BURST_DUR, |
| 8282 | set_value, PDEV_CMD); |
| 8283 | } |
| 8284 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8285 | qdf_mc_timer_start(&hdd_ctx->iface_change_timer, |
| 8286 | hdd_ctx->config->iface_change_wait_time * 5000); |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 8287 | |
| 8288 | if (hdd_ctx->config->goptimize_chan_avoid_event) { |
| 8289 | status = sme_enable_disable_chanavoidind_event( |
| 8290 | hdd_ctx->hHal, 0); |
| 8291 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8292 | hdd_err("Failed to disable Chan Avoidance Indication"); |
| 8293 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8294 | goto success; |
| 8295 | |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 8296 | err_debugfs_exit: |
| 8297 | hdd_debugfs_exit(adapter); |
Anurag Chouhan | ce6a405 | 2016-09-14 18:20:42 +0530 | [diff] [blame] | 8298 | |
| 8299 | err_close_adapter: |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8300 | hdd_close_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8301 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 8302 | if (rtnl_held) |
| 8303 | hdd_release_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8304 | |
Anurag Chouhan | ce6a405 | 2016-09-14 18:20:42 +0530 | [diff] [blame] | 8305 | err_ipa_cleanup: |
| 8306 | hdd_ipa_cleanup(hdd_ctx); |
Yun Park | 6a46ad8 | 2016-01-04 16:48:19 -0800 | [diff] [blame] | 8307 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8308 | err_wiphy_unregister: |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8309 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8310 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8311 | err_stop_modules: |
Prashanth Bhatta | 2ac92bd | 2016-10-11 16:08:00 -0700 | [diff] [blame] | 8312 | hdd_wlan_stop_modules(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8313 | |
| 8314 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8315 | status = cds_sched_close(hdd_ctx->pcds_context); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8316 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8317 | hdd_alert("Failed to close CDS Scheduler"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 8318 | QDF_ASSERT(QDF_IS_STATUS_SUCCESS(status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8319 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8320 | |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 8321 | err_exit_nl_srv: |
Houston Hoffman | 47a4a05 | 2016-11-14 23:22:44 -0800 | [diff] [blame] | 8322 | hdd_green_ap_deinit(hdd_ctx); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 8323 | hdd_exit_netlink_services(hdd_ctx); |
| 8324 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8325 | cds_deinit_ini_config(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8326 | err_hdd_free_context: |
Houston Hoffman | 47a4a05 | 2016-11-14 23:22:44 -0800 | [diff] [blame] | 8327 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8328 | qdf_mc_timer_destroy(&hdd_ctx->iface_change_timer); |
| 8329 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8330 | hdd_context_destroy(hdd_ctx); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 8331 | QDF_BUG(1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8332 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8333 | return -EIO; |
| 8334 | |
| 8335 | success: |
| 8336 | EXIT(); |
| 8337 | return 0; |
| 8338 | } |
| 8339 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8340 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8341 | * hdd_wlan_update_target_info() - update target type info |
| 8342 | * @hdd_ctx: HDD context |
| 8343 | * @context: hif context |
| 8344 | * |
| 8345 | * Update target info received from firmware in hdd context |
| 8346 | * Return:None |
| 8347 | */ |
| 8348 | |
| 8349 | void hdd_wlan_update_target_info(hdd_context_t *hdd_ctx, void *context) |
| 8350 | { |
| 8351 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 8352 | |
| 8353 | if (!tgt_info) { |
| 8354 | hdd_err("Target info is Null"); |
| 8355 | return; |
| 8356 | } |
| 8357 | |
| 8358 | hdd_ctx->target_type = tgt_info->target_type; |
| 8359 | } |
| 8360 | |
| 8361 | /** |
| 8362 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 8363 | * @hdd_ctx: HDD context |
| 8364 | * |
| 8365 | * Register the HDD callbacks to CDS/SME. |
| 8366 | * |
| 8367 | * Return: 0 for success or Error code for failure |
| 8368 | */ |
| 8369 | int hdd_register_cb(hdd_context_t *hdd_ctx) |
| 8370 | { |
| 8371 | QDF_STATUS status; |
| 8372 | int ret = 0; |
| 8373 | |
| 8374 | ENTER(); |
| 8375 | |
| 8376 | sme_register11d_scan_done_callback(hdd_ctx->hHal, hdd_11d_scan_done); |
| 8377 | |
| 8378 | sme_register_oem_data_rsp_callback(hdd_ctx->hHal, |
| 8379 | hdd_send_oem_data_rsp_msg); |
| 8380 | |
| 8381 | status = sme_fw_mem_dump_register_cb(hdd_ctx->hHal, |
| 8382 | wlan_hdd_cfg80211_fw_mem_dump_cb); |
| 8383 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8384 | hdd_err("Failed to register memdump callback"); |
| 8385 | ret = -EINVAL; |
| 8386 | return ret; |
| 8387 | } |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 8388 | sme_register_mgmt_frame_ind_callback(hdd_ctx->hHal, |
| 8389 | hdd_indicate_mgmt_frame); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 8390 | sme_set_tsfcb(hdd_ctx->hHal, hdd_get_tsf_cb, hdd_ctx); |
| 8391 | sme_nan_register_callback(hdd_ctx->hHal, |
| 8392 | wlan_hdd_cfg80211_nan_callback); |
| 8393 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 8394 | wlan_hdd_cfg80211_stats_ext_callback); |
| 8395 | |
| 8396 | sme_ext_scan_register_callback(hdd_ctx->hHal, |
| 8397 | wlan_hdd_cfg80211_extscan_callback); |
| 8398 | |
| 8399 | status = cds_register_sap_restart_channel_switch_cb( |
| 8400 | (void *)hdd_sap_restart_with_channel_switch); |
| 8401 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8402 | hdd_err("restart cb registration failed"); |
| 8403 | ret = -EINVAL; |
| 8404 | return ret; |
| 8405 | } |
| 8406 | |
| 8407 | sme_set_rssi_threshold_breached_cb(hdd_ctx->hHal, |
| 8408 | hdd_rssi_threshold_breached); |
| 8409 | |
| 8410 | status = sme_bpf_offload_register_callback(hdd_ctx->hHal, |
| 8411 | hdd_get_bpf_offload_cb); |
| 8412 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8413 | hdd_err("set bpf offload callback failed"); |
| 8414 | ret = -EINVAL; |
| 8415 | return ret; |
| 8416 | } |
| 8417 | |
| 8418 | sme_set_link_layer_stats_ind_cb(hdd_ctx->hHal, |
| 8419 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 8420 | |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 8421 | status = sme_set_lost_link_info_cb(hdd_ctx->hHal, |
| 8422 | hdd_lost_link_info_cb); |
| 8423 | /* print error and not block the startup process */ |
| 8424 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8425 | hdd_err("set lost link info callback failed"); |
| 8426 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 8427 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 8428 | |
| 8429 | EXIT(); |
| 8430 | |
| 8431 | return ret; |
| 8432 | } |
| 8433 | |
| 8434 | /** |
| 8435 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 8436 | * @hdd_ctx: HDD context |
| 8437 | * |
| 8438 | * De-Register the HDD callbacks to CDS/SME. |
| 8439 | * |
| 8440 | * Return: void |
| 8441 | */ |
| 8442 | void hdd_deregister_cb(hdd_context_t *hdd_ctx) |
| 8443 | { |
| 8444 | QDF_STATUS status; |
| 8445 | |
| 8446 | ENTER(); |
| 8447 | |
| 8448 | status = sme_deregister_for_dcc_stats_event(hdd_ctx->hHal); |
| 8449 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8450 | hdd_err("De-register of dcc stats callback failed: %d", |
| 8451 | status); |
| 8452 | |
| 8453 | sme_reset_link_layer_stats_ind_cb(hdd_ctx->hHal); |
| 8454 | status = sme_bpf_offload_deregister_callback(hdd_ctx->hHal); |
| 8455 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8456 | hdd_err("De-register bpf offload callback failed: %d", |
| 8457 | status); |
| 8458 | sme_reset_rssi_threshold_breached_cb(hdd_ctx->hHal); |
| 8459 | |
| 8460 | status = cds_deregister_sap_restart_channel_switch_cb(); |
| 8461 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8462 | hdd_err("De-register restart cb registration failed: %d", |
| 8463 | status); |
| 8464 | |
| 8465 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 8466 | wlan_hdd_cfg80211_stats_ext_callback); |
| 8467 | |
| 8468 | sme_nan_deregister_callback(hdd_ctx->hHal); |
| 8469 | status = sme_reset_tsfcb(hdd_ctx->hHal); |
| 8470 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8471 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 8472 | status); |
| 8473 | status = sme_fw_mem_dump_unregister_cb(hdd_ctx->hHal); |
| 8474 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8475 | hdd_err("Failed to de-register the fw mem dump callback: %d", |
| 8476 | status); |
| 8477 | |
| 8478 | sme_deregister_oem_data_rsp_callback(hdd_ctx->hHal); |
| 8479 | sme_deregister11d_scan_done_callback(hdd_ctx->hHal); |
| 8480 | |
| 8481 | EXIT(); |
| 8482 | } |
| 8483 | |
| 8484 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8485 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
| 8486 | * @adapter: Pointer to the HDD |
| 8487 | * @enable: bool value |
| 8488 | * |
| 8489 | * This to take counter measure to handle deauth req from HDD |
| 8490 | * |
| 8491 | * Return: None |
| 8492 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8493 | QDF_STATUS hdd_softap_sta_deauth(hdd_adapter_t *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8494 | struct tagCsrDelStaParams *pDelStaParams) |
| 8495 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8496 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8497 | |
| 8498 | ENTER(); |
| 8499 | |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8500 | hdd_notice("hdd_softap_sta_deauth:(%p, false)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8501 | (WLAN_HDD_GET_CTX(adapter))->pcds_context); |
| 8502 | |
| 8503 | /* Ignore request to deauth bcmc station */ |
| 8504 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8505 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8506 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8507 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8508 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 8509 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8510 | |
| 8511 | EXIT(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8512 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8513 | } |
| 8514 | |
| 8515 | /** |
| 8516 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
| 8517 | * @adapter: Pointer to the HDD |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 8518 | * @p_del_sta_params: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8519 | * |
| 8520 | * This to take counter measure to handle deauth req from HDD |
| 8521 | * |
| 8522 | * Return: None |
| 8523 | */ |
| 8524 | void hdd_softap_sta_disassoc(hdd_adapter_t *adapter, |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 8525 | struct tagCsrDelStaParams *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8526 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8527 | ENTER(); |
| 8528 | |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8529 | hdd_err("hdd_softap_sta_disassoc:(%p, false)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8530 | (WLAN_HDD_GET_CTX(adapter))->pcds_context); |
| 8531 | |
| 8532 | /* Ignore request to disassoc bcmc station */ |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 8533 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8534 | return; |
| 8535 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8536 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 8537 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8538 | } |
| 8539 | |
| 8540 | void hdd_softap_tkip_mic_fail_counter_measure(hdd_adapter_t *adapter, |
| 8541 | bool enable) |
| 8542 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8543 | ENTER(); |
| 8544 | |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8545 | hdd_err("hdd_softap_tkip_mic_fail_counter_measure:(%p, false)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8546 | (WLAN_HDD_GET_CTX(adapter))->pcds_context); |
| 8547 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8548 | wlansap_set_counter_measure(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 8549 | (bool) enable); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8550 | } |
| 8551 | |
| 8552 | /** |
| 8553 | * hdd_issta_p2p_clientconnected() - check if sta or p2p client is connected |
| 8554 | * @hdd_ctx: HDD Context |
| 8555 | * |
| 8556 | * API to find if there is any STA or P2P-Client is connected |
| 8557 | * |
| 8558 | * Return: true if connected; false otherwise |
| 8559 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8560 | QDF_STATUS hdd_issta_p2p_clientconnected(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8561 | { |
| 8562 | return sme_is_sta_p2p_client_connected(hdd_ctx->hHal); |
| 8563 | } |
| 8564 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8565 | /** |
| 8566 | * wlan_hdd_disable_roaming() - disable roaming on all STAs except the input one |
| 8567 | * @adapter: HDD adapter pointer |
| 8568 | * |
| 8569 | * This function loop through each adapter and disable roaming on each STA |
| 8570 | * device mode except the input adapter. |
| 8571 | * |
| 8572 | * Note: On the input adapter roaming is not enabled yet hence no need to |
| 8573 | * disable. |
| 8574 | * |
| 8575 | * Return: None |
| 8576 | */ |
| 8577 | void wlan_hdd_disable_roaming(hdd_adapter_t *adapter) |
| 8578 | { |
| 8579 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8580 | hdd_adapter_t *adapterIdx = NULL; |
| 8581 | hdd_adapter_list_node_t *adapterNode = NULL; |
| 8582 | hdd_adapter_list_node_t *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8583 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8584 | |
| 8585 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
| 8586 | hdd_ctx->config->isRoamOffloadScanEnabled && |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8587 | QDF_STA_MODE == adapter->device_mode && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8588 | cds_is_sta_active_connection_exists()) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8589 | hdd_notice("Connect received on STA sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8590 | adapter->sessionId); |
| 8591 | /* |
| 8592 | * Loop through adapter and disable roaming for each STA device |
| 8593 | * mode except the input adapter. |
| 8594 | */ |
| 8595 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 8596 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8597 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8598 | adapterIdx = adapterNode->pAdapter; |
| 8599 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8600 | if (QDF_STA_MODE == adapterIdx->device_mode |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8601 | && adapter->sessionId != adapterIdx->sessionId) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8602 | hdd_notice("Disable Roaming on sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8603 | adapterIdx->sessionId); |
| 8604 | sme_stop_roaming(WLAN_HDD_GET_HAL_CTX |
| 8605 | (adapterIdx), |
| 8606 | adapterIdx->sessionId, 0); |
| 8607 | } |
| 8608 | |
| 8609 | status = hdd_get_next_adapter(hdd_ctx, |
| 8610 | adapterNode, |
| 8611 | &pNext); |
| 8612 | adapterNode = pNext; |
| 8613 | } |
| 8614 | } |
| 8615 | } |
| 8616 | |
| 8617 | /** |
| 8618 | * wlan_hdd_enable_roaming() - enable roaming on all STAs except the input one |
| 8619 | * @adapter: HDD adapter pointer |
| 8620 | * |
| 8621 | * This function loop through each adapter and enable roaming on each STA |
| 8622 | * device mode except the input adapter. |
| 8623 | * Note: On the input adapter no need to enable roaming because link got |
| 8624 | * disconnected on this. |
| 8625 | * |
| 8626 | * Return: None |
| 8627 | */ |
| 8628 | void wlan_hdd_enable_roaming(hdd_adapter_t *adapter) |
| 8629 | { |
| 8630 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8631 | hdd_adapter_t *adapterIdx = NULL; |
| 8632 | hdd_adapter_list_node_t *adapterNode = NULL; |
| 8633 | hdd_adapter_list_node_t *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8634 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8635 | |
| 8636 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
| 8637 | hdd_ctx->config->isRoamOffloadScanEnabled && |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8638 | QDF_STA_MODE == adapter->device_mode && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8639 | cds_is_sta_active_connection_exists()) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8640 | hdd_notice("Disconnect received on STA sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8641 | adapter->sessionId); |
| 8642 | /* |
| 8643 | * Loop through adapter and enable roaming for each STA device |
| 8644 | * mode except the input adapter. |
| 8645 | */ |
| 8646 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 8647 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8648 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8649 | adapterIdx = adapterNode->pAdapter; |
| 8650 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8651 | if (QDF_STA_MODE == adapterIdx->device_mode |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8652 | && adapter->sessionId != adapterIdx->sessionId) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8653 | hdd_notice("Enabling Roaming on sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8654 | adapterIdx->sessionId); |
| 8655 | sme_start_roaming(WLAN_HDD_GET_HAL_CTX |
| 8656 | (adapterIdx), |
| 8657 | adapterIdx->sessionId, |
| 8658 | REASON_CONNECT); |
| 8659 | } |
| 8660 | |
| 8661 | status = hdd_get_next_adapter(hdd_ctx, |
| 8662 | adapterNode, |
| 8663 | &pNext); |
| 8664 | adapterNode = pNext; |
| 8665 | } |
| 8666 | } |
| 8667 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8668 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 8669 | 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] | 8670 | { |
| 8671 | struct sk_buff *skb; |
| 8672 | struct nlmsghdr *nlh; |
| 8673 | tAniMsgHdr *ani_hdr; |
| 8674 | void *nl_data = NULL; |
| 8675 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 8676 | struct radio_index_tlv *radio_info; |
| 8677 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8678 | |
| 8679 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 8680 | flags = GFP_ATOMIC; |
| 8681 | |
| 8682 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 8683 | |
| 8684 | if (skb == NULL) { |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8685 | hdd_err("alloc_skb failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8686 | return; |
| 8687 | } |
| 8688 | |
| 8689 | nlh = (struct nlmsghdr *)skb->data; |
| 8690 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 8691 | nlh->nlmsg_flags = 0; |
| 8692 | nlh->nlmsg_seq = 0; |
| 8693 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 8694 | |
| 8695 | ani_hdr = NLMSG_DATA(nlh); |
| 8696 | ani_hdr->type = type; |
| 8697 | |
| 8698 | switch (type) { |
| 8699 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 8700 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8701 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8702 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 8703 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8704 | ani_hdr->length = 0; |
| 8705 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
| 8706 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr))); |
| 8707 | break; |
| 8708 | case WLAN_SVC_WLAN_STATUS_IND: |
| 8709 | case WLAN_SVC_WLAN_VERSION_IND: |
| 8710 | case WLAN_SVC_DFS_CAC_START_IND: |
| 8711 | case WLAN_SVC_DFS_CAC_END_IND: |
| 8712 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 8713 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 8714 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 8715 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 8716 | case WLAN_SVC_RPS_ENABLE_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8717 | ani_hdr->length = len; |
| 8718 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 8719 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 8720 | memcpy(nl_data, data, len); |
| 8721 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len)); |
| 8722 | break; |
| 8723 | |
| 8724 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 8725 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8726 | type); |
| 8727 | kfree_skb(skb); |
| 8728 | return; |
| 8729 | } |
| 8730 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 8731 | /* |
| 8732 | * Add radio index at the end of the svc event in TLV format to maintain |
| 8733 | * the backward compatibility with userspace applications. |
| 8734 | */ |
| 8735 | |
| 8736 | tlv_len = 0; |
| 8737 | |
| 8738 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 8739 | < WLAN_NL_MAX_PAYLOAD) { |
| 8740 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 8741 | sizeof(*ani_hdr) + len); |
| 8742 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 8743 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 8744 | radio_info->radio = radio; |
| 8745 | tlv_len = sizeof(*radio_info); |
| 8746 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO, |
| 8747 | "Added radio index tlv - radio index %d", |
| 8748 | radio_info->radio); |
| 8749 | } |
| 8750 | |
| 8751 | nlh->nlmsg_len += tlv_len; |
| 8752 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 8753 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8754 | nl_srv_bcast(skb); |
| 8755 | |
| 8756 | return; |
| 8757 | } |
| 8758 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8759 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 8760 | void wlan_hdd_auto_shutdown_cb(void) |
| 8761 | { |
Mahesh Kumar Kalikot Veetil | d214d55 | 2016-09-14 15:15:49 -0700 | [diff] [blame] | 8762 | hdd_context_t *hdd_ctx = cds_get_global_context(); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 8763 | |
| 8764 | if (!hdd_ctx) |
| 8765 | return; |
| 8766 | |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 8767 | hdd_err("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 8768 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 8769 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8770 | } |
| 8771 | |
| 8772 | void wlan_hdd_auto_shutdown_enable(hdd_context_t *hdd_ctx, bool enable) |
| 8773 | { |
| 8774 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8775 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8776 | hdd_adapter_t *adapter; |
| 8777 | bool ap_connected = false, sta_connected = false; |
| 8778 | tHalHandle hal_handle; |
| 8779 | |
| 8780 | hal_handle = hdd_ctx->hHal; |
| 8781 | if (hal_handle == NULL) |
| 8782 | return; |
| 8783 | |
| 8784 | if (hdd_ctx->config->WlanAutoShutdown == 0) |
| 8785 | return; |
| 8786 | |
| 8787 | if (enable == false) { |
| 8788 | if (sme_set_auto_shutdown_timer(hal_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8789 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 8790 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8791 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 8792 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 8793 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8794 | return; |
| 8795 | } |
| 8796 | |
| 8797 | /* To enable shutdown timer check conncurrency */ |
| 8798 | if (cds_concurrent_open_sessions_running()) { |
| 8799 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 8800 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8801 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8802 | adapter = adapterNode->pAdapter; |
| 8803 | if (adapter |
| 8804 | && adapter->device_mode == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8805 | QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8806 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 8807 | conn_info.connState == |
| 8808 | eConnectionState_Associated) { |
| 8809 | sta_connected = true; |
| 8810 | break; |
| 8811 | } |
| 8812 | } |
| 8813 | if (adapter |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8814 | && adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8815 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
| 8816 | bApActive == true) { |
| 8817 | ap_connected = true; |
| 8818 | break; |
| 8819 | } |
| 8820 | } |
| 8821 | status = hdd_get_next_adapter(hdd_ctx, |
| 8822 | adapterNode, |
| 8823 | &pNext); |
| 8824 | adapterNode = pNext; |
| 8825 | } |
| 8826 | } |
| 8827 | |
| 8828 | if (ap_connected == true || sta_connected == true) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 8829 | hdd_notice("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8830 | return; |
| 8831 | } else { |
| 8832 | if (sme_set_auto_shutdown_timer(hal_handle, |
| 8833 | hdd_ctx->config-> |
| 8834 | WlanAutoShutdown) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8835 | != QDF_STATUS_SUCCESS) |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 8836 | hdd_err("Failed to start wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8837 | else |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 8838 | hdd_notice("Auto Shutdown timer for %d seconds enabled", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8839 | hdd_ctx->config->WlanAutoShutdown); |
| 8840 | |
| 8841 | } |
| 8842 | } |
| 8843 | #endif |
| 8844 | |
| 8845 | hdd_adapter_t *hdd_get_con_sap_adapter(hdd_adapter_t *this_sap_adapter, |
| 8846 | bool check_start_bss) |
| 8847 | { |
| 8848 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
| 8849 | hdd_adapter_t *adapter, *con_sap_adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8850 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8851 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 8852 | |
| 8853 | con_sap_adapter = NULL; |
| 8854 | |
| 8855 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8856 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8857 | adapter = adapterNode->pAdapter; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8858 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 8859 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8860 | adapter != this_sap_adapter) { |
| 8861 | if (check_start_bss) { |
| 8862 | if (test_bit(SOFTAP_BSS_STARTED, |
| 8863 | &adapter->event_flags)) { |
| 8864 | con_sap_adapter = adapter; |
| 8865 | break; |
| 8866 | } |
| 8867 | } else { |
| 8868 | con_sap_adapter = adapter; |
| 8869 | break; |
| 8870 | } |
| 8871 | } |
| 8872 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 8873 | adapterNode = pNext; |
| 8874 | } |
| 8875 | |
| 8876 | return con_sap_adapter; |
| 8877 | } |
| 8878 | |
| 8879 | #ifdef MSM_PLATFORM |
| 8880 | void hdd_start_bus_bw_compute_timer(hdd_adapter_t *adapter) |
| 8881 | { |
| 8882 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8883 | |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 8884 | if (QDF_TIMER_STATE_RUNNING == |
| 8885 | qdf_mc_timer_get_current_state(&hdd_ctx->bus_bw_timer)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8886 | return; |
| 8887 | |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 8888 | qdf_mc_timer_start(&hdd_ctx->bus_bw_timer, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8889 | hdd_ctx->config->busBandwidthComputeInterval); |
| 8890 | } |
| 8891 | |
| 8892 | void hdd_stop_bus_bw_compute_timer(hdd_adapter_t *adapter) |
| 8893 | { |
| 8894 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8895 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8896 | bool can_stop = true; |
| 8897 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8898 | |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 8899 | if (QDF_TIMER_STATE_RUNNING != |
| 8900 | qdf_mc_timer_get_current_state(&hdd_ctx->bus_bw_timer)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8901 | /* trying to stop timer, when not running is not good */ |
Srinivas Girigowda | 0ee9644 | 2016-08-17 19:10:56 -0700 | [diff] [blame] | 8902 | hdd_info("bus band width compute timer is not running"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8903 | return; |
| 8904 | } |
| 8905 | |
| 8906 | if (cds_concurrent_open_sessions_running()) { |
| 8907 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 8908 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8909 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8910 | adapter = adapterNode->pAdapter; |
| 8911 | if (adapter |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8912 | && (adapter->device_mode == QDF_STA_MODE |
| 8913 | || adapter->device_mode == QDF_P2P_CLIENT_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8914 | && WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 8915 | conn_info.connState == |
| 8916 | eConnectionState_Associated) { |
| 8917 | can_stop = false; |
| 8918 | break; |
| 8919 | } |
| 8920 | if (adapter |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8921 | && (adapter->device_mode == QDF_SAP_MODE |
| 8922 | || adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8923 | && WLAN_HDD_GET_AP_CTX_PTR(adapter)->bApActive == |
| 8924 | true) { |
| 8925 | can_stop = false; |
| 8926 | break; |
| 8927 | } |
| 8928 | status = hdd_get_next_adapter(hdd_ctx, |
| 8929 | adapterNode, |
| 8930 | &pNext); |
| 8931 | adapterNode = pNext; |
| 8932 | } |
| 8933 | } |
| 8934 | |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 8935 | if (can_stop == true) { |
Chris Guo | c0c95bf | 2016-11-10 14:28:25 +0800 | [diff] [blame] | 8936 | /* reset the ipa perf level */ |
| 8937 | hdd_ipa_set_perf_level(hdd_ctx, 0, 0); |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 8938 | qdf_mc_timer_stop(&hdd_ctx->bus_bw_timer); |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 8939 | hdd_reset_tcp_delack(hdd_ctx); |
| 8940 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8941 | } |
| 8942 | #endif |
| 8943 | |
| 8944 | /** |
| 8945 | * wlan_hdd_check_custom_con_channel_rules() - This function checks the sap's |
| 8946 | * and sta's operating channel. |
| 8947 | * @sta_adapter: Describe the first argument to foobar. |
| 8948 | * @ap_adapter: Describe the second argument to foobar. |
| 8949 | * @roam_profile: Roam profile of AP to which STA wants to connect. |
| 8950 | * @concurrent_chnl_same: If both SAP and STA channels are same then |
| 8951 | * set this flag to true else false. |
| 8952 | * |
| 8953 | * This function checks the sap's operating channel and sta's operating channel. |
| 8954 | * if both are same then it will return false else it will restart the sap in |
| 8955 | * sta's channel and return true. |
| 8956 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8957 | * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8958 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8959 | 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] | 8960 | hdd_adapter_t *ap_adapter, |
| 8961 | tCsrRoamProfile *roam_profile, |
| 8962 | tScanResultHandle *scan_cache, |
| 8963 | bool *concurrent_chnl_same) |
| 8964 | { |
| 8965 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 8966 | uint8_t channel_id; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8967 | QDF_STATUS status; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8968 | enum tQDF_ADAPTER_MODE device_mode = ap_adapter->device_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8969 | *concurrent_chnl_same = true; |
| 8970 | |
| 8971 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 8972 | status = |
| 8973 | sme_get_ap_channel_from_scan_cache(WLAN_HDD_GET_HAL_CTX(sta_adapter), |
| 8974 | roam_profile, |
| 8975 | scan_cache, |
| 8976 | &channel_id); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8977 | if ((QDF_STATUS_SUCCESS == status)) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8978 | if ((QDF_SAP_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8979 | (channel_id < SIR_11A_CHANNEL_BEGIN)) { |
| 8980 | if (hdd_ap_ctx->operatingChannel != channel_id) { |
| 8981 | *concurrent_chnl_same = false; |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 8982 | hdd_info("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8983 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8984 | } else if ((QDF_P2P_GO_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8985 | (channel_id >= SIR_11A_CHANNEL_BEGIN)) { |
| 8986 | if (hdd_ap_ctx->operatingChannel != channel_id) { |
| 8987 | *concurrent_chnl_same = false; |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 8988 | hdd_info("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8989 | } |
| 8990 | } |
| 8991 | } else { |
| 8992 | /* |
| 8993 | * Lets handle worst case scenario here, Scan cache lookup is |
| 8994 | * failed so we have to stop the SAP to avoid any channel |
| 8995 | * discrepancy between SAP's channel and STA's channel. |
| 8996 | * Return the status as failure so caller function could know |
| 8997 | * that scan look up is failed. |
| 8998 | */ |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 8999 | hdd_err("Finding AP from scan cache failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9000 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9001 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9002 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9003 | } |
| 9004 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9005 | /** |
| 9006 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 9007 | * @ap_adapter: SAP adapter |
| 9008 | * |
| 9009 | * This function will process the stopping of sap adapter. |
| 9010 | * |
| 9011 | * Return: None |
| 9012 | */ |
| 9013 | void wlan_hdd_stop_sap(hdd_adapter_t *ap_adapter) |
| 9014 | { |
| 9015 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 9016 | hdd_hostapd_state_t *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 9017 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9018 | hdd_context_t *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9019 | |
| 9020 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9021 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9022 | return; |
| 9023 | } |
| 9024 | |
| 9025 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 9026 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 9027 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9028 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 9029 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9030 | mutex_lock(&hdd_ctx->sap_lock); |
| 9031 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 9032 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9033 | hdd_cleanup_actionframe(hdd_ctx, ap_adapter); |
| 9034 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9035 | hdd_info("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 9036 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9037 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9038 | sapContext)) { |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 9039 | qdf_status = qdf_wait_single_event(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 9040 | qdf_stop_bss_event, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9041 | BSS_WAIT_TIMEOUT); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 9042 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9043 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9044 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9045 | return; |
| 9046 | } |
| 9047 | } |
| 9048 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | 4adb368 | 2016-01-07 15:07:12 -0800 | [diff] [blame] | 9049 | cds_decr_session_set_pcl(ap_adapter->device_mode, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9050 | ap_adapter->sessionId); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9051 | hdd_info("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9052 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9053 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9054 | } |
| 9055 | mutex_unlock(&hdd_ctx->sap_lock); |
| 9056 | return; |
| 9057 | } |
| 9058 | |
| 9059 | /** |
| 9060 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 9061 | * @ap_adapter: SAP adapter |
| 9062 | * |
| 9063 | * This function will process the starting of sap adapter. |
| 9064 | * |
| 9065 | * Return: None |
| 9066 | */ |
| 9067 | void wlan_hdd_start_sap(hdd_adapter_t *ap_adapter) |
| 9068 | { |
| 9069 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 9070 | hdd_hostapd_state_t *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 9071 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9072 | hdd_context_t *hdd_ctx; |
| 9073 | tsap_Config_t *sap_config; |
| 9074 | |
| 9075 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9076 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9077 | return; |
| 9078 | } |
| 9079 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9080 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 9081 | hdd_err("SoftAp role has not been enabled"); |
| 9082 | return; |
| 9083 | } |
| 9084 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9085 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 9086 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 9087 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 9088 | sap_config = &ap_adapter->sessionCtx.ap.sapConfig; |
| 9089 | |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 9090 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9091 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 9092 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9093 | mutex_lock(&hdd_ctx->sap_lock); |
| 9094 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 9095 | goto end; |
| 9096 | |
| 9097 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9098 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9099 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
| 9100 | goto end; |
| 9101 | } |
| 9102 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 9103 | qdf_event_reset(&hostapd_state->qdf_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9104 | if (wlansap_start_bss(hdd_ap_ctx->sapContext, hdd_hostapd_sap_event_cb, |
| 9105 | &hdd_ap_ctx->sapConfig, |
| 9106 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9107 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9108 | goto end; |
| 9109 | |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9110 | hdd_info("Waiting for SAP to start"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 9111 | qdf_status = qdf_wait_single_event(&hostapd_state->qdf_event, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9112 | BSS_WAIT_TIMEOUT); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 9113 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9114 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9115 | goto end; |
| 9116 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 9117 | hdd_info("SAP Start Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9118 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Krunal Soni | b37bb35 | 2016-12-20 14:12:21 -0800 | [diff] [blame] | 9119 | if (hostapd_state->bssState == BSS_START) |
| 9120 | cds_incr_active_session(ap_adapter->device_mode, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9121 | ap_adapter->sessionId); |
| 9122 | hostapd_state->bCommit = true; |
| 9123 | |
| 9124 | end: |
| 9125 | mutex_unlock(&hdd_ctx->sap_lock); |
| 9126 | return; |
| 9127 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9128 | |
| 9129 | /** |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 9130 | * wlan_hdd_soc_set_antenna_mode_cb() - Callback for set dual |
| 9131 | * mac scan config |
| 9132 | * @status: Status of set antenna mode |
| 9133 | * |
| 9134 | * Callback on setting the dual mac configuration |
| 9135 | * |
| 9136 | * Return: None |
| 9137 | */ |
| 9138 | void wlan_hdd_soc_set_antenna_mode_cb( |
| 9139 | enum set_antenna_mode_status status) |
| 9140 | { |
| 9141 | hdd_context_t *hdd_ctx; |
| 9142 | |
| 9143 | hdd_info("Status: %d", status); |
| 9144 | |
| 9145 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 9146 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 9147 | return; |
| 9148 | |
| 9149 | /* Signal the completion of set dual mac config */ |
| 9150 | complete(&hdd_ctx->set_antenna_mode_cmpl); |
| 9151 | } |
| 9152 | |
| 9153 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9154 | * hdd_get_fw_version() - Get FW version |
| 9155 | * @hdd_ctx: pointer to HDD context. |
| 9156 | * @major_spid: FW version - major spid. |
| 9157 | * @minor_spid: FW version - minor spid |
| 9158 | * @ssid: FW version - ssid |
| 9159 | * @crmid: FW version - crmid |
| 9160 | * |
| 9161 | * This function is called to get the firmware build version stored |
| 9162 | * as part of the HDD context |
| 9163 | * |
| 9164 | * Return: None |
| 9165 | */ |
| 9166 | void hdd_get_fw_version(hdd_context_t *hdd_ctx, |
| 9167 | uint32_t *major_spid, uint32_t *minor_spid, |
| 9168 | uint32_t *siid, uint32_t *crmid) |
| 9169 | { |
| 9170 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 9171 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 9172 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 9173 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 9174 | } |
| 9175 | |
| 9176 | #ifdef QCA_CONFIG_SMP |
| 9177 | /** |
| 9178 | * wlan_hdd_get_cpu() - get cpu_index |
| 9179 | * |
| 9180 | * Return: cpu_index |
| 9181 | */ |
| 9182 | int wlan_hdd_get_cpu(void) |
| 9183 | { |
| 9184 | int cpu_index = get_cpu(); |
| 9185 | put_cpu(); |
| 9186 | return cpu_index; |
| 9187 | } |
| 9188 | #endif |
| 9189 | |
| 9190 | /** |
| 9191 | * hdd_get_fwpath() - get framework path |
| 9192 | * |
| 9193 | * This function is used to get the string written by |
| 9194 | * userspace to start the wlan driver |
| 9195 | * |
| 9196 | * Return: string |
| 9197 | */ |
| 9198 | const char *hdd_get_fwpath(void) |
| 9199 | { |
| 9200 | return fwpath.string; |
| 9201 | } |
| 9202 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9203 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9204 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9205 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9206 | * This function initilizes CDS global context with the help of cds_init. This |
| 9207 | * has to be the first function called after probe to get a valid global |
| 9208 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9209 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9210 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9211 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9212 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9213 | { |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9214 | v_CONTEXT_t p_cds_context = NULL; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9215 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9216 | |
| 9217 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9218 | wlan_logging_sock_init_svc(); |
| 9219 | #endif |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9220 | p_cds_context = cds_init(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9221 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9222 | if (p_cds_context == NULL) { |
| 9223 | hdd_alert("Failed to allocate CDS context"); |
| 9224 | ret = -ENOMEM; |
| 9225 | goto err_out; |
| 9226 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9227 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9228 | hdd_trace_init(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 9229 | hdd_register_debug_callback(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9230 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9231 | err_out: |
| 9232 | return ret; |
| 9233 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9234 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9235 | /** |
| 9236 | * hdd_deinit() - Deinitialize Driver |
| 9237 | * |
| 9238 | * This function frees CDS global context with the help of cds_deinit. This |
| 9239 | * has to be the last function call in remove callback to free the global |
| 9240 | * context. |
| 9241 | */ |
| 9242 | void hdd_deinit(void) |
| 9243 | { |
| 9244 | cds_deinit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9245 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9246 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9247 | wlan_logging_sock_deinit_svc(); |
| 9248 | #endif |
| 9249 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9250 | |
| 9251 | #ifdef QCA_WIFI_3_0_ADRASTEA |
| 9252 | #define HDD_WLAN_START_WAIT_TIME (3600 * 1000) |
| 9253 | #else |
| 9254 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
| 9255 | #endif |
| 9256 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9257 | /** |
| 9258 | * __hdd_module_init - Module init helper |
| 9259 | * |
| 9260 | * Module init helper function used by both module and static driver. |
| 9261 | * |
| 9262 | * Return: 0 for success, errno on failure |
| 9263 | */ |
| 9264 | static int __hdd_module_init(void) |
| 9265 | { |
| 9266 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9267 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9268 | pr_err("%s: Loading driver v%s\n", WLAN_MODULE_NAME, |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9269 | QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9270 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 9271 | pld_init(); |
| 9272 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 9273 | ret = hdd_init(); |
| 9274 | if (ret) { |
| 9275 | pr_err("hdd_init failed %x\n", ret); |
| 9276 | goto err_hdd_init; |
| 9277 | } |
| 9278 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 9279 | dispatcher_init(); |
| 9280 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 9281 | qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
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 | hdd_set_conparam((uint32_t) con_mode); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9284 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9285 | ret = wlan_hdd_register_driver(); |
| 9286 | if (ret) { |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 9287 | pr_err("%s: driver load failure, err %d\n", WLAN_MODULE_NAME, |
| 9288 | ret); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9289 | goto out; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9290 | } |
| 9291 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 9292 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9293 | |
| 9294 | return 0; |
| 9295 | out: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 9296 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 9297 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 9298 | hdd_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 9299 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 9300 | err_hdd_init: |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 9301 | pld_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 9302 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9303 | return ret; |
| 9304 | } |
| 9305 | |
| 9306 | /** |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 9307 | * hdd_wait_for_recovery_completion() - Wait for cds recovery completion |
| 9308 | * |
| 9309 | * Block the unloading of the driver until the cds recovery is completed |
| 9310 | * |
| 9311 | * Return: None |
| 9312 | */ |
| 9313 | static void hdd_wait_for_recovery_completion(void) |
| 9314 | { |
| 9315 | int retry = 0; |
| 9316 | |
| 9317 | /* Wait for recovery to complete */ |
| 9318 | while (cds_is_driver_recovering()) { |
| 9319 | hdd_alert("Recovery in progress; wait here!!!"); |
| 9320 | msleep(1000); |
| 9321 | if (retry++ == HDD_MOD_EXIT_SSR_MAX_RETRIES) { |
| 9322 | hdd_alert("SSR never completed, fatal error"); |
| 9323 | QDF_BUG(0); |
| 9324 | } |
| 9325 | } |
| 9326 | } |
| 9327 | |
| 9328 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9329 | * __hdd_module_exit - Module exit helper |
| 9330 | * |
| 9331 | * Module exit helper function used by both module and static driver. |
| 9332 | */ |
| 9333 | static void __hdd_module_exit(void) |
| 9334 | { |
| 9335 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 9336 | QWLAN_VERSIONSTR); |
| 9337 | |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 9338 | hdd_wait_for_recovery_completion(); |
| 9339 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9340 | wlan_hdd_unregister_driver(); |
| 9341 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 9342 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9343 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 9344 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 9345 | hdd_deinit(); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 9346 | pld_deinit(); |
| 9347 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9348 | return; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9349 | } |
| 9350 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9351 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9352 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9353 | * wlan_boot_cb() - Wlan boot callback |
| 9354 | * @kobj: object whose directory we're creating the link in. |
| 9355 | * @attr: attribute the user is interacting with |
| 9356 | * @buff: the buffer containing the user data |
| 9357 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9358 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9359 | * This callback is invoked when the fs is ready to start the |
| 9360 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9361 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9362 | * 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] | 9363 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9364 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 9365 | struct kobj_attribute *attr, |
| 9366 | const char *buf, |
| 9367 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9368 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9369 | |
| 9370 | int ret = 0; |
| 9371 | |
| 9372 | if (wlan_loader->loaded_state) { |
| 9373 | pr_info("Wlan driver already initialized"); |
| 9374 | return 0; |
| 9375 | } |
| 9376 | |
| 9377 | |
| 9378 | pr_err("%s: Loading driver v%s\n", WLAN_MODULE_NAME, |
| 9379 | QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
| 9380 | |
| 9381 | if (__hdd_module_init()) { |
| 9382 | pr_err("%s: Failed to register handler\n", __func__); |
| 9383 | ret = -EINVAL; |
| 9384 | } else |
| 9385 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
| 9386 | |
| 9387 | return count; |
| 9388 | |
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 | |
| 9391 | /** |
| 9392 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 9393 | * ready |
| 9394 | * |
| 9395 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 9396 | * when the filesystem is ready. |
| 9397 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 9398 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9399 | */ |
| 9400 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9401 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9402 | int ret = -EINVAL; |
| 9403 | |
| 9404 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
| 9405 | if (!wlan_loader) { |
| 9406 | pr_err("%s: memory alloc failed\n", __func__); |
| 9407 | ret = -ENOMEM; |
| 9408 | return ret; |
| 9409 | } |
| 9410 | |
| 9411 | wlan_loader->boot_wlan_obj = NULL; |
| 9412 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 9413 | GFP_KERNEL); |
| 9414 | if (!wlan_loader->attr_group) { |
| 9415 | pr_err("%s: malloc attr_group failed\n", __func__); |
| 9416 | ret = -ENOMEM; |
| 9417 | goto error_return; |
| 9418 | } |
| 9419 | |
| 9420 | wlan_loader->loaded_state = 0; |
| 9421 | wlan_loader->attr_group->attrs = attrs; |
| 9422 | |
| 9423 | wlan_loader->boot_wlan_obj = kobject_create_and_add("boot_wlan", |
| 9424 | kernel_kobj); |
| 9425 | if (!wlan_loader->boot_wlan_obj) { |
| 9426 | pr_err("%s: sysfs create and add failed\n", __func__); |
| 9427 | ret = -ENOMEM; |
| 9428 | goto error_return; |
| 9429 | } |
| 9430 | |
| 9431 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 9432 | wlan_loader->attr_group); |
| 9433 | if (ret) { |
| 9434 | pr_err("%s: sysfs create group failed %d\n", __func__, ret); |
| 9435 | goto error_return; |
| 9436 | } |
| 9437 | |
| 9438 | return 0; |
| 9439 | |
| 9440 | error_return: |
| 9441 | |
| 9442 | if (wlan_loader->boot_wlan_obj) { |
| 9443 | kobject_del(wlan_loader->boot_wlan_obj); |
| 9444 | wlan_loader->boot_wlan_obj = NULL; |
| 9445 | } |
| 9446 | |
| 9447 | return ret; |
| 9448 | } |
| 9449 | |
| 9450 | /** |
| 9451 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 9452 | * |
| 9453 | * Return: 0 on success or errno on failure |
| 9454 | */ |
| 9455 | static int wlan_deinit_sysfs(void) |
| 9456 | { |
| 9457 | |
| 9458 | if (!wlan_loader) { |
| 9459 | hdd_alert("wlan loader context is Null!"); |
| 9460 | return -EINVAL; |
| 9461 | } |
| 9462 | |
| 9463 | if (wlan_loader->boot_wlan_obj) { |
| 9464 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 9465 | wlan_loader->attr_group); |
| 9466 | kobject_del(wlan_loader->boot_wlan_obj); |
| 9467 | wlan_loader->boot_wlan_obj = NULL; |
| 9468 | } |
| 9469 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9470 | return 0; |
| 9471 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9472 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9473 | #endif |
| 9474 | |
| 9475 | #ifdef MODULE |
| 9476 | /** |
| 9477 | * __hdd_module_init - Module init helper |
| 9478 | * |
| 9479 | * Module init helper function used by both module and static driver. |
| 9480 | * |
| 9481 | * Return: 0 for success, errno on failure |
| 9482 | */ |
| 9483 | static int hdd_module_init(void) |
| 9484 | { |
| 9485 | int ret = 0; |
| 9486 | |
| 9487 | pr_err("%s: Loading driver v%s\n", WLAN_MODULE_NAME, |
| 9488 | QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
| 9489 | |
| 9490 | if (__hdd_module_init()) { |
| 9491 | pr_err("%s: Failed to register handler\n", __func__); |
| 9492 | ret = -EINVAL; |
| 9493 | } |
| 9494 | |
| 9495 | return ret; |
| 9496 | } |
| 9497 | #else |
| 9498 | static int __init hdd_module_init(void) |
| 9499 | { |
| 9500 | int ret = -EINVAL; |
| 9501 | |
| 9502 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 9503 | if (ret) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9504 | pr_err("Failed to create sysfs entry for loading wlan"); |
| 9505 | |
| 9506 | return ret; |
| 9507 | } |
| 9508 | #endif |
| 9509 | |
| 9510 | |
| 9511 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9512 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9513 | * hdd_module_exit() - Exit function |
| 9514 | * |
| 9515 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 9516 | * |
| 9517 | * Return: None |
| 9518 | */ |
| 9519 | static void __exit hdd_module_exit(void) |
| 9520 | { |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9521 | __hdd_module_exit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9522 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9523 | #else |
| 9524 | static void __exit hdd_module_exit(void) |
| 9525 | { |
| 9526 | __hdd_module_exit(); |
| 9527 | wlan_deinit_sysfs(); |
| 9528 | } |
| 9529 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9530 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9531 | static int fwpath_changed_handler(const char *kmessage, struct kernel_param *kp) |
| 9532 | { |
| 9533 | return param_set_copystring(kmessage, kp); |
| 9534 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9535 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9536 | /** |
| 9537 | * is_con_mode_valid() check con mode is valid or not |
| 9538 | * @mode: global con mode |
| 9539 | * |
| 9540 | * Return: TRUE on success FALSE on failure |
| 9541 | */ |
| 9542 | static bool is_con_mode_valid(enum tQDF_GLOBAL_CON_MODE mode) |
| 9543 | { |
| 9544 | switch (mode) { |
| 9545 | case QDF_GLOBAL_MONITOR_MODE: |
| 9546 | case QDF_GLOBAL_FTM_MODE: |
| 9547 | case QDF_GLOBAL_EPPING_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9548 | case QDF_GLOBAL_MISSION_MODE: |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9549 | return true; |
| 9550 | default: |
| 9551 | return false; |
| 9552 | } |
| 9553 | } |
| 9554 | |
| 9555 | /** |
| 9556 | * hdd_get_adpter_mode() - returns adapter mode based on global con mode |
| 9557 | * @mode: global con mode |
| 9558 | * |
| 9559 | * Return: adapter mode |
| 9560 | */ |
| 9561 | static enum tQDF_ADAPTER_MODE hdd_get_adpter_mode( |
| 9562 | enum tQDF_GLOBAL_CON_MODE mode) |
| 9563 | { |
| 9564 | |
| 9565 | switch (mode) { |
| 9566 | case QDF_GLOBAL_MISSION_MODE: |
| 9567 | return QDF_STA_MODE; |
| 9568 | case QDF_GLOBAL_MONITOR_MODE: |
| 9569 | return QDF_MONITOR_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9570 | case QDF_GLOBAL_EPPING_MODE: |
| 9571 | return QDF_EPPING_MODE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9572 | case QDF_GLOBAL_FTM_MODE: |
| 9573 | return QDF_FTM_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9574 | case QDF_GLOBAL_QVIT_MODE: |
| 9575 | return QDF_QVIT_MODE; |
| 9576 | default: |
| 9577 | return QDF_MAX_NO_OF_MODE; |
| 9578 | } |
| 9579 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9580 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9581 | static void hdd_cleanup_present_mode(hdd_context_t *hdd_ctx, |
| 9582 | enum tQDF_GLOBAL_CON_MODE curr_mode) |
| 9583 | { |
| 9584 | switch (curr_mode) { |
| 9585 | case QDF_GLOBAL_MISSION_MODE: |
| 9586 | case QDF_GLOBAL_MONITOR_MODE: |
| 9587 | case QDF_GLOBAL_FTM_MODE: |
| 9588 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
| 9589 | hdd_stop_all_adapters(hdd_ctx); |
| 9590 | hdd_deinit_all_adapters(hdd_ctx, false); |
| 9591 | hdd_close_all_adapters(hdd_ctx, false); |
| 9592 | break; |
| 9593 | case QDF_GLOBAL_EPPING_MODE: |
| 9594 | epping_disable(); |
| 9595 | epping_close(); |
| 9596 | break; |
| 9597 | default: |
| 9598 | return; |
| 9599 | } |
| 9600 | } |
| 9601 | |
| 9602 | static int hdd_register_req_mode(hdd_context_t *hdd_ctx, |
| 9603 | enum tQDF_GLOBAL_CON_MODE mode) |
| 9604 | { |
| 9605 | hdd_adapter_t *adapter; |
| 9606 | int ret = 0; |
| 9607 | bool rtnl_held; |
| 9608 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 9609 | QDF_STATUS status; |
| 9610 | |
| 9611 | if (!qdf_dev) { |
| 9612 | hdd_err("qdf device context is Null return!"); |
| 9613 | return -EINVAL; |
| 9614 | } |
| 9615 | |
| 9616 | rtnl_held = hdd_hold_rtnl_lock(); |
| 9617 | switch (mode) { |
| 9618 | case QDF_GLOBAL_MISSION_MODE: |
| 9619 | adapter = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 9620 | if (IS_ERR(adapter)) { |
| 9621 | hdd_alert("Failed to open interface, adapter is NULL"); |
| 9622 | ret = -EINVAL; |
| 9623 | } |
| 9624 | break; |
| 9625 | case QDF_GLOBAL_FTM_MODE: |
| 9626 | adapter = hdd_open_adapter(hdd_ctx, QDF_FTM_MODE, "wlan%d", |
| 9627 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 9628 | NET_NAME_UNKNOWN, rtnl_held); |
| 9629 | if (adapter == NULL) |
| 9630 | ret = -EINVAL; |
| 9631 | break; |
| 9632 | case QDF_GLOBAL_MONITOR_MODE: |
| 9633 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
| 9634 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 9635 | NET_NAME_UNKNOWN, rtnl_held); |
| 9636 | if (adapter == NULL) |
| 9637 | ret = -EINVAL; |
| 9638 | break; |
| 9639 | case QDF_GLOBAL_EPPING_MODE: |
| 9640 | status = epping_open(); |
| 9641 | if (status != QDF_STATUS_SUCCESS) { |
| 9642 | hdd_err("Failed to open in eeping mode: %d", status); |
| 9643 | ret = -EINVAL; |
| 9644 | break; |
| 9645 | } |
| 9646 | ret = epping_enable(qdf_dev->dev); |
| 9647 | if (ret) { |
| 9648 | hdd_err("Failed to enable in epping mode : %d", ret); |
| 9649 | epping_close(); |
| 9650 | } |
| 9651 | break; |
| 9652 | default: |
| 9653 | hdd_info("Mode not supported"); |
| 9654 | ret = -ENOTSUPP; |
| 9655 | break; |
| 9656 | } |
| 9657 | hdd_release_rtnl_lock(); |
| 9658 | rtnl_held = false; |
| 9659 | return ret; |
| 9660 | } |
| 9661 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9662 | /** |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 9663 | * __con_mode_handler() - Handles module param con_mode change |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9664 | * @kmessage: con mode name on which driver to be bring up |
| 9665 | * @kp: The associated kernel parameter |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 9666 | * @hdd_ctx: Pointer to the global HDD context |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9667 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9668 | * This function is invoked when user updates con mode using sys entry, |
| 9669 | * to initialize and bring-up driver in that specific mode. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9670 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9671 | * Return - 0 on success and failure code on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9672 | */ |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9673 | static int __con_mode_handler(const char *kmessage, struct kernel_param *kp, |
| 9674 | hdd_context_t *hdd_ctx) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9675 | { |
| 9676 | int ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9677 | hdd_adapter_t *adapter; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9678 | enum tQDF_GLOBAL_CON_MODE curr_mode; |
| 9679 | enum tQDF_ADAPTER_MODE adapter_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9680 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 9681 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9682 | if (ret) |
| 9683 | return ret; |
| 9684 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9685 | cds_set_load_in_progress(true); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9686 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9687 | hdd_info("con_mode handler: %s", kmessage); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9688 | ret = param_set_int(kmessage, kp); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9689 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9690 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9691 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9692 | if (!(is_con_mode_valid(con_mode))) { |
| 9693 | hdd_err("invlaid con_mode %d", con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9694 | ret = -EINVAL; |
| 9695 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9696 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9697 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9698 | curr_mode = hdd_get_conparam(); |
| 9699 | if (curr_mode == con_mode) { |
| 9700 | hdd_err("curr mode: %d is same as user triggered mode %d", |
| 9701 | curr_mode, con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9702 | ret = 0; |
| 9703 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9704 | } |
| 9705 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9706 | /* Cleanup present mode before switching to new mode */ |
| 9707 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 9708 | |
Prashanth Bhatta | 2ac92bd | 2016-10-11 16:08:00 -0700 | [diff] [blame] | 9709 | ret = hdd_wlan_stop_modules(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9710 | if (ret) { |
| 9711 | hdd_err("Stop wlan modules failed"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9712 | goto reset_flags; |
| 9713 | } |
| 9714 | |
| 9715 | hdd_set_conparam(con_mode); |
| 9716 | |
| 9717 | /* Register for new con_mode & then kick_start modules again */ |
| 9718 | ret = hdd_register_req_mode(hdd_ctx, con_mode); |
| 9719 | if (ret) { |
| 9720 | hdd_err("Failed to register for new mode"); |
| 9721 | goto reset_flags; |
| 9722 | } |
| 9723 | |
| 9724 | adapter_mode = hdd_get_adpter_mode(con_mode); |
| 9725 | if (adapter_mode == QDF_MAX_NO_OF_MODE) { |
| 9726 | hdd_err("invalid adapter"); |
| 9727 | ret = -EINVAL; |
| 9728 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9729 | } |
| 9730 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 9731 | adapter = hdd_get_adapter(hdd_ctx, adapter_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9732 | if (!adapter) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9733 | hdd_err("Failed to get adapter:%d", adapter_mode); |
| 9734 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9735 | } |
| 9736 | |
| 9737 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 9738 | if (ret) { |
| 9739 | hdd_err("Start wlan modules failed: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9740 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9741 | } |
| 9742 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9743 | if (con_mode == QDF_GLOBAL_MONITOR_MODE || |
| 9744 | con_mode == QDF_GLOBAL_FTM_MODE) { |
| 9745 | if (hdd_start_adapter(adapter)) { |
| 9746 | hdd_err("Failed to start %s adapter", kmessage); |
| 9747 | ret = -EINVAL; |
| 9748 | goto reset_flags; |
| 9749 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9750 | } |
| 9751 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 9752 | hdd_info("Mode successfully changed to %s", kmessage); |
| 9753 | ret = 0; |
| 9754 | |
| 9755 | reset_flags: |
| 9756 | cds_set_load_in_progress(false); |
| 9757 | return ret; |
| 9758 | } |
| 9759 | |
| 9760 | |
| 9761 | static int con_mode_handler(const char *kmessage, struct kernel_param *kp) |
| 9762 | { |
| 9763 | int ret; |
| 9764 | hdd_context_t *hdd_ctx; |
| 9765 | |
| 9766 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 9767 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9768 | if (ret) |
| 9769 | return ret; |
| 9770 | |
| 9771 | cds_ssr_protect(__func__); |
| 9772 | ret = __con_mode_handler(kmessage, kp, hdd_ctx); |
| 9773 | cds_ssr_unprotect(__func__); |
| 9774 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9775 | return ret; |
| 9776 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9777 | |
| 9778 | /** |
| 9779 | * hdd_get_conparam() - driver exit point |
| 9780 | * |
| 9781 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 9782 | * |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9783 | * Return: enum tQDF_GLOBAL_CON_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9784 | */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9785 | enum tQDF_GLOBAL_CON_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9786 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9787 | return (enum tQDF_GLOBAL_CON_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9788 | } |
| 9789 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 9790 | void hdd_set_conparam(uint32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9791 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 9792 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 9793 | } |
| 9794 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 9795 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 9796 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 9797 | * @hdd_ctx: HDD context |
| 9798 | * |
| 9799 | * Cleans up the pre cac interface, if it exists |
| 9800 | * |
| 9801 | * Return: None |
| 9802 | */ |
| 9803 | void hdd_clean_up_pre_cac_interface(hdd_context_t *hdd_ctx) |
| 9804 | { |
| 9805 | uint8_t session_id; |
| 9806 | QDF_STATUS status; |
| 9807 | struct hdd_adapter_s *precac_adapter; |
| 9808 | |
| 9809 | status = wlan_sap_get_pre_cac_vdev_id(hdd_ctx->hHal, &session_id); |
| 9810 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9811 | hdd_err("failed to get pre cac vdev id"); |
| 9812 | return; |
| 9813 | } |
| 9814 | |
| 9815 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, session_id); |
| 9816 | if (!precac_adapter) { |
| 9817 | hdd_err("invalid pre cac adapater"); |
| 9818 | return; |
| 9819 | } |
| 9820 | |
| 9821 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 9822 | wlan_hdd_sap_pre_cac_failure, |
| 9823 | (void *)precac_adapter); |
| 9824 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 9825 | |
| 9826 | } |
| 9827 | |
| 9828 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9829 | * hdd_update_ol_config - API to update ol configuration parameters |
| 9830 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 9831 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 9832 | * Return: void |
| 9833 | */ |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9834 | static void hdd_update_ol_config(hdd_context_t *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 9835 | { |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9836 | struct ol_config_info cfg; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 9837 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 9838 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9839 | if (!ol_ctx) |
| 9840 | return; |
| 9841 | |
| 9842 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
| 9843 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 9844 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 9845 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 9846 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9847 | |
| 9848 | ol_init_ini_config(ol_ctx, &cfg); |
| 9849 | } |
| 9850 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 9851 | #ifdef FEATURE_RUNTIME_PM |
| 9852 | /** |
| 9853 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 9854 | * @hdd_ctx: hdd context |
| 9855 | * @cfg: pointer to the configuration memory being populated |
| 9856 | * |
| 9857 | * Return: void |
| 9858 | */ |
| 9859 | static void hdd_populate_runtime_cfg(hdd_context_t *hdd_ctx, |
| 9860 | struct hif_config_info *cfg) |
| 9861 | { |
| 9862 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
| 9863 | cfg->runtime_pm_delay = hdd_ctx->config->runtime_pm_delay; |
| 9864 | } |
| 9865 | #else |
| 9866 | static void hdd_populate_runtime_cfg(hdd_context_t *hdd_ctx, |
| 9867 | struct hif_config_info *cfg) |
| 9868 | { |
| 9869 | } |
| 9870 | #endif |
| 9871 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9872 | /** |
| 9873 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 9874 | * @hdd_ctx: HDD Context |
| 9875 | * |
| 9876 | * Return: void |
| 9877 | */ |
| 9878 | static void hdd_update_hif_config(hdd_context_t *hdd_ctx) |
| 9879 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 9880 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9881 | struct hif_config_info cfg; |
| 9882 | |
| 9883 | if (!scn) |
| 9884 | return; |
| 9885 | |
| 9886 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 9887 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9888 | hif_init_ini_config(scn, &cfg); |
| 9889 | } |
| 9890 | |
| 9891 | /** |
| 9892 | * hdd_update_config() - Initialize driver per module ini parameters |
| 9893 | * @hdd_ctx: HDD Context |
| 9894 | * |
| 9895 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9896 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9897 | */ |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9898 | int hdd_update_config(hdd_context_t *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9899 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9900 | int ret; |
| 9901 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 9902 | hdd_update_ol_config(hdd_ctx); |
| 9903 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9904 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 9905 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 9906 | else |
| 9907 | ret = hdd_update_cds_config(hdd_ctx); |
| 9908 | |
| 9909 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 9910 | } |
| 9911 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 9912 | /** |
| 9913 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 9914 | * @mode : cfg80211 DFS mode |
| 9915 | * |
| 9916 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 9917 | */ |
| 9918 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 9919 | { |
| 9920 | switch (mode) { |
| 9921 | case DFS_MODE_ENABLE: |
| 9922 | return ACS_DFS_MODE_ENABLE; |
| 9923 | break; |
| 9924 | case DFS_MODE_DISABLE: |
| 9925 | return ACS_DFS_MODE_DISABLE; |
| 9926 | break; |
| 9927 | case DFS_MODE_DEPRIORITIZE: |
| 9928 | return ACS_DFS_MODE_DEPRIORITIZE; |
| 9929 | break; |
| 9930 | default: |
| 9931 | hdd_err("ACS dfs mode is NONE"); |
| 9932 | return ACS_DFS_MODE_NONE; |
| 9933 | } |
| 9934 | } |
| 9935 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 9936 | /** |
| 9937 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 9938 | * @hddctx: pointer to hdd context |
| 9939 | * @set_value: enable/disable |
| 9940 | * |
| 9941 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 9942 | * Host(even though it is duplicate). When Host send vendor command |
| 9943 | * disable,FW doesn't perform any action. Whenever any change in |
| 9944 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 9945 | * |
| 9946 | * return - 0 on success, appropriate error values on failure. |
| 9947 | */ |
| 9948 | int hdd_enable_disable_ca_event(hdd_context_t *hddctx, uint8_t set_value) |
| 9949 | { |
| 9950 | QDF_STATUS status; |
| 9951 | |
| 9952 | if (0 != wlan_hdd_validate_context(hddctx)) { |
| 9953 | return -EAGAIN; |
| 9954 | } |
| 9955 | |
| 9956 | if (!hddctx->config->goptimize_chan_avoid_event) { |
| 9957 | hdd_warn("goptimize_chan_avoid_event ini param disabled"); |
| 9958 | return -EINVAL; |
| 9959 | } |
| 9960 | |
| 9961 | status = sme_enable_disable_chanavoidind_event(hddctx->hHal, set_value); |
| 9962 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9963 | hdd_err("Failed to send chan avoid command to SME"); |
| 9964 | return -EINVAL; |
| 9965 | } |
| 9966 | return 0; |
| 9967 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 9968 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 9969 | /** |
| 9970 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 9971 | * @value: value to set |
| 9972 | * |
| 9973 | * This function will set the passed value to roaming in progress flag. |
| 9974 | * |
| 9975 | * Return: None |
| 9976 | */ |
| 9977 | void hdd_set_roaming_in_progress(bool value) |
| 9978 | { |
| 9979 | hdd_context_t *hdd_ctx; |
| 9980 | |
| 9981 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 9982 | if (!hdd_ctx) { |
| 9983 | hdd_err("HDD context is NULL"); |
| 9984 | return; |
| 9985 | } |
| 9986 | |
| 9987 | hdd_ctx->roaming_in_progress = value; |
| 9988 | hdd_info("Roaming in Progress set to %d", value); |
| 9989 | } |
| 9990 | |
| 9991 | /** |
| 9992 | * hdd_is_roaming_in_progress() - check if roaming is in progress |
| 9993 | * @hdd_ctx - HDD context |
| 9994 | * |
| 9995 | * Return: true if roaming is in progress else false |
| 9996 | */ |
| 9997 | bool hdd_is_roaming_in_progress(void) |
| 9998 | { |
| 9999 | hdd_context_t *hdd_ctx; |
| 10000 | |
| 10001 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10002 | if (!hdd_ctx) { |
| 10003 | hdd_err("HDD context is NULL"); |
| 10004 | return false; |
| 10005 | } |
| 10006 | return hdd_ctx->roaming_in_progress; |
| 10007 | } |
| 10008 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 10009 | QDF_STATUS hdd_create_and_store_psoc(hdd_context_t *hdd_ctx, uint8_t psoc_id) |
| 10010 | { |
| 10011 | struct wlan_objmgr_psoc *psoc; |
| 10012 | |
| 10013 | psoc = wlan_objmgr_psoc_obj_create(psoc_id, WLAN_DEV_OL); |
| 10014 | if (!psoc) |
| 10015 | return QDF_STATUS_E_FAILURE; |
| 10016 | |
| 10017 | hdd_ctx->hdd_psoc = psoc; |
| 10018 | |
| 10019 | return QDF_STATUS_SUCCESS; |
| 10020 | } |
| 10021 | |
Rajeev Kumar | 1cba9d0 | 2017-01-06 11:36:14 -0800 | [diff] [blame] | 10022 | QDF_STATUS hdd_release_and_destroy_psoc(hdd_context_t *hdd_ctx) |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 10023 | { |
| 10024 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 10025 | |
| 10026 | hdd_ctx->hdd_psoc = NULL; |
| 10027 | if (psoc) { |
| 10028 | wlan_objmgr_psoc_obj_delete(psoc); |
| 10029 | return QDF_STATUS_SUCCESS; |
| 10030 | } else |
| 10031 | return QDF_STATUS_E_FAILURE; |
| 10032 | } |
| 10033 | |
| 10034 | QDF_STATUS hdd_create_and_store_pdev(hdd_context_t *hdd_ctx) |
| 10035 | { |
| 10036 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 10037 | struct wlan_objmgr_pdev *pdev; |
| 10038 | |
| 10039 | if (!psoc) { |
| 10040 | hdd_err("Psoc NULL"); |
| 10041 | return QDF_STATUS_E_FAILURE; |
| 10042 | } |
| 10043 | |
| 10044 | pdev = wlan_objmgr_pdev_obj_create(psoc, NULL); |
| 10045 | if (!pdev) { |
| 10046 | hdd_err("pdev obj create failed"); |
| 10047 | return QDF_STATUS_E_FAILURE; |
| 10048 | } |
| 10049 | hdd_ctx->hdd_pdev = pdev; |
| 10050 | |
| 10051 | return QDF_STATUS_SUCCESS; |
| 10052 | } |
| 10053 | |
Rajeev Kumar | 3a6c13c | 2017-01-06 13:01:08 -0800 | [diff] [blame] | 10054 | QDF_STATUS hdd_release_and_destroy_pdev(hdd_context_t *hdd_ctx) |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 10055 | { |
| 10056 | struct wlan_objmgr_pdev *pdev = hdd_ctx->hdd_pdev; |
| 10057 | |
| 10058 | hdd_ctx->hdd_pdev = NULL; |
| 10059 | if (pdev) { |
| 10060 | wlan_objmgr_pdev_obj_delete(pdev); |
| 10061 | return QDF_STATUS_SUCCESS; |
| 10062 | } else |
| 10063 | return QDF_STATUS_E_FAILURE; |
| 10064 | } |
| 10065 | |
| 10066 | QDF_STATUS hdd_create_and_store_vdev(struct wlan_objmgr_pdev *pdev, |
| 10067 | hdd_adapter_t *adapter) |
| 10068 | { |
| 10069 | struct wlan_objmgr_vdev *vdev; |
| 10070 | struct wlan_objmgr_peer *peer; |
| 10071 | struct wlan_vdev_create_params vdev_params; |
| 10072 | |
| 10073 | vdev_params.opmode = adapter->device_mode; |
| 10074 | qdf_mem_copy(vdev_params.macaddr, adapter->macAddressCurrent.bytes, |
| 10075 | QDF_NET_MAC_ADDR_MAX_LEN); |
| 10076 | if (!pdev) { |
| 10077 | hdd_err("pdev NULL"); |
| 10078 | return QDF_STATUS_E_FAILURE; |
| 10079 | } |
| 10080 | |
| 10081 | vdev = wlan_objmgr_vdev_obj_create(pdev, &vdev_params); |
| 10082 | if (!vdev) { |
| 10083 | hdd_err("vdev obj create fails"); |
| 10084 | return QDF_STATUS_E_FAILURE; |
| 10085 | } |
| 10086 | |
| 10087 | if (adapter->sessionId != wlan_vdev_get_id(vdev)) { |
| 10088 | hdd_err("session id and vdev id mismatch"); |
| 10089 | wlan_objmgr_vdev_obj_delete(vdev); |
| 10090 | QDF_ASSERT(0); |
| 10091 | return QDF_STATUS_E_FAILURE; |
| 10092 | } |
| 10093 | |
| 10094 | peer = wlan_objmgr_peer_obj_create(vdev, WLAN_PEER_SELF, |
| 10095 | vdev_params.macaddr); |
| 10096 | if (!peer) { |
| 10097 | hdd_err("obj manager self peer create fails for adapter %d", |
| 10098 | adapter->device_mode); |
| 10099 | wlan_objmgr_vdev_obj_delete(vdev); |
| 10100 | return QDF_STATUS_E_FAILURE; |
| 10101 | } |
Himanshu Agarwal | 2fdf77a | 2016-12-29 11:41:00 +0530 | [diff] [blame] | 10102 | wlan_objmgr_peer_ref_peer(peer); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 10103 | adapter->hdd_vdev = vdev; |
| 10104 | |
| 10105 | return QDF_STATUS_SUCCESS; |
| 10106 | } |
| 10107 | |
Rajeev Kumar | ba77885 | 2017-01-06 13:23:04 -0800 | [diff] [blame] | 10108 | QDF_STATUS hdd_release_and_destroy_vdev(hdd_adapter_t *adapter) |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 10109 | { |
| 10110 | struct wlan_objmgr_vdev *vdev = adapter->hdd_vdev; |
| 10111 | |
| 10112 | adapter->hdd_vdev = NULL; |
| 10113 | if (vdev) { |
| 10114 | if (hdd_remove_peer_object(vdev, |
| 10115 | wlan_vdev_mlme_get_macaddr(vdev))) { |
| 10116 | hdd_err("Self peer delete fails"); |
| 10117 | return QDF_STATUS_E_FAILURE; |
| 10118 | } |
| 10119 | |
| 10120 | wlan_objmgr_vdev_obj_delete(vdev); |
| 10121 | return QDF_STATUS_SUCCESS; |
| 10122 | } else |
| 10123 | return QDF_STATUS_E_FAILURE; |
| 10124 | } |
| 10125 | |
| 10126 | QDF_STATUS hdd_add_peer_object(struct wlan_objmgr_vdev *vdev, |
| 10127 | enum tQDF_ADAPTER_MODE adapter_mode, |
| 10128 | uint8_t *mac_addr) |
| 10129 | { |
| 10130 | enum wlan_peer_type peer_type; |
| 10131 | |
| 10132 | if ((adapter_mode == QDF_STA_MODE) || |
| 10133 | (adapter_mode == QDF_P2P_CLIENT_MODE)) |
| 10134 | peer_type = WLAN_PEER_AP; |
| 10135 | else if ((adapter_mode == QDF_SAP_MODE) || |
| 10136 | (adapter_mode == QDF_P2P_GO_MODE)) |
| 10137 | peer_type = WLAN_PEER_STA; |
| 10138 | else if (adapter_mode == QDF_IBSS_MODE) |
| 10139 | peer_type = WLAN_PEER_IBSS; |
| 10140 | else { |
| 10141 | hdd_err("Unsupported device mode %d", adapter_mode); |
| 10142 | return QDF_STATUS_E_FAILURE; |
| 10143 | } |
| 10144 | |
| 10145 | if (!vdev) { |
| 10146 | hdd_err("vdev NULL"); |
| 10147 | QDF_ASSERT(0); |
| 10148 | return QDF_STATUS_E_FAILURE; |
| 10149 | } |
| 10150 | |
| 10151 | if (!wlan_objmgr_peer_obj_create(vdev, peer_type, mac_addr)) |
| 10152 | return QDF_STATUS_E_FAILURE; |
| 10153 | |
| 10154 | hdd_info("Peer object "MAC_ADDRESS_STR" add success!", |
| 10155 | MAC_ADDR_ARRAY(mac_addr)); |
| 10156 | |
| 10157 | return QDF_STATUS_SUCCESS; |
| 10158 | } |
| 10159 | |
| 10160 | QDF_STATUS hdd_remove_peer_object(struct wlan_objmgr_vdev *vdev, |
| 10161 | uint8_t *mac_addr) |
| 10162 | { |
| 10163 | struct wlan_objmgr_psoc *psoc; |
| 10164 | struct wlan_objmgr_peer *peer; |
| 10165 | |
| 10166 | if (!vdev) { |
| 10167 | hdd_err("vdev NULL"); |
| 10168 | QDF_ASSERT(0); |
| 10169 | return QDF_STATUS_E_FAILURE; |
| 10170 | } |
| 10171 | |
| 10172 | psoc = wlan_vdev_get_psoc(vdev); |
| 10173 | if (!psoc) { |
| 10174 | hdd_err("Psoc NUll"); |
| 10175 | QDF_ASSERT(0); |
| 10176 | return QDF_STATUS_E_FAILURE; |
| 10177 | } |
| 10178 | |
| 10179 | peer = wlan_objmgr_find_peer(psoc, mac_addr); |
| 10180 | if (peer) { |
| 10181 | if (wlan_objmgr_peer_obj_delete(peer)) |
| 10182 | return QDF_STATUS_E_FAILURE; |
| 10183 | |
| 10184 | hdd_info("Peer obj "MAC_ADDRESS_STR" deleted", |
| 10185 | MAC_ADDR_ARRAY(mac_addr)); |
| 10186 | return QDF_STATUS_SUCCESS; |
| 10187 | } |
| 10188 | |
| 10189 | hdd_err("Peer obj "MAC_ADDRESS_STR" not found", |
| 10190 | MAC_ADDR_ARRAY(mac_addr)); |
| 10191 | |
| 10192 | return QDF_STATUS_E_FAILURE; |
| 10193 | } |
| 10194 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10195 | /* Register the module init/exit functions */ |
| 10196 | module_init(hdd_module_init); |
| 10197 | module_exit(hdd_module_exit); |
| 10198 | |
| 10199 | MODULE_LICENSE("Dual BSD/GPL"); |
| 10200 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 10201 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 10202 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10203 | module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode, |
| 10204 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10205 | |
| 10206 | module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath, |
| 10207 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 10208 | |
| 10209 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 10210 | |
| 10211 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 10212 | |
| 10213 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |