Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4 | * Permission to use, copy, modify, and/or distribute this software for |
| 5 | * any purpose with or without fee is hereby granted, provided that the |
| 6 | * above copyright notice and this permission notice appear in all |
| 7 | * copies. |
| 8 | * |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 10 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 11 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 12 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 13 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 14 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 15 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 16 | * PERFORMANCE OF THIS SOFTWARE. |
| 17 | */ |
| 18 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19 | /** |
| 20 | * DOC: wlan_hdd_power.c |
| 21 | * |
| 22 | * WLAN power management functions |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | /* Include files */ |
| 27 | |
| 28 | #include <linux/pm.h> |
| 29 | #include <linux/wait.h> |
| 30 | #include <linux/cpu.h> |
| 31 | #include <wlan_hdd_includes.h> |
| 32 | #if defined(WLAN_OPEN_SOURCE) && defined(CONFIG_HAS_WAKELOCK) |
| 33 | #include <linux/wakelock.h> |
| 34 | #endif |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 35 | #include "qdf_types.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 36 | #include "sme_api.h" |
| 37 | #include <cds_api.h> |
| 38 | #include <cds_sched.h> |
| 39 | #include <mac_init_api.h> |
| 40 | #include <wlan_qct_sys.h> |
| 41 | #include <wlan_hdd_main.h> |
| 42 | #include <wlan_hdd_assoc.h> |
| 43 | #include <wlan_nlink_srv.h> |
| 44 | #include <wlan_hdd_misc.h> |
| 45 | #include <wlan_hdd_power.h> |
Jeff Johnson | c8d0c25 | 2016-10-05 16:19:50 -0700 | [diff] [blame] | 46 | #include <wlan_hdd_host_offload.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 47 | #include <dbglog_host.h> |
| 48 | #include <wlan_hdd_trace.h> |
Masti, Narayanraddi | 3e26de6 | 2016-08-19 14:33:22 +0530 | [diff] [blame] | 49 | #include <wlan_hdd_p2p.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 50 | |
| 51 | #include <linux/semaphore.h> |
| 52 | #include <wlan_hdd_hostapd.h> |
| 53 | #include "cfg_api.h" |
| 54 | |
| 55 | #include <linux/inetdevice.h> |
| 56 | #include <wlan_hdd_cfg.h> |
Sandeep Puligilla | e390be5 | 2016-02-08 17:07:05 -0800 | [diff] [blame] | 57 | #include <wlan_hdd_scan.h> |
Jeff Johnson | 5fe539b | 2018-03-23 13:53:30 -0700 | [diff] [blame] | 58 | #include <wlan_hdd_stats.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 59 | #include <wlan_hdd_cfg80211.h> |
| 60 | #include <net/addrconf.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 61 | #include <wlan_hdd_lpass.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 62 | |
| 63 | #include <wma_types.h> |
Poddar, Siddarth | a78cac3 | 2016-12-29 20:08:34 +0530 | [diff] [blame] | 64 | #include <ol_txrx_osif_api.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 65 | #include "hif.h" |
Dustin Brown | 0f8dc3d | 2017-06-01 14:37:26 -0700 | [diff] [blame] | 66 | #include "hif_unit_test_suspend.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 67 | #include "sme_power_save_api.h" |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 68 | #include "wlan_policy_mgr_api.h" |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 69 | #include "cdp_txrx_flow_ctrl_v2.h" |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 70 | #include "pld_common.h" |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 71 | #include "wlan_hdd_driver_ops.h" |
Himanshu Agarwal | f65bd4c | 2016-12-05 17:21:12 +0530 | [diff] [blame] | 72 | #include <wlan_logging_sock_svc.h> |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 73 | #include "scheduler_api.h" |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 74 | #include "cds_utils.h" |
Hanumanth Reddy Pothula | 3def894 | 2017-10-05 16:19:36 +0530 | [diff] [blame] | 75 | #include "wlan_hdd_packet_filter_api.h" |
Arunk Khandavalli | f0c0d76 | 2017-12-07 10:18:50 +0530 | [diff] [blame] | 76 | #include "wlan_cfg80211_scan.h" |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 77 | #include "wlan_ipa_ucfg_api.h" |
Naveen Rawat | e8b1b82 | 2018-01-30 09:46:16 -0800 | [diff] [blame] | 78 | #include <wlan_cfg80211_mc_cp_stats.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 79 | |
| 80 | /* Preprocessor definitions and constants */ |
Yue Ma | 5fe30dd | 2017-05-02 15:47:40 -0700 | [diff] [blame] | 81 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 82 | #define HDD_SSR_BRING_UP_TIME 3000000 |
| 83 | #else |
Yue Ma | 4ea4f05 | 2015-10-27 12:25:27 -0700 | [diff] [blame] | 84 | #define HDD_SSR_BRING_UP_TIME 30000 |
Yue Ma | 5fe30dd | 2017-05-02 15:47:40 -0700 | [diff] [blame] | 85 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 86 | |
| 87 | /* Type declarations */ |
| 88 | |
Abhishek Singh | baea27d | 2016-04-27 13:29:30 +0530 | [diff] [blame] | 89 | #ifdef FEATURE_WLAN_DIAG_SUPPORT |
Abhishek Singh | baea27d | 2016-04-27 13:29:30 +0530 | [diff] [blame] | 90 | void hdd_wlan_suspend_resume_event(uint8_t state) |
| 91 | { |
| 92 | WLAN_HOST_DIAG_EVENT_DEF(suspend_state, struct host_event_suspend); |
| 93 | qdf_mem_zero(&suspend_state, sizeof(suspend_state)); |
| 94 | |
| 95 | suspend_state.state = state; |
| 96 | WLAN_HOST_DIAG_EVENT_REPORT(&suspend_state, EVENT_WLAN_SUSPEND_RESUME); |
| 97 | } |
Abhishek Singh | 4aad0f7 | 2016-04-27 13:43:29 +0530 | [diff] [blame] | 98 | |
| 99 | /** |
| 100 | * hdd_wlan_offload_event()- send offloads event |
| 101 | * @type: offload type |
| 102 | * @state: enabled or disabled |
| 103 | * |
| 104 | * This Function send offloads enable/disable diag event |
| 105 | * |
| 106 | * Return: void. |
| 107 | */ |
| 108 | |
| 109 | void hdd_wlan_offload_event(uint8_t type, uint8_t state) |
| 110 | { |
| 111 | WLAN_HOST_DIAG_EVENT_DEF(host_offload, struct host_event_offload_req); |
| 112 | qdf_mem_zero(&host_offload, sizeof(host_offload)); |
| 113 | |
| 114 | host_offload.offload_type = type; |
| 115 | host_offload.state = state; |
| 116 | |
| 117 | WLAN_HOST_DIAG_EVENT_REPORT(&host_offload, EVENT_WLAN_OFFLOAD_REQ); |
| 118 | } |
Abhishek Singh | baea27d | 2016-04-27 13:29:30 +0530 | [diff] [blame] | 119 | #endif |
| 120 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 121 | /** |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 122 | * hdd_enable_gtk_offload() - enable GTK offload |
| 123 | * @adapter: pointer to the adapter |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 124 | * |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 125 | * Central function to enable GTK offload. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 126 | * |
| 127 | * Return: nothing |
| 128 | */ |
Jeff Johnson | 75b737d | 2017-08-29 14:24:41 -0700 | [diff] [blame] | 129 | static void hdd_enable_gtk_offload(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 130 | { |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 131 | QDF_STATUS status; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 132 | |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 133 | status = pmo_ucfg_enable_gtk_offload_in_fwr(adapter->hdd_vdev); |
| 134 | if (status != QDF_STATUS_SUCCESS) |
| 135 | hdd_info("Failed to enable gtk offload"); |
| 136 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 137 | |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 138 | /** |
| 139 | * hdd_disable_gtk_offload() - disable GTK offload |
Jeff Johnson | f6d2428 | 2017-10-02 13:25:25 -0700 | [diff] [blame] | 140 | * @adapter: pointer to the adapter |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 141 | * |
| 142 | * Central function to disable GTK offload. |
| 143 | * |
| 144 | * Return: nothing |
| 145 | */ |
Jeff Johnson | 75b737d | 2017-08-29 14:24:41 -0700 | [diff] [blame] | 146 | static void hdd_disable_gtk_offload(struct hdd_adapter *adapter) |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 147 | { |
| 148 | struct pmo_gtk_rsp_req gtk_rsp_request; |
| 149 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 150 | |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 151 | /* ensure to get gtk rsp first before disable it*/ |
| 152 | gtk_rsp_request.callback = |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 153 | wlan_hdd_cfg80211_update_replay_counter_cb; |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 154 | /* Passing as void* as PMO does not know legacy HDD adapter type */ |
| 155 | gtk_rsp_request.callback_context = |
| 156 | (void *)adapter; |
| 157 | status = pmo_ucfg_get_gtk_rsp(adapter->hdd_vdev, |
| 158 | >k_rsp_request); |
| 159 | if (status != QDF_STATUS_SUCCESS) { |
| 160 | hdd_err("Failed to send get gtk rsp status:%d", status); |
| 161 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 162 | } |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 163 | hdd_debug("send get_gtk_rsp successful"); |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 164 | status = pmo_ucfg_disable_gtk_offload_in_fwr(adapter->hdd_vdev); |
| 165 | if (status != QDF_STATUS_SUCCESS) |
| 166 | hdd_info("Failed to disable gtk offload"); |
| 167 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 168 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 169 | |
Qiwei Cai | 1083f5b | 2018-07-02 19:10:11 +0800 | [diff] [blame^] | 170 | #ifdef WLAN_NS_OFFLOAD |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 171 | /** |
| 172 | * __wlan_hdd_ipv6_changed() - IPv6 notifier callback function |
| 173 | * @nb: notifier block that was registered with the kernel |
| 174 | * @data: (unused) generic data that was registered with the kernel |
| 175 | * @arg: (unused) generic argument that was registered with the kernel |
| 176 | * |
| 177 | * This is a callback function that is registered with the kernel via |
| 178 | * register_inet6addr_notifier() which allows the driver to be |
| 179 | * notified when there is an IPv6 address change. |
| 180 | * |
| 181 | * Return: NOTIFY_DONE to indicate we don't care what happens with |
| 182 | * other callbacks |
| 183 | */ |
| 184 | static int __wlan_hdd_ipv6_changed(struct notifier_block *nb, |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 185 | unsigned long data, void *arg) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 186 | { |
| 187 | struct inet6_ifaddr *ifa = (struct inet6_ifaddr *)arg; |
| 188 | struct net_device *ndev = ifa->idev->dev; |
Jeff Johnson | 75b737d | 2017-08-29 14:24:41 -0700 | [diff] [blame] | 189 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
Jeff Johnson | cfb65a8 | 2017-08-28 11:45:41 -0700 | [diff] [blame] | 190 | struct hdd_context *hdd_ctx; |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 191 | int errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 192 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 193 | hdd_enter_dev(ndev); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 194 | |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 195 | errno = hdd_validate_adapter(adapter); |
| 196 | if (errno) |
| 197 | goto exit; |
| 198 | |
| 199 | if (adapter->dev == ndev && |
| 200 | (adapter->device_mode == QDF_STA_MODE || |
| 201 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 202 | adapter->device_mode == QDF_NDI_MODE)) { |
| 203 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 204 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 205 | if (errno) |
| 206 | goto exit; |
| 207 | |
Nachiket Kukade | c9045fe | 2017-06-19 15:14:43 +0530 | [diff] [blame] | 208 | /* Ignore if the interface is down */ |
| 209 | if (!(ndev->flags & IFF_UP)) { |
| 210 | hdd_err("Rcvd change addr request on %s(flags 0x%X)", |
| 211 | ndev->name, ndev->flags); |
| 212 | hdd_err("NETDEV Interface is down, ignoring..."); |
| 213 | goto exit; |
| 214 | } |
| 215 | |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 216 | hdd_debug("invoking sme_dhcp_done_ind"); |
Jeff Johnson | 2954ded | 2018-06-13 16:34:49 -0700 | [diff] [blame] | 217 | sme_dhcp_done_ind(hdd_ctx->mac_handle, adapter->session_id); |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 218 | schedule_work(&adapter->ipv6_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 219 | } |
| 220 | |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 221 | exit: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 222 | hdd_exit(); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 223 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 224 | return NOTIFY_DONE; |
| 225 | } |
| 226 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 227 | int wlan_hdd_ipv6_changed(struct notifier_block *nb, |
| 228 | unsigned long data, void *arg) |
| 229 | { |
| 230 | int ret; |
| 231 | |
| 232 | cds_ssr_protect(__func__); |
| 233 | ret = __wlan_hdd_ipv6_changed(nb, data, arg); |
| 234 | cds_ssr_unprotect(__func__); |
| 235 | |
| 236 | return ret; |
| 237 | } |
| 238 | |
| 239 | /** |
Sravan Kumar Kairam | c087358 | 2016-07-26 17:34:57 +0530 | [diff] [blame] | 240 | * hdd_fill_ipv6_uc_addr() - fill IPv6 unicast addresses |
| 241 | * @idev: pointer to net device |
| 242 | * @ipv6addr: destination array to fill IPv6 addresses |
| 243 | * @ipv6addr_type: IPv6 Address type |
| 244 | * @count: number of IPv6 addresses |
| 245 | * |
| 246 | * This is the IPv6 utility function to populate unicast addresses. |
| 247 | * |
| 248 | * Return: 0 on success, error number otherwise. |
| 249 | */ |
| 250 | static int hdd_fill_ipv6_uc_addr(struct inet6_dev *idev, |
| 251 | uint8_t ipv6_uc_addr[][SIR_MAC_IPV6_ADDR_LEN], |
| 252 | uint8_t *ipv6addr_type, uint32_t *count) |
| 253 | { |
| 254 | struct inet6_ifaddr *ifa; |
| 255 | struct list_head *p; |
| 256 | uint32_t scope; |
| 257 | |
Srinivas Girigowda | 90cdd3c | 2016-10-18 11:28:10 -0700 | [diff] [blame] | 258 | read_lock_bh(&idev->lock); |
Sravan Kumar Kairam | c087358 | 2016-07-26 17:34:57 +0530 | [diff] [blame] | 259 | list_for_each(p, &idev->addr_list) { |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 260 | if (*count >= PMO_MAC_NUM_TARGET_IPV6_NS_OFFLOAD_NA) { |
Srinivas Girigowda | 90cdd3c | 2016-10-18 11:28:10 -0700 | [diff] [blame] | 261 | read_unlock_bh(&idev->lock); |
Sravan Kumar Kairam | c087358 | 2016-07-26 17:34:57 +0530 | [diff] [blame] | 262 | return -EINVAL; |
Srinivas Girigowda | 90cdd3c | 2016-10-18 11:28:10 -0700 | [diff] [blame] | 263 | } |
Sravan Kumar Kairam | c087358 | 2016-07-26 17:34:57 +0530 | [diff] [blame] | 264 | ifa = list_entry(p, struct inet6_ifaddr, if_list); |
| 265 | if (ifa->flags & IFA_F_DADFAILED) |
| 266 | continue; |
| 267 | scope = ipv6_addr_src_scope(&ifa->addr); |
| 268 | switch (scope) { |
| 269 | case IPV6_ADDR_SCOPE_GLOBAL: |
| 270 | case IPV6_ADDR_SCOPE_LINKLOCAL: |
| 271 | qdf_mem_copy(ipv6_uc_addr[*count], &ifa->addr.s6_addr, |
| 272 | sizeof(ifa->addr.s6_addr)); |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 273 | ipv6addr_type[*count] = PMO_IPV6_ADDR_UC_TYPE; |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 274 | hdd_debug("Index %d scope = %s UC-Address: %pI6", |
Sravan Kumar Kairam | c087358 | 2016-07-26 17:34:57 +0530 | [diff] [blame] | 275 | *count, (scope == IPV6_ADDR_SCOPE_LINKLOCAL) ? |
| 276 | "LINK LOCAL" : "GLOBAL", ipv6_uc_addr[*count]); |
| 277 | *count += 1; |
| 278 | break; |
| 279 | default: |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 280 | hdd_warn("The Scope %d is not supported", scope); |
Sravan Kumar Kairam | c087358 | 2016-07-26 17:34:57 +0530 | [diff] [blame] | 281 | } |
| 282 | } |
Srinivas Girigowda | 90cdd3c | 2016-10-18 11:28:10 -0700 | [diff] [blame] | 283 | |
| 284 | read_unlock_bh(&idev->lock); |
Sravan Kumar Kairam | c087358 | 2016-07-26 17:34:57 +0530 | [diff] [blame] | 285 | return 0; |
| 286 | } |
| 287 | |
| 288 | /** |
| 289 | * hdd_fill_ipv6_ac_addr() - fill IPv6 anycast addresses |
| 290 | * @idev: pointer to net device |
| 291 | * @ipv6addr: destination array to fill IPv6 addresses |
| 292 | * @ipv6addr_type: IPv6 Address type |
| 293 | * @count: number of IPv6 addresses |
| 294 | * |
| 295 | * This is the IPv6 utility function to populate anycast addresses. |
| 296 | * |
| 297 | * Return: 0 on success, error number otherwise. |
| 298 | */ |
| 299 | static int hdd_fill_ipv6_ac_addr(struct inet6_dev *idev, |
| 300 | uint8_t ipv6_ac_addr[][SIR_MAC_IPV6_ADDR_LEN], |
| 301 | uint8_t *ipv6addr_type, uint32_t *count) |
| 302 | { |
| 303 | struct ifacaddr6 *ifaca; |
| 304 | uint32_t scope; |
| 305 | |
Srinivas Girigowda | 90cdd3c | 2016-10-18 11:28:10 -0700 | [diff] [blame] | 306 | read_lock_bh(&idev->lock); |
Sravan Kumar Kairam | c087358 | 2016-07-26 17:34:57 +0530 | [diff] [blame] | 307 | for (ifaca = idev->ac_list; ifaca; ifaca = ifaca->aca_next) { |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 308 | if (*count >= PMO_MAC_NUM_TARGET_IPV6_NS_OFFLOAD_NA) { |
Srinivas Girigowda | 90cdd3c | 2016-10-18 11:28:10 -0700 | [diff] [blame] | 309 | read_unlock_bh(&idev->lock); |
Sravan Kumar Kairam | c087358 | 2016-07-26 17:34:57 +0530 | [diff] [blame] | 310 | return -EINVAL; |
Srinivas Girigowda | 90cdd3c | 2016-10-18 11:28:10 -0700 | [diff] [blame] | 311 | } |
Sravan Kumar Kairam | c087358 | 2016-07-26 17:34:57 +0530 | [diff] [blame] | 312 | /* For anycast addr no DAD */ |
| 313 | scope = ipv6_addr_src_scope(&ifaca->aca_addr); |
| 314 | switch (scope) { |
| 315 | case IPV6_ADDR_SCOPE_GLOBAL: |
| 316 | case IPV6_ADDR_SCOPE_LINKLOCAL: |
| 317 | qdf_mem_copy(ipv6_ac_addr[*count], &ifaca->aca_addr, |
| 318 | sizeof(ifaca->aca_addr)); |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 319 | ipv6addr_type[*count] = PMO_IPV6_ADDR_AC_TYPE; |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 320 | hdd_debug("Index %d scope = %s AC-Address: %pI6", |
Sravan Kumar Kairam | c087358 | 2016-07-26 17:34:57 +0530 | [diff] [blame] | 321 | *count, (scope == IPV6_ADDR_SCOPE_LINKLOCAL) ? |
| 322 | "LINK LOCAL" : "GLOBAL", ipv6_ac_addr[*count]); |
| 323 | *count += 1; |
| 324 | break; |
| 325 | default: |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 326 | hdd_warn("The Scope %d is not supported", scope); |
Sravan Kumar Kairam | c087358 | 2016-07-26 17:34:57 +0530 | [diff] [blame] | 327 | } |
| 328 | } |
Srinivas Girigowda | 90cdd3c | 2016-10-18 11:28:10 -0700 | [diff] [blame] | 329 | |
| 330 | read_unlock_bh(&idev->lock); |
Sravan Kumar Kairam | c087358 | 2016-07-26 17:34:57 +0530 | [diff] [blame] | 331 | return 0; |
| 332 | } |
| 333 | |
Jeff Johnson | 75b737d | 2017-08-29 14:24:41 -0700 | [diff] [blame] | 334 | void hdd_enable_ns_offload(struct hdd_adapter *adapter, |
Dustin Brown | c1cdb71 | 2018-06-11 15:42:17 -0700 | [diff] [blame] | 335 | enum pmo_offload_trigger trigger) |
Dustin Brown | 2444ee6 | 2016-09-06 17:20:36 -0700 | [diff] [blame] | 336 | { |
Jeff Johnson | cfb65a8 | 2017-08-28 11:45:41 -0700 | [diff] [blame] | 337 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 338 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
Dustin Brown | c1cdb71 | 2018-06-11 15:42:17 -0700 | [diff] [blame] | 339 | struct inet6_dev *in6_dev; |
| 340 | struct pmo_ns_req *ns_req; |
| 341 | QDF_STATUS status; |
| 342 | int errno; |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 343 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 344 | hdd_enter(); |
Dustin Brown | c1cdb71 | 2018-06-11 15:42:17 -0700 | [diff] [blame] | 345 | |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 346 | if (!psoc) { |
| 347 | hdd_err("psoc is NULL"); |
| 348 | goto out; |
| 349 | } |
Dustin Brown | 2444ee6 | 2016-09-06 17:20:36 -0700 | [diff] [blame] | 350 | |
| 351 | in6_dev = __in6_dev_get(adapter->dev); |
| 352 | if (NULL == in6_dev) { |
| 353 | hdd_err("IPv6 dev does not exist. Failed to request NSOffload"); |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 354 | goto out; |
Dustin Brown | 2444ee6 | 2016-09-06 17:20:36 -0700 | [diff] [blame] | 355 | } |
| 356 | |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 357 | ns_req = qdf_mem_malloc(sizeof(*ns_req)); |
| 358 | if (!ns_req) { |
| 359 | hdd_err("fail to allocate ns_req"); |
| 360 | goto out; |
| 361 | } |
| 362 | |
| 363 | ns_req->psoc = psoc; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 364 | ns_req->vdev_id = adapter->session_id; |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 365 | ns_req->trigger = trigger; |
| 366 | ns_req->count = 0; |
| 367 | |
Dustin Brown | 2444ee6 | 2016-09-06 17:20:36 -0700 | [diff] [blame] | 368 | /* Unicast Addresses */ |
Dustin Brown | c1cdb71 | 2018-06-11 15:42:17 -0700 | [diff] [blame] | 369 | errno = hdd_fill_ipv6_uc_addr(in6_dev, ns_req->ipv6_addr, |
| 370 | ns_req->ipv6_addr_type, &ns_req->count); |
| 371 | if (errno) { |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 372 | hdd_disable_ns_offload(adapter, trigger); |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 373 | hdd_debug("Max supported addresses: disabling NS offload"); |
Dustin Brown | c1cdb71 | 2018-06-11 15:42:17 -0700 | [diff] [blame] | 374 | goto free_req; |
Dustin Brown | 2444ee6 | 2016-09-06 17:20:36 -0700 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | /* Anycast Addresses */ |
Dustin Brown | c1cdb71 | 2018-06-11 15:42:17 -0700 | [diff] [blame] | 378 | errno = hdd_fill_ipv6_ac_addr(in6_dev, ns_req->ipv6_addr, |
| 379 | ns_req->ipv6_addr_type, &ns_req->count); |
| 380 | if (errno) { |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 381 | hdd_disable_ns_offload(adapter, trigger); |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 382 | hdd_debug("Max supported addresses: disabling NS offload"); |
Dustin Brown | c1cdb71 | 2018-06-11 15:42:17 -0700 | [diff] [blame] | 383 | goto free_req; |
Dustin Brown | 2444ee6 | 2016-09-06 17:20:36 -0700 | [diff] [blame] | 384 | } |
| 385 | |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 386 | /* cache ns request */ |
| 387 | status = pmo_ucfg_cache_ns_offload_req(ns_req); |
Dustin Brown | c1cdb71 | 2018-06-11 15:42:17 -0700 | [diff] [blame] | 388 | if (QDF_IS_STATUS_ERROR(status)) { |
| 389 | hdd_err("Failed to cache ns request; status:%d", status); |
| 390 | goto free_req; |
Dustin Brown | 2444ee6 | 2016-09-06 17:20:36 -0700 | [diff] [blame] | 391 | } |
| 392 | |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 393 | /* enable ns request */ |
| 394 | status = pmo_ucfg_enable_ns_offload_in_fwr(adapter->hdd_vdev, trigger); |
Dustin Brown | c1cdb71 | 2018-06-11 15:42:17 -0700 | [diff] [blame] | 395 | if (QDF_IS_STATUS_ERROR(status)) { |
| 396 | hdd_err("Failed to enable ns offload; status:%d", status); |
| 397 | goto free_req; |
| 398 | } |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 399 | |
Dustin Brown | c1cdb71 | 2018-06-11 15:42:17 -0700 | [diff] [blame] | 400 | hdd_wlan_offload_event(SIR_IPV6_NS_OFFLOAD, SIR_OFFLOAD_ENABLE); |
| 401 | |
| 402 | free_req: |
| 403 | qdf_mem_free(ns_req); |
| 404 | |
| 405 | out: |
| 406 | hdd_exit(); |
Dustin Brown | 2444ee6 | 2016-09-06 17:20:36 -0700 | [diff] [blame] | 407 | } |
| 408 | |
Jeff Johnson | 75b737d | 2017-08-29 14:24:41 -0700 | [diff] [blame] | 409 | void hdd_disable_ns_offload(struct hdd_adapter *adapter, |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 410 | enum pmo_offload_trigger trigger) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 411 | { |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 412 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 413 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 414 | hdd_enter(); |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 415 | status = pmo_ucfg_flush_ns_offload_req(adapter->hdd_vdev); |
| 416 | if (status != QDF_STATUS_SUCCESS) { |
| 417 | hdd_err("Failed to flush NS Offload"); |
| 418 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 419 | } |
| 420 | |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 421 | status = pmo_ucfg_disable_ns_offload_in_fwr(adapter->hdd_vdev, trigger); |
| 422 | if (status != QDF_STATUS_SUCCESS) |
| 423 | hdd_err("Failed to disable NS Offload"); |
Dustin Brown | 2444ee6 | 2016-09-06 17:20:36 -0700 | [diff] [blame] | 424 | else |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 425 | hdd_wlan_offload_event(SIR_IPV6_NS_OFFLOAD, |
| 426 | SIR_OFFLOAD_DISABLE); |
| 427 | out: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 428 | hdd_exit(); |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 429 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 430 | } |
| 431 | |
| 432 | /** |
| 433 | * __hdd_ipv6_notifier_work_queue() - IPv6 notification work function |
| 434 | * @work: registered work item |
| 435 | * |
| 436 | * This function performs the work initially trigged by a callback |
| 437 | * from the IPv6 netdev notifier. Since this means there has been a |
| 438 | * change in IPv6 state for the interface, the NS offload is |
| 439 | * reconfigured. |
| 440 | * |
| 441 | * Return: None |
| 442 | */ |
Jeff Johnson | c8d0c25 | 2016-10-05 16:19:50 -0700 | [diff] [blame] | 443 | static void __hdd_ipv6_notifier_work_queue(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 444 | { |
Jeff Johnson | cfb65a8 | 2017-08-28 11:45:41 -0700 | [diff] [blame] | 445 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 75b737d | 2017-08-29 14:24:41 -0700 | [diff] [blame] | 446 | struct hdd_adapter *adapter; |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 447 | int errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 448 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 449 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 450 | |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 451 | adapter = container_of(work, struct hdd_adapter, ipv6_notifier_work); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 452 | errno = hdd_validate_adapter(adapter); |
| 453 | if (errno) |
| 454 | goto exit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 455 | |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 456 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 457 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 458 | if (errno) |
| 459 | goto exit; |
| 460 | |
| 461 | hdd_enable_ns_offload(adapter, pmo_ipv6_change_notify); |
| 462 | |
| 463 | exit: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 464 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 465 | } |
| 466 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 467 | void hdd_ipv6_notifier_work_queue(struct work_struct *work) |
| 468 | { |
| 469 | cds_ssr_protect(__func__); |
| 470 | __hdd_ipv6_notifier_work_queue(work); |
| 471 | cds_ssr_unprotect(__func__); |
| 472 | } |
Qiwei Cai | 1083f5b | 2018-07-02 19:10:11 +0800 | [diff] [blame^] | 473 | #endif /* WLAN_NS_OFFLOAD */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 474 | |
Jeff Johnson | 75b737d | 2017-08-29 14:24:41 -0700 | [diff] [blame] | 475 | static void hdd_enable_hw_filter(struct hdd_adapter *adapter) |
Dustin Brown | 1224e21 | 2017-05-12 14:02:12 -0700 | [diff] [blame] | 476 | { |
| 477 | QDF_STATUS status; |
| 478 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 479 | hdd_enter(); |
Dustin Brown | 1224e21 | 2017-05-12 14:02:12 -0700 | [diff] [blame] | 480 | |
| 481 | status = pmo_ucfg_enable_hw_filter_in_fwr(adapter->hdd_vdev); |
| 482 | if (status != QDF_STATUS_SUCCESS) |
| 483 | hdd_info("Failed to enable hardware filter"); |
| 484 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 485 | hdd_exit(); |
Dustin Brown | 1224e21 | 2017-05-12 14:02:12 -0700 | [diff] [blame] | 486 | } |
| 487 | |
Jeff Johnson | 75b737d | 2017-08-29 14:24:41 -0700 | [diff] [blame] | 488 | static void hdd_disable_hw_filter(struct hdd_adapter *adapter) |
Dustin Brown | 1224e21 | 2017-05-12 14:02:12 -0700 | [diff] [blame] | 489 | { |
| 490 | QDF_STATUS status; |
| 491 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 492 | hdd_enter(); |
Dustin Brown | 1224e21 | 2017-05-12 14:02:12 -0700 | [diff] [blame] | 493 | |
| 494 | status = pmo_ucfg_disable_hw_filter_in_fwr(adapter->hdd_vdev); |
| 495 | if (status != QDF_STATUS_SUCCESS) |
| 496 | hdd_info("Failed to disable hardware filter"); |
| 497 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 498 | hdd_exit(); |
Dustin Brown | 1224e21 | 2017-05-12 14:02:12 -0700 | [diff] [blame] | 499 | } |
| 500 | |
Jeff Johnson | 75b737d | 2017-08-29 14:24:41 -0700 | [diff] [blame] | 501 | void hdd_enable_host_offloads(struct hdd_adapter *adapter, |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 502 | enum pmo_offload_trigger trigger) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 503 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 504 | hdd_enter(); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 505 | |
Rajeev Kumar | ec1194d | 2017-11-16 17:30:01 -0800 | [diff] [blame] | 506 | if (!ucfg_pmo_is_vdev_supports_offload(adapter->hdd_vdev)) { |
Dustin Brown | c1cdb71 | 2018-06-11 15:42:17 -0700 | [diff] [blame] | 507 | hdd_debug("offload is not supported on vdev opmode %d", |
| 508 | adapter->device_mode); |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 509 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 510 | } |
| 511 | |
Rajeev Kumar | 9084cc8 | 2017-10-31 14:32:08 -0700 | [diff] [blame] | 512 | if (!ucfg_pmo_is_vdev_connected(adapter->hdd_vdev)) { |
Dustin Brown | c1cdb71 | 2018-06-11 15:42:17 -0700 | [diff] [blame] | 513 | hdd_debug("offload is not supported on disconnected vdevs"); |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 514 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 515 | } |
| 516 | |
Dustin Brown | c1cdb71 | 2018-06-11 15:42:17 -0700 | [diff] [blame] | 517 | hdd_debug("enable offloads"); |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 518 | hdd_enable_gtk_offload(adapter); |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 519 | hdd_enable_arp_offload(adapter, trigger); |
| 520 | hdd_enable_ns_offload(adapter, trigger); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 521 | hdd_enable_mc_addr_filtering(adapter, trigger); |
Dustin Brown | 1224e21 | 2017-05-12 14:02:12 -0700 | [diff] [blame] | 522 | hdd_enable_hw_filter(adapter); |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 523 | out: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 524 | hdd_exit(); |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 525 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 526 | } |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 527 | |
Jeff Johnson | 75b737d | 2017-08-29 14:24:41 -0700 | [diff] [blame] | 528 | void hdd_disable_host_offloads(struct hdd_adapter *adapter, |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 529 | enum pmo_offload_trigger trigger) |
| 530 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 531 | hdd_enter(); |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 532 | |
Rajeev Kumar | ec1194d | 2017-11-16 17:30:01 -0800 | [diff] [blame] | 533 | if (!ucfg_pmo_is_vdev_supports_offload(adapter->hdd_vdev)) { |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 534 | hdd_info("offload is not supported on this vdev opmode: %d", |
| 535 | adapter->device_mode); |
| 536 | goto out; |
| 537 | } |
| 538 | |
Rajeev Kumar | 9084cc8 | 2017-10-31 14:32:08 -0700 | [diff] [blame] | 539 | if (!ucfg_pmo_is_vdev_connected(adapter->hdd_vdev)) { |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 540 | hdd_info("vdev is not connected"); |
| 541 | goto out; |
| 542 | } |
| 543 | |
Dustin Brown | c1cdb71 | 2018-06-11 15:42:17 -0700 | [diff] [blame] | 544 | hdd_debug("disable offloads"); |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 545 | hdd_disable_gtk_offload(adapter); |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 546 | hdd_disable_arp_offload(adapter, trigger); |
| 547 | hdd_disable_ns_offload(adapter, trigger); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 548 | hdd_disable_mc_addr_filtering(adapter, trigger); |
Dustin Brown | 1224e21 | 2017-05-12 14:02:12 -0700 | [diff] [blame] | 549 | hdd_disable_hw_filter(adapter); |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 550 | out: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 551 | hdd_exit(); |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 552 | |
| 553 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 554 | |
| 555 | /** |
Dustin Brown | 3c31ceb | 2017-02-01 14:43:52 -0800 | [diff] [blame] | 556 | * hdd_lookup_ifaddr() - Lookup interface address data by name |
| 557 | * @adapter: the adapter whose name should be searched for |
| 558 | * |
| 559 | * return in_ifaddr pointer on success, NULL for failure |
| 560 | */ |
Jeff Johnson | 75b737d | 2017-08-29 14:24:41 -0700 | [diff] [blame] | 561 | static struct in_ifaddr *hdd_lookup_ifaddr(struct hdd_adapter *adapter) |
Dustin Brown | 3c31ceb | 2017-02-01 14:43:52 -0800 | [diff] [blame] | 562 | { |
| 563 | struct in_ifaddr *ifa; |
| 564 | struct in_device *in_dev; |
| 565 | |
| 566 | if (!adapter) { |
| 567 | hdd_err("adapter is null"); |
| 568 | return NULL; |
| 569 | } |
| 570 | |
| 571 | in_dev = __in_dev_get_rtnl(adapter->dev); |
| 572 | if (!in_dev) { |
| 573 | hdd_err("Failed to get in_device"); |
| 574 | return NULL; |
| 575 | } |
| 576 | |
| 577 | /* lookup address data by interface name */ |
| 578 | for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) { |
| 579 | if (!strcmp(adapter->dev->name, ifa->ifa_label)) |
| 580 | return ifa; |
| 581 | } |
| 582 | |
| 583 | return NULL; |
| 584 | } |
| 585 | |
| 586 | /** |
| 587 | * hdd_populate_ipv4_addr() - Populates the adapter's IPv4 address |
| 588 | * @adapter: the adapter whose IPv4 address is desired |
| 589 | * @ipv4_addr: the address of the array to copy the IPv4 address into |
| 590 | * |
| 591 | * return: zero for success; non-zero for failure |
| 592 | */ |
Jeff Johnson | d6d1f63 | 2017-10-06 20:06:10 -0700 | [diff] [blame] | 593 | static int hdd_populate_ipv4_addr(struct hdd_adapter *adapter, |
| 594 | uint8_t *ipv4_addr) |
Dustin Brown | 3c31ceb | 2017-02-01 14:43:52 -0800 | [diff] [blame] | 595 | { |
| 596 | struct in_ifaddr *ifa; |
| 597 | int i; |
| 598 | |
| 599 | if (!adapter) { |
| 600 | hdd_err("adapter is null"); |
| 601 | return -EINVAL; |
| 602 | } |
| 603 | |
| 604 | if (!ipv4_addr) { |
| 605 | hdd_err("ipv4_addr is null"); |
| 606 | return -EINVAL; |
| 607 | } |
| 608 | |
| 609 | ifa = hdd_lookup_ifaddr(adapter); |
| 610 | if (!ifa || !ifa->ifa_local) { |
| 611 | hdd_err("ipv4 address not found"); |
| 612 | return -EINVAL; |
| 613 | } |
| 614 | |
| 615 | /* convert u32 to byte array */ |
| 616 | for (i = 0; i < 4; i++) |
| 617 | ipv4_addr[i] = (ifa->ifa_local >> i * 8) & 0xff; |
| 618 | |
| 619 | return 0; |
| 620 | } |
| 621 | |
| 622 | /** |
| 623 | * hdd_set_grat_arp_keepalive() - Enable grat APR keepalive |
| 624 | * @adapter: the HDD adapter to configure |
| 625 | * |
| 626 | * This configures gratuitous APR keepalive based on the adapter's current |
| 627 | * connection information, specifically IPv4 address and BSSID |
| 628 | * |
| 629 | * return: zero for success, non-zero for failure |
| 630 | */ |
Jeff Johnson | 75b737d | 2017-08-29 14:24:41 -0700 | [diff] [blame] | 631 | static int hdd_set_grat_arp_keepalive(struct hdd_adapter *adapter) |
Dustin Brown | 3c31ceb | 2017-02-01 14:43:52 -0800 | [diff] [blame] | 632 | { |
| 633 | QDF_STATUS status; |
| 634 | int exit_code; |
Jeff Johnson | cfb65a8 | 2017-08-28 11:45:41 -0700 | [diff] [blame] | 635 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 636 | struct hdd_station_ctx *sta_ctx; |
Dustin Brown | 3c31ceb | 2017-02-01 14:43:52 -0800 | [diff] [blame] | 637 | tSirKeepAliveReq req = { |
| 638 | .packetType = SIR_KEEP_ALIVE_UNSOLICIT_ARP_RSP, |
Dustin Brown | ce5b3d3 | 2018-01-17 15:07:38 -0800 | [diff] [blame] | 639 | .dest_macaddr = QDF_MAC_ADDR_BCAST_INIT, |
Dustin Brown | 3c31ceb | 2017-02-01 14:43:52 -0800 | [diff] [blame] | 640 | }; |
| 641 | |
| 642 | if (!adapter) { |
| 643 | hdd_err("adapter is null"); |
| 644 | return -EINVAL; |
| 645 | } |
| 646 | |
| 647 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 648 | if (!hdd_ctx) { |
| 649 | hdd_err("hdd_ctx is null"); |
| 650 | return -EINVAL; |
| 651 | } |
| 652 | |
| 653 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 654 | if (!sta_ctx) { |
| 655 | hdd_err("sta_ctx is null"); |
| 656 | return -EINVAL; |
| 657 | } |
| 658 | |
| 659 | exit_code = hdd_populate_ipv4_addr(adapter, req.hostIpv4Addr); |
| 660 | if (exit_code) { |
| 661 | hdd_err("Failed to populate ipv4 address"); |
| 662 | return exit_code; |
| 663 | } |
| 664 | |
Dustin Brown | 6b4643d | 2017-02-09 12:19:28 -0800 | [diff] [blame] | 665 | /* according to RFC5227, sender/target ip address should be the same */ |
| 666 | qdf_mem_copy(&req.destIpv4Addr, &req.hostIpv4Addr, |
| 667 | sizeof(req.destIpv4Addr)); |
| 668 | |
Dustin Brown | 3c31ceb | 2017-02-01 14:43:52 -0800 | [diff] [blame] | 669 | qdf_copy_macaddr(&req.bssid, &sta_ctx->conn_info.bssId); |
| 670 | req.timePeriod = hdd_ctx->config->infraStaKeepAlivePeriod; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 671 | req.sessionId = adapter->session_id; |
Dustin Brown | 3c31ceb | 2017-02-01 14:43:52 -0800 | [diff] [blame] | 672 | |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 673 | hdd_debug("Setting gratuitous ARP keepalive; ipv4_addr:%u.%u.%u.%u", |
Dustin Brown | 3c31ceb | 2017-02-01 14:43:52 -0800 | [diff] [blame] | 674 | req.hostIpv4Addr[0], req.hostIpv4Addr[1], |
| 675 | req.hostIpv4Addr[2], req.hostIpv4Addr[3]); |
| 676 | |
Jeff Johnson | 2954ded | 2018-06-13 16:34:49 -0700 | [diff] [blame] | 677 | status = sme_set_keep_alive(hdd_ctx->mac_handle, req.sessionId, &req); |
Dustin Brown | 3c31ceb | 2017-02-01 14:43:52 -0800 | [diff] [blame] | 678 | if (QDF_IS_STATUS_ERROR(status)) { |
| 679 | hdd_err("Failed to set keepalive"); |
| 680 | return qdf_status_to_os_return(status); |
| 681 | } |
| 682 | |
| 683 | return 0; |
| 684 | } |
| 685 | |
| 686 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 687 | * __hdd_ipv4_notifier_work_queue() - IPv4 notification work function |
| 688 | * @work: registered work item |
| 689 | * |
| 690 | * This function performs the work initially trigged by a callback |
| 691 | * from the IPv4 netdev notifier. Since this means there has been a |
| 692 | * change in IPv4 state for the interface, the ARP offload is |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 693 | * reconfigured. Also, Updates the HLP IE info with IP address info |
| 694 | * to fw if LFR3 is enabled |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 695 | * |
| 696 | * Return: None |
| 697 | */ |
Jeff Johnson | c8d0c25 | 2016-10-05 16:19:50 -0700 | [diff] [blame] | 698 | static void __hdd_ipv4_notifier_work_queue(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 699 | { |
Jeff Johnson | cfb65a8 | 2017-08-28 11:45:41 -0700 | [diff] [blame] | 700 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 75b737d | 2017-08-29 14:24:41 -0700 | [diff] [blame] | 701 | struct hdd_adapter *adapter; |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 702 | int errno; |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 703 | struct csr_roam_profile *roam_profile; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 704 | struct in_ifaddr *ifa; |
Dustin Brown | b6b0f18 | 2017-03-08 13:08:27 -0800 | [diff] [blame] | 705 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 706 | hdd_enter(); |
Dustin Brown | b6b0f18 | 2017-03-08 13:08:27 -0800 | [diff] [blame] | 707 | |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 708 | adapter = container_of(work, struct hdd_adapter, ipv4_notifier_work); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 709 | errno = hdd_validate_adapter(adapter); |
| 710 | if (errno) |
| 711 | goto exit; |
Dustin Brown | b6b0f18 | 2017-03-08 13:08:27 -0800 | [diff] [blame] | 712 | |
| 713 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 714 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 715 | if (errno) |
| 716 | goto exit; |
| 717 | |
| 718 | hdd_enable_arp_offload(adapter, pmo_ipv4_change_notify); |
| 719 | |
Dustin Brown | b6b0f18 | 2017-03-08 13:08:27 -0800 | [diff] [blame] | 720 | if (hdd_ctx->config->sta_keepalive_method == HDD_STA_KEEPALIVE_GRAT_ARP) |
| 721 | hdd_set_grat_arp_keepalive(adapter); |
| 722 | |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 723 | hdd_debug("FILS Roaming support: %d", |
| 724 | hdd_ctx->is_fils_roaming_supported); |
Jeff Johnson | a0c1ca7 | 2018-03-18 14:52:03 -0700 | [diff] [blame] | 725 | roam_profile = hdd_roam_profile(adapter); |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 726 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 727 | ifa = hdd_lookup_ifaddr(adapter); |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 728 | if (ifa && hdd_ctx->is_fils_roaming_supported) |
Jeff Johnson | 2954ded | 2018-06-13 16:34:49 -0700 | [diff] [blame] | 729 | sme_send_hlp_ie_info(hdd_ctx->mac_handle, adapter->session_id, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 730 | roam_profile, ifa->ifa_local); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 731 | exit: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 732 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 733 | } |
| 734 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 735 | void hdd_ipv4_notifier_work_queue(struct work_struct *work) |
| 736 | { |
| 737 | cds_ssr_protect(__func__); |
| 738 | __hdd_ipv4_notifier_work_queue(work); |
| 739 | cds_ssr_unprotect(__func__); |
| 740 | } |
| 741 | |
| 742 | /** |
| 743 | * __wlan_hdd_ipv4_changed() - IPv4 notifier callback function |
| 744 | * @nb: notifier block that was registered with the kernel |
| 745 | * @data: (unused) generic data that was registered with the kernel |
| 746 | * @arg: (unused) generic argument that was registered with the kernel |
| 747 | * |
| 748 | * This is a callback function that is registered with the kernel via |
| 749 | * register_inetaddr_notifier() which allows the driver to be |
| 750 | * notified when there is an IPv4 address change. |
| 751 | * |
| 752 | * Return: NOTIFY_DONE to indicate we don't care what happens with |
| 753 | * other callbacks |
| 754 | */ |
| 755 | static int __wlan_hdd_ipv4_changed(struct notifier_block *nb, |
| 756 | unsigned long data, void *arg) |
| 757 | { |
| 758 | struct in_ifaddr *ifa = (struct in_ifaddr *)arg; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 759 | struct net_device *ndev = ifa->ifa_dev->dev; |
Jeff Johnson | 75b737d | 2017-08-29 14:24:41 -0700 | [diff] [blame] | 760 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
Jeff Johnson | cfb65a8 | 2017-08-28 11:45:41 -0700 | [diff] [blame] | 761 | struct hdd_context *hdd_ctx; |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 762 | int errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 763 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 764 | hdd_enter_dev(ndev); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 765 | |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 766 | errno = hdd_validate_adapter(adapter); |
| 767 | if (errno) |
| 768 | goto exit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 769 | |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 770 | if (adapter->dev == ndev && |
| 771 | (adapter->device_mode == QDF_STA_MODE || |
| 772 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 773 | adapter->device_mode == QDF_NDI_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 774 | |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 775 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 776 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 777 | if (errno) |
| 778 | goto exit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 779 | |
Nachiket Kukade | c9045fe | 2017-06-19 15:14:43 +0530 | [diff] [blame] | 780 | /* Ignore if the interface is down */ |
| 781 | if (!(ndev->flags & IFF_UP)) { |
| 782 | hdd_err("Rcvd change addr request on %s(flags 0x%X)", |
| 783 | ndev->name, ndev->flags); |
| 784 | hdd_err("NETDEV Interface is down, ignoring..."); |
| 785 | goto exit; |
| 786 | } |
Padma, Santhosh Kumar | 8392fb4 | 2017-03-17 12:35:27 +0530 | [diff] [blame] | 787 | hdd_debug("invoking sme_dhcp_done_ind"); |
Jeff Johnson | 2954ded | 2018-06-13 16:34:49 -0700 | [diff] [blame] | 788 | sme_dhcp_done_ind(hdd_ctx->mac_handle, adapter->session_id); |
Abhishek Singh | ca40803 | 2016-09-13 15:26:12 +0530 | [diff] [blame] | 789 | |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 790 | if (!hdd_ctx->config->fhostArpOffload) { |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 791 | hdd_debug("Offload not enabled ARPOffload=%d", |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 792 | hdd_ctx->config->fhostArpOffload); |
| 793 | goto exit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 794 | } |
| 795 | |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 796 | ifa = hdd_lookup_ifaddr(adapter); |
Dustin Brown | 3c31ceb | 2017-02-01 14:43:52 -0800 | [diff] [blame] | 797 | if (ifa && ifa->ifa_local) |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 798 | schedule_work(&adapter->ipv4_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 799 | } |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 800 | |
| 801 | exit: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 802 | hdd_exit(); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 803 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 804 | return NOTIFY_DONE; |
| 805 | } |
| 806 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 807 | int wlan_hdd_ipv4_changed(struct notifier_block *nb, |
| 808 | unsigned long data, void *arg) |
| 809 | { |
| 810 | int ret; |
| 811 | |
| 812 | cds_ssr_protect(__func__); |
| 813 | ret = __wlan_hdd_ipv4_changed(nb, data, arg); |
| 814 | cds_ssr_unprotect(__func__); |
| 815 | |
| 816 | return ret; |
| 817 | } |
| 818 | |
| 819 | /** |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 820 | * hdd_get_ipv4_local_interface() - get ipv4 local interafce from iface list |
Jeff Johnson | f6d2428 | 2017-10-02 13:25:25 -0700 | [diff] [blame] | 821 | * @adapter: Adapter context for which ARP offload is to be configured |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 822 | * |
| 823 | * Return: |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 824 | * ifa - on successful operation, |
| 825 | * NULL - on failure of operation |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 826 | */ |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 827 | static struct in_ifaddr *hdd_get_ipv4_local_interface( |
Jeff Johnson | f6d2428 | 2017-10-02 13:25:25 -0700 | [diff] [blame] | 828 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 829 | { |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 830 | struct in_ifaddr **ifap = NULL; |
| 831 | struct in_ifaddr *ifa = NULL; |
| 832 | struct in_device *in_dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 833 | |
Jeff Johnson | f6d2428 | 2017-10-02 13:25:25 -0700 | [diff] [blame] | 834 | in_dev = __in_dev_get_rtnl(adapter->dev); |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 835 | if (in_dev) { |
| 836 | for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL; |
| 837 | ifap = &ifa->ifa_next) { |
Jeff Johnson | f6d2428 | 2017-10-02 13:25:25 -0700 | [diff] [blame] | 838 | if (!strcmp(adapter->dev->name, ifa->ifa_label)) { |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 839 | /* if match break */ |
| 840 | return ifa; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 841 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 842 | } |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 843 | } |
| 844 | ifa = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 845 | |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 846 | return ifa; |
| 847 | } |
| 848 | |
Jeff Johnson | 75b737d | 2017-08-29 14:24:41 -0700 | [diff] [blame] | 849 | void hdd_enable_arp_offload(struct hdd_adapter *adapter, |
Dustin Brown | c1cdb71 | 2018-06-11 15:42:17 -0700 | [diff] [blame] | 850 | enum pmo_offload_trigger trigger) |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 851 | { |
Jeff Johnson | cfb65a8 | 2017-08-28 11:45:41 -0700 | [diff] [blame] | 852 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 853 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 854 | QDF_STATUS status; |
Dustin Brown | c1cdb71 | 2018-06-11 15:42:17 -0700 | [diff] [blame] | 855 | struct pmo_arp_req *arp_req; |
| 856 | struct in_ifaddr *ifa; |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 857 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 858 | hdd_enter(); |
Dustin Brown | c1cdb71 | 2018-06-11 15:42:17 -0700 | [diff] [blame] | 859 | |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 860 | arp_req = qdf_mem_malloc(sizeof(*arp_req)); |
| 861 | if (!arp_req) { |
| 862 | hdd_err("cannot allocate arp_req"); |
| 863 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 864 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 865 | |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 866 | arp_req->psoc = psoc; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 867 | arp_req->vdev_id = adapter->session_id; |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 868 | arp_req->trigger = trigger; |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 869 | |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 870 | ifa = hdd_get_ipv4_local_interface(adapter); |
Dustin Brown | c1cdb71 | 2018-06-11 15:42:17 -0700 | [diff] [blame] | 871 | if (!ifa || !ifa->ifa_local) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 872 | hdd_info("IP Address is not assigned"); |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 873 | status = QDF_STATUS_NOT_INITIALIZED; |
Dustin Brown | c1cdb71 | 2018-06-11 15:42:17 -0700 | [diff] [blame] | 874 | goto free_req; |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 875 | } |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 876 | |
Dustin Brown | c1cdb71 | 2018-06-11 15:42:17 -0700 | [diff] [blame] | 877 | arp_req->ipv4_addr = (uint32_t)ifa->ifa_local; |
| 878 | |
| 879 | status = pmo_ucfg_cache_arp_offload_req(arp_req); |
| 880 | if (QDF_IS_STATUS_ERROR(status)) { |
| 881 | hdd_err("failed to cache arp offload request"); |
| 882 | goto free_req; |
| 883 | } |
| 884 | |
| 885 | status = pmo_ucfg_enable_arp_offload_in_fwr(adapter->hdd_vdev, trigger); |
| 886 | if (QDF_IS_STATUS_ERROR(status)) { |
| 887 | hdd_err("failed to configure arp offload in firmware"); |
| 888 | goto free_req; |
| 889 | } |
| 890 | |
| 891 | hdd_wlan_offload_event(PMO_IPV4_ARP_REPLY_OFFLOAD, PMO_OFFLOAD_ENABLE); |
| 892 | |
| 893 | free_req: |
| 894 | qdf_mem_free(arp_req); |
| 895 | |
| 896 | out: |
| 897 | hdd_exit(); |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 898 | } |
| 899 | |
Jeff Johnson | 75b737d | 2017-08-29 14:24:41 -0700 | [diff] [blame] | 900 | void hdd_disable_arp_offload(struct hdd_adapter *adapter, |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 901 | enum pmo_offload_trigger trigger) |
| 902 | { |
| 903 | QDF_STATUS status; |
| 904 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 905 | hdd_enter(); |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 906 | status = pmo_ucfg_flush_arp_offload_req(adapter->hdd_vdev); |
| 907 | if (status != QDF_STATUS_SUCCESS) { |
| 908 | hdd_err("Failed to flush arp Offload"); |
| 909 | goto out; |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 910 | } |
| 911 | |
Jeff Johnson | d6d1f63 | 2017-10-06 20:06:10 -0700 | [diff] [blame] | 912 | status = pmo_ucfg_disable_arp_offload_in_fwr(adapter->hdd_vdev, |
| 913 | trigger); |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 914 | if (status == QDF_STATUS_SUCCESS) |
| 915 | hdd_wlan_offload_event(PMO_IPV4_ARP_REPLY_OFFLOAD, |
| 916 | PMO_OFFLOAD_DISABLE); |
| 917 | else |
| 918 | hdd_info("fail to disable arp offload"); |
| 919 | out: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 920 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 921 | } |
| 922 | |
Jeff Johnson | 75b737d | 2017-08-29 14:24:41 -0700 | [diff] [blame] | 923 | void hdd_enable_mc_addr_filtering(struct hdd_adapter *adapter, |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 924 | enum pmo_offload_trigger trigger) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 925 | { |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 926 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 927 | QDF_STATUS status; |
| 928 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 929 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 930 | hdd_enter(); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 931 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 932 | goto out; |
Ravi Joshi | 24477b7 | 2016-07-19 15:45:09 -0700 | [diff] [blame] | 933 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 934 | status = pmo_ucfg_enable_mc_addr_filtering_in_fwr(psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 935 | adapter->session_id, trigger); |
Dustin Brown | c1cdb71 | 2018-06-11 15:42:17 -0700 | [diff] [blame] | 936 | if (QDF_IS_STATUS_ERROR(status)) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 937 | hdd_info("failed to enable mc list status %d", status); |
| 938 | out: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 939 | hdd_exit(); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 940 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 941 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 942 | |
Jeff Johnson | 75b737d | 2017-08-29 14:24:41 -0700 | [diff] [blame] | 943 | void hdd_disable_mc_addr_filtering(struct hdd_adapter *adapter, |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 944 | enum pmo_offload_trigger trigger) |
| 945 | { |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 946 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 947 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 948 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 949 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 950 | hdd_enter(); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 951 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 952 | goto out; |
| 953 | |
| 954 | status = pmo_ucfg_disable_mc_addr_filtering_in_fwr(psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 955 | adapter->session_id, trigger); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 956 | if (status != QDF_STATUS_SUCCESS) |
| 957 | hdd_info("failed to disable mc list status %d", status); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 958 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 959 | out: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 960 | hdd_exit(); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 961 | } |
| 962 | |
| 963 | int hdd_cache_mc_addr_list(struct pmo_mc_addr_list_params *mc_list_config) |
| 964 | { |
| 965 | QDF_STATUS status; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 966 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 967 | hdd_enter(); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 968 | status = pmo_ucfg_cache_mc_addr_list(mc_list_config); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 969 | hdd_exit(); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 970 | |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 971 | return qdf_status_to_os_return(status); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 972 | } |
| 973 | |
Jeff Johnson | 75b737d | 2017-08-29 14:24:41 -0700 | [diff] [blame] | 974 | void hdd_disable_and_flush_mc_addr_list(struct hdd_adapter *adapter, |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 975 | enum pmo_offload_trigger trigger) |
| 976 | { |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 977 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 978 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 979 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 980 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 981 | hdd_enter(); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 982 | /* disable mc list first */ |
| 983 | status = pmo_ucfg_disable_mc_addr_filtering_in_fwr(psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 984 | adapter->session_id, trigger); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 985 | if (status != QDF_STATUS_SUCCESS) |
| 986 | hdd_info("fail to disable mc list"); |
| 987 | |
| 988 | /* flush mc list */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 989 | status = pmo_ucfg_flush_mc_addr_list(psoc, adapter->session_id); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 990 | if (status != QDF_STATUS_SUCCESS) |
| 991 | hdd_info("fail to flush mc list status %d", status); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 992 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 993 | hdd_exit(); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 994 | |
| 995 | return; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 996 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 997 | |
| 998 | /** |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 999 | * hdd_update_conn_state_mask(): record info needed by wma_suspend_req |
| 1000 | * @adapter: adapter to get info from |
| 1001 | * @conn_state_mask: mask of connection info |
| 1002 | * |
| 1003 | * currently only need to send connection info. |
| 1004 | */ |
Jeff Johnson | d6d1f63 | 2017-10-06 20:06:10 -0700 | [diff] [blame] | 1005 | static void hdd_update_conn_state_mask(struct hdd_adapter *adapter, |
| 1006 | uint32_t *conn_state_mask) |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 1007 | { |
| 1008 | |
| 1009 | eConnectionState connState; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 1010 | struct hdd_station_ctx *sta_ctx; |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 1011 | |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 1012 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 1013 | |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 1014 | connState = sta_ctx->conn_info.connState; |
| 1015 | |
| 1016 | if (connState == eConnectionState_Associated || |
| 1017 | connState == eConnectionState_IbssConnected) |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1018 | *conn_state_mask |= (1 << adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1019 | } |
| 1020 | |
| 1021 | /** |
| 1022 | * hdd_suspend_wlan() - Driver suspend function |
| 1023 | * @callback: Callback function to invoke when driver is ready to suspend |
| 1024 | * @callbackContext: Context to pass back to @callback function |
| 1025 | * |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 1026 | * Return: 0 on success else error code. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1027 | */ |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 1028 | static int |
| 1029 | hdd_suspend_wlan(void) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1030 | { |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1031 | struct hdd_context *hdd_ctx; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1032 | QDF_STATUS status; |
Jeff Johnson | f6d2428 | 2017-10-02 13:25:25 -0700 | [diff] [blame] | 1033 | struct hdd_adapter *adapter = NULL; |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 1034 | uint32_t conn_state_mask = 0; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 1035 | |
Jeff Johnson | c327332 | 2016-07-06 15:28:17 -0700 | [diff] [blame] | 1036 | hdd_info("WLAN being suspended by OS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1037 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1038 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 1039 | if (!hdd_ctx) { |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 1040 | hdd_err("HDD context is Null"); |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 1041 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1042 | } |
| 1043 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1044 | if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 1045 | hdd_info("Recovery in Progress. State: 0x%x Ignore suspend!!!", |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 1046 | cds_get_driver_state()); |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 1047 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1048 | } |
| 1049 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 1050 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1051 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 1052 | hdd_err("invalid session id: %d", adapter->session_id); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 1053 | continue; |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 1054 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1055 | |
| 1056 | /* stop all TX queues before suspend */ |
Dustin Brown | c1cdb71 | 2018-06-11 15:42:17 -0700 | [diff] [blame] | 1057 | hdd_debug("Disabling queues for dev mode %s", |
| 1058 | hdd_device_mode_to_string(adapter->device_mode)); |
Jeff Johnson | f6d2428 | 2017-10-02 13:25:25 -0700 | [diff] [blame] | 1059 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 1060 | WLAN_STOP_ALL_NETIF_QUEUE, |
| 1061 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1062 | |
Hanumanth Reddy Pothula | 3def894 | 2017-10-05 16:19:36 +0530 | [diff] [blame] | 1063 | if (adapter->device_mode == QDF_STA_MODE) |
| 1064 | status = hdd_enable_default_pkt_filters(adapter); |
| 1065 | |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 1066 | /* Configure supported OffLoads */ |
Jeff Johnson | f6d2428 | 2017-10-02 13:25:25 -0700 | [diff] [blame] | 1067 | hdd_enable_host_offloads(adapter, pmo_apps_suspend); |
| 1068 | hdd_update_conn_state_mask(adapter, &conn_state_mask); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1069 | } |
| 1070 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1071 | status = pmo_ucfg_psoc_user_space_suspend_req(hdd_ctx->hdd_psoc, |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 1072 | QDF_SYSTEM_SUSPEND); |
| 1073 | if (status != QDF_STATUS_SUCCESS) |
| 1074 | return -EAGAIN; |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 1075 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1076 | hdd_ctx->hdd_wlan_suspended = true; |
Abhishek Singh | baea27d | 2016-04-27 13:29:30 +0530 | [diff] [blame] | 1077 | hdd_wlan_suspend_resume_event(HDD_WLAN_EARLY_SUSPEND); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1078 | |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 1079 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1080 | } |
| 1081 | |
| 1082 | /** |
| 1083 | * hdd_resume_wlan() - Driver resume function |
| 1084 | * |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 1085 | * Return: 0 on success else error code. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1086 | */ |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 1087 | static int hdd_resume_wlan(void) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1088 | { |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1089 | struct hdd_context *hdd_ctx; |
Dustin Brown | c1cdb71 | 2018-06-11 15:42:17 -0700 | [diff] [blame] | 1090 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1091 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1092 | |
Dustin Brown | 2d22823 | 2016-09-22 15:06:19 -0700 | [diff] [blame] | 1093 | hdd_info("WLAN being resumed by OS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1094 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1095 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 1096 | if (!hdd_ctx) { |
Dustin Brown | 2d22823 | 2016-09-22 15:06:19 -0700 | [diff] [blame] | 1097 | hdd_err("HDD context is Null"); |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 1098 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1099 | } |
| 1100 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1101 | if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 1102 | hdd_info("Recovery in Progress. State: 0x%x Ignore resume!!!", |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 1103 | cds_get_driver_state()); |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 1104 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1105 | } |
| 1106 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1107 | hdd_ctx->hdd_wlan_suspended = false; |
Abhishek Singh | baea27d | 2016-04-27 13:29:30 +0530 | [diff] [blame] | 1108 | hdd_wlan_suspend_resume_event(HDD_WLAN_EARLY_RESUME); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1109 | |
| 1110 | /*loop through all adapters. Concurrency */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 1111 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1112 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 1113 | hdd_err("invalid session id: %d", adapter->session_id); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 1114 | continue; |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 1115 | } |
| 1116 | /* Disable supported OffLoads */ |
Jeff Johnson | f6d2428 | 2017-10-02 13:25:25 -0700 | [diff] [blame] | 1117 | hdd_disable_host_offloads(adapter, pmo_apps_resume); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1118 | |
| 1119 | /* wake the tx queues */ |
Dustin Brown | c1cdb71 | 2018-06-11 15:42:17 -0700 | [diff] [blame] | 1120 | hdd_debug("Enabling queues for dev mode %s", |
| 1121 | hdd_device_mode_to_string(adapter->device_mode)); |
Jeff Johnson | f6d2428 | 2017-10-02 13:25:25 -0700 | [diff] [blame] | 1122 | wlan_hdd_netif_queue_control(adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1123 | WLAN_WAKE_ALL_NETIF_QUEUE, |
| 1124 | WLAN_CONTROL_PATH); |
| 1125 | |
Hanumanth Reddy Pothula | 3def894 | 2017-10-05 16:19:36 +0530 | [diff] [blame] | 1126 | if (adapter->device_mode == QDF_STA_MODE) |
| 1127 | status = hdd_disable_default_pkt_filters(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1128 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 1129 | |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 1130 | ucfg_ipa_resume(hdd_ctx->hdd_pdev); |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1131 | status = pmo_ucfg_psoc_user_space_resume_req(hdd_ctx->hdd_psoc, |
Dustin Brown | c1cdb71 | 2018-06-11 15:42:17 -0700 | [diff] [blame] | 1132 | QDF_SYSTEM_SUSPEND); |
| 1133 | if (QDF_IS_STATUS_ERROR(status)) |
| 1134 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1135 | |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 1136 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1137 | } |
| 1138 | |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 1139 | void hdd_svc_fw_shutdown_ind(struct device *dev) |
| 1140 | { |
Jeff Johnson | cfb65a8 | 2017-08-28 11:45:41 -0700 | [diff] [blame] | 1141 | struct hdd_context *hdd_ctx; |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 1142 | |
| 1143 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 1144 | |
| 1145 | hdd_ctx ? wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 1146 | WLAN_SVC_FW_SHUTDOWN_IND, |
| 1147 | NULL, 0) : 0; |
| 1148 | } |
| 1149 | |
| 1150 | /** |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 1151 | * hdd_ssr_restart_sap() - restart sap on SSR |
| 1152 | * @hdd_ctx: hdd context |
| 1153 | * |
| 1154 | * Return: nothing |
| 1155 | */ |
Jeff Johnson | cfb65a8 | 2017-08-28 11:45:41 -0700 | [diff] [blame] | 1156 | static void hdd_ssr_restart_sap(struct hdd_context *hdd_ctx) |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 1157 | { |
Jeff Johnson | 75b737d | 2017-08-29 14:24:41 -0700 | [diff] [blame] | 1158 | struct hdd_adapter *adapter; |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 1159 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 1160 | hdd_enter(); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 1161 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 1162 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 1163 | if (adapter->device_mode == QDF_SAP_MODE) { |
Manikandan Mohan | 0a0ac95 | 2017-02-16 15:49:31 -0800 | [diff] [blame] | 1164 | if (test_bit(SOFTAP_INIT_DONE, &adapter->event_flags)) { |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 1165 | hdd_debug("Restart prev SAP session"); |
Manikandan Mohan | 0a0ac95 | 2017-02-16 15:49:31 -0800 | [diff] [blame] | 1166 | wlan_hdd_start_sap(adapter, true); |
| 1167 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 1168 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 1169 | } |
| 1170 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 1171 | hdd_exit(); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 1172 | } |
| 1173 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1174 | QDF_STATUS hdd_wlan_shutdown(void) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1175 | { |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1176 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1177 | p_cds_sched_context cds_sched_context = NULL; |
Manikandan Mohan | 8b4e201 | 2017-03-22 11:15:55 -0700 | [diff] [blame] | 1178 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1179 | |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 1180 | hdd_info("WLAN driver shutting down!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1181 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1182 | /* Get the HDD context. */ |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1183 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 1184 | if (!hdd_ctx) { |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 1185 | hdd_err("HDD context is Null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1186 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1187 | } |
| 1188 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1189 | policy_mgr_clear_concurrent_session_count(hdd_ctx->hdd_psoc); |
Himanshu Agarwal | f65bd4c | 2016-12-05 17:21:12 +0530 | [diff] [blame] | 1190 | |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 1191 | hdd_debug("Invoking packetdump deregistration API"); |
Himanshu Agarwal | f65bd4c | 2016-12-05 17:21:12 +0530 | [diff] [blame] | 1192 | wlan_deregister_txrx_packetdump(); |
jitiphil | fb41061 | 2018-03-26 22:37:56 +0530 | [diff] [blame] | 1193 | |
| 1194 | /* |
| 1195 | * After SSR, FW clear its txrx stats. In host, |
| 1196 | * as adapter is intact so those counts are still |
| 1197 | * available. Now if agains Set stats command comes, |
| 1198 | * then host will increment its counts start from its |
| 1199 | * last saved value, i.e., count before SSR, and FW will |
| 1200 | * increment its count from 0. This will finally sends a |
| 1201 | * mismatch of packet counts b/w host and FW to framework |
| 1202 | * that will create ambiquity. Therfore, Resetting the host |
| 1203 | * counts here so that after SSR both FW and host start |
| 1204 | * increment their counts from 0. |
| 1205 | */ |
| 1206 | hdd_reset_all_adapters_connectivity_stats(hdd_ctx); |
| 1207 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1208 | hdd_reset_all_adapters(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1209 | |
Poddar, Siddarth | 1ab0a3d | 2016-09-29 18:58:45 +0530 | [diff] [blame] | 1210 | /* Flush cached rx frame queue */ |
Manikandan Mohan | 8b4e201 | 2017-03-22 11:15:55 -0700 | [diff] [blame] | 1211 | if (soc) |
| 1212 | cdp_flush_cache_rx_queue(soc); |
Poddar, Siddarth | 1ab0a3d | 2016-09-29 18:58:45 +0530 | [diff] [blame] | 1213 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 1214 | /* De-register the HDD callbacks */ |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1215 | hdd_deregister_cb(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1216 | |
| 1217 | cds_sched_context = get_cds_sched_ctxt(); |
| 1218 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1219 | if (hdd_ctx->is_scheduler_suspended) { |
Rajeev Kumar | 0b73295 | 2016-12-08 17:51:39 -0800 | [diff] [blame] | 1220 | scheduler_resume(); |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1221 | hdd_ctx->is_scheduler_suspended = false; |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 1222 | hdd_ctx->is_wiphy_suspended = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1223 | } |
| 1224 | #ifdef QCA_CONFIG_SMP |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1225 | if (true == hdd_ctx->is_ol_rx_thread_suspended) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1226 | complete(&cds_sched_context->ol_resume_rx_event); |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1227 | hdd_ctx->is_ol_rx_thread_suspended = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1228 | } |
| 1229 | #endif |
| 1230 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1231 | hdd_bus_bandwidth_destroy(hdd_ctx); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 1232 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1233 | hdd_wlan_stop_modules(hdd_ctx, false); |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 1234 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1235 | hdd_lpass_notify_stop(hdd_ctx); |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 1236 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1237 | wlan_objmgr_print_ref_all_objects_per_psoc(hdd_ctx->hdd_psoc); |
Yue Ma | 2be1287 | 2017-06-02 13:06:58 -0700 | [diff] [blame] | 1238 | |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 1239 | hdd_info("WLAN driver shutdown complete"); |
Yue Ma | 2be1287 | 2017-06-02 13:06:58 -0700 | [diff] [blame] | 1240 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1241 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1242 | } |
| 1243 | |
Sen, Devendra | 154b3c4 | 2017-02-13 20:44:15 +0530 | [diff] [blame] | 1244 | #ifdef FEATURE_WLAN_DIAG_SUPPORT |
| 1245 | /** |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 1246 | * hdd_wlan_ssr_reinit_event()- send ssr reinit state |
| 1247 | * |
| 1248 | * This Function send send ssr reinit state diag event |
| 1249 | * |
| 1250 | * Return: void. |
| 1251 | */ |
Sen, Devendra | 154b3c4 | 2017-02-13 20:44:15 +0530 | [diff] [blame] | 1252 | static void hdd_wlan_ssr_reinit_event(void) |
| 1253 | { |
| 1254 | WLAN_HOST_DIAG_EVENT_DEF(ssr_reinit, struct host_event_wlan_ssr_reinit); |
| 1255 | qdf_mem_zero(&ssr_reinit, sizeof(ssr_reinit)); |
| 1256 | ssr_reinit.status = SSR_SUB_SYSTEM_REINIT; |
| 1257 | WLAN_HOST_DIAG_EVENT_REPORT(&ssr_reinit, |
| 1258 | EVENT_WLAN_SSR_REINIT_SUBSYSTEM); |
| 1259 | } |
| 1260 | #else |
| 1261 | static inline void hdd_wlan_ssr_reinit_event(void) |
| 1262 | { |
| 1263 | |
| 1264 | } |
| 1265 | #endif |
| 1266 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1267 | /** |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 1268 | * hdd_send_default_scan_ies - send default scan ies to fw |
| 1269 | * |
| 1270 | * This function is used to send default scan ies to fw |
| 1271 | * in case of wlan re-init |
| 1272 | * |
| 1273 | * Return: void |
| 1274 | */ |
| 1275 | static void hdd_send_default_scan_ies(struct hdd_context *hdd_ctx) |
| 1276 | { |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 1277 | struct hdd_adapter *adapter; |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 1278 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 1279 | hdd_for_each_adapter(hdd_ctx, adapter) { |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 1280 | if (hdd_is_interface_up(adapter) && |
| 1281 | (adapter->device_mode == QDF_STA_MODE || |
Hanumanth Reddy Pothula | 53dec12 | 2017-12-12 17:08:18 +0530 | [diff] [blame] | 1282 | adapter->device_mode == QDF_P2P_DEVICE_MODE) && |
| 1283 | adapter->scan_info.default_scan_ies) { |
Jeff Johnson | 2954ded | 2018-06-13 16:34:49 -0700 | [diff] [blame] | 1284 | sme_set_default_scan_ie(hdd_ctx->mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1285 | adapter->session_id, |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 1286 | adapter->scan_info.default_scan_ies, |
| 1287 | adapter->scan_info.default_scan_ies_len); |
| 1288 | } |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 1289 | } |
| 1290 | } |
| 1291 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1292 | QDF_STATUS hdd_wlan_re_init(void) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1293 | { |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1294 | struct hdd_context *hdd_ctx = NULL; |
Jeff Johnson | f6d2428 | 2017-10-02 13:25:25 -0700 | [diff] [blame] | 1295 | struct hdd_adapter *adapter; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1296 | int ret; |
Mukul Sharma | f7d62e1 | 2016-09-03 15:16:22 +0530 | [diff] [blame] | 1297 | bool bug_on_reinit_failure = CFG_BUG_ON_REINIT_FAILURE_DEFAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1298 | |
| 1299 | hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_REINIT); |
| 1300 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1301 | /* Get the HDD context */ |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1302 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 1303 | if (!hdd_ctx) { |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 1304 | hdd_err("HDD context is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1305 | goto err_re_init; |
| 1306 | } |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1307 | bug_on_reinit_failure = hdd_ctx->config->bug_on_reinit_failure; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1308 | |
Sourav Mohapatra | 92ea8d6 | 2018-02-05 10:03:10 +0530 | [diff] [blame] | 1309 | adapter = hdd_get_first_valid_adapter(hdd_ctx); |
| 1310 | if (!adapter) |
| 1311 | hdd_err("Failed to get adapter"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1312 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 1313 | hdd_dp_trace_init(hdd_ctx->config); |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 1314 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1315 | hdd_bus_bandwidth_init(hdd_ctx); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 1316 | |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 1317 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 1318 | ret = hdd_wlan_start_modules(hdd_ctx, true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1319 | if (ret) { |
| 1320 | hdd_err("Failed to start wlan after error"); |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1321 | goto err_re_init; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1322 | } |
| 1323 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 1324 | hdd_update_hw_sw_info(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1325 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1326 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 1327 | WLAN_SVC_FW_CRASHED_IND, NULL, 0); |
| 1328 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1329 | /* Restart all adapters */ |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1330 | hdd_start_all_adapters(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1331 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1332 | hdd_ctx->last_scan_reject_session_id = 0xFF; |
| 1333 | hdd_ctx->last_scan_reject_reason = 0; |
| 1334 | hdd_ctx->last_scan_reject_timestamp = 0; |
| 1335 | hdd_ctx->scan_reject_cnt = 0; |
Sreelakshmi Konamki | b53c629 | 2017-03-01 13:13:23 +0530 | [diff] [blame] | 1336 | |
Selvaraj, Sridhar | 1c48756 | 2017-04-19 14:29:07 +0530 | [diff] [blame] | 1337 | hdd_set_roaming_in_progress(false); |
Jeff Johnson | f6d2428 | 2017-10-02 13:25:25 -0700 | [diff] [blame] | 1338 | complete(&adapter->roaming_comp_var); |
Jeff Johnson | 59b1931 | 2017-11-02 21:14:33 -0700 | [diff] [blame] | 1339 | hdd_ctx->bt_coex_mode_set = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1340 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1341 | /* Allow the phone to go to sleep */ |
| 1342 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_REINIT); |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 1343 | /* set chip power save failure detected callback */ |
Jeff Johnson | 2954ded | 2018-06-13 16:34:49 -0700 | [diff] [blame] | 1344 | sme_set_chip_pwr_save_fail_cb(hdd_ctx->mac_handle, |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 1345 | hdd_chip_pwr_save_fail_detected_cb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1346 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1347 | hdd_lpass_notify_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1348 | |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 1349 | hdd_send_default_scan_ies(hdd_ctx); |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 1350 | hdd_info("WLAN host driver reinitiation completed!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1351 | goto success; |
| 1352 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1353 | err_re_init: |
Rachit Kankane | 3080733 | 2018-06-27 18:39:36 +0530 | [diff] [blame] | 1354 | qdf_dp_trace_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1355 | /* Allow the phone to go to sleep */ |
| 1356 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_REINIT); |
Mukul Sharma | f7d62e1 | 2016-09-03 15:16:22 +0530 | [diff] [blame] | 1357 | if (bug_on_reinit_failure) |
| 1358 | QDF_BUG(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1359 | return -EPERM; |
| 1360 | |
| 1361 | success: |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1362 | if (hdd_ctx->config->sap_internal_restart) |
| 1363 | hdd_ssr_restart_sap(hdd_ctx); |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1364 | |
Sen, Devendra | 154b3c4 | 2017-02-13 20:44:15 +0530 | [diff] [blame] | 1365 | hdd_wlan_ssr_reinit_event(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1366 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1367 | } |
| 1368 | |
Jeff Johnson | 75b737d | 2017-08-29 14:24:41 -0700 | [diff] [blame] | 1369 | int wlan_hdd_set_powersave(struct hdd_adapter *adapter, |
Dustin Brown | f660fb4 | 2016-09-09 12:04:00 -0700 | [diff] [blame] | 1370 | bool allow_power_save, uint32_t timeout) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1371 | { |
Jeff Johnson | 2954ded | 2018-06-13 16:34:49 -0700 | [diff] [blame] | 1372 | mac_handle_t mac_handle; |
Jeff Johnson | cfb65a8 | 2017-08-28 11:45:41 -0700 | [diff] [blame] | 1373 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1374 | |
| 1375 | if (NULL == adapter) { |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 1376 | hdd_err("Adapter NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1377 | return -ENODEV; |
| 1378 | } |
| 1379 | |
| 1380 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 1381 | if (!hdd_ctx) { |
Jeff Johnson | c327332 | 2016-07-06 15:28:17 -0700 | [diff] [blame] | 1382 | hdd_err("hdd context is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1383 | return -EINVAL; |
| 1384 | } |
| 1385 | |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 1386 | hdd_debug("Allow power save: %d", allow_power_save); |
Jeff Johnson | 2954ded | 2018-06-13 16:34:49 -0700 | [diff] [blame] | 1387 | mac_handle = hdd_ctx->mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1388 | |
Dustin Brown | 84411b0 | 2017-07-21 16:44:44 -0700 | [diff] [blame] | 1389 | /* |
| 1390 | * This is a workaround for defective AP's that send a disassoc |
| 1391 | * immediately after WPS connection completes. Defer powersave by a |
| 1392 | * small amount if the affected AP is detected. |
| 1393 | */ |
| 1394 | if (allow_power_save && |
| 1395 | adapter->device_mode == QDF_STA_MODE && |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 1396 | !adapter->session.station.ap_supports_immediate_power_save) { |
Dustin Brown | 84411b0 | 2017-07-21 16:44:44 -0700 | [diff] [blame] | 1397 | timeout = AUTO_PS_DEFER_TIMEOUT_MS; |
| 1398 | hdd_debug("Defer power-save due to AP spec non-conformance"); |
Krunal Soni | 364e087 | 2017-05-10 21:24:34 -0700 | [diff] [blame] | 1399 | } |
| 1400 | |
Dustin Brown | f660fb4 | 2016-09-09 12:04:00 -0700 | [diff] [blame] | 1401 | if (allow_power_save) { |
| 1402 | if (QDF_STA_MODE == adapter->device_mode || |
| 1403 | QDF_P2P_CLIENT_MODE == adapter->device_mode) { |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 1404 | hdd_debug("Disabling Auto Power save timer"); |
Jeff Johnson | 2954ded | 2018-06-13 16:34:49 -0700 | [diff] [blame] | 1405 | sme_ps_disable_auto_ps_timer(mac_handle, |
| 1406 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1407 | } |
Dustin Brown | f660fb4 | 2016-09-09 12:04:00 -0700 | [diff] [blame] | 1408 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1409 | if (hdd_ctx->config && hdd_ctx->config->is_ps_enabled) { |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 1410 | hdd_debug("Wlan driver Entering Power save"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1411 | |
| 1412 | /* |
| 1413 | * Enter Power Save command received from GUI |
| 1414 | * this means DHCP is completed |
| 1415 | */ |
Yeshwanth Sriram Guntuka | ae03c43 | 2017-11-12 13:31:02 +0530 | [diff] [blame] | 1416 | if (timeout) |
Jeff Johnson | 2954ded | 2018-06-13 16:34:49 -0700 | [diff] [blame] | 1417 | sme_ps_enable_auto_ps_timer(mac_handle, |
Yeshwanth Sriram Guntuka | ae03c43 | 2017-11-12 13:31:02 +0530 | [diff] [blame] | 1418 | adapter->session_id, |
| 1419 | timeout); |
| 1420 | else |
Jeff Johnson | 2954ded | 2018-06-13 16:34:49 -0700 | [diff] [blame] | 1421 | sme_ps_enable_disable(mac_handle, |
| 1422 | adapter->session_id, |
Yeshwanth Sriram Guntuka | ae03c43 | 2017-11-12 13:31:02 +0530 | [diff] [blame] | 1423 | SME_PS_ENABLE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1424 | } else { |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 1425 | hdd_debug("Power Save is not enabled in the cfg"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1426 | } |
Dustin Brown | f660fb4 | 2016-09-09 12:04:00 -0700 | [diff] [blame] | 1427 | } else { |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 1428 | hdd_debug("Wlan driver Entering Full Power"); |
Dustin Brown | f660fb4 | 2016-09-09 12:04:00 -0700 | [diff] [blame] | 1429 | |
| 1430 | /* |
| 1431 | * Enter Full power command received from GUI |
| 1432 | * this means we are disconnected |
| 1433 | */ |
Jeff Johnson | 2954ded | 2018-06-13 16:34:49 -0700 | [diff] [blame] | 1434 | sme_ps_disable_auto_ps_timer(mac_handle, |
| 1435 | adapter->session_id); |
| 1436 | sme_ps_enable_disable(mac_handle, adapter->session_id, |
| 1437 | SME_PS_DISABLE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1438 | } |
Dustin Brown | f660fb4 | 2016-09-09 12:04:00 -0700 | [diff] [blame] | 1439 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1440 | return 0; |
| 1441 | } |
| 1442 | |
Jeff Johnson | cfb65a8 | 2017-08-28 11:45:41 -0700 | [diff] [blame] | 1443 | static void wlan_hdd_print_suspend_fail_stats(struct hdd_context *hdd_ctx) |
Dustin Brown | 105d790 | 2016-10-03 16:27:59 -0700 | [diff] [blame] | 1444 | { |
Dustin Brown | d932248 | 2017-01-09 12:46:03 -0800 | [diff] [blame] | 1445 | struct suspend_resume_stats *stats = &hdd_ctx->suspend_resume_stats; |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 1446 | |
Dustin Brown | 105d790 | 2016-10-03 16:27:59 -0700 | [diff] [blame] | 1447 | hdd_err("ipa:%d, radar:%d, roam:%d, scan:%d, initial_wakeup:%d", |
Dustin Brown | d932248 | 2017-01-09 12:46:03 -0800 | [diff] [blame] | 1448 | stats->suspend_fail[SUSPEND_FAIL_IPA], |
| 1449 | stats->suspend_fail[SUSPEND_FAIL_RADAR], |
| 1450 | stats->suspend_fail[SUSPEND_FAIL_ROAM], |
| 1451 | stats->suspend_fail[SUSPEND_FAIL_SCAN], |
| 1452 | stats->suspend_fail[SUSPEND_FAIL_INITIAL_WAKEUP]); |
Dustin Brown | 105d790 | 2016-10-03 16:27:59 -0700 | [diff] [blame] | 1453 | } |
| 1454 | |
Jeff Johnson | cfb65a8 | 2017-08-28 11:45:41 -0700 | [diff] [blame] | 1455 | void wlan_hdd_inc_suspend_stats(struct hdd_context *hdd_ctx, |
Dustin Brown | 105d790 | 2016-10-03 16:27:59 -0700 | [diff] [blame] | 1456 | enum suspend_fail_reason reason) |
| 1457 | { |
| 1458 | wlan_hdd_print_suspend_fail_stats(hdd_ctx); |
Dustin Brown | d932248 | 2017-01-09 12:46:03 -0800 | [diff] [blame] | 1459 | hdd_ctx->suspend_resume_stats.suspend_fail[reason]++; |
Dustin Brown | 105d790 | 2016-10-03 16:27:59 -0700 | [diff] [blame] | 1460 | wlan_hdd_print_suspend_fail_stats(hdd_ctx); |
| 1461 | } |
| 1462 | |
Dustin Brown | 5fbb105 | 2017-08-11 17:25:51 -0700 | [diff] [blame] | 1463 | #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0) |
| 1464 | static inline void |
| 1465 | hdd_sched_scan_results(struct wiphy *wiphy, uint64_t reqid) |
| 1466 | { |
| 1467 | cfg80211_sched_scan_results(wiphy); |
| 1468 | } |
| 1469 | #else |
| 1470 | static inline void |
| 1471 | hdd_sched_scan_results(struct wiphy *wiphy, uint64_t reqid) |
| 1472 | { |
| 1473 | cfg80211_sched_scan_results(wiphy, reqid); |
| 1474 | } |
| 1475 | #endif |
| 1476 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1477 | /** |
| 1478 | * __wlan_hdd_cfg80211_resume_wlan() - cfg80211 resume callback |
| 1479 | * @wiphy: Pointer to wiphy |
| 1480 | * |
| 1481 | * This API is called when cfg80211 driver resumes driver updates |
| 1482 | * latest sched_scan scan result(if any) to cfg80211 database |
| 1483 | * |
| 1484 | * Return: integer status |
| 1485 | */ |
| 1486 | static int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy) |
| 1487 | { |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1488 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1489 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Dustin Brown | d932248 | 2017-01-09 12:46:03 -0800 | [diff] [blame] | 1490 | int exit_code; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1491 | p_cds_sched_context cds_sched_context = get_cds_sched_ctxt(); |
| 1492 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 1493 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1494 | |
Dustin Brown | d932248 | 2017-01-09 12:46:03 -0800 | [diff] [blame] | 1495 | if (cds_is_driver_recovering()) { |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 1496 | hdd_debug("Driver is recovering; Skipping resume"); |
Dustin Brown | d932248 | 2017-01-09 12:46:03 -0800 | [diff] [blame] | 1497 | exit_code = 0; |
| 1498 | goto exit_with_code; |
| 1499 | } |
Prashanth Bhatta | 697dd0c | 2016-10-20 18:42:41 -0700 | [diff] [blame] | 1500 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1501 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | c327332 | 2016-07-06 15:28:17 -0700 | [diff] [blame] | 1502 | hdd_err("Command not allowed in FTM mode"); |
Dustin Brown | d932248 | 2017-01-09 12:46:03 -0800 | [diff] [blame] | 1503 | exit_code = -EINVAL; |
| 1504 | goto exit_with_code; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1505 | } |
| 1506 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1507 | exit_code = wlan_hdd_validate_context(hdd_ctx); |
Dustin Brown | d932248 | 2017-01-09 12:46:03 -0800 | [diff] [blame] | 1508 | if (exit_code) { |
| 1509 | hdd_err("Invalid HDD context"); |
| 1510 | goto exit_with_code; |
| 1511 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1512 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1513 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 1514 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 1515 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 1516 | hdd_debug("Driver is not enabled; Skipping resume"); |
Dustin Brown | d932248 | 2017-01-09 12:46:03 -0800 | [diff] [blame] | 1517 | exit_code = 0; |
| 1518 | goto exit_with_code; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1519 | } |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1520 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | d932248 | 2017-01-09 12:46:03 -0800 | [diff] [blame] | 1521 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1522 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, PLD_BUS_WIDTH_MEDIUM); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1523 | |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 1524 | status = hdd_resume_wlan(); |
| 1525 | if (status != QDF_STATUS_SUCCESS) { |
| 1526 | exit_code = 0; |
| 1527 | goto exit_with_code; |
| 1528 | } |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 1529 | /* Resume control path scheduler */ |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1530 | if (hdd_ctx->is_scheduler_suspended) { |
Rajeev Kumar | 0b73295 | 2016-12-08 17:51:39 -0800 | [diff] [blame] | 1531 | scheduler_resume(); |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1532 | hdd_ctx->is_scheduler_suspended = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1533 | } |
| 1534 | #ifdef QCA_CONFIG_SMP |
| 1535 | /* Resume tlshim Rx thread */ |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1536 | if (hdd_ctx->is_ol_rx_thread_suspended) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1537 | complete(&cds_sched_context->ol_resume_rx_event); |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1538 | hdd_ctx->is_ol_rx_thread_suspended = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1539 | } |
| 1540 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1541 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1542 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Sreelakshmi Konamki | 6744cff | 2015-09-07 12:10:39 +0530 | [diff] [blame] | 1543 | TRACE_CODE_HDD_CFG80211_RESUME_WLAN, |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 1544 | NO_SESSION, hdd_ctx->is_wiphy_suspended)); |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 1545 | hdd_ctx->is_wiphy_suspended = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1546 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1547 | hdd_ctx->suspend_resume_stats.resumes++; |
Dustin Brown | d932248 | 2017-01-09 12:46:03 -0800 | [diff] [blame] | 1548 | exit_code = 0; |
| 1549 | |
| 1550 | exit_with_code: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 1551 | hdd_exit(); |
Dustin Brown | d932248 | 2017-01-09 12:46:03 -0800 | [diff] [blame] | 1552 | return exit_code; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1553 | } |
| 1554 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1555 | int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy) |
| 1556 | { |
| 1557 | int ret; |
| 1558 | |
| 1559 | cds_ssr_protect(__func__); |
| 1560 | ret = __wlan_hdd_cfg80211_resume_wlan(wiphy); |
| 1561 | cds_ssr_unprotect(__func__); |
| 1562 | |
| 1563 | return ret; |
| 1564 | } |
| 1565 | |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 1566 | static void hdd_suspend_cb(void) |
| 1567 | { |
Jeff Johnson | cfb65a8 | 2017-08-28 11:45:41 -0700 | [diff] [blame] | 1568 | struct hdd_context *hdd_ctx; |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 1569 | |
| 1570 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 1571 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 1572 | hdd_err("HDD context is NULL"); |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 1573 | return; |
| 1574 | } |
| 1575 | |
| 1576 | complete(&hdd_ctx->mc_sus_event_var); |
| 1577 | } |
| 1578 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1579 | /** |
| 1580 | * __wlan_hdd_cfg80211_suspend_wlan() - cfg80211 suspend callback |
| 1581 | * @wiphy: Pointer to wiphy |
| 1582 | * @wow: Pointer to wow |
| 1583 | * |
| 1584 | * This API is called when cfg80211 driver suspends |
| 1585 | * |
| 1586 | * Return: integer status |
| 1587 | */ |
| 1588 | static int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy, |
| 1589 | struct cfg80211_wowlan *wow) |
| 1590 | { |
| 1591 | #ifdef QCA_CONFIG_SMP |
| 1592 | #define RX_TLSHIM_SUSPEND_TIMEOUT 200 /* msecs */ |
| 1593 | #endif |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1594 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1595 | p_cds_sched_context cds_sched_context = get_cds_sched_ctxt(); |
Jeff Johnson | f6d2428 | 2017-10-02 13:25:25 -0700 | [diff] [blame] | 1596 | struct hdd_adapter *adapter; |
Jeff Johnson | 5287de5 | 2017-10-28 12:23:06 -0700 | [diff] [blame] | 1597 | struct hdd_scan_info *scan_info; |
Jeff Johnson | 2954ded | 2018-06-13 16:34:49 -0700 | [diff] [blame] | 1598 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1599 | int rc; |
| 1600 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 1601 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1602 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1603 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | c327332 | 2016-07-06 15:28:17 -0700 | [diff] [blame] | 1604 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1605 | return -EINVAL; |
| 1606 | } |
| 1607 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1608 | rc = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 1609 | if (0 != rc) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1610 | return rc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1611 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1612 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 1613 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 1614 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 1615 | hdd_debug("Driver Modules not Enabled "); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1616 | return 0; |
| 1617 | } |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1618 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1619 | |
Jeff Johnson | 2954ded | 2018-06-13 16:34:49 -0700 | [diff] [blame] | 1620 | mac_handle = hdd_ctx->mac_handle; |
| 1621 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1622 | /* If RADAR detection is in progress (HDD), prevent suspend. The flag |
| 1623 | * "dfs_cac_block_tx" is set to true when RADAR is found and stay true |
| 1624 | * until CAC is done for a SoftAP which is in started state. |
| 1625 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 1626 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1627 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
Rajeev Kumar | 9176ca4 | 2018-05-03 09:20:40 -0700 | [diff] [blame] | 1628 | hdd_debug("invalid session id: %d", adapter->session_id); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 1629 | continue; |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 1630 | } |
| 1631 | |
Jeff Johnson | f6d2428 | 2017-10-02 13:25:25 -0700 | [diff] [blame] | 1632 | if (QDF_SAP_MODE == adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1633 | if (BSS_START == |
Jeff Johnson | 0f9f87b | 2017-10-28 09:21:06 -0700 | [diff] [blame] | 1634 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter)->bss_state && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1635 | true == |
Jeff Johnson | f6d2428 | 2017-10-02 13:25:25 -0700 | [diff] [blame] | 1636 | WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1637 | dfs_cac_block_tx) { |
Dustin Brown | 2d22823 | 2016-09-22 15:06:19 -0700 | [diff] [blame] | 1638 | hdd_err("RADAR detection in progress, do not allow suspend"); |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1639 | wlan_hdd_inc_suspend_stats(hdd_ctx, |
Dustin Brown | 105d790 | 2016-10-03 16:27:59 -0700 | [diff] [blame] | 1640 | SUSPEND_FAIL_RADAR); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1641 | return -EAGAIN; |
Jeff Johnson | 60cbd2d | 2017-11-03 18:26:28 -0700 | [diff] [blame] | 1642 | } else if (!hdd_ctx->config->enable_sap_suspend) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1643 | /* return -EOPNOTSUPP if SAP does not support |
| 1644 | * suspend |
| 1645 | */ |
Jeff Johnson | c327332 | 2016-07-06 15:28:17 -0700 | [diff] [blame] | 1646 | hdd_err("SAP does not support suspend!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1647 | return -EOPNOTSUPP; |
| 1648 | } |
Jeff Johnson | f6d2428 | 2017-10-02 13:25:25 -0700 | [diff] [blame] | 1649 | } else if (QDF_P2P_GO_MODE == adapter->device_mode) { |
Jeff Johnson | 60cbd2d | 2017-11-03 18:26:28 -0700 | [diff] [blame] | 1650 | if (!hdd_ctx->config->enable_sap_suspend) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1651 | /* return -EOPNOTSUPP if GO does not support |
| 1652 | * suspend |
| 1653 | */ |
Jeff Johnson | c327332 | 2016-07-06 15:28:17 -0700 | [diff] [blame] | 1654 | hdd_err("GO does not support suspend!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1655 | return -EOPNOTSUPP; |
| 1656 | } |
| 1657 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1658 | } |
| 1659 | |
| 1660 | /* Stop ongoing scan on each interface */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 1661 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 5287de5 | 2017-10-28 12:23:06 -0700 | [diff] [blame] | 1662 | scan_info = &adapter->scan_info; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1663 | |
Jeff Johnson | 2954ded | 2018-06-13 16:34:49 -0700 | [diff] [blame] | 1664 | if (sme_neighbor_middle_of_roaming(mac_handle, |
Padma, Santhosh Kumar | 4155278 | 2018-06-29 15:31:25 +0530 | [diff] [blame] | 1665 | adapter->session_id) || |
| 1666 | hdd_is_roaming_in_progress(hdd_ctx)) { |
Dustin Brown | 2d22823 | 2016-09-22 15:06:19 -0700 | [diff] [blame] | 1667 | hdd_err("Roaming in progress, do not allow suspend"); |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1668 | wlan_hdd_inc_suspend_stats(hdd_ctx, |
Dustin Brown | 105d790 | 2016-10-03 16:27:59 -0700 | [diff] [blame] | 1669 | SUSPEND_FAIL_ROAM); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1670 | return -EAGAIN; |
| 1671 | } |
| 1672 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1673 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1674 | adapter->session_id, INVALID_SCAN_ID, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1675 | } |
| 1676 | |
Dustin Brown | 84411b0 | 2017-07-21 16:44:44 -0700 | [diff] [blame] | 1677 | /* flush any pending powersave timers */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 1678 | hdd_for_each_adapter(hdd_ctx, adapter) |
Jeff Johnson | 2954ded | 2018-06-13 16:34:49 -0700 | [diff] [blame] | 1679 | sme_ps_timer_flush_sync(mac_handle, adapter->session_id); |
Dustin Brown | 84411b0 | 2017-07-21 16:44:44 -0700 | [diff] [blame] | 1680 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1681 | /* |
| 1682 | * Suspend IPA early before proceeding to suspend other entities like |
| 1683 | * firmware to avoid any race conditions. |
| 1684 | */ |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 1685 | if (ucfg_ipa_suspend(hdd_ctx->hdd_pdev)) { |
Dustin Brown | 2d22823 | 2016-09-22 15:06:19 -0700 | [diff] [blame] | 1686 | hdd_err("IPA not ready to suspend!"); |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1687 | wlan_hdd_inc_suspend_stats(hdd_ctx, SUSPEND_FAIL_IPA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1688 | return -EAGAIN; |
| 1689 | } |
| 1690 | |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 1691 | /* Suspend control path scheduler */ |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 1692 | scheduler_register_hdd_suspend_callback(hdd_suspend_cb); |
Manjeet Singh | 1a376ce | 2016-10-06 19:31:10 +0530 | [diff] [blame] | 1693 | scheduler_set_event_mask(MC_SUSPEND_EVENT); |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 1694 | scheduler_wake_up_controller_thread(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1695 | |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 1696 | /* Wait for suspend confirmation from scheduler */ |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1697 | rc = wait_for_completion_timeout(&hdd_ctx->mc_sus_event_var, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1698 | msecs_to_jiffies(WLAN_WAIT_TIME_MCTHREAD_SUSPEND)); |
| 1699 | if (!rc) { |
Manjeet Singh | 1a376ce | 2016-10-06 19:31:10 +0530 | [diff] [blame] | 1700 | scheduler_clear_event_mask(MC_SUSPEND_EVENT); |
Jeff Johnson | c327332 | 2016-07-06 15:28:17 -0700 | [diff] [blame] | 1701 | hdd_err("Failed to stop mc thread"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1702 | goto resume_tx; |
| 1703 | } |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1704 | hdd_ctx->is_scheduler_suspended = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1705 | |
| 1706 | #ifdef QCA_CONFIG_SMP |
| 1707 | /* Suspend tlshim rx thread */ |
Manjeet Singh | 1a376ce | 2016-10-06 19:31:10 +0530 | [diff] [blame] | 1708 | set_bit(RX_SUSPEND_EVENT, &cds_sched_context->ol_rx_event_flag); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1709 | wake_up_interruptible(&cds_sched_context->ol_rx_wait_queue); |
| 1710 | rc = wait_for_completion_timeout(&cds_sched_context-> |
| 1711 | ol_suspend_rx_event, |
| 1712 | msecs_to_jiffies |
| 1713 | (RX_TLSHIM_SUSPEND_TIMEOUT)); |
| 1714 | if (!rc) { |
Manjeet Singh | 1a376ce | 2016-10-06 19:31:10 +0530 | [diff] [blame] | 1715 | clear_bit(RX_SUSPEND_EVENT, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1716 | &cds_sched_context->ol_rx_event_flag); |
Jeff Johnson | c327332 | 2016-07-06 15:28:17 -0700 | [diff] [blame] | 1717 | hdd_err("Failed to stop tl_shim rx thread"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1718 | goto resume_all; |
| 1719 | } |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1720 | hdd_ctx->is_ol_rx_thread_suspended = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1721 | #endif |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 1722 | if (hdd_suspend_wlan() < 0) |
| 1723 | goto resume_all; |
| 1724 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1725 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Sreelakshmi Konamki | 6744cff | 2015-09-07 12:10:39 +0530 | [diff] [blame] | 1726 | TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN, |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 1727 | NO_SESSION, hdd_ctx->is_wiphy_suspended)); |
| 1728 | hdd_ctx->is_wiphy_suspended = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1729 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1730 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, PLD_BUS_WIDTH_NONE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1731 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 1732 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1733 | return 0; |
| 1734 | |
| 1735 | #ifdef QCA_CONFIG_SMP |
| 1736 | resume_all: |
| 1737 | |
Rajeev Kumar | 0b73295 | 2016-12-08 17:51:39 -0800 | [diff] [blame] | 1738 | scheduler_resume(); |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1739 | hdd_ctx->is_scheduler_suspended = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1740 | #endif |
| 1741 | |
| 1742 | resume_tx: |
| 1743 | |
| 1744 | hdd_resume_wlan(); |
| 1745 | return -ETIME; |
| 1746 | |
| 1747 | } |
| 1748 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1749 | int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy, |
| 1750 | struct cfg80211_wowlan *wow) |
| 1751 | { |
| 1752 | int ret; |
| 1753 | |
| 1754 | cds_ssr_protect(__func__); |
| 1755 | ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow); |
| 1756 | cds_ssr_unprotect(__func__); |
| 1757 | |
| 1758 | return ret; |
| 1759 | } |
| 1760 | |
| 1761 | /** |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 1762 | * hdd_stop_dhcp_ind() - API to stop DHCP sequence |
| 1763 | * @adapter: Adapter on which DHCP needs to be stopped |
| 1764 | * |
| 1765 | * Release the wakelock held for DHCP process and allow |
| 1766 | * the runtime pm to continue |
| 1767 | * |
| 1768 | * Return: None |
| 1769 | */ |
Jeff Johnson | 75b737d | 2017-08-29 14:24:41 -0700 | [diff] [blame] | 1770 | static void hdd_stop_dhcp_ind(struct hdd_adapter *adapter) |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 1771 | { |
Jeff Johnson | cfb65a8 | 2017-08-28 11:45:41 -0700 | [diff] [blame] | 1772 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 1773 | |
Srinivas Girigowda | c06543c | 2017-03-09 15:10:03 -0800 | [diff] [blame] | 1774 | hdd_debug("DHCP stop indicated through power save"); |
Jeff Johnson | 2954ded | 2018-06-13 16:34:49 -0700 | [diff] [blame] | 1775 | sme_dhcp_stop_ind(hdd_ctx->mac_handle, adapter->device_mode, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 1776 | adapter->mac_addr.bytes, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1777 | adapter->session_id); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 1778 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_DHCP); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1779 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 1780 | } |
| 1781 | |
| 1782 | /** |
| 1783 | * hdd_start_dhcp_ind() - API to start DHCP sequence |
| 1784 | * @adapter: Adapter on which DHCP needs to be stopped |
| 1785 | * |
| 1786 | * Prevent APPS suspend and the runtime suspend during |
| 1787 | * DHCP sequence |
| 1788 | * |
| 1789 | * Return: None |
| 1790 | */ |
Jeff Johnson | 75b737d | 2017-08-29 14:24:41 -0700 | [diff] [blame] | 1791 | static void hdd_start_dhcp_ind(struct hdd_adapter *adapter) |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 1792 | { |
Jeff Johnson | cfb65a8 | 2017-08-28 11:45:41 -0700 | [diff] [blame] | 1793 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 1794 | |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 1795 | hdd_debug("DHCP start indicated through power save"); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1796 | qdf_runtime_pm_prevent_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 1797 | hdd_prevent_suspend_timeout(HDD_WAKELOCK_TIMEOUT_CONNECT, |
| 1798 | WIFI_POWER_EVENT_WAKELOCK_DHCP); |
Jeff Johnson | 2954ded | 2018-06-13 16:34:49 -0700 | [diff] [blame] | 1799 | sme_dhcp_start_ind(hdd_ctx->mac_handle, adapter->device_mode, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 1800 | adapter->mac_addr.bytes, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1801 | adapter->session_id); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 1802 | } |
| 1803 | |
| 1804 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1805 | * __wlan_hdd_cfg80211_set_power_mgmt() - set cfg80211 power management config |
| 1806 | * @wiphy: Pointer to wiphy |
| 1807 | * @dev: Pointer to network device |
Dustin Brown | f660fb4 | 2016-09-09 12:04:00 -0700 | [diff] [blame] | 1808 | * @allow_power_save: is wlan allowed to go into power save mode |
| 1809 | * @timeout: Timeout value in ms |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1810 | * |
| 1811 | * Return: 0 for success, non-zero for failure |
| 1812 | */ |
| 1813 | static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy, |
Dustin Brown | f660fb4 | 2016-09-09 12:04:00 -0700 | [diff] [blame] | 1814 | struct net_device *dev, |
| 1815 | bool allow_power_save, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1816 | int timeout) |
| 1817 | { |
Jeff Johnson | f6d2428 | 2017-10-02 13:25:25 -0700 | [diff] [blame] | 1818 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1819 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1820 | int status; |
| 1821 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 1822 | hdd_enter(); |
Dustin Brown | ecfce63 | 2016-09-13 10:41:45 -0700 | [diff] [blame] | 1823 | |
Dustin Brown | f660fb4 | 2016-09-09 12:04:00 -0700 | [diff] [blame] | 1824 | if (timeout < 0) { |
Yeshwanth Sriram Guntuka | ae03c43 | 2017-11-12 13:31:02 +0530 | [diff] [blame] | 1825 | hdd_debug("User space timeout: %d; Enter full power or power save", |
| 1826 | timeout); |
| 1827 | timeout = 0; |
Dustin Brown | f660fb4 | 2016-09-09 12:04:00 -0700 | [diff] [blame] | 1828 | } |
| 1829 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1830 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | c327332 | 2016-07-06 15:28:17 -0700 | [diff] [blame] | 1831 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1832 | return -EINVAL; |
| 1833 | } |
| 1834 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1835 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 1836 | hdd_err("invalid session id: %d", adapter->session_id); |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 1837 | return -EINVAL; |
| 1838 | } |
| 1839 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1840 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1841 | TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1842 | adapter->session_id, timeout)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1843 | |
Jeff Johnson | f6d2428 | 2017-10-02 13:25:25 -0700 | [diff] [blame] | 1844 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1845 | status = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1846 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 1847 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1848 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1849 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1850 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 1851 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 1852 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 1853 | hdd_debug("Driver Module not enabled return success"); |
Arun Khandavalli | 9928645 | 2016-08-22 12:13:41 +0530 | [diff] [blame] | 1854 | return 0; |
| 1855 | } |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1856 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | 9928645 | 2016-08-22 12:13:41 +0530 | [diff] [blame] | 1857 | |
Jeff Johnson | f6d2428 | 2017-10-02 13:25:25 -0700 | [diff] [blame] | 1858 | status = wlan_hdd_set_powersave(adapter, allow_power_save, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1859 | |
Jeff Johnson | f6d2428 | 2017-10-02 13:25:25 -0700 | [diff] [blame] | 1860 | allow_power_save ? hdd_stop_dhcp_ind(adapter) : |
| 1861 | hdd_start_dhcp_ind(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1862 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 1863 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1864 | return status; |
| 1865 | } |
| 1866 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1867 | int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy, |
Dustin Brown | f660fb4 | 2016-09-09 12:04:00 -0700 | [diff] [blame] | 1868 | struct net_device *dev, |
| 1869 | bool allow_power_save, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1870 | int timeout) |
| 1871 | { |
| 1872 | int ret; |
| 1873 | |
| 1874 | cds_ssr_protect(__func__); |
Dustin Brown | f660fb4 | 2016-09-09 12:04:00 -0700 | [diff] [blame] | 1875 | ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, |
| 1876 | allow_power_save, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1877 | cds_ssr_unprotect(__func__); |
| 1878 | |
| 1879 | return ret; |
| 1880 | } |
| 1881 | |
| 1882 | /** |
| 1883 | * __wlan_hdd_cfg80211_set_txpower() - set TX power |
| 1884 | * @wiphy: Pointer to wiphy |
| 1885 | * @wdev: Pointer to network device |
| 1886 | * @type: TX power setting type |
| 1887 | * @dbm: TX power in dbm |
| 1888 | * |
| 1889 | * Return: 0 for success, non-zero for failure |
| 1890 | */ |
| 1891 | static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1892 | struct wireless_dev *wdev, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1893 | enum nl80211_tx_power_setting type, |
| 1894 | int dbm) |
| 1895 | { |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1896 | struct hdd_context *hdd_ctx = (struct hdd_context *) wiphy_priv(wiphy); |
Jeff Johnson | 2954ded | 2018-06-13 16:34:49 -0700 | [diff] [blame] | 1897 | mac_handle_t mac_handle; |
Dustin Brown | ce5b3d3 | 2018-01-17 15:07:38 -0800 | [diff] [blame] | 1898 | struct qdf_mac_addr bssid = QDF_MAC_ADDR_BCAST_INIT; |
| 1899 | struct qdf_mac_addr selfMac = QDF_MAC_ADDR_BCAST_INIT; |
Jeff Johnson | 2954ded | 2018-06-13 16:34:49 -0700 | [diff] [blame] | 1900 | QDF_STATUS status; |
| 1901 | int errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1902 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 1903 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1904 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1905 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | c327332 | 2016-07-06 15:28:17 -0700 | [diff] [blame] | 1906 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1907 | return -EINVAL; |
| 1908 | } |
| 1909 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1910 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1911 | TRACE_CODE_HDD_CFG80211_SET_TXPOWER, |
| 1912 | NO_SESSION, type)); |
| 1913 | |
Jeff Johnson | 2954ded | 2018-06-13 16:34:49 -0700 | [diff] [blame] | 1914 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 1915 | if (errno) |
| 1916 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1917 | |
Jeff Johnson | 2954ded | 2018-06-13 16:34:49 -0700 | [diff] [blame] | 1918 | mac_handle = hdd_ctx->mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1919 | |
Jeff Johnson | 2954ded | 2018-06-13 16:34:49 -0700 | [diff] [blame] | 1920 | status = sme_cfg_set_int(mac_handle, WNI_CFG_CURRENT_TX_POWER_LEVEL, |
| 1921 | dbm); |
| 1922 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1923 | hdd_err("sme_cfg_set_int failed for tx power %hu, %d", |
| 1924 | dbm, status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1925 | return -EIO; |
| 1926 | } |
| 1927 | |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 1928 | hdd_debug("Set tx power level %d dbm", dbm); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1929 | |
| 1930 | switch (type) { |
| 1931 | /* Automatically determine transmit power */ |
| 1932 | case NL80211_TX_POWER_AUTOMATIC: |
| 1933 | /* Fall through */ |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 1934 | case NL80211_TX_POWER_LIMITED: |
| 1935 | /* Limit TX power by the mBm parameter */ |
Jeff Johnson | 2954ded | 2018-06-13 16:34:49 -0700 | [diff] [blame] | 1936 | status = sme_set_max_tx_power(mac_handle, bssid, selfMac, dbm); |
| 1937 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1938 | hdd_err("Setting maximum tx power failed, %d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1939 | return -EIO; |
| 1940 | } |
| 1941 | break; |
| 1942 | |
| 1943 | case NL80211_TX_POWER_FIXED: /* Fix TX power to the mBm parameter */ |
Jeff Johnson | c327332 | 2016-07-06 15:28:17 -0700 | [diff] [blame] | 1944 | hdd_err("NL80211_TX_POWER_FIXED not supported"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1945 | return -EOPNOTSUPP; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1946 | |
| 1947 | default: |
Jeff Johnson | c327332 | 2016-07-06 15:28:17 -0700 | [diff] [blame] | 1948 | hdd_err("Invalid power setting type %d", type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1949 | return -EIO; |
| 1950 | } |
| 1951 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 1952 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1953 | return 0; |
| 1954 | } |
| 1955 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1956 | int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1957 | struct wireless_dev *wdev, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1958 | enum nl80211_tx_power_setting type, |
| 1959 | int dbm) |
| 1960 | { |
| 1961 | int ret; |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 1962 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1963 | cds_ssr_protect(__func__); |
| 1964 | ret = __wlan_hdd_cfg80211_set_txpower(wiphy, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1965 | wdev, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1966 | type, dbm); |
| 1967 | cds_ssr_unprotect(__func__); |
| 1968 | |
| 1969 | return ret; |
| 1970 | } |
| 1971 | |
Naveen Rawat | e8b1b82 | 2018-01-30 09:46:16 -0800 | [diff] [blame] | 1972 | #ifdef QCA_SUPPORT_CP_STATS |
| 1973 | static void wlan_hdd_get_tx_power(struct hdd_adapter *adapter, int *dbm) |
| 1974 | { |
| 1975 | wlan_cfg80211_mc_cp_stats_get_tx_power(adapter->hdd_vdev, dbm); |
| 1976 | } |
| 1977 | #else |
| 1978 | static void wlan_hdd_get_tx_power(struct hdd_adapter *adapter, int *dbm) |
| 1979 | { |
| 1980 | wlan_hdd_get_class_astats(adapter); |
| 1981 | *dbm = adapter->hdd_stats.class_a_stat.max_pwr; |
| 1982 | } |
| 1983 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1984 | /** |
| 1985 | * __wlan_hdd_cfg80211_get_txpower() - get TX power |
| 1986 | * @wiphy: Pointer to wiphy |
| 1987 | * @wdev: Pointer to network device |
| 1988 | * @dbm: Pointer to TX power in dbm |
| 1989 | * |
| 1990 | * Return: 0 for success, non-zero for failure |
| 1991 | */ |
| 1992 | static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1993 | struct wireless_dev *wdev, |
Srinivas Girigowda | 5557a39 | 2017-03-09 14:28:36 -0800 | [diff] [blame] | 1994 | int *dbm) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1995 | { |
| 1996 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 1997 | struct hdd_context *hdd_ctx = (struct hdd_context *) wiphy_priv(wiphy); |
Srinivas Girigowda | 5557a39 | 2017-03-09 14:28:36 -0800 | [diff] [blame] | 1998 | struct net_device *ndev = wdev->netdev; |
Jeff Johnson | 75b737d | 2017-08-29 14:24:41 -0700 | [diff] [blame] | 1999 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2000 | int status; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 2001 | struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2002 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 2003 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2004 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2005 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | c327332 | 2016-07-06 15:28:17 -0700 | [diff] [blame] | 2006 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2007 | return -EINVAL; |
| 2008 | } |
| 2009 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 2010 | status = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2011 | if (0 != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2012 | *dbm = 0; |
| 2013 | return status; |
| 2014 | } |
| 2015 | |
Arun Khandavalli | 9928645 | 2016-08-22 12:13:41 +0530 | [diff] [blame] | 2016 | /* Validate adapter sessionId */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2017 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 2018 | hdd_err("invalid session id: %d", adapter->session_id); |
Srinivas Girigowda | 5557a39 | 2017-03-09 14:28:36 -0800 | [diff] [blame] | 2019 | return -EINVAL; |
Arun Khandavalli | 9928645 | 2016-08-22 12:13:41 +0530 | [diff] [blame] | 2020 | } |
| 2021 | |
Abhinav Kumar | 50d4dc7 | 2018-06-15 16:35:50 +0530 | [diff] [blame] | 2022 | if (sta_ctx->hdd_reassoc_scenario) { |
| 2023 | hdd_debug("Roaming is in progress, rej this req"); |
| 2024 | return -EINVAL; |
| 2025 | } |
| 2026 | |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 2027 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 2028 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 2029 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Srinivas Girigowda | 5d6bde6 | 2017-03-06 18:26:02 -0800 | [diff] [blame] | 2030 | hdd_debug("Driver Module not enabled return success"); |
Arun Khandavalli | 9928645 | 2016-08-22 12:13:41 +0530 | [diff] [blame] | 2031 | /* Send cached data to upperlayer*/ |
Jeff Johnson | 861dd4f | 2017-10-24 10:10:40 -0700 | [diff] [blame] | 2032 | *dbm = adapter->hdd_stats.class_a_stat.max_pwr; |
Arun Khandavalli | 9928645 | 2016-08-22 12:13:41 +0530 | [diff] [blame] | 2033 | return 0; |
| 2034 | } |
Jeff Johnson | 1a9b979 | 2017-09-03 09:22:08 -0700 | [diff] [blame] | 2035 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | 9928645 | 2016-08-22 12:13:41 +0530 | [diff] [blame] | 2036 | |
Ganesh Kondabattini | f847f06 | 2017-05-26 12:36:24 +0530 | [diff] [blame] | 2037 | if (sta_ctx->conn_info.connState != eConnectionState_Associated) { |
| 2038 | hdd_debug("Not associated"); |
| 2039 | /*To keep GUI happy */ |
| 2040 | *dbm = 0; |
| 2041 | return 0; |
| 2042 | } |
| 2043 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2044 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Sreelakshmi Konamki | 6744cff | 2015-09-07 12:10:39 +0530 | [diff] [blame] | 2045 | TRACE_CODE_HDD_CFG80211_GET_TXPOWER, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2046 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2047 | |
Naveen Rawat | e8b1b82 | 2018-01-30 09:46:16 -0800 | [diff] [blame] | 2048 | wlan_hdd_get_tx_power(adapter, dbm); |
| 2049 | hdd_debug("power: %d", *dbm); |
| 2050 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2051 | return 0; |
| 2052 | } |
| 2053 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2054 | int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2055 | struct wireless_dev *wdev, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2056 | int *dbm) |
| 2057 | { |
Srinivas Girigowda | 5557a39 | 2017-03-09 14:28:36 -0800 | [diff] [blame] | 2058 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2059 | |
| 2060 | cds_ssr_protect(__func__); |
Srinivas Girigowda | 5557a39 | 2017-03-09 14:28:36 -0800 | [diff] [blame] | 2061 | ret = __wlan_hdd_cfg80211_get_txpower(wiphy, wdev, dbm); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2062 | cds_ssr_unprotect(__func__); |
| 2063 | |
| 2064 | return ret; |
| 2065 | } |
Kapil Gupta | 6213c01 | 2016-09-02 19:39:09 +0530 | [diff] [blame] | 2066 | |
Jeff Johnson | 4fbee2f | 2017-10-03 11:19:35 -0700 | [diff] [blame] | 2067 | int hdd_set_qpower_config(struct hdd_context *hddctx, |
| 2068 | struct hdd_adapter *adapter, |
Dustin Brown | 10a7b71 | 2016-10-07 10:31:16 -0700 | [diff] [blame] | 2069 | u8 qpower) |
Kapil Gupta | 6213c01 | 2016-09-02 19:39:09 +0530 | [diff] [blame] | 2070 | { |
Dustin Brown | 10a7b71 | 2016-10-07 10:31:16 -0700 | [diff] [blame] | 2071 | QDF_STATUS status; |
Kapil Gupta | 6213c01 | 2016-09-02 19:39:09 +0530 | [diff] [blame] | 2072 | |
| 2073 | if (!hddctx->config->enablePowersaveOffload) { |
| 2074 | hdd_err("qpower is disabled in configuration"); |
| 2075 | return -EINVAL; |
| 2076 | } |
Manjeet Singh | 91b7bb8 | 2017-02-10 18:35:40 +0530 | [diff] [blame] | 2077 | if (adapter->device_mode != QDF_STA_MODE && |
| 2078 | adapter->device_mode != QDF_P2P_CLIENT_MODE) { |
Dustin Brown | bacc48f | 2018-03-14 14:48:44 -0700 | [diff] [blame] | 2079 | hdd_info("QPOWER only allowed in STA/P2P-Client modes:%d", |
| 2080 | adapter->device_mode); |
Manjeet Singh | 91b7bb8 | 2017-02-10 18:35:40 +0530 | [diff] [blame] | 2081 | return -EINVAL; |
| 2082 | } |
Dustin Brown | 10a7b71 | 2016-10-07 10:31:16 -0700 | [diff] [blame] | 2083 | |
Kapil Gupta | 6213c01 | 2016-09-02 19:39:09 +0530 | [diff] [blame] | 2084 | if (qpower > PS_DUTY_CYCLING_QPOWER || |
| 2085 | qpower < PS_LEGACY_NODEEPSLEEP) { |
Dustin Brown | 10a7b71 | 2016-10-07 10:31:16 -0700 | [diff] [blame] | 2086 | hdd_err("invalid qpower value: %d", qpower); |
Kapil Gupta | 6213c01 | 2016-09-02 19:39:09 +0530 | [diff] [blame] | 2087 | return -EINVAL; |
| 2088 | } |
Kapil Gupta | 6213c01 | 2016-09-02 19:39:09 +0530 | [diff] [blame] | 2089 | |
Kiran Kumar Lokere | 7006e0a | 2017-03-07 19:28:36 -0800 | [diff] [blame] | 2090 | if (hddctx->config->nMaxPsPoll) { |
| 2091 | if ((qpower == PS_QPOWER_NODEEPSLEEP) || |
| 2092 | (qpower == PS_LEGACY_NODEEPSLEEP)) |
| 2093 | qpower = PS_LEGACY_NODEEPSLEEP; |
| 2094 | else |
| 2095 | qpower = PS_LEGACY_DEEPSLEEP; |
| 2096 | hdd_info("Qpower disabled, %d", qpower); |
| 2097 | } |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2098 | status = wma_set_qpower_config(adapter->session_id, qpower); |
Dustin Brown | 10a7b71 | 2016-10-07 10:31:16 -0700 | [diff] [blame] | 2099 | if (status != QDF_STATUS_SUCCESS) { |
| 2100 | hdd_err("failed to configure qpower: %d", status); |
| 2101 | return -EINVAL; |
Kapil Gupta | 6213c01 | 2016-09-02 19:39:09 +0530 | [diff] [blame] | 2102 | } |
Dustin Brown | 10a7b71 | 2016-10-07 10:31:16 -0700 | [diff] [blame] | 2103 | |
Kapil Gupta | 6213c01 | 2016-09-02 19:39:09 +0530 | [diff] [blame] | 2104 | return 0; |
| 2105 | } |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2106 | |
Dustin Brown | 5409643 | 2017-02-23 13:00:44 -0800 | [diff] [blame] | 2107 | |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2108 | #ifdef WLAN_SUSPEND_RESUME_TEST |
Dustin Brown | bc81a47 | 2016-10-26 16:56:59 -0700 | [diff] [blame] | 2109 | static struct net_device *g_dev; |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2110 | static struct wiphy *g_wiphy; |
Dustin Brown | 3ed3e9b | 2017-03-23 12:57:58 -0700 | [diff] [blame] | 2111 | static enum wow_resume_trigger g_resume_trigger; |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2112 | |
| 2113 | #define HDD_FA_SUSPENDED_BIT (0) |
| 2114 | static unsigned long fake_apps_state; |
| 2115 | |
Dustin Brown | d53d1a8 | 2016-10-03 12:57:33 -0700 | [diff] [blame] | 2116 | /** |
| 2117 | * __hdd_wlan_fake_apps_resume() - The core logic for |
| 2118 | * hdd_wlan_fake_apps_resume() skipping the call to hif_fake_apps_resume(), |
| 2119 | * which is only need for non-irq resume |
Dustin Brown | bc81a47 | 2016-10-26 16:56:59 -0700 | [diff] [blame] | 2120 | * @wiphy: the kernel wiphy struct for the device being resumed |
| 2121 | * @dev: the kernel net_device struct for the device being resumed |
Dustin Brown | d53d1a8 | 2016-10-03 12:57:33 -0700 | [diff] [blame] | 2122 | * |
Dustin Brown | bc81a47 | 2016-10-26 16:56:59 -0700 | [diff] [blame] | 2123 | * Return: none, calls QDF_BUG() on failure |
Dustin Brown | d53d1a8 | 2016-10-03 12:57:33 -0700 | [diff] [blame] | 2124 | */ |
Dustin Brown | bc81a47 | 2016-10-26 16:56:59 -0700 | [diff] [blame] | 2125 | static void __hdd_wlan_fake_apps_resume(struct wiphy *wiphy, |
| 2126 | struct net_device *dev) |
Dustin Brown | d53d1a8 | 2016-10-03 12:57:33 -0700 | [diff] [blame] | 2127 | { |
Dustin Brown | 3ed3e9b | 2017-03-23 12:57:58 -0700 | [diff] [blame] | 2128 | struct hif_opaque_softc *hif_ctx; |
Dustin Brown | ddb5970 | 2017-01-12 16:20:31 -0800 | [diff] [blame] | 2129 | qdf_device_t qdf_dev; |
Dustin Brown | d53d1a8 | 2016-10-03 12:57:33 -0700 | [diff] [blame] | 2130 | |
Dustin Brown | 0f8dc3d | 2017-06-01 14:37:26 -0700 | [diff] [blame] | 2131 | hdd_info("Unit-test resume WLAN"); |
Dustin Brown | ddb5970 | 2017-01-12 16:20:31 -0800 | [diff] [blame] | 2132 | |
| 2133 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2134 | if (!qdf_dev) { |
| 2135 | hdd_err("Failed to get QDF device context"); |
| 2136 | QDF_BUG(0); |
| 2137 | return; |
| 2138 | } |
| 2139 | |
Dustin Brown | 3ed3e9b | 2017-03-23 12:57:58 -0700 | [diff] [blame] | 2140 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2141 | if (!hif_ctx) { |
| 2142 | hdd_err("Failed to get HIF context"); |
| 2143 | return; |
| 2144 | } |
| 2145 | |
Dustin Brown | d53d1a8 | 2016-10-03 12:57:33 -0700 | [diff] [blame] | 2146 | if (!test_and_clear_bit(HDD_FA_SUSPENDED_BIT, &fake_apps_state)) { |
Dustin Brown | 0f8dc3d | 2017-06-01 14:37:26 -0700 | [diff] [blame] | 2147 | hdd_alert("Not unit-test suspended; Nothing to do"); |
Dustin Brown | d53d1a8 | 2016-10-03 12:57:33 -0700 | [diff] [blame] | 2148 | return; |
| 2149 | } |
| 2150 | |
Dustin Brown | 3ed3e9b | 2017-03-23 12:57:58 -0700 | [diff] [blame] | 2151 | /* simulate kernel disable irqs */ |
| 2152 | QDF_BUG(!hif_apps_wake_irq_disable(hif_ctx)); |
Dustin Brown | d53d1a8 | 2016-10-03 12:57:33 -0700 | [diff] [blame] | 2153 | |
Dustin Brown | 3ed3e9b | 2017-03-23 12:57:58 -0700 | [diff] [blame] | 2154 | QDF_BUG(!wlan_hdd_bus_resume_noirq()); |
Dustin Brown | d53d1a8 | 2016-10-03 12:57:33 -0700 | [diff] [blame] | 2155 | |
| 2156 | /* simulate kernel enable irqs */ |
Dustin Brown | 3ed3e9b | 2017-03-23 12:57:58 -0700 | [diff] [blame] | 2157 | QDF_BUG(!hif_apps_irqs_enable(hif_ctx)); |
Dustin Brown | d53d1a8 | 2016-10-03 12:57:33 -0700 | [diff] [blame] | 2158 | |
Dustin Brown | 3ed3e9b | 2017-03-23 12:57:58 -0700 | [diff] [blame] | 2159 | QDF_BUG(!wlan_hdd_bus_resume()); |
Dustin Brown | d53d1a8 | 2016-10-03 12:57:33 -0700 | [diff] [blame] | 2160 | |
Dustin Brown | 3ed3e9b | 2017-03-23 12:57:58 -0700 | [diff] [blame] | 2161 | QDF_BUG(!wlan_hdd_cfg80211_resume_wlan(wiphy)); |
| 2162 | |
| 2163 | if (g_resume_trigger == WOW_RESUME_TRIGGER_HTC_WAKEUP) |
| 2164 | hif_vote_link_down(hif_ctx); |
Dustin Brown | bc81a47 | 2016-10-26 16:56:59 -0700 | [diff] [blame] | 2165 | |
| 2166 | dev->watchdog_timeo = HDD_TX_TIMEOUT; |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 2167 | |
Dustin Brown | 0f8dc3d | 2017-06-01 14:37:26 -0700 | [diff] [blame] | 2168 | hdd_alert("Unit-test resume succeeded"); |
Dustin Brown | d53d1a8 | 2016-10-03 12:57:33 -0700 | [diff] [blame] | 2169 | } |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2170 | |
| 2171 | /** |
| 2172 | * hdd_wlan_fake_apps_resume_irq_callback() - Irq callback function for resuming |
| 2173 | * from unit-test initiated suspend from irq wakeup signal |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2174 | * |
| 2175 | * Resume wlan after getting very 1st CE interrupt from target |
| 2176 | * |
| 2177 | * Return: none |
| 2178 | */ |
Dustin Brown | 0f8dc3d | 2017-06-01 14:37:26 -0700 | [diff] [blame] | 2179 | static void hdd_wlan_fake_apps_resume_irq_callback(void) |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2180 | { |
Dustin Brown | 0f8dc3d | 2017-06-01 14:37:26 -0700 | [diff] [blame] | 2181 | hdd_info("Trigger unit-test resume WLAN"); |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2182 | |
| 2183 | QDF_BUG(g_wiphy); |
Dustin Brown | bc81a47 | 2016-10-26 16:56:59 -0700 | [diff] [blame] | 2184 | QDF_BUG(g_dev); |
| 2185 | __hdd_wlan_fake_apps_resume(g_wiphy, g_dev); |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2186 | g_wiphy = NULL; |
Dustin Brown | bc81a47 | 2016-10-26 16:56:59 -0700 | [diff] [blame] | 2187 | g_dev = NULL; |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2188 | } |
| 2189 | |
Dustin Brown | 5409643 | 2017-02-23 13:00:44 -0800 | [diff] [blame] | 2190 | int hdd_wlan_fake_apps_suspend(struct wiphy *wiphy, struct net_device *dev, |
| 2191 | enum wow_interface_pause pause_setting, |
| 2192 | enum wow_resume_trigger resume_setting) |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2193 | { |
Rajeev Kumar | 15b40a2 | 2018-04-12 11:45:24 -0700 | [diff] [blame] | 2194 | int errno; |
Dustin Brown | ddb5970 | 2017-01-12 16:20:31 -0800 | [diff] [blame] | 2195 | qdf_device_t qdf_dev; |
| 2196 | struct hif_opaque_softc *hif_ctx; |
Rajeev Kumar | 15b40a2 | 2018-04-12 11:45:24 -0700 | [diff] [blame] | 2197 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Dustin Brown | 5409643 | 2017-02-23 13:00:44 -0800 | [diff] [blame] | 2198 | struct wow_enable_params wow_params = { |
| 2199 | .is_unit_test = true, |
| 2200 | .interface_pause = pause_setting, |
| 2201 | .resume_trigger = resume_setting |
| 2202 | }; |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2203 | |
Rajeev Kumar | 15b40a2 | 2018-04-12 11:45:24 -0700 | [diff] [blame] | 2204 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 2205 | return -EINVAL; |
| 2206 | |
| 2207 | if (!hdd_ctx->config->is_unit_test_framework_enabled) { |
| 2208 | hdd_warn_rl("UT framework is disabled"); |
| 2209 | return -EINVAL; |
| 2210 | } |
| 2211 | |
Dustin Brown | 0f8dc3d | 2017-06-01 14:37:26 -0700 | [diff] [blame] | 2212 | hdd_info("Unit-test suspend WLAN"); |
Dustin Brown | ddb5970 | 2017-01-12 16:20:31 -0800 | [diff] [blame] | 2213 | |
Dustin Brown | 5409643 | 2017-02-23 13:00:44 -0800 | [diff] [blame] | 2214 | if (pause_setting < WOW_INTERFACE_PAUSE_DEFAULT || |
| 2215 | pause_setting >= WOW_INTERFACE_PAUSE_COUNT) { |
| 2216 | hdd_err("Invalid interface pause %d (expected range [0, 2])", |
| 2217 | pause_setting); |
| 2218 | return -EINVAL; |
| 2219 | } |
| 2220 | |
| 2221 | if (resume_setting < WOW_RESUME_TRIGGER_DEFAULT || |
| 2222 | resume_setting >= WOW_RESUME_TRIGGER_COUNT) { |
| 2223 | hdd_err("Invalid resume trigger %d (expected range [0, 2])", |
| 2224 | resume_setting); |
| 2225 | return -EINVAL; |
| 2226 | } |
| 2227 | |
Dustin Brown | ddb5970 | 2017-01-12 16:20:31 -0800 | [diff] [blame] | 2228 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2229 | if (!qdf_dev) { |
| 2230 | hdd_err("Failed to get QDF device context"); |
| 2231 | return -EINVAL; |
| 2232 | } |
| 2233 | |
| 2234 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2235 | if (!hif_ctx) { |
| 2236 | hdd_err("Failed to get HIF context"); |
| 2237 | return -EINVAL; |
| 2238 | } |
| 2239 | |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2240 | if (test_and_set_bit(HDD_FA_SUSPENDED_BIT, &fake_apps_state)) { |
Dustin Brown | 0f8dc3d | 2017-06-01 14:37:26 -0700 | [diff] [blame] | 2241 | hdd_alert("Already unit-test suspended; Nothing to do"); |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2242 | return 0; |
| 2243 | } |
| 2244 | |
Dustin Brown | 3ed3e9b | 2017-03-23 12:57:58 -0700 | [diff] [blame] | 2245 | /* pci link is needed to wakeup from HTC wakeup trigger */ |
| 2246 | if (resume_setting == WOW_RESUME_TRIGGER_HTC_WAKEUP) |
| 2247 | hif_vote_link_up(hif_ctx); |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2248 | |
Dustin Brown | 3ed3e9b | 2017-03-23 12:57:58 -0700 | [diff] [blame] | 2249 | errno = wlan_hdd_cfg80211_suspend_wlan(wiphy, NULL); |
| 2250 | if (errno) |
| 2251 | goto link_down; |
| 2252 | |
| 2253 | errno = wlan_hdd_unit_test_bus_suspend(wow_params); |
| 2254 | if (errno) |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2255 | goto cfg80211_resume; |
| 2256 | |
| 2257 | /* simulate kernel disabling irqs */ |
Dustin Brown | 3ed3e9b | 2017-03-23 12:57:58 -0700 | [diff] [blame] | 2258 | errno = hif_apps_irqs_disable(hif_ctx); |
| 2259 | if (errno) |
| 2260 | goto bus_resume; |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2261 | |
Dustin Brown | 3ed3e9b | 2017-03-23 12:57:58 -0700 | [diff] [blame] | 2262 | errno = wlan_hdd_bus_suspend_noirq(); |
| 2263 | if (errno) |
| 2264 | goto enable_irqs; |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2265 | |
Dustin Brown | bc81a47 | 2016-10-26 16:56:59 -0700 | [diff] [blame] | 2266 | /* pass wiphy/dev to callback via global variables */ |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2267 | g_wiphy = wiphy; |
Dustin Brown | bc81a47 | 2016-10-26 16:56:59 -0700 | [diff] [blame] | 2268 | g_dev = dev; |
Dustin Brown | 3ed3e9b | 2017-03-23 12:57:58 -0700 | [diff] [blame] | 2269 | g_resume_trigger = resume_setting; |
Dustin Brown | 0f8dc3d | 2017-06-01 14:37:26 -0700 | [diff] [blame] | 2270 | hif_ut_apps_suspend(hif_ctx, hdd_wlan_fake_apps_resume_irq_callback); |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2271 | |
Dustin Brown | 3ed3e9b | 2017-03-23 12:57:58 -0700 | [diff] [blame] | 2272 | /* re-enable wake irq */ |
| 2273 | errno = hif_apps_wake_irq_enable(hif_ctx); |
| 2274 | if (errno) |
| 2275 | goto fake_apps_resume; |
| 2276 | |
Dustin Brown | bc81a47 | 2016-10-26 16:56:59 -0700 | [diff] [blame] | 2277 | /* |
| 2278 | * Tell the kernel not to worry if TX queues aren't moving. This is |
| 2279 | * expected since we are suspending the wifi hardware, but not APPS |
| 2280 | */ |
| 2281 | dev->watchdog_timeo = INT_MAX; |
| 2282 | |
Dustin Brown | 0f8dc3d | 2017-06-01 14:37:26 -0700 | [diff] [blame] | 2283 | hdd_alert("Unit-test suspend succeeded"); |
Dustin Brown | 3ed3e9b | 2017-03-23 12:57:58 -0700 | [diff] [blame] | 2284 | |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2285 | return 0; |
| 2286 | |
Dustin Brown | 3ed3e9b | 2017-03-23 12:57:58 -0700 | [diff] [blame] | 2287 | fake_apps_resume: |
Dustin Brown | 0f8dc3d | 2017-06-01 14:37:26 -0700 | [diff] [blame] | 2288 | hif_ut_apps_resume(hif_ctx); |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2289 | |
Dustin Brown | 3ed3e9b | 2017-03-23 12:57:58 -0700 | [diff] [blame] | 2290 | enable_irqs: |
| 2291 | QDF_BUG(!hif_apps_irqs_enable(hif_ctx)); |
| 2292 | |
| 2293 | bus_resume: |
| 2294 | QDF_BUG(!wlan_hdd_bus_resume()); |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2295 | |
| 2296 | cfg80211_resume: |
Dustin Brown | 3ed3e9b | 2017-03-23 12:57:58 -0700 | [diff] [blame] | 2297 | QDF_BUG(!wlan_hdd_cfg80211_resume_wlan(wiphy)); |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2298 | |
Dustin Brown | 3ed3e9b | 2017-03-23 12:57:58 -0700 | [diff] [blame] | 2299 | link_down: |
| 2300 | hif_vote_link_down(hif_ctx); |
| 2301 | |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2302 | clear_bit(HDD_FA_SUSPENDED_BIT, &fake_apps_state); |
Dustin Brown | 3ed3e9b | 2017-03-23 12:57:58 -0700 | [diff] [blame] | 2303 | hdd_err("Unit-test suspend failed: %d", errno); |
| 2304 | |
| 2305 | return errno; |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2306 | } |
| 2307 | |
Dustin Brown | bc81a47 | 2016-10-26 16:56:59 -0700 | [diff] [blame] | 2308 | int hdd_wlan_fake_apps_resume(struct wiphy *wiphy, struct net_device *dev) |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2309 | { |
Dustin Brown | ddb5970 | 2017-01-12 16:20:31 -0800 | [diff] [blame] | 2310 | struct hif_opaque_softc *hif_ctx; |
Rajeev Kumar | 15b40a2 | 2018-04-12 11:45:24 -0700 | [diff] [blame] | 2311 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 2312 | |
| 2313 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 2314 | return -EINVAL; |
| 2315 | |
| 2316 | if (!hdd_ctx->config->is_unit_test_framework_enabled) { |
| 2317 | hdd_warn_rl("UT framework is disabled"); |
| 2318 | return -EINVAL; |
| 2319 | } |
Dustin Brown | ddb5970 | 2017-01-12 16:20:31 -0800 | [diff] [blame] | 2320 | |
| 2321 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2322 | if (!hif_ctx) { |
| 2323 | hdd_err("Failed to get HIF context"); |
| 2324 | return -EINVAL; |
| 2325 | } |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2326 | |
Dustin Brown | 0f8dc3d | 2017-06-01 14:37:26 -0700 | [diff] [blame] | 2327 | hif_ut_apps_resume(hif_ctx); |
Dustin Brown | bc81a47 | 2016-10-26 16:56:59 -0700 | [diff] [blame] | 2328 | __hdd_wlan_fake_apps_resume(wiphy, dev); |
Rajeev Kumar | 9bb2e85 | 2016-09-24 12:29:25 -0700 | [diff] [blame] | 2329 | |
| 2330 | return 0; |
| 2331 | } |
| 2332 | #endif |