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