Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -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 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
| 28 | /** |
| 29 | * |
| 30 | * @file wlan_hdd_p2p.c |
| 31 | * |
| 32 | * @brief WLAN Host Device Driver implementation for P2P commands interface |
| 33 | * |
| 34 | */ |
| 35 | |
| 36 | #include <wlan_hdd_includes.h> |
| 37 | #include <wlan_hdd_hostapd.h> |
| 38 | #include <net/cfg80211.h> |
| 39 | #include "sme_api.h" |
| 40 | #include "sme_qos_api.h" |
| 41 | #include "wlan_hdd_p2p.h" |
| 42 | #include "sap_api.h" |
| 43 | #include "wlan_hdd_main.h" |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 44 | #include "qdf_trace.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 45 | #include <linux/netdevice.h> |
| 46 | #include <linux/skbuff.h> |
| 47 | #include <linux/etherdevice.h> |
| 48 | #include <net/ieee80211_radiotap.h> |
| 49 | #include "wlan_hdd_tdls.h" |
| 50 | #include "wlan_hdd_trace.h" |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 51 | #include "qdf_types.h" |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 52 | #include "qdf_trace.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 53 | #include "cds_sched.h" |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 54 | #include "wlan_policy_mgr_api.h" |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 55 | #include "cds_utils.h" |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 56 | #include "wlan_p2p_public_struct.h" |
| 57 | #include "wlan_p2p_ucfg_api.h" |
| 58 | #include "wlan_cfg80211_p2p.h" |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 59 | |
Manishekar Chandrasekaran | 371e5af | 2016-06-30 23:17:29 +0530 | [diff] [blame] | 60 | /* Ms to Time Unit Micro Sec */ |
| 61 | #define MS_TO_TU_MUS(x) ((x) * 1024) |
Archana Ramachandran | 1e6b926 | 2016-09-30 15:15:10 -0700 | [diff] [blame] | 62 | #define MAX_MUS_VAL (INT_MAX / 1024) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 63 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 64 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 65 | #define MAX_P2P_ACTION_FRAME_TYPE 9 |
| 66 | const char *p2p_action_frame_type[] = { "GO Negotiation Request", |
| 67 | "GO Negotiation Response", |
| 68 | "GO Negotiation Confirmation", |
| 69 | "P2P Invitation Request", |
| 70 | "P2P Invitation Response", |
| 71 | "Device Discoverability Request", |
| 72 | "Device Discoverability Response", |
| 73 | "Provision Discovery Request", |
| 74 | "Provision Discovery Response"}; |
| 75 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 76 | #endif |
| 77 | #define MAX_TDLS_ACTION_FRAME_TYPE 11 |
| 78 | const char *tdls_action_frame_type[] = { "TDLS Setup Request", |
| 79 | "TDLS Setup Response", |
| 80 | "TDLS Setup Confirm", |
| 81 | "TDLS Teardown", |
| 82 | "TDLS Peer Traffic Indication", |
| 83 | "TDLS Channel Switch Request", |
| 84 | "TDLS Channel Switch Response", |
| 85 | "TDLS Peer PSM Request", |
| 86 | "TDLS Peer PSM Response", |
| 87 | "TDLS Peer Traffic Response", |
| 88 | "TDLS Discovery Request"}; |
| 89 | |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 90 | void wlan_hdd_cancel_existing_remain_on_channel(struct hdd_adapter *adapter) |
Wu Gao | 8a45ede | 2017-04-06 20:04:06 +0800 | [diff] [blame] | 91 | { |
| 92 | QDF_STATUS status; |
| 93 | |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 94 | if (!adapter) { |
Wu Gao | 8a45ede | 2017-04-06 20:04:06 +0800 | [diff] [blame] | 95 | hdd_err("null adapter"); |
| 96 | return; |
| 97 | } |
| 98 | |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 99 | status = ucfg_p2p_cleanup_roc(adapter->hdd_vdev); |
Wu Gao | 8a45ede | 2017-04-06 20:04:06 +0800 | [diff] [blame] | 100 | hdd_debug("status:%d", status); |
| 101 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 102 | |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 103 | int wlan_hdd_check_remain_on_channel(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 104 | { |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 105 | if (QDF_P2P_GO_MODE != adapter->device_mode) |
| 106 | wlan_hdd_cancel_existing_remain_on_channel(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 107 | |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 108 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 109 | } |
| 110 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 111 | /* Clean up RoC context at hdd_stop_adapter*/ |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 112 | void wlan_hdd_cleanup_remain_on_channel_ctx(struct hdd_adapter *adapter) |
Wu Gao | 8a45ede | 2017-04-06 20:04:06 +0800 | [diff] [blame] | 113 | { |
| 114 | QDF_STATUS status; |
| 115 | |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 116 | if (!adapter) { |
Wu Gao | 8a45ede | 2017-04-06 20:04:06 +0800 | [diff] [blame] | 117 | hdd_err("null adapter"); |
| 118 | return; |
| 119 | } |
| 120 | |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 121 | status = ucfg_p2p_cleanup_roc(adapter->hdd_vdev); |
Wu Gao | 8a45ede | 2017-04-06 20:04:06 +0800 | [diff] [blame] | 122 | hdd_debug("status:%d", status); |
| 123 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 124 | |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 125 | static int __wlan_hdd_cfg80211_remain_on_channel(struct wiphy *wiphy, |
| 126 | struct wireless_dev *wdev, |
| 127 | struct ieee80211_channel *chan, |
| 128 | unsigned int duration, |
| 129 | u64 *cookie) |
| 130 | { |
| 131 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 132 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 1876762 | 2017-08-28 11:46:50 -0700 | [diff] [blame] | 133 | struct hdd_context *hdd_ctx; |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 134 | QDF_STATUS status; |
| 135 | int ret; |
| 136 | |
| 137 | ENTER(); |
| 138 | |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 139 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 140 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 141 | if (0 != ret) |
| 142 | return ret; |
| 143 | |
| 144 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 145 | hdd_err("Command not allowed in FTM mode"); |
| 146 | return -EINVAL; |
| 147 | } |
| 148 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 149 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 150 | hdd_err("invalid session id: %d", adapter->session_id); |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 151 | return -EINVAL; |
| 152 | } |
| 153 | |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 154 | status = wlan_cfg80211_roc(adapter->hdd_vdev, chan, |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 155 | duration, cookie); |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 156 | hdd_debug("remain on channel request, status:%d", status); |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 157 | |
| 158 | return qdf_status_to_os_return(status); |
| 159 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 160 | |
| 161 | int wlan_hdd_cfg80211_remain_on_channel(struct wiphy *wiphy, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 162 | struct wireless_dev *wdev, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 163 | struct ieee80211_channel *chan, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 164 | unsigned int duration, u64 *cookie) |
| 165 | { |
| 166 | int ret; |
| 167 | |
| 168 | cds_ssr_protect(__func__); |
| 169 | ret = __wlan_hdd_cfg80211_remain_on_channel(wiphy, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 170 | wdev, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 171 | chan, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 172 | duration, cookie); |
| 173 | cds_ssr_unprotect(__func__); |
| 174 | |
| 175 | return ret; |
| 176 | } |
| 177 | |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 178 | static int |
| 179 | __wlan_hdd_cfg80211_cancel_remain_on_channel(struct wiphy *wiphy, |
| 180 | struct wireless_dev *wdev, |
| 181 | u64 cookie) |
| 182 | { |
| 183 | QDF_STATUS status; |
| 184 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 185 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 186 | |
| 187 | ENTER(); |
| 188 | |
| 189 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 190 | hdd_err("Command not allowed in FTM mode"); |
| 191 | return -EINVAL; |
| 192 | } |
| 193 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 194 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 195 | hdd_err("invalid session id: %d", adapter->session_id); |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 196 | return -EINVAL; |
| 197 | } |
| 198 | |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 199 | status = wlan_cfg80211_cancel_roc(adapter->hdd_vdev, cookie); |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 200 | hdd_debug("cancel remain on channel, status:%d", status); |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 201 | |
| 202 | return 0; |
| 203 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 204 | |
| 205 | int wlan_hdd_cfg80211_cancel_remain_on_channel(struct wiphy *wiphy, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 206 | struct wireless_dev *wdev, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 207 | u64 cookie) |
| 208 | { |
| 209 | int ret; |
| 210 | |
| 211 | cds_ssr_protect(__func__); |
| 212 | ret = __wlan_hdd_cfg80211_cancel_remain_on_channel(wiphy, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 213 | wdev, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 214 | cookie); |
| 215 | cds_ssr_unprotect(__func__); |
| 216 | |
| 217 | return ret; |
| 218 | } |
| 219 | |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 220 | static int __wlan_hdd_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, |
| 221 | struct ieee80211_channel *chan, bool offchan, |
| 222 | unsigned int wait, |
| 223 | const u8 *buf, size_t len, bool no_cck, |
| 224 | bool dont_wait_for_ack, u64 *cookie) |
| 225 | { |
| 226 | QDF_STATUS status; |
| 227 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 228 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Padma, Santhosh Kumar | 22c462c | 2018-01-16 17:56:44 +0530 | [diff] [blame] | 229 | uint8_t type; |
| 230 | uint8_t sub_type; |
| 231 | QDF_STATUS qdf_status; |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 232 | |
| 233 | ENTER(); |
| 234 | |
| 235 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 236 | hdd_err("Command not allowed in FTM mode"); |
| 237 | return -EINVAL; |
| 238 | } |
| 239 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 240 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 241 | hdd_err("invalid session id: %d", adapter->session_id); |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 242 | return -EINVAL; |
| 243 | } |
| 244 | |
Padma, Santhosh Kumar | 22c462c | 2018-01-16 17:56:44 +0530 | [diff] [blame] | 245 | type = WLAN_HDD_GET_TYPE_FRM_FC(buf[0]); |
| 246 | sub_type = WLAN_HDD_GET_SUBTYPE_FRM_FC(buf[0]); |
| 247 | |
| 248 | /* When frame to be transmitted is auth mgmt, then trigger |
| 249 | * sme_send_mgmt_tx to send auth frame without need for policy manager. |
| 250 | * Where as wlan_cfg80211_mgmt_tx requires roc and requires approval |
| 251 | * from policy manager. |
| 252 | */ |
| 253 | if ((adapter->device_mode == QDF_STA_MODE) && |
| 254 | (type == SIR_MAC_MGMT_FRAME && |
| 255 | sub_type == SIR_MAC_MGMT_AUTH)) { |
| 256 | qdf_status = sme_send_mgmt_tx(WLAN_HDD_GET_HAL_CTX(adapter), |
| 257 | adapter->session_id, buf, len); |
| 258 | |
| 259 | if (QDF_IS_STATUS_SUCCESS(qdf_status)) |
| 260 | return 0; |
| 261 | else |
| 262 | return -EINVAL; |
| 263 | } |
| 264 | |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 265 | status = wlan_cfg80211_mgmt_tx(adapter->hdd_vdev, chan, |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 266 | offchan, wait, buf, len, no_cck, |
| 267 | dont_wait_for_ack, cookie); |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 268 | hdd_debug("mgmt tx, status:%d", status); |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 269 | |
| 270 | return 0; |
| 271 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 272 | |
| 273 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 274 | int wlan_hdd_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, |
| 275 | struct cfg80211_mgmt_tx_params *params, u64 *cookie) |
Amar Singhal | 01098f7 | 2015-10-08 11:55:32 -0700 | [diff] [blame] | 276 | #else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 277 | int wlan_hdd_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, |
| 278 | struct ieee80211_channel *chan, bool offchan, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 279 | unsigned int wait, |
| 280 | const u8 *buf, size_t len, bool no_cck, |
| 281 | bool dont_wait_for_ack, u64 *cookie) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 282 | #endif /* LINUX_VERSION_CODE */ |
| 283 | { |
| 284 | int ret; |
| 285 | |
| 286 | cds_ssr_protect(__func__); |
| 287 | |
| 288 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 289 | ret = __wlan_hdd_mgmt_tx(wiphy, wdev, params->chan, params->offchan, |
| 290 | params->wait, params->buf, params->len, |
| 291 | params->no_cck, params->dont_wait_for_ack, |
| 292 | cookie); |
Amar Singhal | 01098f7 | 2015-10-08 11:55:32 -0700 | [diff] [blame] | 293 | #else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 294 | ret = __wlan_hdd_mgmt_tx(wiphy, wdev, chan, offchan, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 295 | wait, buf, len, no_cck, |
| 296 | dont_wait_for_ack, cookie); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 297 | #endif /* LINUX_VERSION_CODE */ |
| 298 | cds_ssr_unprotect(__func__); |
| 299 | |
| 300 | return ret; |
| 301 | } |
| 302 | |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 303 | static int __wlan_hdd_cfg80211_mgmt_tx_cancel_wait(struct wiphy *wiphy, |
| 304 | struct wireless_dev *wdev, |
| 305 | u64 cookie) |
| 306 | { |
| 307 | QDF_STATUS status; |
| 308 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 309 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 310 | |
| 311 | ENTER(); |
| 312 | |
| 313 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 314 | hdd_err("Command not allowed in FTM mode"); |
| 315 | return -EINVAL; |
| 316 | } |
| 317 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 318 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 319 | hdd_err("invalid session id: %d", adapter->session_id); |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 320 | return -EINVAL; |
| 321 | } |
| 322 | |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 323 | status = wlan_cfg80211_mgmt_tx_cancel(adapter->hdd_vdev, |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 324 | cookie); |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 325 | hdd_debug("cancel mgmt tx, status:%d", status); |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 326 | |
| 327 | return 0; |
| 328 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 329 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 330 | int wlan_hdd_cfg80211_mgmt_tx_cancel_wait(struct wiphy *wiphy, |
| 331 | struct wireless_dev *wdev, u64 cookie) |
| 332 | { |
| 333 | int ret; |
| 334 | |
| 335 | cds_ssr_protect(__func__); |
| 336 | ret = __wlan_hdd_cfg80211_mgmt_tx_cancel_wait(wiphy, wdev, cookie); |
| 337 | cds_ssr_unprotect(__func__); |
| 338 | |
| 339 | return ret; |
| 340 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 341 | |
Selvaraj, Sridhar | 4577a9b | 2016-09-04 15:17:07 +0530 | [diff] [blame] | 342 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 343 | * hdd_set_p2p_noa |
| 344 | * |
| 345 | ***FUNCTION: |
| 346 | * This function is called from hdd_hostapd_ioctl function when Driver |
| 347 | * get P2P_SET_NOA comand from wpa_supplicant using private ioctl |
| 348 | * |
| 349 | ***LOGIC: |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 350 | * Fill noa Struct According to P2P Power save Option and Pass it to SME layer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 351 | * |
| 352 | ***ASSUMPTIONS: |
| 353 | * |
| 354 | * |
| 355 | ***NOTE: |
| 356 | * |
| 357 | * @param dev Pointer to net device structure |
| 358 | * @param command Pointer to command |
| 359 | * |
| 360 | * @return Status |
| 361 | */ |
| 362 | |
| 363 | int hdd_set_p2p_noa(struct net_device *dev, uint8_t *command) |
| 364 | { |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 365 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 366 | struct p2p_ps_config noa = {0}; |
Manishekar Chandrasekaran | 371e5af | 2016-06-30 23:17:29 +0530 | [diff] [blame] | 367 | int count, duration, interval; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 368 | char *param; |
| 369 | int ret; |
| 370 | |
| 371 | param = strnchr(command, strlen(command), ' '); |
| 372 | if (param == NULL) { |
Archana Ramachandran | dfb6f85 | 2016-08-19 17:25:29 -0700 | [diff] [blame] | 373 | hdd_err("strnchr failed to find delimeter"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 374 | return -EINVAL; |
| 375 | } |
| 376 | param++; |
Manishekar Chandrasekaran | 371e5af | 2016-06-30 23:17:29 +0530 | [diff] [blame] | 377 | ret = sscanf(param, "%d %d %d", &count, &interval, &duration); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 378 | if (ret != 3) { |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 379 | hdd_err("P2P_SET GO noa: fail to read params, ret=%d", |
Archana Ramachandran | dfb6f85 | 2016-08-19 17:25:29 -0700 | [diff] [blame] | 380 | ret); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 381 | return -EINVAL; |
| 382 | } |
Archana Ramachandran | 1e6b926 | 2016-09-30 15:15:10 -0700 | [diff] [blame] | 383 | if (count < 0 || interval < 0 || duration < 0 || |
| 384 | interval > MAX_MUS_VAL || duration > MAX_MUS_VAL) { |
| 385 | hdd_err("Invalid NOA parameters"); |
| 386 | return -EINVAL; |
| 387 | } |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 388 | hdd_debug("P2P_SET GO noa: count=%d interval=%d duration=%d", |
Archana Ramachandran | dfb6f85 | 2016-08-19 17:25:29 -0700 | [diff] [blame] | 389 | count, interval, duration); |
Manishekar Chandrasekaran | 371e5af | 2016-06-30 23:17:29 +0530 | [diff] [blame] | 390 | duration = MS_TO_TU_MUS(duration); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 391 | /* PS Selection |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 392 | * Periodic noa (2) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 393 | * Single NOA (4) |
| 394 | */ |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 395 | noa.opp_ps = 0; |
| 396 | noa.ct_window = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 397 | if (count == 1) { |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 398 | noa.duration = 0; |
| 399 | noa.single_noa_duration = duration; |
| 400 | noa.ps_selection = P2P_POWER_SAVE_TYPE_SINGLE_NOA; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 401 | } else { |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 402 | noa.duration = duration; |
| 403 | noa.single_noa_duration = 0; |
| 404 | noa.ps_selection = P2P_POWER_SAVE_TYPE_PERIODIC_NOA; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 405 | } |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 406 | noa.interval = MS_TO_TU_MUS(interval); |
| 407 | noa.count = count; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 408 | noa.vdev_id = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 409 | |
Srinivas Girigowda | c7f00d4 | 2017-03-06 18:01:35 -0800 | [diff] [blame] | 410 | hdd_debug("P2P_PS_ATTR:oppPS %d ctWindow %d duration %d " |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 411 | "interval %d count %d single noa duration %d " |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 412 | "PsSelection %x", noa.opp_ps, |
| 413 | noa.ct_window, noa.duration, noa.interval, |
| 414 | noa.count, noa.single_noa_duration, noa.ps_selection); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 415 | |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 416 | return wlan_hdd_set_power_save(adapter, &noa); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | /** |
| 420 | * hdd_set_p2p_opps |
| 421 | * |
| 422 | ***FUNCTION: |
| 423 | * This function is called from hdd_hostapd_ioctl function when Driver |
| 424 | * get P2P_SET_PS comand from wpa_supplicant using private ioctl |
| 425 | * |
| 426 | ***LOGIC: |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 427 | * Fill noa Struct According to P2P Power save Option and Pass it to SME layer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 428 | * |
| 429 | ***ASSUMPTIONS: |
| 430 | * |
| 431 | * |
| 432 | ***NOTE: |
| 433 | * |
| 434 | * @param dev Pointer to net device structure |
| 435 | * @param command Pointer to command |
| 436 | * |
| 437 | * @return Status |
| 438 | */ |
| 439 | |
| 440 | int hdd_set_p2p_opps(struct net_device *dev, uint8_t *command) |
| 441 | { |
Jeff Johnson | fbb5452 | 2017-08-29 14:25:27 -0700 | [diff] [blame] | 442 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 443 | struct p2p_ps_config noa = {0}; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 444 | char *param; |
| 445 | int legacy_ps, opp_ps, ctwindow; |
| 446 | int ret; |
| 447 | |
| 448 | param = strnchr(command, strlen(command), ' '); |
| 449 | if (param == NULL) { |
Manishekar Chandrasekaran | 0575bee | 2016-07-11 15:25:47 +0530 | [diff] [blame] | 450 | hdd_err("strnchr failed to find delimiter"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 451 | return -EINVAL; |
| 452 | } |
| 453 | param++; |
| 454 | ret = sscanf(param, "%d %d %d", &legacy_ps, &opp_ps, &ctwindow); |
| 455 | if (ret != 3) { |
Manishekar Chandrasekaran | 0575bee | 2016-07-11 15:25:47 +0530 | [diff] [blame] | 456 | hdd_err("P2P_SET GO PS: fail to read params, ret=%d", ret); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 457 | return -EINVAL; |
| 458 | } |
Manishekar Chandrasekaran | 0575bee | 2016-07-11 15:25:47 +0530 | [diff] [blame] | 459 | |
| 460 | if ((opp_ps != -1) && (opp_ps != 0) && (opp_ps != 1)) { |
| 461 | hdd_err("Invalid opp_ps value:%d", opp_ps); |
| 462 | return -EINVAL; |
| 463 | } |
| 464 | |
| 465 | /* P2P spec: 3.3.2 Power Management and discovery: |
| 466 | * CTWindow should be at least 10 TU. |
| 467 | * P2P spec: Table 27 - CTWindow and OppPS Parameters field format: |
| 468 | * CTWindow and OppPS Parameters together is 8 bits. |
| 469 | * CTWindow uses 7 bits (0-6, Bit 7 is for OppPS) |
| 470 | * 0 indicates that there shall be no CTWindow |
| 471 | */ |
| 472 | if ((ctwindow != -1) && (ctwindow != 0) && |
| 473 | (!((ctwindow >= 10) && (ctwindow <= 127)))) { |
| 474 | hdd_err("Invalid CT window value:%d", ctwindow); |
| 475 | return -EINVAL; |
| 476 | } |
| 477 | |
Srinivas Girigowda | c7f00d4 | 2017-03-06 18:01:35 -0800 | [diff] [blame] | 478 | hdd_debug("P2P_SET GO PS: legacy_ps=%d opp_ps=%d ctwindow=%d", |
Manishekar Chandrasekaran | 0575bee | 2016-07-11 15:25:47 +0530 | [diff] [blame] | 479 | legacy_ps, opp_ps, ctwindow); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 480 | |
| 481 | /* PS Selection |
| 482 | * Opportunistic Power Save (1) |
| 483 | */ |
| 484 | |
Srinivas Girigowda | ef32780 | 2017-03-24 23:13:20 -0700 | [diff] [blame] | 485 | /* From wpa_cli user need to use separate command to set ctWindow and |
| 486 | * Opps when user want to set ctWindow during that time other parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 487 | * values are coming from wpa_supplicant as -1. |
| 488 | * Example : User want to set ctWindow with 30 then wpa_cli command : |
| 489 | * P2P_SET ctwindow 30 |
| 490 | * Command Received at hdd_hostapd_ioctl is as below: |
| 491 | * P2P_SET_PS -1 -1 30 (legacy_ps = -1, opp_ps = -1, ctwindow = 30) |
Manishekar Chandrasekaran | 0575bee | 2016-07-11 15:25:47 +0530 | [diff] [blame] | 492 | * |
| 493 | * e.g., 1: P2P_SET_PS 1 1 30 |
| 494 | * Driver sets the Opps and CTwindow as 30 and send it to FW. |
| 495 | * e.g., 2: P2P_SET_PS 1 -1 15 |
| 496 | * Driver caches the CTwindow value but not send the command to FW. |
| 497 | * e.g., 3: P2P_SET_PS 1 1 -1 |
| 498 | * Driver sends the command to FW with Opps enabled and CT window as |
| 499 | * 15 (last cached CTWindow value). |
| 500 | * (or) : P2P_SET_PS 1 1 20 |
| 501 | * Driver sends the command to FW with opps enabled and CT window |
| 502 | * as 20. |
| 503 | * |
| 504 | * legacy_ps param remains unused until required in the future. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 505 | */ |
Manishekar Chandrasekaran | 0575bee | 2016-07-11 15:25:47 +0530 | [diff] [blame] | 506 | if (ctwindow != -1) |
| 507 | adapter->ctw = ctwindow; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 508 | |
Manishekar Chandrasekaran | 0575bee | 2016-07-11 15:25:47 +0530 | [diff] [blame] | 509 | /* Send command to FW when OppPS is either enabled(1)/disbaled(0) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 510 | if (opp_ps != -1) { |
Manishekar Chandrasekaran | 0575bee | 2016-07-11 15:25:47 +0530 | [diff] [blame] | 511 | adapter->ops = opp_ps; |
| 512 | noa.opp_ps = adapter->ops; |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 513 | noa.ct_window = adapter->ctw; |
Manishekar Chandrasekaran | 0575bee | 2016-07-11 15:25:47 +0530 | [diff] [blame] | 514 | noa.duration = 0; |
| 515 | noa.single_noa_duration = 0; |
| 516 | noa.interval = 0; |
| 517 | noa.count = 0; |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 518 | noa.ps_selection = P2P_POWER_SAVE_TYPE_OPPORTUNISTIC; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 519 | noa.vdev_id = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 520 | |
Manishekar Chandrasekaran | 0575bee | 2016-07-11 15:25:47 +0530 | [diff] [blame] | 521 | hdd_debug("P2P_PS_ATTR: oppPS %d ctWindow %d duration %d interval %d count %d single noa duration %d PsSelection %x", |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 522 | noa.opp_ps, noa.ct_window, |
Manishekar Chandrasekaran | 0575bee | 2016-07-11 15:25:47 +0530 | [diff] [blame] | 523 | noa.duration, noa.interval, noa.count, |
| 524 | noa.single_noa_duration, |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 525 | noa.ps_selection); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 526 | |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 527 | wlan_hdd_set_power_save(adapter, &noa); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 528 | } |
Manishekar Chandrasekaran | 0575bee | 2016-07-11 15:25:47 +0530 | [diff] [blame] | 529 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 530 | return 0; |
| 531 | } |
| 532 | |
| 533 | int hdd_set_p2p_ps(struct net_device *dev, void *msgData) |
| 534 | { |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 535 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 536 | struct p2p_ps_config noa = {0}; |
| 537 | struct p2p_app_set_ps *pappnoa = (struct p2p_app_set_ps *) msgData; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 538 | |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 539 | noa.opp_ps = pappnoa->opp_ps; |
| 540 | noa.ct_window = pappnoa->ctWindow; |
| 541 | noa.duration = pappnoa->duration; |
| 542 | noa.interval = pappnoa->interval; |
| 543 | noa.count = pappnoa->count; |
| 544 | noa.single_noa_duration = pappnoa->single_noa_duration; |
| 545 | noa.ps_selection = pappnoa->psSelection; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 546 | noa.vdev_id = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 547 | |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 548 | return wlan_hdd_set_power_save(adapter, &noa); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 549 | } |
| 550 | |
| 551 | static uint8_t wlan_hdd_get_session_type(enum nl80211_iftype type) |
| 552 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 553 | switch (type) { |
| 554 | case NL80211_IFTYPE_AP: |
Dustin Brown | 0a1da14 | 2016-09-13 13:31:52 -0700 | [diff] [blame] | 555 | return QDF_SAP_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 556 | case NL80211_IFTYPE_P2P_GO: |
Dustin Brown | 0a1da14 | 2016-09-13 13:31:52 -0700 | [diff] [blame] | 557 | return QDF_P2P_GO_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 558 | case NL80211_IFTYPE_P2P_CLIENT: |
Dustin Brown | 0a1da14 | 2016-09-13 13:31:52 -0700 | [diff] [blame] | 559 | return QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 560 | case NL80211_IFTYPE_STATION: |
Dustin Brown | 0a1da14 | 2016-09-13 13:31:52 -0700 | [diff] [blame] | 561 | return QDF_STA_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 562 | default: |
Dustin Brown | 0a1da14 | 2016-09-13 13:31:52 -0700 | [diff] [blame] | 563 | return QDF_STA_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 564 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 565 | } |
| 566 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 567 | /** |
Rajeev Kumar Sirasanagandla | bb03b2c | 2017-12-12 17:51:09 +0530 | [diff] [blame] | 568 | * wlan_hdd_allow_sap_add() - check to add new sap interface |
| 569 | * @hdd_ctx: pointer to hdd context |
| 570 | * @name: name of the new interface |
| 571 | * @sap_dev: output pointer to hold existing interface |
| 572 | * |
| 573 | * Return: If able to add interface return true else false |
| 574 | */ |
| 575 | static bool |
| 576 | wlan_hdd_allow_sap_add(struct hdd_context *hdd_ctx, const char *name, |
| 577 | struct wireless_dev **sap_dev) |
| 578 | { |
Rajeev Kumar Sirasanagandla | bb03b2c | 2017-12-12 17:51:09 +0530 | [diff] [blame] | 579 | struct hdd_adapter *adapter; |
| 580 | |
| 581 | *sap_dev = NULL; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 582 | |
| 583 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 584 | if (adapter->device_mode == QDF_SAP_MODE && |
Rajeev Kumar Sirasanagandla | bb03b2c | 2017-12-12 17:51:09 +0530 | [diff] [blame] | 585 | test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags) && |
| 586 | !strncmp(adapter->dev->name, name, IFNAMSIZ)) { |
| 587 | struct hdd_beacon_data *beacon = |
| 588 | adapter->session.ap.beacon; |
| 589 | |
| 590 | hdd_debug("iface already registered"); |
| 591 | if (beacon) { |
| 592 | adapter->session.ap.beacon = NULL; |
| 593 | qdf_mem_free(beacon); |
| 594 | } |
| 595 | if (adapter->dev && adapter->dev->ieee80211_ptr) { |
| 596 | *sap_dev = adapter->dev->ieee80211_ptr; |
| 597 | return false; |
| 598 | } |
| 599 | |
| 600 | hdd_err("ieee80211_ptr points to NULL"); |
| 601 | return false; |
| 602 | } |
Rajeev Kumar Sirasanagandla | bb03b2c | 2017-12-12 17:51:09 +0530 | [diff] [blame] | 603 | } |
| 604 | |
| 605 | return true; |
| 606 | } |
| 607 | |
| 608 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 609 | * __wlan_hdd_add_virtual_intf() - Add virtual interface |
| 610 | * @wiphy: wiphy pointer |
| 611 | * @name: User-visible name of the interface |
| 612 | * @name_assign_type: the name of assign type of the netdev |
| 613 | * @nl80211_iftype: (virtual) interface types |
| 614 | * @flags: moniter configuraiton flags (not used) |
| 615 | * @vif_params: virtual interface parameters (not used) |
| 616 | * |
Arun Khandavalli | c67110c | 2016-08-18 16:18:51 +0530 | [diff] [blame] | 617 | * Return: the pointer of wireless dev, otherwise ERR_PTR. |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 618 | */ |
Jeff Johnson | d229104 | 2016-10-05 16:18:50 -0700 | [diff] [blame] | 619 | static |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 620 | struct wireless_dev *__wlan_hdd_add_virtual_intf(struct wiphy *wiphy, |
| 621 | const char *name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 622 | unsigned char name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 623 | enum nl80211_iftype type, |
| 624 | u32 *flags, |
| 625 | struct vif_params *params) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 626 | { |
Jeff Johnson | 7c794a1 | 2017-09-03 09:20:55 -0700 | [diff] [blame] | 627 | struct hdd_context *hdd_ctx = (struct hdd_context *) wiphy_priv(wiphy); |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 628 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 629 | int ret; |
Peng Xu | 45486ea | 2015-11-12 16:37:44 -0800 | [diff] [blame] | 630 | uint8_t session_type; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 631 | |
| 632 | ENTER(); |
| 633 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 634 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Archana Ramachandran | dfb6f85 | 2016-08-19 17:25:29 -0700 | [diff] [blame] | 635 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 636 | return ERR_PTR(-EINVAL); |
| 637 | } |
| 638 | |
Jeff Johnson | 7c794a1 | 2017-09-03 09:20:55 -0700 | [diff] [blame] | 639 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 640 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 641 | return ERR_PTR(ret); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 642 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 643 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 644 | TRACE_CODE_HDD_ADD_VIRTUAL_INTF, NO_SESSION, type)); |
| 645 | /* |
Krunal Soni | fb84cbd | 2016-03-10 13:09:07 -0800 | [diff] [blame] | 646 | * Allow addition multiple interfaces for QDF_P2P_GO_MODE, |
| 647 | * QDF_SAP_MODE, QDF_P2P_CLIENT_MODE and QDF_STA_MODE |
Peng Xu | 45486ea | 2015-11-12 16:37:44 -0800 | [diff] [blame] | 648 | * session type. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 649 | */ |
Peng Xu | 45486ea | 2015-11-12 16:37:44 -0800 | [diff] [blame] | 650 | session_type = wlan_hdd_get_session_type(type); |
Jeff Johnson | 7c794a1 | 2017-09-03 09:20:55 -0700 | [diff] [blame] | 651 | if (hdd_get_adapter(hdd_ctx, session_type) != NULL |
Krunal Soni | fb84cbd | 2016-03-10 13:09:07 -0800 | [diff] [blame] | 652 | && QDF_SAP_MODE != session_type |
| 653 | && QDF_P2P_GO_MODE != session_type |
Krunal Soni | fb84cbd | 2016-03-10 13:09:07 -0800 | [diff] [blame] | 654 | && QDF_P2P_CLIENT_MODE != session_type |
| 655 | && QDF_STA_MODE != session_type) { |
Archana Ramachandran | dfb6f85 | 2016-08-19 17:25:29 -0700 | [diff] [blame] | 656 | hdd_err("Interface type %d already exists. Two interfaces of same type are not supported currently.", |
| 657 | type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 658 | return ERR_PTR(-EINVAL); |
| 659 | } |
| 660 | |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 661 | adapter = hdd_get_adapter(hdd_ctx, QDF_STA_MODE); |
| 662 | if ((adapter != NULL) && |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 663 | !(wlan_hdd_validate_session_id(adapter->session_id))) { |
Sandeep Puligilla | 5f86d99 | 2017-10-29 14:58:53 -0700 | [diff] [blame] | 664 | if (ucfg_scan_get_vdev_status(adapter->hdd_vdev) != |
| 665 | SCAN_NOT_IN_PROGRESS) { |
Jeff Johnson | 7c794a1 | 2017-09-03 09:20:55 -0700 | [diff] [blame] | 666 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 667 | adapter->session_id, INVALID_SCAN_ID, false); |
Srinivas Girigowda | c7f00d4 | 2017-03-06 18:01:35 -0800 | [diff] [blame] | 668 | hdd_debug("Abort Scan while adding virtual interface"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 669 | } |
| 670 | } |
| 671 | |
Hanumanth Reddy Pothula | 74a97d4 | 2017-11-20 21:43:54 +0530 | [diff] [blame] | 672 | if (session_type == QDF_SAP_MODE) { |
Rajeev Kumar Sirasanagandla | bb03b2c | 2017-12-12 17:51:09 +0530 | [diff] [blame] | 673 | struct wireless_dev *sap_dev; |
| 674 | bool allow_add_sap = wlan_hdd_allow_sap_add(hdd_ctx, name, |
| 675 | &sap_dev); |
| 676 | if (!allow_add_sap) { |
| 677 | if (sap_dev) |
| 678 | return sap_dev; |
Hanumanth Reddy Pothula | 74a97d4 | 2017-11-20 21:43:54 +0530 | [diff] [blame] | 679 | |
Hanumanth Reddy Pothula | 74a97d4 | 2017-11-20 21:43:54 +0530 | [diff] [blame] | 680 | return ERR_PTR(-EINVAL); |
| 681 | } |
| 682 | } |
| 683 | |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 684 | adapter = NULL; |
Jeff Johnson | 7c794a1 | 2017-09-03 09:20:55 -0700 | [diff] [blame] | 685 | if (hdd_ctx->config->isP2pDeviceAddrAdministrated && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 686 | ((NL80211_IFTYPE_P2P_GO == type) || |
| 687 | (NL80211_IFTYPE_P2P_CLIENT == type))) { |
| 688 | /* |
| 689 | * Generate the P2P Interface Address. this address must be |
| 690 | * different from the P2P Device Address. |
| 691 | */ |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 692 | struct qdf_mac_addr p2p_device_address = |
| 693 | hdd_ctx->p2p_device_address; |
| 694 | p2p_device_address.bytes[4] ^= 0x80; |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 695 | adapter = hdd_open_adapter(hdd_ctx, |
Dustin Brown | 0a1da14 | 2016-09-13 13:31:52 -0700 | [diff] [blame] | 696 | session_type, |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 697 | name, p2p_device_address.bytes, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 698 | name_assign_type, |
| 699 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 700 | } else { |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 701 | adapter = hdd_open_adapter(hdd_ctx, |
Dustin Brown | 0a1da14 | 2016-09-13 13:31:52 -0700 | [diff] [blame] | 702 | session_type, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 703 | name, |
Jeff Johnson | 7c794a1 | 2017-09-03 09:20:55 -0700 | [diff] [blame] | 704 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 705 | name_assign_type, |
| 706 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 707 | } |
| 708 | |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 709 | if (NULL == adapter) { |
Archana Ramachandran | dfb6f85 | 2016-08-19 17:25:29 -0700 | [diff] [blame] | 710 | hdd_err("hdd_open_adapter failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 711 | return ERR_PTR(-ENOSPC); |
| 712 | } |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 713 | |
Arun Khandavalli | 9928645 | 2016-08-22 12:13:41 +0530 | [diff] [blame] | 714 | /* |
| 715 | * Add interface can be requested from the upper layer at any time |
| 716 | * check the statemachine for modules state and if they are closed |
| 717 | * open the modules. |
| 718 | */ |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 719 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 720 | if (ret) { |
| 721 | hdd_err("Failed to start the wlan_modules"); |
| 722 | goto close_adapter; |
| 723 | } |
Arun Khandavalli | 9928645 | 2016-08-22 12:13:41 +0530 | [diff] [blame] | 724 | |
Arun Khandavalli | 812d069 | 2016-09-01 19:11:56 +0530 | [diff] [blame] | 725 | /* |
| 726 | * Once the support for session creation/deletion from |
| 727 | * hdd_hostapd_open/hdd_host_stop is in place. |
| 728 | * The support for starting adapter from here can be removed. |
| 729 | */ |
| 730 | if (NL80211_IFTYPE_AP == type || (NL80211_IFTYPE_P2P_GO == type)) { |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 731 | ret = hdd_start_adapter(adapter); |
Arun Khandavalli | c67110c | 2016-08-18 16:18:51 +0530 | [diff] [blame] | 732 | if (ret) { |
| 733 | hdd_err("Failed to start %s", name); |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 734 | goto stop_modules; |
Arun Khandavalli | c67110c | 2016-08-18 16:18:51 +0530 | [diff] [blame] | 735 | } |
| 736 | } |
| 737 | |
Jeff Johnson | 7c794a1 | 2017-09-03 09:20:55 -0700 | [diff] [blame] | 738 | if (hdd_ctx->rps) |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 739 | hdd_send_rps_ind(adapter); |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 740 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 741 | EXIT(); |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 742 | return adapter->dev->ieee80211_ptr; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 743 | |
| 744 | stop_modules: |
| 745 | /* |
| 746 | * Find if any iface is up. If there is not iface which is up |
| 747 | * start the timer to close the modules |
| 748 | */ |
Jeff Johnson | 7c794a1 | 2017-09-03 09:20:55 -0700 | [diff] [blame] | 749 | if (hdd_check_for_opened_interfaces(hdd_ctx)) { |
Srinivas Girigowda | c7f00d4 | 2017-03-06 18:01:35 -0800 | [diff] [blame] | 750 | hdd_debug("Closing all modules from the add_virt_iface"); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 751 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 752 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 753 | hdd_prevent_suspend_timeout( |
| 754 | hdd_ctx->config->iface_change_wait_time, |
| 755 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 756 | } else |
Srinivas Girigowda | c7f00d4 | 2017-03-06 18:01:35 -0800 | [diff] [blame] | 757 | hdd_debug("Other interfaces are still up dont close modules!"); |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 758 | |
| 759 | close_adapter: |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 760 | hdd_close_adapter(hdd_ctx, adapter, true); |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 761 | |
| 762 | return ERR_PTR(-EINVAL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 763 | } |
| 764 | |
Dustin Brown | 9ed30a5 | 2017-08-16 13:59:38 -0700 | [diff] [blame] | 765 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) |
| 766 | struct wireless_dev *wlan_hdd_add_virtual_intf(struct wiphy *wiphy, |
| 767 | const char *name, |
| 768 | unsigned char name_assign_type, |
| 769 | enum nl80211_iftype type, |
| 770 | struct vif_params *params) |
| 771 | { |
| 772 | struct wireless_dev *wdev; |
| 773 | |
| 774 | cds_ssr_protect(__func__); |
| 775 | wdev = __wlan_hdd_add_virtual_intf(wiphy, name, name_assign_type, |
| 776 | type, ¶ms->flags, params); |
| 777 | cds_ssr_unprotect(__func__); |
| 778 | |
| 779 | return wdev; |
| 780 | } |
| 781 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)) || defined(WITH_BACKPORTS) |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 782 | /** |
| 783 | * wlan_hdd_add_virtual_intf() - Add virtual interface wrapper |
| 784 | * @wiphy: wiphy pointer |
| 785 | * @name: User-visible name of the interface |
| 786 | * @name_assign_type: the name of assign type of the netdev |
| 787 | * @nl80211_iftype: (virtual) interface types |
| 788 | * @flags: monitor mode configuration flags (not used) |
| 789 | * @vif_params: virtual interface parameters (not used) |
| 790 | * |
Arun Khandavalli | c67110c | 2016-08-18 16:18:51 +0530 | [diff] [blame] | 791 | * Return: the pointer of wireless dev, otherwise ERR_PTR. |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 792 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 793 | struct wireless_dev *wlan_hdd_add_virtual_intf(struct wiphy *wiphy, |
| 794 | const char *name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 795 | unsigned char name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 796 | enum nl80211_iftype type, |
| 797 | u32 *flags, |
| 798 | struct vif_params *params) |
| 799 | { |
| 800 | struct wireless_dev *wdev; |
| 801 | |
| 802 | cds_ssr_protect(__func__); |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 803 | wdev = __wlan_hdd_add_virtual_intf(wiphy, name, name_assign_type, |
| 804 | type, flags, params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 805 | cds_ssr_unprotect(__func__); |
| 806 | return wdev; |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 807 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 808 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 809 | #else |
| 810 | /** |
| 811 | * wlan_hdd_add_virtual_intf() - Add virtual interface wrapper |
| 812 | * @wiphy: wiphy pointer |
| 813 | * @name: User-visible name of the interface |
| 814 | * @nl80211_iftype: (virtual) interface types |
| 815 | * @flags: monitor mode configuration flags (not used) |
| 816 | * @vif_params: virtual interface parameters (not used) |
| 817 | * |
Arun Khandavalli | c67110c | 2016-08-18 16:18:51 +0530 | [diff] [blame] | 818 | * Return: the pointer of wireless dev, otherwise ERR_PTR. |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 819 | */ |
| 820 | struct wireless_dev *wlan_hdd_add_virtual_intf(struct wiphy *wiphy, |
| 821 | const char *name, |
| 822 | enum nl80211_iftype type, |
| 823 | u32 *flags, |
| 824 | struct vif_params *params) |
| 825 | { |
| 826 | struct wireless_dev *wdev; |
| 827 | unsigned char name_assign_type = 0; |
| 828 | |
| 829 | cds_ssr_protect(__func__); |
| 830 | wdev = __wlan_hdd_add_virtual_intf(wiphy, name, name_assign_type, |
| 831 | type, flags, params); |
| 832 | cds_ssr_unprotect(__func__); |
| 833 | return wdev; |
| 834 | |
| 835 | } |
| 836 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 837 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 838 | int __wlan_hdd_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 839 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 840 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | 7c794a1 | 2017-09-03 09:20:55 -0700 | [diff] [blame] | 841 | struct hdd_context *hdd_ctx = (struct hdd_context *) wiphy_priv(wiphy); |
Jeff Johnson | fbb5452 | 2017-08-29 14:25:27 -0700 | [diff] [blame] | 842 | struct hdd_adapter *pVirtAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 843 | int status; |
Srinivas Girigowda | ef32780 | 2017-03-24 23:13:20 -0700 | [diff] [blame] | 844 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 845 | ENTER(); |
| 846 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 847 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Archana Ramachandran | dfb6f85 | 2016-08-19 17:25:29 -0700 | [diff] [blame] | 848 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 849 | return -EINVAL; |
| 850 | } |
| 851 | |
Hanumanth Reddy Pothula | 74a97d4 | 2017-11-20 21:43:54 +0530 | [diff] [blame] | 852 | /* |
| 853 | * Clear SOFTAP_INIT_DONE flag to mark SAP unload, so that we do |
| 854 | * not restart SAP after SSR as SAP is already stopped from user space. |
| 855 | */ |
| 856 | clear_bit(SOFTAP_INIT_DONE, &pVirtAdapter->event_flags); |
| 857 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 858 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 859 | TRACE_CODE_HDD_DEL_VIRTUAL_INTF, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 860 | pVirtAdapter->session_id, pVirtAdapter->device_mode)); |
Srinivas Girigowda | c7f00d4 | 2017-03-06 18:01:35 -0800 | [diff] [blame] | 861 | hdd_debug("Device_mode %s(%d)", |
Archana Ramachandran | dfb6f85 | 2016-08-19 17:25:29 -0700 | [diff] [blame] | 862 | hdd_device_mode_to_string(pVirtAdapter->device_mode), |
| 863 | pVirtAdapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 864 | |
Jeff Johnson | 7c794a1 | 2017-09-03 09:20:55 -0700 | [diff] [blame] | 865 | status = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 866 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 867 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 868 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 869 | |
Mukul Sharma | 24699bd | 2017-04-03 19:50:44 +0530 | [diff] [blame] | 870 | /* check state machine state and kickstart modules if they are closed */ |
Jeff Johnson | 7c794a1 | 2017-09-03 09:20:55 -0700 | [diff] [blame] | 871 | status = hdd_wlan_start_modules(hdd_ctx, pVirtAdapter, false); |
Arun Khandavalli | 9928645 | 2016-08-22 12:13:41 +0530 | [diff] [blame] | 872 | if (status) |
| 873 | return status; |
| 874 | |
Mukul Sharma | 24699bd | 2017-04-03 19:50:44 +0530 | [diff] [blame] | 875 | if (pVirtAdapter->device_mode == QDF_SAP_MODE && |
Jeff Johnson | 7c794a1 | 2017-09-03 09:20:55 -0700 | [diff] [blame] | 876 | wlan_sap_is_pre_cac_active(hdd_ctx->hHal)) { |
| 877 | hdd_clean_up_pre_cac_interface(hdd_ctx); |
Mukul Sharma | 24699bd | 2017-04-03 19:50:44 +0530 | [diff] [blame] | 878 | } else { |
Jeff Johnson | 7c794a1 | 2017-09-03 09:20:55 -0700 | [diff] [blame] | 879 | wlan_hdd_release_intf_addr(hdd_ctx, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 880 | pVirtAdapter->mac_addr.bytes); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 881 | hdd_stop_adapter(hdd_ctx, pVirtAdapter); |
Krunal Soni | c68ee30 | 2017-11-14 20:33:32 -0800 | [diff] [blame] | 882 | hdd_deinit_adapter(hdd_ctx, pVirtAdapter, true); |
Jeff Johnson | 7c794a1 | 2017-09-03 09:20:55 -0700 | [diff] [blame] | 883 | hdd_close_adapter(hdd_ctx, pVirtAdapter, true); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 884 | } |
| 885 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 886 | EXIT(); |
Mukul Sharma | 24699bd | 2017-04-03 19:50:44 +0530 | [diff] [blame] | 887 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 888 | return 0; |
| 889 | } |
| 890 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 891 | int wlan_hdd_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 892 | { |
| 893 | int ret; |
| 894 | |
| 895 | cds_ssr_protect(__func__); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 896 | ret = __wlan_hdd_del_virtual_intf(wiphy, wdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 897 | cds_ssr_unprotect(__func__); |
| 898 | |
| 899 | return ret; |
| 900 | } |
| 901 | |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 902 | void __hdd_indicate_mgmt_frame(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 903 | uint32_t nFrameLength, |
| 904 | uint8_t *pbFrames, |
| 905 | uint8_t frameType, uint32_t rxChan, int8_t rxRssi) |
| 906 | { |
| 907 | uint16_t freq; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 908 | uint8_t type = 0; |
| 909 | uint8_t subType = 0; |
Jeff Johnson | 7c794a1 | 2017-09-03 09:20:55 -0700 | [diff] [blame] | 910 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 911 | |
Srinivas Girigowda | c7f00d4 | 2017-03-06 18:01:35 -0800 | [diff] [blame] | 912 | hdd_debug("Frame Type = %d Frame Length = %d", |
Samuel Ahn | 065e649 | 2016-09-30 22:48:09 +0530 | [diff] [blame] | 913 | frameType, nFrameLength); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 914 | |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 915 | if (NULL == adapter) { |
| 916 | hdd_err("adapter is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 917 | return; |
| 918 | } |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 919 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 920 | |
| 921 | if (0 == nFrameLength) { |
Archana Ramachandran | dfb6f85 | 2016-08-19 17:25:29 -0700 | [diff] [blame] | 922 | hdd_err("Frame Length is Invalid ZERO"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 923 | return; |
| 924 | } |
| 925 | |
| 926 | if (NULL == pbFrames) { |
Archana Ramachandran | dfb6f85 | 2016-08-19 17:25:29 -0700 | [diff] [blame] | 927 | hdd_err("pbFrames is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 928 | return; |
| 929 | } |
| 930 | |
| 931 | type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]); |
| 932 | subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]); |
| 933 | |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 934 | /* Get adapter from Destination mac address of the frame */ |
Sreelakshmi Konamki | 2b1cd52 | 2017-05-26 11:32:44 +0530 | [diff] [blame] | 935 | if ((type == SIR_MAC_MGMT_FRAME) && |
| 936 | (subType != SIR_MAC_MGMT_PROBE_REQ) && |
| 937 | !qdf_is_macaddr_broadcast( |
| 938 | (struct qdf_mac_addr *)&pbFrames[WLAN_HDD_80211_FRM_DA_OFFSET])) { |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 939 | adapter = |
Jeff Johnson | 7c794a1 | 2017-09-03 09:20:55 -0700 | [diff] [blame] | 940 | hdd_get_adapter_by_macaddr(hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 941 | &pbFrames |
| 942 | [WLAN_HDD_80211_FRM_DA_OFFSET]); |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 943 | if (NULL == adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 944 | /* |
| 945 | * Under assumtion that we don't receive any action |
| 946 | * frame with BCST as destination, |
| 947 | * we are dropping action frame |
| 948 | */ |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 949 | hdd_err("adapter for action frame is NULL Macaddr = " |
Archana Ramachandran | dfb6f85 | 2016-08-19 17:25:29 -0700 | [diff] [blame] | 950 | MAC_ADDRESS_STR, |
| 951 | MAC_ADDR_ARRAY(&pbFrames |
| 952 | [WLAN_HDD_80211_FRM_DA_OFFSET])); |
Srinivas Girigowda | c7f00d4 | 2017-03-06 18:01:35 -0800 | [diff] [blame] | 953 | hdd_debug("Frame Type = %d Frame Length = %d subType = %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 954 | frameType, nFrameLength, subType); |
Jeff Johnson | 3aaa492 | 2017-01-12 08:46:09 -0800 | [diff] [blame] | 955 | /* |
| 956 | * We will receive broadcast management frames |
| 957 | * in OCB mode |
| 958 | */ |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 959 | adapter = hdd_get_adapter(hdd_ctx, QDF_OCB_MODE); |
| 960 | if (NULL == adapter || !qdf_is_macaddr_broadcast( |
Samuel Ahn | 065e649 | 2016-09-30 22:48:09 +0530 | [diff] [blame] | 961 | (struct qdf_mac_addr *)&pbFrames |
| 962 | [WLAN_HDD_80211_FRM_DA_OFFSET])) { |
| 963 | /* |
Jeff Johnson | 3aaa492 | 2017-01-12 08:46:09 -0800 | [diff] [blame] | 964 | * Under assumtion that we don't |
| 965 | * receive any action frame with BCST |
| 966 | * as destination, we are dropping |
| 967 | * action frame |
| 968 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 969 | return; |
Samuel Ahn | 065e649 | 2016-09-30 22:48:09 +0530 | [diff] [blame] | 970 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 971 | } |
| 972 | } |
| 973 | |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 974 | if (NULL == adapter->dev) { |
| 975 | hdd_err("adapter->dev is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 976 | return; |
| 977 | } |
| 978 | |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 979 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
| 980 | hdd_err("adapter has invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 981 | return; |
| 982 | } |
| 983 | |
| 984 | /* Channel indicated may be wrong. TODO */ |
| 985 | /* Indicate an action frame. */ |
| 986 | if (rxChan <= MAX_NO_OF_2_4_CHANNELS) |
| 987 | freq = ieee80211_channel_to_frequency(rxChan, |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 988 | NL80211_BAND_2GHZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 989 | else |
| 990 | freq = ieee80211_channel_to_frequency(rxChan, |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 991 | NL80211_BAND_5GHZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 992 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 993 | /* Indicate Frame Over Normal Interface */ |
Srinivas Girigowda | c7f00d4 | 2017-03-06 18:01:35 -0800 | [diff] [blame] | 994 | hdd_debug("Indicate Frame over NL80211 sessionid : %d, idx :%d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 995 | adapter->session_id, adapter->dev->ifindex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 996 | |
| 997 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)) |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 998 | cfg80211_rx_mgmt(adapter->dev->ieee80211_ptr, |
Samuel Ahn | 065e649 | 2016-09-30 22:48:09 +0530 | [diff] [blame] | 999 | freq, rxRssi * 100, pbFrames, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1000 | nFrameLength, NL80211_RXMGMT_FLAG_ANSWERED); |
| 1001 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)) |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 1002 | cfg80211_rx_mgmt(adapter->dev->ieee80211_ptr, |
Samuel Ahn | 065e649 | 2016-09-30 22:48:09 +0530 | [diff] [blame] | 1003 | freq, rxRssi * 100, pbFrames, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1004 | nFrameLength, NL80211_RXMGMT_FLAG_ANSWERED, |
| 1005 | GFP_ATOMIC); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1006 | #else |
Jeff Johnson | 19b66e8 | 2017-10-02 13:25:56 -0700 | [diff] [blame] | 1007 | cfg80211_rx_mgmt(adapter->dev->ieee80211_ptr, freq, |
Samuel Ahn | 065e649 | 2016-09-30 22:48:09 +0530 | [diff] [blame] | 1008 | rxRssi * 100, |
| 1009 | pbFrames, nFrameLength, GFP_ATOMIC); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1010 | #endif /* LINUX_VERSION_CODE */ |
| 1011 | } |
| 1012 | |
Jeff Johnson | fbb5452 | 2017-08-29 14:25:27 -0700 | [diff] [blame] | 1013 | int wlan_hdd_set_power_save(struct hdd_adapter *adapter, |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 1014 | struct p2p_ps_config *ps_config) |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 1015 | { |
| 1016 | struct wlan_objmgr_psoc *psoc; |
Jeff Johnson | 1876762 | 2017-08-28 11:46:50 -0700 | [diff] [blame] | 1017 | struct hdd_context *hdd_ctx; |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 1018 | QDF_STATUS status; |
| 1019 | |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 1020 | if (!adapter || !ps_config) { |
| 1021 | hdd_err("null param, adapter:%pK, ps_config:%pK", |
| 1022 | adapter, ps_config); |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 1023 | return -EINVAL; |
| 1024 | } |
| 1025 | |
| 1026 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 1027 | psoc = hdd_ctx->hdd_psoc; |
| 1028 | if (!psoc) { |
| 1029 | hdd_err("psoc is null"); |
| 1030 | return -EINVAL; |
| 1031 | } |
| 1032 | |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 1033 | hdd_debug("opp ps:%d, ct window:%d, duration:%d, interval:%d, count:%d, single noa duration:%d, ps selection:%d, vdev id:%d", |
| 1034 | ps_config->opp_ps, ps_config->ct_window, |
| 1035 | ps_config->duration, ps_config->interval, |
| 1036 | ps_config->count, ps_config->single_noa_duration, |
| 1037 | ps_config->ps_selection, ps_config->vdev_id); |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 1038 | |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 1039 | status = ucfg_p2p_set_ps(psoc, ps_config); |
| 1040 | hdd_debug("p2p set power save, status:%d", status); |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 1041 | |
| 1042 | return qdf_status_to_os_return(status); |
| 1043 | } |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 1044 | |
Jeff Johnson | fbb5452 | 2017-08-29 14:25:27 -0700 | [diff] [blame] | 1045 | int wlan_hdd_listen_offload_start(struct hdd_adapter *adapter, |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 1046 | struct sir_p2p_lo_start *params) |
| 1047 | { |
| 1048 | struct wlan_objmgr_psoc *psoc; |
| 1049 | struct p2p_lo_start lo_start; |
Jeff Johnson | 1876762 | 2017-08-28 11:46:50 -0700 | [diff] [blame] | 1050 | struct hdd_context *hdd_ctx; |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 1051 | QDF_STATUS status; |
| 1052 | |
| 1053 | if (!adapter || !params) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 1054 | hdd_err("null param, adapter:%pK, params:%pK", |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 1055 | adapter, params); |
| 1056 | return -EINVAL; |
| 1057 | } |
| 1058 | |
| 1059 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 1060 | psoc = hdd_ctx->hdd_psoc; |
| 1061 | if (!psoc) { |
| 1062 | hdd_err("psoc is null"); |
| 1063 | return -EINVAL; |
| 1064 | } |
| 1065 | |
| 1066 | lo_start.vdev_id = params->vdev_id; |
| 1067 | lo_start.ctl_flags = params->ctl_flags; |
| 1068 | lo_start.freq = params->freq; |
| 1069 | lo_start.period = params->period; |
| 1070 | lo_start.interval = params->interval; |
| 1071 | lo_start.count = params->count; |
| 1072 | lo_start.device_types = params->device_types; |
| 1073 | lo_start.dev_types_len = params->dev_types_len; |
| 1074 | lo_start.probe_resp_tmplt = params->probe_resp_tmplt; |
| 1075 | lo_start.probe_resp_len = params->probe_resp_len; |
| 1076 | |
| 1077 | status = ucfg_p2p_lo_start(psoc, &lo_start); |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 1078 | hdd_debug("p2p listen offload start, status:%d", status); |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 1079 | |
| 1080 | return qdf_status_to_os_return(status); |
| 1081 | } |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 1082 | |
Jeff Johnson | fbb5452 | 2017-08-29 14:25:27 -0700 | [diff] [blame] | 1083 | int wlan_hdd_listen_offload_stop(struct hdd_adapter *adapter) |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 1084 | { |
| 1085 | struct wlan_objmgr_psoc *psoc; |
Jeff Johnson | 1876762 | 2017-08-28 11:46:50 -0700 | [diff] [blame] | 1086 | struct hdd_context *hdd_ctx; |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 1087 | uint32_t vdev_id; |
| 1088 | QDF_STATUS status; |
| 1089 | |
| 1090 | if (!adapter) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 1091 | hdd_err("adapter is null, adapter:%pK", adapter); |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 1092 | return -EINVAL; |
| 1093 | } |
| 1094 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1095 | vdev_id = (uint32_t)adapter->session_id; |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 1096 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 1097 | psoc = hdd_ctx->hdd_psoc; |
| 1098 | if (!psoc) { |
| 1099 | hdd_err("psoc is null"); |
| 1100 | return -EINVAL; |
| 1101 | } |
| 1102 | |
| 1103 | status = ucfg_p2p_lo_stop(psoc, vdev_id); |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 1104 | hdd_debug("p2p listen offload stop, status:%d", status); |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 1105 | |
| 1106 | return qdf_status_to_os_return(status); |
| 1107 | } |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 1108 | |
| 1109 | /** |
| 1110 | * wlan_hdd_update_mcc_adaptive_scheduler() - Function to update |
| 1111 | * MAS value to FW |
| 1112 | * @adapter: adapter object data |
| 1113 | * @is_enable: 0-Disable, 1-Enable MAS |
| 1114 | * |
| 1115 | * This function passes down the value of MAS to UMAC |
| 1116 | * |
| 1117 | * Return: 0 for success else non zero |
| 1118 | * |
| 1119 | */ |
| 1120 | static int32_t wlan_hdd_update_mcc_adaptive_scheduler( |
Jeff Johnson | fbb5452 | 2017-08-29 14:25:27 -0700 | [diff] [blame] | 1121 | struct hdd_adapter *adapter, bool is_enable) |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 1122 | { |
Jeff Johnson | 1876762 | 2017-08-28 11:46:50 -0700 | [diff] [blame] | 1123 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 1124 | |
| 1125 | if (hdd_ctx == NULL) { |
| 1126 | hdd_err("HDD context is null"); |
| 1127 | return -EINVAL; |
| 1128 | } |
| 1129 | |
| 1130 | hdd_info("enable/disable MAS :%d", is_enable); |
| 1131 | if (hdd_ctx->config && |
| 1132 | hdd_ctx->config->enableMCCAdaptiveScheduler) { |
| 1133 | /* Todo check where to set the MCC apative SCHED for read */ |
| 1134 | |
| 1135 | if (QDF_STATUS_SUCCESS != sme_set_mas(is_enable)) { |
| 1136 | hdd_err("Failed to enable/disable MAS"); |
| 1137 | return -EAGAIN; |
| 1138 | } |
| 1139 | } |
| 1140 | |
| 1141 | return 0; |
| 1142 | } |
| 1143 | |
| 1144 | /** |
| 1145 | * wlan_hdd_update_mcc_p2p_quota() - Function to Update P2P |
| 1146 | * quota to FW |
| 1147 | * @adapter: Pointer to HDD adapter |
| 1148 | * @is_set: 0-reset, 1-set |
| 1149 | * |
| 1150 | * This function passes down the value of MAS to UMAC |
| 1151 | * |
| 1152 | * Return: none |
| 1153 | * |
| 1154 | */ |
Jeff Johnson | fbb5452 | 2017-08-29 14:25:27 -0700 | [diff] [blame] | 1155 | static void wlan_hdd_update_mcc_p2p_quota(struct hdd_adapter *adapter, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 1156 | bool is_set) |
| 1157 | { |
| 1158 | |
| 1159 | hdd_info("Set/reset P2P quota: %d", is_set); |
| 1160 | if (is_set) { |
| 1161 | if (adapter->device_mode == QDF_STA_MODE) |
| 1162 | wlan_hdd_set_mcc_p2p_quota(adapter, |
| 1163 | 100 - HDD_DEFAULT_MCC_P2P_QUOTA |
| 1164 | ); |
| 1165 | else if (adapter->device_mode == QDF_P2P_GO_MODE) |
| 1166 | wlan_hdd_go_set_mcc_p2p_quota(adapter, |
| 1167 | HDD_DEFAULT_MCC_P2P_QUOTA); |
| 1168 | else |
| 1169 | wlan_hdd_set_mcc_p2p_quota(adapter, |
| 1170 | HDD_DEFAULT_MCC_P2P_QUOTA); |
| 1171 | } else { |
| 1172 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
| 1173 | wlan_hdd_go_set_mcc_p2p_quota(adapter, |
| 1174 | HDD_RESET_MCC_P2P_QUOTA); |
| 1175 | else |
| 1176 | wlan_hdd_set_mcc_p2p_quota(adapter, |
| 1177 | HDD_RESET_MCC_P2P_QUOTA); |
| 1178 | } |
| 1179 | } |
| 1180 | |
Jeff Johnson | fbb5452 | 2017-08-29 14:25:27 -0700 | [diff] [blame] | 1181 | int32_t wlan_hdd_set_mas(struct hdd_adapter *adapter, uint8_t mas_value) |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 1182 | { |
| 1183 | int32_t ret = 0; |
| 1184 | |
| 1185 | if (!adapter) { |
| 1186 | hdd_err("Adapter is NULL"); |
| 1187 | return -EINVAL; |
| 1188 | } |
| 1189 | |
| 1190 | if (mas_value) { |
| 1191 | hdd_info("Miracast is ON. Disable MAS and configure P2P quota"); |
| 1192 | ret = wlan_hdd_update_mcc_adaptive_scheduler( |
| 1193 | adapter, false); |
| 1194 | if (0 != ret) { |
| 1195 | hdd_err("Failed to disable MAS"); |
| 1196 | goto done; |
| 1197 | } |
| 1198 | |
| 1199 | /* Config p2p quota */ |
| 1200 | wlan_hdd_update_mcc_p2p_quota(adapter, true); |
| 1201 | } else { |
| 1202 | hdd_info("Miracast is OFF. Enable MAS and reset P2P quota"); |
| 1203 | wlan_hdd_update_mcc_p2p_quota(adapter, false); |
| 1204 | |
| 1205 | ret = wlan_hdd_update_mcc_adaptive_scheduler( |
| 1206 | adapter, true); |
| 1207 | if (0 != ret) { |
| 1208 | hdd_err("Failed to enable MAS"); |
| 1209 | goto done; |
| 1210 | } |
| 1211 | } |
| 1212 | |
| 1213 | done: |
| 1214 | return ret; |
| 1215 | } |
| 1216 | |
| 1217 | /** |
| 1218 | * set_first_connection_operating_channel() - Function to set |
| 1219 | * first connection oerating channel |
| 1220 | * @adapter: adapter data |
| 1221 | * @set_value: Quota value for the interface |
| 1222 | * @dev_mode: Device mode |
| 1223 | * This function is used to set the first adapter operating |
| 1224 | * channel |
| 1225 | * |
| 1226 | * Return: operating channel updated in set value |
| 1227 | * |
| 1228 | */ |
| 1229 | static uint32_t set_first_connection_operating_channel( |
Jeff Johnson | 1876762 | 2017-08-28 11:46:50 -0700 | [diff] [blame] | 1230 | struct hdd_context *hdd_ctx, uint32_t set_value, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 1231 | enum QDF_OPMODE dev_mode) |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 1232 | { |
| 1233 | uint8_t operating_channel; |
| 1234 | |
| 1235 | operating_channel = hdd_get_operating_channel( |
| 1236 | hdd_ctx, dev_mode); |
| 1237 | if (!operating_channel) { |
| 1238 | hdd_err(" First adpter operating channel is invalid"); |
| 1239 | return -EINVAL; |
| 1240 | } |
| 1241 | |
| 1242 | hdd_info("First connection channel No.:%d and quota:%dms", |
| 1243 | operating_channel, set_value); |
| 1244 | /* Move the time quota for first channel to bits 15-8 */ |
| 1245 | set_value = set_value << 8; |
| 1246 | |
| 1247 | /* |
Jeff Johnson | dcf84ce | 2017-10-05 09:26:24 -0700 | [diff] [blame] | 1248 | * Store the channel number of 1st channel at bits 7-0 |
| 1249 | * of the bit vector |
| 1250 | */ |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 1251 | return set_value | operating_channel; |
| 1252 | } |
| 1253 | |
| 1254 | /** |
| 1255 | * set_second_connection_operating_channel() - Function to set |
| 1256 | * second connection oerating channel |
| 1257 | * @adapter: adapter data |
| 1258 | * @set_value: Quota value for the interface |
| 1259 | * @vdev_id: vdev id |
| 1260 | * |
| 1261 | * This function is used to set the first adapter operating |
| 1262 | * channel |
| 1263 | * |
| 1264 | * Return: operating channel updated in set value |
| 1265 | * |
| 1266 | */ |
| 1267 | static uint32_t set_second_connection_operating_channel( |
Jeff Johnson | 1876762 | 2017-08-28 11:46:50 -0700 | [diff] [blame] | 1268 | struct hdd_context *hdd_ctx, uint32_t set_value, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 1269 | uint8_t vdev_id) |
| 1270 | { |
| 1271 | uint8_t operating_channel; |
| 1272 | |
| 1273 | operating_channel = policy_mgr_get_mcc_operating_channel( |
| 1274 | hdd_ctx->hdd_psoc, vdev_id); |
| 1275 | |
| 1276 | if (operating_channel == 0) { |
| 1277 | hdd_err("Second adapter operating channel is invalid"); |
| 1278 | return -EINVAL; |
| 1279 | } |
| 1280 | |
| 1281 | hdd_info("Second connection channel No.:%d and quota:%dms", |
| 1282 | operating_channel, set_value); |
| 1283 | /* |
Jeff Johnson | dcf84ce | 2017-10-05 09:26:24 -0700 | [diff] [blame] | 1284 | * Now move the time quota and channel number of the |
| 1285 | * 1st adapter to bits 23-16 and bits 15-8 of the bit |
| 1286 | * vector, respectively. |
| 1287 | */ |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 1288 | set_value = set_value << 8; |
| 1289 | |
| 1290 | /* |
Jeff Johnson | dcf84ce | 2017-10-05 09:26:24 -0700 | [diff] [blame] | 1291 | * Set the channel number for 2nd MCC vdev at bits |
| 1292 | * 7-0 of set_value |
| 1293 | */ |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 1294 | return set_value | operating_channel; |
| 1295 | } |
| 1296 | |
| 1297 | /** |
| 1298 | * wlan_hdd_set_mcc_p2p_quota() - Function to set quota for P2P |
| 1299 | * @psoc: PSOC object information |
| 1300 | * @set_value: Qouta value for the interface |
| 1301 | * @operating_channel First adapter operating channel |
| 1302 | * @vdev_id vdev id |
| 1303 | * |
| 1304 | * This function is used to set the quota for P2P cases |
| 1305 | * |
| 1306 | * Return: Configuration message posting status, SUCCESS or Fail |
| 1307 | * |
| 1308 | */ |
Jeff Johnson | fbb5452 | 2017-08-29 14:25:27 -0700 | [diff] [blame] | 1309 | int wlan_hdd_set_mcc_p2p_quota(struct hdd_adapter *adapter, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 1310 | uint32_t set_value) |
| 1311 | { |
| 1312 | int32_t ret = 0; |
| 1313 | uint32_t concurrent_state; |
Jeff Johnson | 1876762 | 2017-08-28 11:46:50 -0700 | [diff] [blame] | 1314 | struct hdd_context *hdd_ctx; |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 1315 | |
| 1316 | if (!adapter) { |
| 1317 | hdd_err("Invalid adapter"); |
| 1318 | return -EFAULT; |
| 1319 | } |
| 1320 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 1321 | if (hdd_ctx == NULL) { |
| 1322 | hdd_err("HDD context is null"); |
| 1323 | return -EINVAL; |
| 1324 | } |
| 1325 | |
| 1326 | concurrent_state = policy_mgr_get_concurrency_mode( |
| 1327 | hdd_ctx->hdd_psoc); |
| 1328 | /* |
| 1329 | * Check if concurrency mode is active. |
| 1330 | * Need to modify this code to support MCC modes other than STA/P2P |
| 1331 | */ |
| 1332 | if ((concurrent_state == |
| 1333 | (QDF_STA_MASK | QDF_P2P_CLIENT_MASK)) || |
| 1334 | (concurrent_state == (QDF_STA_MASK | QDF_P2P_GO_MASK))) { |
| 1335 | hdd_info("STA & P2P are both enabled"); |
| 1336 | |
| 1337 | /* |
| 1338 | * The channel numbers for both adapters and the time |
| 1339 | * quota for the 1st adapter, i.e., one specified in cmd |
| 1340 | * are formatted as a bit vector then passed on to WMA |
| 1341 | * +***********************************************************+ |
| 1342 | * |bit 31-24 | bit 23-16 | bits 15-8 | bits 7-0 | |
| 1343 | * | Unused | Quota for | chan. # for | chan. # for | |
| 1344 | * | | 1st chan. | 1st chan. | 2nd chan. | |
| 1345 | * +***********************************************************+ |
| 1346 | */ |
| 1347 | |
| 1348 | set_value = set_first_connection_operating_channel( |
| 1349 | hdd_ctx, set_value, adapter->device_mode); |
| 1350 | |
| 1351 | |
| 1352 | set_value = set_second_connection_operating_channel( |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1353 | hdd_ctx, set_value, adapter->session_id); |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 1354 | |
| 1355 | |
| 1356 | ret = wlan_hdd_send_p2p_quota(adapter, set_value); |
| 1357 | } else { |
| 1358 | hdd_info("MCC is not active. Exit w/o setting latency"); |
| 1359 | } |
| 1360 | |
| 1361 | return ret; |
| 1362 | } |
| 1363 | |
Jeff Johnson | fbb5452 | 2017-08-29 14:25:27 -0700 | [diff] [blame] | 1364 | int wlan_hdd_go_set_mcc_p2p_quota(struct hdd_adapter *hostapd_adapter, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 1365 | uint32_t set_value) |
| 1366 | { |
| 1367 | return wlan_hdd_set_mcc_p2p_quota(hostapd_adapter, set_value); |
| 1368 | } |
| 1369 | |
Jeff Johnson | fbb5452 | 2017-08-29 14:25:27 -0700 | [diff] [blame] | 1370 | void wlan_hdd_set_mcc_latency(struct hdd_adapter *adapter, int set_value) |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 1371 | { |
| 1372 | uint32_t concurrent_state; |
Jeff Johnson | 1876762 | 2017-08-28 11:46:50 -0700 | [diff] [blame] | 1373 | struct hdd_context *hdd_ctx; |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 1374 | |
| 1375 | if (!adapter) { |
| 1376 | hdd_err("Invalid adapter"); |
| 1377 | return; |
| 1378 | } |
| 1379 | |
| 1380 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 1381 | if (hdd_ctx == NULL) { |
| 1382 | hdd_err("HDD context is null"); |
| 1383 | return; |
| 1384 | } |
| 1385 | |
| 1386 | concurrent_state = policy_mgr_get_concurrency_mode( |
| 1387 | hdd_ctx->hdd_psoc); |
| 1388 | /** |
| 1389 | * Check if concurrency mode is active. |
| 1390 | * Need to modify this code to support MCC modes other than STA/P2P |
| 1391 | */ |
| 1392 | if ((concurrent_state == |
| 1393 | (QDF_STA_MASK | QDF_P2P_CLIENT_MASK)) || |
| 1394 | (concurrent_state == (QDF_STA_MASK | QDF_P2P_GO_MASK))) { |
| 1395 | hdd_info("STA & P2P are both enabled"); |
| 1396 | /* |
| 1397 | * The channel number and latency are formatted in |
| 1398 | * a bit vector then passed on to WMA layer. |
| 1399 | * +**********************************************+ |
| 1400 | * |bits 31-16 | bits 15-8 | bits 7-0 | |
| 1401 | * | Unused | latency - Chan. 1 | channel no. | |
| 1402 | * +**********************************************+ |
| 1403 | */ |
| 1404 | set_value = set_first_connection_operating_channel( |
| 1405 | hdd_ctx, set_value, adapter->device_mode); |
| 1406 | |
| 1407 | wlan_hdd_send_mcc_latency(adapter, set_value); |
| 1408 | } else { |
| 1409 | hdd_info("MCC is not active. Exit w/o setting latency"); |
| 1410 | } |
| 1411 | } |