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