| 1 |
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause |
| 2 |
/* |
| 3 |
* Copyright (C) 2012-2014, 2018-2025 Intel Corporation |
| 4 |
* Copyright (C) 2013-2015 Intel Mobile Communications GmbH |
| 5 |
* Copyright (C) 2016-2017 Intel Deutschland GmbH |
| 6 |
*/ |
| 7 |
#include <linux/kernel.h> |
| 8 |
#include <linux/fips.h> |
| 9 |
#include <linux/slab.h> |
| 10 |
#include <linux/skbuff.h> |
| 11 |
#include <linux/netdevice.h> |
| 12 |
#include <linux/etherdevice.h> |
| 13 |
#include <linux/ip.h> |
| 14 |
#include <linux/if_arp.h> |
| 15 |
#include <linux/time.h> |
| 16 |
#include <net/mac80211.h> |
| 17 |
#include <net/ieee80211_radiotap.h> |
| 18 |
#include <net/tcp.h> |
| 19 |
|
| 20 |
#include "iwl-drv.h" |
| 21 |
#include "iwl-op-mode.h" |
| 22 |
#include "iwl-io.h" |
| 23 |
#include "mvm.h" |
| 24 |
#include "sta.h" |
| 25 |
#include "time-event.h" |
| 26 |
#include "iwl-nvm-utils.h" |
| 27 |
#include "iwl-phy-db.h" |
| 28 |
#include "testmode.h" |
| 29 |
#include "fw/error-dump.h" |
| 30 |
#include "iwl-prph.h" |
| 31 |
#include "iwl-nvm-parse.h" |
| 32 |
#include "time-sync.h" |
| 33 |
|
| 34 |
#define IWL_MVM_LIMITS(ap) \ |
| 35 |
{ \ |
| 36 |
.max = 1, \ |
| 37 |
.types = BIT(NL80211_IFTYPE_STATION), \ |
| 38 |
}, \ |
| 39 |
{ \ |
| 40 |
.max = 1, \ |
| 41 |
.types = ap | \ |
| 42 |
BIT(NL80211_IFTYPE_P2P_CLIENT) | \ |
| 43 |
BIT(NL80211_IFTYPE_P2P_GO), \ |
| 44 |
}, \ |
| 45 |
{ \ |
| 46 |
.max = 1, \ |
| 47 |
.types = BIT(NL80211_IFTYPE_P2P_DEVICE), \ |
| 48 |
} |
| 49 |
|
| 50 |
static const struct ieee80211_iface_limit iwl_mvm_limits[] = { |
| 51 |
IWL_MVM_LIMITS(0) |
| 52 |
}; |
| 53 |
|
| 54 |
static const struct ieee80211_iface_limit iwl_mvm_limits_ap[] = { |
| 55 |
IWL_MVM_LIMITS(BIT(NL80211_IFTYPE_AP)) |
| 56 |
}; |
| 57 |
|
| 58 |
static const struct ieee80211_iface_combination iwl_mvm_iface_combinations[] = { |
| 59 |
{ |
| 60 |
.num_different_channels = 2, |
| 61 |
.max_interfaces = 3, |
| 62 |
.limits = iwl_mvm_limits, |
| 63 |
.n_limits = ARRAY_SIZE(iwl_mvm_limits), |
| 64 |
}, |
| 65 |
{ |
| 66 |
.num_different_channels = 1, |
| 67 |
.max_interfaces = 3, |
| 68 |
.limits = iwl_mvm_limits_ap, |
| 69 |
.n_limits = ARRAY_SIZE(iwl_mvm_limits_ap), |
| 70 |
}, |
| 71 |
}; |
| 72 |
|
| 73 |
static const struct cfg80211_pmsr_capabilities iwl_mvm_pmsr_capa = { |
| 74 |
.max_peers = IWL_TOF_MAX_APS, |
| 75 |
.report_ap_tsf = 1, |
| 76 |
.randomize_mac_addr = 1, |
| 77 |
|
| 78 |
.ftm = { |
| 79 |
.supported = 1, |
| 80 |
.asap = 1, |
| 81 |
.non_asap = 1, |
| 82 |
.request_lci = 1, |
| 83 |
.request_civicloc = 1, |
| 84 |
.trigger_based = 1, |
| 85 |
.non_trigger_based = 1, |
| 86 |
.max_bursts_exponent = -1, /* all supported */ |
| 87 |
.max_ftms_per_burst = 0, /* no limits */ |
| 88 |
.bandwidths = BIT(NL80211_CHAN_WIDTH_20_NOHT) | |
| 89 |
BIT(NL80211_CHAN_WIDTH_20) | |
| 90 |
BIT(NL80211_CHAN_WIDTH_40) | |
| 91 |
BIT(NL80211_CHAN_WIDTH_80) | |
| 92 |
BIT(NL80211_CHAN_WIDTH_160), |
| 93 |
.preambles = BIT(NL80211_PREAMBLE_LEGACY) | |
| 94 |
BIT(NL80211_PREAMBLE_HT) | |
| 95 |
BIT(NL80211_PREAMBLE_VHT) | |
| 96 |
BIT(NL80211_PREAMBLE_HE), |
| 97 |
}, |
| 98 |
}; |
| 99 |
|
| 100 |
static int __iwl_mvm_mac_set_key(struct ieee80211_hw *hw, |
| 101 |
enum set_key_cmd cmd, |
| 102 |
struct ieee80211_vif *vif, |
| 103 |
struct ieee80211_sta *sta, |
| 104 |
struct ieee80211_key_conf *key); |
| 105 |
|
| 106 |
static void iwl_mvm_reset_phy_ctxts(struct iwl_mvm *mvm) |
| 107 |
{ |
| 108 |
int i; |
| 109 |
|
| 110 |
memset(mvm->phy_ctxts, 0, sizeof(mvm->phy_ctxts)); |
| 111 |
for (i = 0; i < NUM_PHY_CTX; i++) { |
| 112 |
mvm->phy_ctxts[i].id = i; |
| 113 |
mvm->phy_ctxts[i].ref = 0; |
| 114 |
} |
| 115 |
} |
| 116 |
|
| 117 |
struct ieee80211_regdomain *iwl_mvm_get_regdomain(struct wiphy *wiphy, |
| 118 |
const char *alpha2, |
| 119 |
enum iwl_mcc_source src_id, |
| 120 |
bool *changed) |
| 121 |
{ |
| 122 |
struct ieee80211_regdomain *regd = NULL; |
| 123 |
struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); |
| 124 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 125 |
struct iwl_mcc_update_resp_v8 *resp; |
| 126 |
u8 resp_ver; |
| 127 |
|
| 128 |
IWL_DEBUG_LAR(mvm, "Getting regdomain data for %s from FW\n", alpha2); |
| 129 |
|
| 130 |
lockdep_assert_held(&mvm->mutex); |
| 131 |
|
| 132 |
resp = iwl_mvm_update_mcc(mvm, alpha2, src_id); |
| 133 |
if (IS_ERR_OR_NULL(resp)) { |
| 134 |
IWL_DEBUG_LAR(mvm, "Could not get update from FW %d\n", |
| 135 |
PTR_ERR_OR_ZERO(resp)); |
| 136 |
resp = NULL; |
| 137 |
goto out; |
| 138 |
} |
| 139 |
|
| 140 |
if (changed) { |
| 141 |
u32 status = le32_to_cpu(resp->status); |
| 142 |
|
| 143 |
*changed = (status == MCC_RESP_NEW_CHAN_PROFILE || |
| 144 |
status == MCC_RESP_ILLEGAL); |
| 145 |
} |
| 146 |
resp_ver = iwl_fw_lookup_notif_ver(mvm->fw, IWL_ALWAYS_LONG_GROUP, |
| 147 |
MCC_UPDATE_CMD, 0); |
| 148 |
IWL_DEBUG_LAR(mvm, "MCC update response version: %d\n", resp_ver); |
| 149 |
|
| 150 |
regd = iwl_parse_nvm_mcc_info(mvm->trans, |
| 151 |
__le32_to_cpu(resp->n_channels), |
| 152 |
resp->channels, |
| 153 |
__le16_to_cpu(resp->mcc), |
| 154 |
__le16_to_cpu(resp->geo_info), |
| 155 |
le32_to_cpu(resp->cap), resp_ver); |
| 156 |
/* Store the return source id */ |
| 157 |
src_id = resp->source_id; |
| 158 |
if (IS_ERR_OR_NULL(regd)) { |
| 159 |
IWL_DEBUG_LAR(mvm, "Could not get parse update from FW %d\n", |
| 160 |
PTR_ERR_OR_ZERO(regd)); |
| 161 |
goto out; |
| 162 |
} |
| 163 |
|
| 164 |
IWL_DEBUG_LAR(mvm, "setting alpha2 from FW to %s (0x%x, 0x%x) src=%d\n", |
| 165 |
regd->alpha2, regd->alpha2[0], regd->alpha2[1], src_id); |
| 166 |
mvm->lar_regdom_set = true; |
| 167 |
mvm->mcc_src = src_id; |
| 168 |
|
| 169 |
iwl_mei_set_country_code(__le16_to_cpu(resp->mcc)); |
| 170 |
|
| 171 |
out: |
| 172 |
kfree(resp); |
| 173 |
return regd; |
| 174 |
} |
| 175 |
|
| 176 |
void iwl_mvm_update_changed_regdom(struct iwl_mvm *mvm) |
| 177 |
{ |
| 178 |
bool changed; |
| 179 |
struct ieee80211_regdomain *regd; |
| 180 |
|
| 181 |
if (!iwl_mvm_is_lar_supported(mvm)) |
| 182 |
return; |
| 183 |
|
| 184 |
regd = iwl_mvm_get_current_regdomain(mvm, &changed); |
| 185 |
if (!IS_ERR_OR_NULL(regd)) { |
| 186 |
/* only update the regulatory core if changed */ |
| 187 |
if (changed) |
| 188 |
regulatory_set_wiphy_regd(mvm->hw->wiphy, regd); |
| 189 |
|
| 190 |
kfree(regd); |
| 191 |
} |
| 192 |
} |
| 193 |
|
| 194 |
struct ieee80211_regdomain *iwl_mvm_get_current_regdomain(struct iwl_mvm *mvm, |
| 195 |
bool *changed) |
| 196 |
{ |
| 197 |
return iwl_mvm_get_regdomain(mvm->hw->wiphy, "ZZ", |
| 198 |
iwl_mvm_is_wifi_mcc_supported(mvm) ? |
| 199 |
MCC_SOURCE_GET_CURRENT : |
| 200 |
MCC_SOURCE_OLD_FW, changed); |
| 201 |
} |
| 202 |
|
| 203 |
int iwl_mvm_init_fw_regd(struct iwl_mvm *mvm, bool force_regd_sync) |
| 204 |
{ |
| 205 |
enum iwl_mcc_source used_src; |
| 206 |
struct ieee80211_regdomain *regd; |
| 207 |
int ret; |
| 208 |
bool changed; |
| 209 |
const struct ieee80211_regdomain *r = |
| 210 |
wiphy_dereference(mvm->hw->wiphy, mvm->hw->wiphy->regd); |
| 211 |
|
| 212 |
if (!r) |
| 213 |
return -ENOENT; |
| 214 |
|
| 215 |
/* save the last source in case we overwrite it below */ |
| 216 |
used_src = mvm->mcc_src; |
| 217 |
if (iwl_mvm_is_wifi_mcc_supported(mvm)) { |
| 218 |
/* Notify the firmware we support wifi location updates */ |
| 219 |
regd = iwl_mvm_get_current_regdomain(mvm, NULL); |
| 220 |
if (!IS_ERR_OR_NULL(regd)) |
| 221 |
kfree(regd); |
| 222 |
} |
| 223 |
|
| 224 |
/* Now set our last stored MCC and source */ |
| 225 |
regd = iwl_mvm_get_regdomain(mvm->hw->wiphy, r->alpha2, used_src, |
| 226 |
&changed); |
| 227 |
if (IS_ERR_OR_NULL(regd)) |
| 228 |
return -EIO; |
| 229 |
|
| 230 |
/* update cfg80211 if the regdomain was changed or the caller explicitly |
| 231 |
* asked to update regdomain |
| 232 |
*/ |
| 233 |
if (changed || force_regd_sync) |
| 234 |
ret = regulatory_set_wiphy_regd_sync(mvm->hw->wiphy, regd); |
| 235 |
else |
| 236 |
ret = 0; |
| 237 |
|
| 238 |
kfree(regd); |
| 239 |
return ret; |
| 240 |
} |
| 241 |
|
| 242 |
/* Each capability added here should also be add to tm_if_types_ext_capa_sta */ |
| 243 |
static const u8 he_if_types_ext_capa_sta[] = { |
| 244 |
[0] = WLAN_EXT_CAPA1_EXT_CHANNEL_SWITCHING, |
| 245 |
[2] = WLAN_EXT_CAPA3_MULTI_BSSID_SUPPORT, |
| 246 |
[7] = WLAN_EXT_CAPA8_OPMODE_NOTIF | |
| 247 |
WLAN_EXT_CAPA8_MAX_MSDU_IN_AMSDU_LSB, |
| 248 |
[8] = WLAN_EXT_CAPA9_MAX_MSDU_IN_AMSDU_MSB, |
| 249 |
}; |
| 250 |
|
| 251 |
static const u8 tm_if_types_ext_capa_sta[] = { |
| 252 |
[0] = WLAN_EXT_CAPA1_EXT_CHANNEL_SWITCHING, |
| 253 |
[2] = WLAN_EXT_CAPA3_MULTI_BSSID_SUPPORT | |
| 254 |
WLAN_EXT_CAPA3_TIMING_MEASUREMENT_SUPPORT, |
| 255 |
[7] = WLAN_EXT_CAPA8_OPMODE_NOTIF | |
| 256 |
WLAN_EXT_CAPA8_MAX_MSDU_IN_AMSDU_LSB, |
| 257 |
[8] = WLAN_EXT_CAPA9_MAX_MSDU_IN_AMSDU_MSB, |
| 258 |
[9] = WLAN_EXT_CAPA10_TWT_REQUESTER_SUPPORT, |
| 259 |
}; |
| 260 |
|
| 261 |
/* Additional interface types for which extended capabilities are |
| 262 |
* specified separately |
| 263 |
*/ |
| 264 |
|
| 265 |
#define IWL_MVM_EMLSR_CAPA (IEEE80211_EML_CAP_EMLSR_SUPP | \ |
| 266 |
IEEE80211_EML_CAP_EMLSR_PADDING_DELAY_32US << \ |
| 267 |
__bf_shf(IEEE80211_EML_CAP_EMLSR_PADDING_DELAY) | \ |
| 268 |
IEEE80211_EML_CAP_EMLSR_TRANSITION_DELAY_64US << \ |
| 269 |
__bf_shf(IEEE80211_EML_CAP_EMLSR_TRANSITION_DELAY)) |
| 270 |
#define IWL_MVM_MLD_CAPA_OPS (FIELD_PREP_CONST( \ |
| 271 |
IEEE80211_MLD_CAP_OP_TID_TO_LINK_MAP_NEG_SUPP, \ |
| 272 |
IEEE80211_MLD_CAP_OP_TID_TO_LINK_MAP_NEG_SUPP_SAME) | \ |
| 273 |
IEEE80211_MLD_CAP_OP_LINK_RECONF_SUPPORT) |
| 274 |
|
| 275 |
static const struct wiphy_iftype_ext_capab add_iftypes_ext_capa[] = { |
| 276 |
{ |
| 277 |
.iftype = NL80211_IFTYPE_STATION, |
| 278 |
.extended_capabilities = he_if_types_ext_capa_sta, |
| 279 |
.extended_capabilities_mask = he_if_types_ext_capa_sta, |
| 280 |
.extended_capabilities_len = sizeof(he_if_types_ext_capa_sta), |
| 281 |
/* relevant only if EHT is supported */ |
| 282 |
.eml_capabilities = IWL_MVM_EMLSR_CAPA, |
| 283 |
.mld_capa_and_ops = IWL_MVM_MLD_CAPA_OPS, |
| 284 |
}, |
| 285 |
{ |
| 286 |
.iftype = NL80211_IFTYPE_STATION, |
| 287 |
.extended_capabilities = tm_if_types_ext_capa_sta, |
| 288 |
.extended_capabilities_mask = tm_if_types_ext_capa_sta, |
| 289 |
.extended_capabilities_len = sizeof(tm_if_types_ext_capa_sta), |
| 290 |
/* relevant only if EHT is supported */ |
| 291 |
.eml_capabilities = IWL_MVM_EMLSR_CAPA, |
| 292 |
.mld_capa_and_ops = IWL_MVM_MLD_CAPA_OPS, |
| 293 |
}, |
| 294 |
}; |
| 295 |
|
| 296 |
int iwl_mvm_op_get_antenna(struct ieee80211_hw *hw, int radio_idx, |
| 297 |
u32 *tx_ant, u32 *rx_ant) |
| 298 |
{ |
| 299 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 300 |
*tx_ant = iwl_mvm_get_valid_tx_ant(mvm); |
| 301 |
*rx_ant = iwl_mvm_get_valid_rx_ant(mvm); |
| 302 |
return 0; |
| 303 |
} |
| 304 |
|
| 305 |
int iwl_mvm_op_set_antenna(struct ieee80211_hw *hw, int radio_idx, u32 tx_ant, |
| 306 |
u32 rx_ant) |
| 307 |
{ |
| 308 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 309 |
|
| 310 |
/* This has been tested on those devices only */ |
| 311 |
if (mvm->trans->mac_cfg->device_family != IWL_DEVICE_FAMILY_9000 && |
| 312 |
mvm->trans->mac_cfg->device_family != IWL_DEVICE_FAMILY_22000 && |
| 313 |
mvm->trans->mac_cfg->device_family != IWL_DEVICE_FAMILY_AX210) |
| 314 |
return -EOPNOTSUPP; |
| 315 |
|
| 316 |
if (!mvm->nvm_data) |
| 317 |
return -EBUSY; |
| 318 |
|
| 319 |
/* mac80211 ensures the device is not started, |
| 320 |
* so the firmware cannot be running |
| 321 |
*/ |
| 322 |
|
| 323 |
mvm->set_tx_ant = tx_ant; |
| 324 |
mvm->set_rx_ant = rx_ant; |
| 325 |
|
| 326 |
iwl_reinit_cab(mvm->trans, mvm->nvm_data, tx_ant, rx_ant, mvm->fw); |
| 327 |
|
| 328 |
return 0; |
| 329 |
} |
| 330 |
|
| 331 |
int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm) |
| 332 |
{ |
| 333 |
struct ieee80211_hw *hw = mvm->hw; |
| 334 |
int num_mac, ret, i; |
| 335 |
static const u32 mvm_ciphers[] = { |
| 336 |
WLAN_CIPHER_SUITE_WEP40, |
| 337 |
WLAN_CIPHER_SUITE_WEP104, |
| 338 |
WLAN_CIPHER_SUITE_TKIP, |
| 339 |
WLAN_CIPHER_SUITE_CCMP, |
| 340 |
}; |
| 341 |
#ifdef CONFIG_PM_SLEEP |
| 342 |
bool unified = fw_has_capa(&mvm->fw->ucode_capa, |
| 343 |
IWL_UCODE_TLV_CAPA_CNSLDTD_D3_D0_IMG); |
| 344 |
#endif |
| 345 |
u32 sec_key_id = WIDE_ID(DATA_PATH_GROUP, SEC_KEY_CMD); |
| 346 |
u8 sec_key_ver = iwl_fw_lookup_cmd_ver(mvm->fw, sec_key_id, 0); |
| 347 |
|
| 348 |
/* Tell mac80211 our characteristics */ |
| 349 |
ieee80211_hw_set(hw, SIGNAL_DBM); |
| 350 |
ieee80211_hw_set(hw, SPECTRUM_MGMT); |
| 351 |
ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS); |
| 352 |
ieee80211_hw_set(hw, WANT_MONITOR_VIF); |
| 353 |
ieee80211_hw_set(hw, SUPPORTS_PS); |
| 354 |
ieee80211_hw_set(hw, SUPPORTS_DYNAMIC_PS); |
| 355 |
ieee80211_hw_set(hw, AMPDU_AGGREGATION); |
| 356 |
ieee80211_hw_set(hw, CONNECTION_MONITOR); |
| 357 |
ieee80211_hw_set(hw, CHANCTX_STA_CSA); |
| 358 |
ieee80211_hw_set(hw, SUPPORT_FAST_XMIT); |
| 359 |
ieee80211_hw_set(hw, SUPPORTS_CLONED_SKBS); |
| 360 |
ieee80211_hw_set(hw, SUPPORTS_AMSDU_IN_AMPDU); |
| 361 |
ieee80211_hw_set(hw, NEEDS_UNIQUE_STA_ADDR); |
| 362 |
ieee80211_hw_set(hw, SUPPORTS_VHT_EXT_NSS_BW); |
| 363 |
ieee80211_hw_set(hw, BUFF_MMPDU_TXQ); |
| 364 |
ieee80211_hw_set(hw, STA_MMPDU_TXQ); |
| 365 |
|
| 366 |
/* Set this early since we need to have it for the check below */ |
| 367 |
if (mvm->mld_api_is_used && mvm->nvm_data->sku_cap_11be_enable && |
| 368 |
!iwlwifi_mod_params.disable_11ax && |
| 369 |
!iwlwifi_mod_params.disable_11be) { |
| 370 |
hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_MLO; |
| 371 |
/* we handle this already earlier, but need it for MLO */ |
| 372 |
ieee80211_hw_set(hw, HANDLES_QUIET_CSA); |
| 373 |
} |
| 374 |
|
| 375 |
/* With MLD FW API, it tracks timing by itself, |
| 376 |
* no need for any timing from the host |
| 377 |
*/ |
| 378 |
if (!mvm->mld_api_is_used) |
| 379 |
ieee80211_hw_set(hw, TIMING_BEACON_ONLY); |
| 380 |
|
| 381 |
/* |
| 382 |
* On older devices, enabling TX A-MSDU occasionally leads to |
| 383 |
* something getting messed up, the command read from the FIFO |
| 384 |
* gets out of sync and isn't a TX command, so that we have an |
| 385 |
* assert EDC. |
| 386 |
* |
| 387 |
* It's not clear where the bug is, but since we didn't used to |
| 388 |
* support A-MSDU until moving the mac80211 iTXQs, just leave it |
| 389 |
* for older devices. We also don't see this issue on any newer |
| 390 |
* devices. |
| 391 |
*/ |
| 392 |
if (mvm->trans->mac_cfg->device_family >= IWL_DEVICE_FAMILY_9000) |
| 393 |
ieee80211_hw_set(hw, TX_AMSDU); |
| 394 |
ieee80211_hw_set(hw, TX_FRAG_LIST); |
| 395 |
|
| 396 |
if (iwl_mvm_has_tlc_offload(mvm)) { |
| 397 |
ieee80211_hw_set(hw, TX_AMPDU_SETUP_IN_HW); |
| 398 |
ieee80211_hw_set(hw, HAS_RATE_CONTROL); |
| 399 |
} |
| 400 |
|
| 401 |
/* We want to use the mac80211's reorder buffer for 9000 */ |
| 402 |
if (iwl_mvm_has_new_rx_api(mvm) && |
| 403 |
mvm->trans->mac_cfg->device_family > IWL_DEVICE_FAMILY_9000) |
| 404 |
ieee80211_hw_set(hw, SUPPORTS_REORDERING_BUFFER); |
| 405 |
|
| 406 |
if (fw_has_capa(&mvm->fw->ucode_capa, |
| 407 |
IWL_UCODE_TLV_CAPA_STA_PM_NOTIF)) { |
| 408 |
ieee80211_hw_set(hw, AP_LINK_PS); |
| 409 |
} else if (WARN_ON(iwl_mvm_has_new_tx_api(mvm))) { |
| 410 |
/* |
| 411 |
* we absolutely need this for the new TX API since that comes |
| 412 |
* with many more queues than the current code can deal with |
| 413 |
* for station powersave |
| 414 |
*/ |
| 415 |
return -EINVAL; |
| 416 |
} |
| 417 |
|
| 418 |
if (mvm->trans->info.num_rxqs > 1) |
| 419 |
ieee80211_hw_set(hw, USES_RSS); |
| 420 |
|
| 421 |
if (mvm->trans->info.max_skb_frags) |
| 422 |
hw->netdev_features = NETIF_F_HIGHDMA | NETIF_F_SG; |
| 423 |
|
| 424 |
hw->queues = IEEE80211_NUM_ACS; |
| 425 |
hw->offchannel_tx_hw_queue = IWL_MVM_OFFCHANNEL_QUEUE; |
| 426 |
hw->radiotap_mcs_details |= IEEE80211_RADIOTAP_MCS_HAVE_FEC | |
| 427 |
IEEE80211_RADIOTAP_MCS_HAVE_STBC; |
| 428 |
hw->radiotap_vht_details |= IEEE80211_RADIOTAP_VHT_KNOWN_STBC | |
| 429 |
IEEE80211_RADIOTAP_VHT_KNOWN_BEAMFORMED; |
| 430 |
|
| 431 |
hw->radiotap_timestamp.units_pos = |
| 432 |
IEEE80211_RADIOTAP_TIMESTAMP_UNIT_US | |
| 433 |
IEEE80211_RADIOTAP_TIMESTAMP_SPOS_PLCP_SIG_ACQ; |
| 434 |
/* this is the case for CCK frames, it's better (only 8) for OFDM */ |
| 435 |
hw->radiotap_timestamp.accuracy = 22; |
| 436 |
|
| 437 |
if (!iwl_mvm_has_tlc_offload(mvm)) |
| 438 |
hw->rate_control_algorithm = RS_NAME; |
| 439 |
|
| 440 |
hw->uapsd_queues = IWL_MVM_UAPSD_QUEUES; |
| 441 |
hw->uapsd_max_sp_len = IWL_UAPSD_MAX_SP; |
| 442 |
hw->max_tx_fragments = mvm->trans->info.max_skb_frags; |
| 443 |
|
| 444 |
BUILD_BUG_ON(ARRAY_SIZE(mvm->ciphers) < ARRAY_SIZE(mvm_ciphers) + 6); |
| 445 |
memcpy(mvm->ciphers, mvm_ciphers, sizeof(mvm_ciphers)); |
| 446 |
hw->wiphy->n_cipher_suites = ARRAY_SIZE(mvm_ciphers); |
| 447 |
hw->wiphy->cipher_suites = mvm->ciphers; |
| 448 |
|
| 449 |
if (iwl_mvm_has_new_rx_api(mvm)) { |
| 450 |
mvm->ciphers[hw->wiphy->n_cipher_suites] = |
| 451 |
WLAN_CIPHER_SUITE_GCMP; |
| 452 |
hw->wiphy->n_cipher_suites++; |
| 453 |
mvm->ciphers[hw->wiphy->n_cipher_suites] = |
| 454 |
WLAN_CIPHER_SUITE_GCMP_256; |
| 455 |
hw->wiphy->n_cipher_suites++; |
| 456 |
} |
| 457 |
|
| 458 |
if (iwlwifi_mod_params.swcrypto) |
| 459 |
IWL_ERR(mvm, |
| 460 |
"iwlmvm doesn't allow to disable HW crypto, check swcrypto module parameter\n"); |
| 461 |
if (!iwlwifi_mod_params.bt_coex_active) |
| 462 |
IWL_ERR(mvm, |
| 463 |
"iwlmvm doesn't allow to disable BT Coex, check bt_coex_active module parameter\n"); |
| 464 |
|
| 465 |
if (!fips_enabled) |
| 466 |
ieee80211_hw_set(hw, MFP_CAPABLE); |
| 467 |
|
| 468 |
mvm->ciphers[hw->wiphy->n_cipher_suites] = WLAN_CIPHER_SUITE_AES_CMAC; |
| 469 |
hw->wiphy->n_cipher_suites++; |
| 470 |
if (iwl_mvm_has_new_rx_api(mvm)) { |
| 471 |
mvm->ciphers[hw->wiphy->n_cipher_suites] = |
| 472 |
WLAN_CIPHER_SUITE_BIP_GMAC_128; |
| 473 |
hw->wiphy->n_cipher_suites++; |
| 474 |
mvm->ciphers[hw->wiphy->n_cipher_suites] = |
| 475 |
WLAN_CIPHER_SUITE_BIP_GMAC_256; |
| 476 |
hw->wiphy->n_cipher_suites++; |
| 477 |
} |
| 478 |
|
| 479 |
wiphy_ext_feature_set(hw->wiphy, |
| 480 |
NL80211_EXT_FEATURE_BEACON_RATE_LEGACY); |
| 481 |
wiphy_ext_feature_set(hw->wiphy, |
| 482 |
NL80211_EXT_FEATURE_SCAN_MIN_PREQ_CONTENT); |
| 483 |
|
| 484 |
if (fw_has_capa(&mvm->fw->ucode_capa, |
| 485 |
IWL_UCODE_TLV_CAPA_FTM_CALIBRATED)) { |
| 486 |
wiphy_ext_feature_set(hw->wiphy, |
| 487 |
NL80211_EXT_FEATURE_ENABLE_FTM_RESPONDER); |
| 488 |
hw->wiphy->pmsr_capa = &iwl_mvm_pmsr_capa; |
| 489 |
} |
| 490 |
|
| 491 |
/* |
| 492 |
* beacon protection must be handled by firmware, |
| 493 |
* so cannot be done with fips_enabled |
| 494 |
*/ |
| 495 |
if (!fips_enabled && sec_key_ver && |
| 496 |
fw_has_capa(&mvm->fw->ucode_capa, |
| 497 |
IWL_UCODE_TLV_CAPA_BIGTK_TX_SUPPORT)) |
| 498 |
wiphy_ext_feature_set(hw->wiphy, |
| 499 |
NL80211_EXT_FEATURE_BEACON_PROTECTION); |
| 500 |
else if (!fips_enabled && |
| 501 |
fw_has_capa(&mvm->fw->ucode_capa, |
| 502 |
IWL_UCODE_TLV_CAPA_BIGTK_SUPPORT)) |
| 503 |
wiphy_ext_feature_set(hw->wiphy, |
| 504 |
NL80211_EXT_FEATURE_BEACON_PROTECTION_CLIENT); |
| 505 |
|
| 506 |
if (fw_has_capa(&mvm->fw->ucode_capa, |
| 507 |
IWL_UCODE_TLV_CAPA_TIME_SYNC_BOTH_FTM_TM)) |
| 508 |
hw->wiphy->hw_timestamp_max_peers = 1; |
| 509 |
|
| 510 |
if (fw_has_capa(&mvm->fw->ucode_capa, |
| 511 |
IWL_UCODE_TLV_CAPA_SPP_AMSDU_SUPPORT)) |
| 512 |
wiphy_ext_feature_set(hw->wiphy, |
| 513 |
NL80211_EXT_FEATURE_SPP_AMSDU_SUPPORT); |
| 514 |
|
| 515 |
ieee80211_hw_set(hw, SINGLE_SCAN_ON_ALL_BANDS); |
| 516 |
hw->wiphy->features |= |
| 517 |
NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR | |
| 518 |
NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR | |
| 519 |
NL80211_FEATURE_ND_RANDOM_MAC_ADDR; |
| 520 |
|
| 521 |
hw->sta_data_size = sizeof(struct iwl_mvm_sta); |
| 522 |
hw->vif_data_size = sizeof(struct iwl_mvm_vif); |
| 523 |
hw->chanctx_data_size = sizeof(u16); |
| 524 |
hw->txq_data_size = sizeof(struct iwl_mvm_txq); |
| 525 |
|
| 526 |
hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | |
| 527 |
BIT(NL80211_IFTYPE_P2P_CLIENT) | |
| 528 |
BIT(NL80211_IFTYPE_AP) | |
| 529 |
BIT(NL80211_IFTYPE_P2P_GO) | |
| 530 |
BIT(NL80211_IFTYPE_P2P_DEVICE) | |
| 531 |
BIT(NL80211_IFTYPE_ADHOC); |
| 532 |
|
| 533 |
hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; |
| 534 |
wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_VHT_IBSS); |
| 535 |
|
| 536 |
/* The new Tx API does not allow to pass the key or keyid of a MPDU to |
| 537 |
* the hw, preventing us to control which key(id) to use per MPDU. |
| 538 |
* Till that's fixed we can't use Extended Key ID for the newer cards. |
| 539 |
*/ |
| 540 |
if (!iwl_mvm_has_new_tx_api(mvm)) |
| 541 |
wiphy_ext_feature_set(hw->wiphy, |
| 542 |
NL80211_EXT_FEATURE_EXT_KEY_ID); |
| 543 |
hw->wiphy->features |= NL80211_FEATURE_HT_IBSS; |
| 544 |
|
| 545 |
hw->wiphy->regulatory_flags |= REGULATORY_ENABLE_RELAX_NO_IR; |
| 546 |
if (iwl_mvm_is_lar_supported(mvm)) |
| 547 |
hw->wiphy->regulatory_flags |= REGULATORY_WIPHY_SELF_MANAGED; |
| 548 |
else |
| 549 |
hw->wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG | |
| 550 |
REGULATORY_DISABLE_BEACON_HINTS; |
| 551 |
|
| 552 |
if (mvm->trans->mac_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) |
| 553 |
wiphy_ext_feature_set(hw->wiphy, |
| 554 |
NL80211_EXT_FEATURE_DFS_CONCURRENT); |
| 555 |
|
| 556 |
hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD; |
| 557 |
hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH; |
| 558 |
hw->wiphy->flags |= WIPHY_FLAG_SPLIT_SCAN_6GHZ; |
| 559 |
|
| 560 |
hw->wiphy->iface_combinations = iwl_mvm_iface_combinations; |
| 561 |
hw->wiphy->n_iface_combinations = |
| 562 |
ARRAY_SIZE(iwl_mvm_iface_combinations); |
| 563 |
|
| 564 |
hw->wiphy->max_remain_on_channel_duration = 10000; |
| 565 |
hw->max_listen_interval = IWL_MVM_CONN_LISTEN_INTERVAL; |
| 566 |
|
| 567 |
/* Extract MAC address */ |
| 568 |
memcpy(mvm->addresses[0].addr, mvm->nvm_data->hw_addr, ETH_ALEN); |
| 569 |
hw->wiphy->addresses = mvm->addresses; |
| 570 |
hw->wiphy->n_addresses = 1; |
| 571 |
|
| 572 |
/* Extract additional MAC addresses if available */ |
| 573 |
num_mac = (mvm->nvm_data->n_hw_addrs > 1) ? |
| 574 |
min(IWL_MVM_MAX_ADDRESSES, mvm->nvm_data->n_hw_addrs) : 1; |
| 575 |
|
| 576 |
for (i = 1; i < num_mac; i++) { |
| 577 |
memcpy(mvm->addresses[i].addr, mvm->addresses[i-1].addr, |
| 578 |
ETH_ALEN); |
| 579 |
mvm->addresses[i].addr[5]++; |
| 580 |
hw->wiphy->n_addresses++; |
| 581 |
} |
| 582 |
|
| 583 |
iwl_mvm_reset_phy_ctxts(mvm); |
| 584 |
|
| 585 |
hw->wiphy->max_scan_ie_len = iwl_mvm_max_scan_ie_len(mvm); |
| 586 |
|
| 587 |
hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; |
| 588 |
|
| 589 |
BUILD_BUG_ON(IWL_MVM_SCAN_STOPPING_MASK & IWL_MVM_SCAN_MASK); |
| 590 |
BUILD_BUG_ON(IWL_MAX_UMAC_SCANS > HWEIGHT32(IWL_MVM_SCAN_MASK) || |
| 591 |
IWL_MAX_LMAC_SCANS > HWEIGHT32(IWL_MVM_SCAN_MASK)); |
| 592 |
|
| 593 |
if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) |
| 594 |
mvm->max_scans = IWL_MAX_UMAC_SCANS; |
| 595 |
else |
| 596 |
mvm->max_scans = IWL_MAX_LMAC_SCANS; |
| 597 |
|
| 598 |
if (mvm->nvm_data->bands[NL80211_BAND_2GHZ].n_channels) |
| 599 |
hw->wiphy->bands[NL80211_BAND_2GHZ] = |
| 600 |
&mvm->nvm_data->bands[NL80211_BAND_2GHZ]; |
| 601 |
if (mvm->nvm_data->bands[NL80211_BAND_5GHZ].n_channels) { |
| 602 |
hw->wiphy->bands[NL80211_BAND_5GHZ] = |
| 603 |
&mvm->nvm_data->bands[NL80211_BAND_5GHZ]; |
| 604 |
|
| 605 |
if (fw_has_capa(&mvm->fw->ucode_capa, |
| 606 |
IWL_UCODE_TLV_CAPA_BEAMFORMER) && |
| 607 |
fw_has_api(&mvm->fw->ucode_capa, |
| 608 |
IWL_UCODE_TLV_API_LQ_SS_PARAMS)) |
| 609 |
hw->wiphy->bands[NL80211_BAND_5GHZ]->vht_cap.cap |= |
| 610 |
IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 611 |
} |
| 612 |
if (fw_has_capa(&mvm->fw->ucode_capa, |
| 613 |
IWL_UCODE_TLV_CAPA_PSC_CHAN_SUPPORT) && |
| 614 |
mvm->nvm_data->bands[NL80211_BAND_6GHZ].n_channels) |
| 615 |
hw->wiphy->bands[NL80211_BAND_6GHZ] = |
| 616 |
&mvm->nvm_data->bands[NL80211_BAND_6GHZ]; |
| 617 |
|
| 618 |
hw->wiphy->hw_version = mvm->trans->info.hw_id; |
| 619 |
|
| 620 |
if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM) |
| 621 |
hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT; |
| 622 |
else |
| 623 |
hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; |
| 624 |
|
| 625 |
hw->wiphy->max_sched_scan_reqs = 1; |
| 626 |
hw->wiphy->max_sched_scan_ssids = PROBE_OPTION_MAX; |
| 627 |
hw->wiphy->max_match_sets = iwl_umac_scan_get_max_profiles(mvm->fw); |
| 628 |
/* we create the 802.11 header and zero length SSID IE. */ |
| 629 |
hw->wiphy->max_sched_scan_ie_len = |
| 630 |
SCAN_OFFLOAD_PROBE_REQ_SIZE - 24 - 2; |
| 631 |
hw->wiphy->max_sched_scan_plans = IWL_MAX_SCHED_SCAN_PLANS; |
| 632 |
hw->wiphy->max_sched_scan_plan_interval = U16_MAX; |
| 633 |
|
| 634 |
/* |
| 635 |
* the firmware uses u8 for num of iterations, but 0xff is saved for |
| 636 |
* infinite loop, so the maximum number of iterations is actually 254. |
| 637 |
*/ |
| 638 |
hw->wiphy->max_sched_scan_plan_iterations = 254; |
| 639 |
|
| 640 |
hw->wiphy->features |= NL80211_FEATURE_P2P_GO_CTWIN | |
| 641 |
NL80211_FEATURE_LOW_PRIORITY_SCAN | |
| 642 |
NL80211_FEATURE_P2P_GO_OPPPS | |
| 643 |
NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE | |
| 644 |
NL80211_FEATURE_SUPPORTS_WMM_ADMISSION; |
| 645 |
|
| 646 |
/* when firmware supports RLC/SMPS offload, do not set these |
| 647 |
* driver features, since it's no longer supported by driver. |
| 648 |
*/ |
| 649 |
if (!iwl_mvm_has_rlc_offload(mvm)) |
| 650 |
hw->wiphy->features |= NL80211_FEATURE_STATIC_SMPS | |
| 651 |
NL80211_FEATURE_DYNAMIC_SMPS; |
| 652 |
|
| 653 |
if (fw_has_capa(&mvm->fw->ucode_capa, |
| 654 |
IWL_UCODE_TLV_CAPA_TXPOWER_INSERTION_SUPPORT)) |
| 655 |
hw->wiphy->features |= NL80211_FEATURE_TX_POWER_INSERTION; |
| 656 |
if (fw_has_capa(&mvm->fw->ucode_capa, |
| 657 |
IWL_UCODE_TLV_CAPA_QUIET_PERIOD_SUPPORT)) |
| 658 |
hw->wiphy->features |= NL80211_FEATURE_QUIET; |
| 659 |
|
| 660 |
if (fw_has_capa(&mvm->fw->ucode_capa, |
| 661 |
IWL_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT)) |
| 662 |
hw->wiphy->features |= |
| 663 |
NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES; |
| 664 |
|
| 665 |
if (fw_has_capa(&mvm->fw->ucode_capa, |
| 666 |
IWL_UCODE_TLV_CAPA_WFA_TPC_REP_IE_SUPPORT)) |
| 667 |
hw->wiphy->features |= NL80211_FEATURE_WFA_TPC_IE_IN_PROBES; |
| 668 |
|
| 669 |
if (iwl_fw_lookup_cmd_ver(mvm->fw, WOWLAN_KEK_KCK_MATERIAL, |
| 670 |
IWL_FW_CMD_VER_UNKNOWN) >= 3) |
| 671 |
hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK; |
| 672 |
|
| 673 |
if (fw_has_api(&mvm->fw->ucode_capa, |
| 674 |
IWL_UCODE_TLV_API_SCAN_TSF_REPORT)) { |
| 675 |
wiphy_ext_feature_set(hw->wiphy, |
| 676 |
NL80211_EXT_FEATURE_SCAN_START_TIME); |
| 677 |
wiphy_ext_feature_set(hw->wiphy, |
| 678 |
NL80211_EXT_FEATURE_BSS_PARENT_TSF); |
| 679 |
} |
| 680 |
|
| 681 |
if (iwl_mvm_is_oce_supported(mvm)) { |
| 682 |
u8 scan_ver = iwl_fw_lookup_cmd_ver(mvm->fw, SCAN_REQ_UMAC, 0); |
| 683 |
|
| 684 |
wiphy_ext_feature_set(hw->wiphy, |
| 685 |
NL80211_EXT_FEATURE_ACCEPT_BCAST_PROBE_RESP); |
| 686 |
wiphy_ext_feature_set(hw->wiphy, |
| 687 |
NL80211_EXT_FEATURE_FILS_MAX_CHANNEL_TIME); |
| 688 |
wiphy_ext_feature_set(hw->wiphy, |
| 689 |
NL80211_EXT_FEATURE_OCE_PROBE_REQ_HIGH_TX_RATE); |
| 690 |
|
| 691 |
/* Old firmware also supports probe deferral and suppression */ |
| 692 |
if (scan_ver < 15) |
| 693 |
wiphy_ext_feature_set(hw->wiphy, |
| 694 |
NL80211_EXT_FEATURE_OCE_PROBE_REQ_DEFERRAL_SUPPRESSION); |
| 695 |
} |
| 696 |
|
| 697 |
hw->wiphy->iftype_ext_capab = NULL; |
| 698 |
hw->wiphy->num_iftype_ext_capab = 0; |
| 699 |
|
| 700 |
if (mvm->nvm_data->sku_cap_11ax_enable && |
| 701 |
!iwlwifi_mod_params.disable_11ax) { |
| 702 |
hw->wiphy->iftype_ext_capab = add_iftypes_ext_capa; |
| 703 |
hw->wiphy->num_iftype_ext_capab = |
| 704 |
ARRAY_SIZE(add_iftypes_ext_capa) - 1; |
| 705 |
|
| 706 |
ieee80211_hw_set(hw, SUPPORTS_MULTI_BSSID); |
| 707 |
ieee80211_hw_set(hw, SUPPORTS_ONLY_HE_MULTI_BSSID); |
| 708 |
} |
| 709 |
|
| 710 |
if (iwl_fw_lookup_cmd_ver(mvm->fw, |
| 711 |
WIDE_ID(DATA_PATH_GROUP, |
| 712 |
WNM_80211V_TIMING_MEASUREMENT_CONFIG_CMD), |
| 713 |
IWL_FW_CMD_VER_UNKNOWN) >= 1) { |
| 714 |
IWL_DEBUG_INFO(mvm->trans, "Timing measurement supported\n"); |
| 715 |
|
| 716 |
if (!hw->wiphy->iftype_ext_capab) { |
| 717 |
hw->wiphy->num_iftype_ext_capab = 1; |
| 718 |
hw->wiphy->iftype_ext_capab = add_iftypes_ext_capa + |
| 719 |
ARRAY_SIZE(add_iftypes_ext_capa) - 1; |
| 720 |
} else { |
| 721 |
hw->wiphy->iftype_ext_capab = add_iftypes_ext_capa + 1; |
| 722 |
} |
| 723 |
} |
| 724 |
|
| 725 |
if (iwl_fw_lookup_cmd_ver(mvm->fw, WIDE_ID(LOCATION_GROUP, |
| 726 |
TOF_RANGE_REQ_CMD), |
| 727 |
IWL_FW_CMD_VER_UNKNOWN) >= 11) { |
| 728 |
wiphy_ext_feature_set(hw->wiphy, |
| 729 |
NL80211_EXT_FEATURE_PROT_RANGE_NEGO_AND_MEASURE); |
| 730 |
|
| 731 |
if (fw_has_capa(&mvm->fw->ucode_capa, |
| 732 |
IWL_UCODE_TLV_CAPA_SECURE_LTF_SUPPORT)) |
| 733 |
wiphy_ext_feature_set(hw->wiphy, |
| 734 |
NL80211_EXT_FEATURE_SECURE_LTF); |
| 735 |
} |
| 736 |
|
| 737 |
mvm->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD; |
| 738 |
|
| 739 |
#ifdef CONFIG_PM_SLEEP |
| 740 |
if ((unified || mvm->fw->img[IWL_UCODE_WOWLAN].num_sec) && |
| 741 |
device_can_wakeup(mvm->trans->dev) && !fips_enabled) { |
| 742 |
mvm->wowlan.flags |= WIPHY_WOWLAN_MAGIC_PKT | |
| 743 |
WIPHY_WOWLAN_DISCONNECT | |
| 744 |
WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 745 |
WIPHY_WOWLAN_RFKILL_RELEASE | |
| 746 |
WIPHY_WOWLAN_NET_DETECT; |
| 747 |
mvm->wowlan.flags |= WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 748 |
WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 749 |
WIPHY_WOWLAN_4WAY_HANDSHAKE; |
| 750 |
|
| 751 |
mvm->wowlan.n_patterns = IWL_WOWLAN_MAX_PATTERNS; |
| 752 |
mvm->wowlan.pattern_min_len = IWL_WOWLAN_MIN_PATTERN_LEN; |
| 753 |
mvm->wowlan.pattern_max_len = IWL_WOWLAN_MAX_PATTERN_LEN; |
| 754 |
mvm->wowlan.max_nd_match_sets = |
| 755 |
iwl_umac_scan_get_max_profiles(mvm->fw); |
| 756 |
hw->wiphy->wowlan = &mvm->wowlan; |
| 757 |
} |
| 758 |
#endif |
| 759 |
|
| 760 |
ret = iwl_mvm_leds_init(mvm); |
| 761 |
if (ret) |
| 762 |
return ret; |
| 763 |
|
| 764 |
if (fw_has_capa(&mvm->fw->ucode_capa, |
| 765 |
IWL_UCODE_TLV_CAPA_TDLS_SUPPORT)) { |
| 766 |
IWL_DEBUG_TDLS(mvm, "TDLS supported\n"); |
| 767 |
hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS; |
| 768 |
ieee80211_hw_set(hw, TDLS_WIDER_BW); |
| 769 |
} |
| 770 |
|
| 771 |
if (fw_has_capa(&mvm->fw->ucode_capa, |
| 772 |
IWL_UCODE_TLV_CAPA_TDLS_CHANNEL_SWITCH)) { |
| 773 |
IWL_DEBUG_TDLS(mvm, "TDLS channel switch supported\n"); |
| 774 |
hw->wiphy->features |= NL80211_FEATURE_TDLS_CHANNEL_SWITCH; |
| 775 |
} |
| 776 |
|
| 777 |
hw->netdev_features |= mvm->trans->mac_cfg->base->features; |
| 778 |
if (!iwl_mvm_is_csum_supported(mvm)) |
| 779 |
hw->netdev_features &= ~IWL_CSUM_NETIF_FLAGS_MASK; |
| 780 |
|
| 781 |
if (mvm->cfg->vht_mu_mimo_supported) |
| 782 |
wiphy_ext_feature_set(hw->wiphy, |
| 783 |
NL80211_EXT_FEATURE_MU_MIMO_AIR_SNIFFER); |
| 784 |
|
| 785 |
if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_PROTECTED_TWT)) |
| 786 |
wiphy_ext_feature_set(hw->wiphy, |
| 787 |
NL80211_EXT_FEATURE_PROTECTED_TWT); |
| 788 |
|
| 789 |
iwl_mvm_vendor_cmds_register(mvm); |
| 790 |
|
| 791 |
hw->wiphy->available_antennas_tx = iwl_mvm_get_valid_tx_ant(mvm); |
| 792 |
hw->wiphy->available_antennas_rx = iwl_mvm_get_valid_rx_ant(mvm); |
| 793 |
|
| 794 |
ret = ieee80211_register_hw(mvm->hw); |
| 795 |
if (ret) { |
| 796 |
iwl_mvm_leds_exit(mvm); |
| 797 |
} |
| 798 |
|
| 799 |
return ret; |
| 800 |
} |
| 801 |
|
| 802 |
static void iwl_mvm_tx_skb(struct iwl_mvm *mvm, struct sk_buff *skb, |
| 803 |
struct ieee80211_sta *sta) |
| 804 |
{ |
| 805 |
if (likely(sta)) { |
| 806 |
if (likely(iwl_mvm_tx_skb_sta(mvm, skb, sta) == 0)) |
| 807 |
return; |
| 808 |
} else { |
| 809 |
if (likely(iwl_mvm_tx_skb_non_sta(mvm, skb) == 0)) |
| 810 |
return; |
| 811 |
} |
| 812 |
|
| 813 |
ieee80211_free_txskb(mvm->hw, skb); |
| 814 |
} |
| 815 |
|
| 816 |
void iwl_mvm_mac_tx(struct ieee80211_hw *hw, |
| 817 |
struct ieee80211_tx_control *control, struct sk_buff *skb) |
| 818 |
{ |
| 819 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 820 |
struct ieee80211_sta *sta = control->sta; |
| 821 |
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
| 822 |
struct ieee80211_hdr *hdr = (void *)skb->data; |
| 823 |
bool offchannel = IEEE80211_SKB_CB(skb)->flags & |
| 824 |
IEEE80211_TX_CTL_TX_OFFCHAN; |
| 825 |
u32 link_id = u32_get_bits(info->control.flags, |
| 826 |
IEEE80211_TX_CTRL_MLO_LINK); |
| 827 |
struct ieee80211_sta *tmp_sta = sta; |
| 828 |
|
| 829 |
if (iwl_mvm_is_radio_killed(mvm)) { |
| 830 |
IWL_DEBUG_DROP(mvm, "Dropping - RF/CT KILL\n"); |
| 831 |
goto drop; |
| 832 |
} |
| 833 |
|
| 834 |
if (offchannel && |
| 835 |
!test_bit(IWL_MVM_STATUS_ROC_P2P_RUNNING, &mvm->status) && |
| 836 |
!test_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING, &mvm->status)) |
| 837 |
goto drop; |
| 838 |
|
| 839 |
/* |
| 840 |
* bufferable MMPDUs or MMPDUs on STA interfaces come via TXQs |
| 841 |
* so we treat the others as broadcast |
| 842 |
*/ |
| 843 |
if (ieee80211_is_mgmt(hdr->frame_control)) |
| 844 |
sta = NULL; |
| 845 |
|
| 846 |
/* this shouldn't even happen: just drop */ |
| 847 |
if (!sta && info->control.vif->type == NL80211_IFTYPE_STATION && |
| 848 |
!offchannel) |
| 849 |
goto drop; |
| 850 |
|
| 851 |
if (tmp_sta && !sta && link_id != IEEE80211_LINK_UNSPECIFIED && |
| 852 |
!ieee80211_is_probe_resp(hdr->frame_control)) { |
| 853 |
/* translate MLD addresses to LINK addresses */ |
| 854 |
struct ieee80211_link_sta *link_sta = |
| 855 |
rcu_dereference(tmp_sta->link[link_id]); |
| 856 |
struct ieee80211_bss_conf *link_conf = |
| 857 |
rcu_dereference(info->control.vif->link_conf[link_id]); |
| 858 |
struct ieee80211_mgmt *mgmt; |
| 859 |
|
| 860 |
if (WARN_ON(!link_sta || !link_conf)) |
| 861 |
goto drop; |
| 862 |
|
| 863 |
/* if sta is NULL, the frame is a management frame */ |
| 864 |
mgmt = (void *)hdr; |
| 865 |
memcpy(mgmt->da, link_sta->addr, ETH_ALEN); |
| 866 |
memcpy(mgmt->sa, link_conf->addr, ETH_ALEN); |
| 867 |
memcpy(mgmt->bssid, link_conf->bssid, ETH_ALEN); |
| 868 |
} |
| 869 |
|
| 870 |
iwl_mvm_tx_skb(mvm, skb, sta); |
| 871 |
return; |
| 872 |
drop: |
| 873 |
ieee80211_free_txskb(hw, skb); |
| 874 |
} |
| 875 |
|
| 876 |
void iwl_mvm_mac_itxq_xmit(struct ieee80211_hw *hw, struct ieee80211_txq *txq) |
| 877 |
{ |
| 878 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 879 |
struct iwl_mvm_txq *mvmtxq = iwl_mvm_txq_from_mac80211(txq); |
| 880 |
struct sk_buff *skb = NULL; |
| 881 |
|
| 882 |
/* |
| 883 |
* No need for threads to be pending here, they can leave the first |
| 884 |
* taker all the work. |
| 885 |
* |
| 886 |
* mvmtxq->tx_request logic: |
| 887 |
* |
| 888 |
* If 0, no one is currently TXing, set to 1 to indicate current thread |
| 889 |
* will now start TX and other threads should quit. |
| 890 |
* |
| 891 |
* If 1, another thread is currently TXing, set to 2 to indicate to |
| 892 |
* that thread that there was another request. Since that request may |
| 893 |
* have raced with the check whether the queue is empty, the TXing |
| 894 |
* thread should check the queue's status one more time before leaving. |
| 895 |
* This check is done in order to not leave any TX hanging in the queue |
| 896 |
* until the next TX invocation (which may not even happen). |
| 897 |
* |
| 898 |
* If 2, another thread is currently TXing, and it will already double |
| 899 |
* check the queue, so do nothing. |
| 900 |
*/ |
| 901 |
if (atomic_fetch_add_unless(&mvmtxq->tx_request, 1, 2)) |
| 902 |
return; |
| 903 |
|
| 904 |
rcu_read_lock(); |
| 905 |
do { |
| 906 |
while (likely(!test_bit(IWL_MVM_TXQ_STATE_STOP_FULL, |
| 907 |
&mvmtxq->state) && |
| 908 |
!test_bit(IWL_MVM_TXQ_STATE_STOP_REDIRECT, |
| 909 |
&mvmtxq->state) && |
| 910 |
!test_bit(IWL_MVM_TXQ_STATE_STOP_AP_CSA, |
| 911 |
&mvmtxq->state) && |
| 912 |
!test_bit(IWL_MVM_STATUS_IN_D3, &mvm->status))) { |
| 913 |
skb = ieee80211_tx_dequeue(hw, txq); |
| 914 |
|
| 915 |
if (!skb) { |
| 916 |
if (txq->sta) |
| 917 |
IWL_DEBUG_TX(mvm, |
| 918 |
"TXQ of sta %pM tid %d is now empty\n", |
| 919 |
txq->sta->addr, |
| 920 |
txq->tid); |
| 921 |
break; |
| 922 |
} |
| 923 |
|
| 924 |
iwl_mvm_tx_skb(mvm, skb, txq->sta); |
| 925 |
} |
| 926 |
} while (atomic_dec_return(&mvmtxq->tx_request)); |
| 927 |
rcu_read_unlock(); |
| 928 |
} |
| 929 |
|
| 930 |
void iwl_mvm_mac_wake_tx_queue(struct ieee80211_hw *hw, |
| 931 |
struct ieee80211_txq *txq) |
| 932 |
{ |
| 933 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 934 |
struct iwl_mvm_txq *mvmtxq = iwl_mvm_txq_from_mac80211(txq); |
| 935 |
|
| 936 |
if (likely(test_bit(IWL_MVM_TXQ_STATE_READY, &mvmtxq->state)) || |
| 937 |
!txq->sta) { |
| 938 |
iwl_mvm_mac_itxq_xmit(hw, txq); |
| 939 |
return; |
| 940 |
} |
| 941 |
|
| 942 |
/* iwl_mvm_mac_itxq_xmit() will later be called by the worker |
| 943 |
* to handle any packets we leave on the txq now |
| 944 |
*/ |
| 945 |
|
| 946 |
spin_lock_bh(&mvm->add_stream_lock); |
| 947 |
/* The list is being deleted only after the queue is fully allocated. */ |
| 948 |
if (list_empty(&mvmtxq->list) && |
| 949 |
/* recheck under lock */ |
| 950 |
!test_bit(IWL_MVM_TXQ_STATE_READY, &mvmtxq->state)) { |
| 951 |
list_add_tail(&mvmtxq->list, &mvm->add_stream_txqs); |
| 952 |
schedule_work(&mvm->add_stream_wk); |
| 953 |
} |
| 954 |
spin_unlock_bh(&mvm->add_stream_lock); |
| 955 |
} |
| 956 |
|
| 957 |
#define CHECK_BA_TRIGGER(_mvm, _trig, _tid_bm, _tid, _fmt...) \ |
| 958 |
do { \ |
| 959 |
if (!(le16_to_cpu(_tid_bm) & BIT(_tid))) \ |
| 960 |
break; \ |
| 961 |
iwl_fw_dbg_collect_trig(&(_mvm)->fwrt, _trig, _fmt); \ |
| 962 |
} while (0) |
| 963 |
|
| 964 |
static void |
| 965 |
iwl_mvm_ampdu_check_trigger(struct iwl_mvm *mvm, struct ieee80211_vif *vif, |
| 966 |
struct ieee80211_sta *sta, u16 tid, u16 rx_ba_ssn, |
| 967 |
enum ieee80211_ampdu_mlme_action action) |
| 968 |
{ |
| 969 |
struct iwl_fw_dbg_trigger_tlv *trig; |
| 970 |
struct iwl_fw_dbg_trigger_ba *ba_trig; |
| 971 |
|
| 972 |
trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif), |
| 973 |
FW_DBG_TRIGGER_BA); |
| 974 |
if (!trig) |
| 975 |
return; |
| 976 |
|
| 977 |
ba_trig = (void *)trig->data; |
| 978 |
|
| 979 |
switch (action) { |
| 980 |
case IEEE80211_AMPDU_TX_OPERATIONAL: { |
| 981 |
struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); |
| 982 |
struct iwl_mvm_tid_data *tid_data = &mvmsta->tid_data[tid]; |
| 983 |
|
| 984 |
CHECK_BA_TRIGGER(mvm, trig, ba_trig->tx_ba_start, tid, |
| 985 |
"TX AGG START: MAC %pM tid %d ssn %d\n", |
| 986 |
sta->addr, tid, tid_data->ssn); |
| 987 |
break; |
| 988 |
} |
| 989 |
case IEEE80211_AMPDU_TX_STOP_CONT: |
| 990 |
CHECK_BA_TRIGGER(mvm, trig, ba_trig->tx_ba_stop, tid, |
| 991 |
"TX AGG STOP: MAC %pM tid %d\n", |
| 992 |
sta->addr, tid); |
| 993 |
break; |
| 994 |
case IEEE80211_AMPDU_RX_START: |
| 995 |
CHECK_BA_TRIGGER(mvm, trig, ba_trig->rx_ba_start, tid, |
| 996 |
"RX AGG START: MAC %pM tid %d ssn %d\n", |
| 997 |
sta->addr, tid, rx_ba_ssn); |
| 998 |
break; |
| 999 |
case IEEE80211_AMPDU_RX_STOP: |
| 1000 |
CHECK_BA_TRIGGER(mvm, trig, ba_trig->rx_ba_stop, tid, |
| 1001 |
"RX AGG STOP: MAC %pM tid %d\n", |
| 1002 |
sta->addr, tid); |
| 1003 |
break; |
| 1004 |
default: |
| 1005 |
break; |
| 1006 |
} |
| 1007 |
} |
| 1008 |
|
| 1009 |
int iwl_mvm_mac_ampdu_action(struct ieee80211_hw *hw, |
| 1010 |
struct ieee80211_vif *vif, |
| 1011 |
struct ieee80211_ampdu_params *params) |
| 1012 |
{ |
| 1013 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1014 |
int ret; |
| 1015 |
struct ieee80211_sta *sta = params->sta; |
| 1016 |
enum ieee80211_ampdu_mlme_action action = params->action; |
| 1017 |
u16 tid = params->tid; |
| 1018 |
u16 *ssn = ¶ms->ssn; |
| 1019 |
u16 buf_size = params->buf_size; |
| 1020 |
bool amsdu = params->amsdu; |
| 1021 |
u16 timeout = params->timeout; |
| 1022 |
|
| 1023 |
IWL_DEBUG_HT(mvm, "A-MPDU action on addr %pM tid %d: action %d\n", |
| 1024 |
sta->addr, tid, action); |
| 1025 |
|
| 1026 |
if (!(mvm->nvm_data->sku_cap_11n_enable)) |
| 1027 |
return -EACCES; |
| 1028 |
|
| 1029 |
mutex_lock(&mvm->mutex); |
| 1030 |
|
| 1031 |
switch (action) { |
| 1032 |
case IEEE80211_AMPDU_RX_START: |
| 1033 |
if (iwl_mvm_vif_from_mac80211(vif)->deflink.ap_sta_id == |
| 1034 |
iwl_mvm_sta_from_mac80211(sta)->deflink.sta_id) { |
| 1035 |
struct iwl_mvm_vif *mvmvif; |
| 1036 |
u16 macid = iwl_mvm_vif_from_mac80211(vif)->id; |
| 1037 |
struct iwl_mvm_tcm_mac *mdata = &mvm->tcm.data[macid]; |
| 1038 |
|
| 1039 |
mdata->opened_rx_ba_sessions = true; |
| 1040 |
mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1041 |
cancel_delayed_work(&mvmvif->uapsd_nonagg_detected_wk); |
| 1042 |
} |
| 1043 |
if (!iwl_enable_rx_ampdu()) { |
| 1044 |
ret = -EINVAL; |
| 1045 |
break; |
| 1046 |
} |
| 1047 |
ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, *ssn, true, buf_size, |
| 1048 |
timeout); |
| 1049 |
break; |
| 1050 |
case IEEE80211_AMPDU_RX_STOP: |
| 1051 |
ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, 0, false, buf_size, |
| 1052 |
timeout); |
| 1053 |
break; |
| 1054 |
case IEEE80211_AMPDU_TX_START: |
| 1055 |
if (!iwl_enable_tx_ampdu()) { |
| 1056 |
ret = -EINVAL; |
| 1057 |
break; |
| 1058 |
} |
| 1059 |
ret = iwl_mvm_sta_tx_agg_start(mvm, vif, sta, tid, ssn); |
| 1060 |
break; |
| 1061 |
case IEEE80211_AMPDU_TX_STOP_CONT: |
| 1062 |
ret = iwl_mvm_sta_tx_agg_stop(mvm, vif, sta, tid); |
| 1063 |
break; |
| 1064 |
case IEEE80211_AMPDU_TX_STOP_FLUSH: |
| 1065 |
case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: |
| 1066 |
ret = iwl_mvm_sta_tx_agg_flush(mvm, vif, sta, tid); |
| 1067 |
break; |
| 1068 |
case IEEE80211_AMPDU_TX_OPERATIONAL: |
| 1069 |
ret = iwl_mvm_sta_tx_agg_oper(mvm, vif, sta, tid, |
| 1070 |
buf_size, amsdu); |
| 1071 |
break; |
| 1072 |
default: |
| 1073 |
WARN_ON_ONCE(1); |
| 1074 |
ret = -EINVAL; |
| 1075 |
break; |
| 1076 |
} |
| 1077 |
|
| 1078 |
if (!ret) { |
| 1079 |
u16 rx_ba_ssn = 0; |
| 1080 |
|
| 1081 |
if (action == IEEE80211_AMPDU_RX_START) |
| 1082 |
rx_ba_ssn = *ssn; |
| 1083 |
|
| 1084 |
iwl_mvm_ampdu_check_trigger(mvm, vif, sta, tid, |
| 1085 |
rx_ba_ssn, action); |
| 1086 |
} |
| 1087 |
mutex_unlock(&mvm->mutex); |
| 1088 |
|
| 1089 |
return ret; |
| 1090 |
} |
| 1091 |
|
| 1092 |
static void iwl_mvm_cleanup_iterator(void *data, u8 *mac, |
| 1093 |
struct ieee80211_vif *vif) |
| 1094 |
{ |
| 1095 |
struct iwl_mvm *mvm = data; |
| 1096 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1097 |
struct iwl_probe_resp_data *probe_data; |
| 1098 |
unsigned int link_id; |
| 1099 |
|
| 1100 |
mvmvif->uploaded = false; |
| 1101 |
|
| 1102 |
spin_lock_bh(&mvm->time_event_lock); |
| 1103 |
iwl_mvm_te_clear_data(mvm, &mvmvif->time_event_data); |
| 1104 |
spin_unlock_bh(&mvm->time_event_lock); |
| 1105 |
|
| 1106 |
mvmvif->roc_activity = ROC_NUM_ACTIVITIES; |
| 1107 |
|
| 1108 |
mvmvif->bf_enabled = false; |
| 1109 |
mvmvif->ba_enabled = false; |
| 1110 |
mvmvif->ap_sta = NULL; |
| 1111 |
|
| 1112 |
vif->driver_flags &= ~IEEE80211_VIF_EML_ACTIVE; |
| 1113 |
|
| 1114 |
for_each_mvm_vif_valid_link(mvmvif, link_id) { |
| 1115 |
mvmvif->link[link_id]->ap_sta_id = IWL_INVALID_STA; |
| 1116 |
mvmvif->link[link_id]->fw_link_id = IWL_MVM_FW_LINK_ID_INVALID; |
| 1117 |
mvmvif->link[link_id]->phy_ctxt = NULL; |
| 1118 |
mvmvif->link[link_id]->active = 0; |
| 1119 |
mvmvif->link[link_id]->igtk = NULL; |
| 1120 |
memset(&mvmvif->link[link_id]->bf_data, 0, |
| 1121 |
sizeof(mvmvif->link[link_id]->bf_data)); |
| 1122 |
} |
| 1123 |
|
| 1124 |
probe_data = rcu_dereference_protected(mvmvif->deflink.probe_resp_data, |
| 1125 |
lockdep_is_held(&mvm->mutex)); |
| 1126 |
if (probe_data) |
| 1127 |
kfree_rcu(probe_data, rcu_head); |
| 1128 |
RCU_INIT_POINTER(mvmvif->deflink.probe_resp_data, NULL); |
| 1129 |
} |
| 1130 |
|
| 1131 |
static void iwl_mvm_restart_cleanup(struct iwl_mvm *mvm) |
| 1132 |
{ |
| 1133 |
iwl_mvm_stop_device(mvm); |
| 1134 |
|
| 1135 |
mvm->cur_aid = 0; |
| 1136 |
|
| 1137 |
mvm->scan_status = 0; |
| 1138 |
mvm->ps_disabled = false; |
| 1139 |
mvm->rfkill_safe_init_done = false; |
| 1140 |
|
| 1141 |
/* just in case one was running */ |
| 1142 |
iwl_mvm_cleanup_roc_te(mvm); |
| 1143 |
ieee80211_remain_on_channel_expired(mvm->hw); |
| 1144 |
|
| 1145 |
iwl_mvm_ftm_restart(mvm); |
| 1146 |
|
| 1147 |
/* |
| 1148 |
* cleanup all interfaces, even inactive ones, as some might have |
| 1149 |
* gone down during the HW restart |
| 1150 |
*/ |
| 1151 |
ieee80211_iterate_interfaces(mvm->hw, 0, iwl_mvm_cleanup_iterator, mvm); |
| 1152 |
|
| 1153 |
mvm->p2p_device_vif = NULL; |
| 1154 |
|
| 1155 |
iwl_mvm_reset_phy_ctxts(mvm); |
| 1156 |
memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table)); |
| 1157 |
memset(&mvm->last_bt_notif, 0, sizeof(mvm->last_bt_notif)); |
| 1158 |
memset(&mvm->last_bt_ci_cmd, 0, sizeof(mvm->last_bt_ci_cmd)); |
| 1159 |
|
| 1160 |
ieee80211_wake_queues(mvm->hw); |
| 1161 |
|
| 1162 |
mvm->rx_ba_sessions = 0; |
| 1163 |
mvm->fwrt.dump.conf = FW_DBG_INVALID; |
| 1164 |
mvm->monitor_on = false; |
| 1165 |
#ifdef CONFIG_IWLWIFI_DEBUGFS |
| 1166 |
mvm->beacon_inject_active = false; |
| 1167 |
#endif |
| 1168 |
|
| 1169 |
/* keep statistics ticking */ |
| 1170 |
iwl_mvm_accu_radio_stats(mvm); |
| 1171 |
} |
| 1172 |
|
| 1173 |
int __iwl_mvm_mac_start(struct iwl_mvm *mvm) |
| 1174 |
{ |
| 1175 |
bool fast_resume = false; |
| 1176 |
int ret; |
| 1177 |
|
| 1178 |
lockdep_assert_held(&mvm->mutex); |
| 1179 |
|
| 1180 |
ret = iwl_mvm_mei_get_ownership(mvm); |
| 1181 |
if (ret) |
| 1182 |
return ret; |
| 1183 |
|
| 1184 |
if (mvm->mei_nvm_data) { |
| 1185 |
/* We got the NIC, we can now free the MEI NVM data */ |
| 1186 |
kfree(mvm->mei_nvm_data); |
| 1187 |
mvm->mei_nvm_data = NULL; |
| 1188 |
|
| 1189 |
/* |
| 1190 |
* We can't free the nvm_data we allocated based on the SAP |
| 1191 |
* data because we registered to cfg80211 with the channels |
| 1192 |
* allocated on mvm->nvm_data. Keep a pointer in temp_nvm_data |
| 1193 |
* just in order to be able free it later. |
| 1194 |
* NULLify nvm_data so that we will read the NVM from the |
| 1195 |
* firmware this time. |
| 1196 |
*/ |
| 1197 |
mvm->temp_nvm_data = mvm->nvm_data; |
| 1198 |
mvm->nvm_data = NULL; |
| 1199 |
} |
| 1200 |
|
| 1201 |
#ifdef CONFIG_PM_SLEEP |
| 1202 |
/* fast_resume will be cleared by iwl_mvm_fast_resume */ |
| 1203 |
fast_resume = mvm->fast_resume; |
| 1204 |
|
| 1205 |
if (fast_resume) { |
| 1206 |
iwl_mvm_mei_device_state(mvm, true); |
| 1207 |
ret = iwl_mvm_fast_resume(mvm); |
| 1208 |
if (ret) { |
| 1209 |
iwl_mvm_stop_device(mvm); |
| 1210 |
/* iwl_mvm_up() will be called further down */ |
| 1211 |
} else { |
| 1212 |
/* |
| 1213 |
* We clear IWL_MVM_STATUS_FIRMWARE_RUNNING upon |
| 1214 |
* mac_down() so that debugfs will stop honoring |
| 1215 |
* requests after we flush all the workers. |
| 1216 |
* Set the IWL_MVM_STATUS_FIRMWARE_RUNNING bit again |
| 1217 |
* now that we are back. This is a bit abusing the |
| 1218 |
* flag since the firmware wasn't really ever stopped, |
| 1219 |
* but this still serves the purpose. |
| 1220 |
*/ |
| 1221 |
set_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status); |
| 1222 |
} |
| 1223 |
} |
| 1224 |
#endif /* CONFIG_PM_SLEEP */ |
| 1225 |
|
| 1226 |
if (test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, &mvm->status)) { |
| 1227 |
/* |
| 1228 |
* Now convert the HW_RESTART_REQUESTED flag to IN_HW_RESTART |
| 1229 |
* so later code will - from now on - see that we're doing it. |
| 1230 |
*/ |
| 1231 |
set_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status); |
| 1232 |
clear_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, &mvm->status); |
| 1233 |
/* Clean up some internal and mac80211 state on restart */ |
| 1234 |
iwl_mvm_restart_cleanup(mvm); |
| 1235 |
} |
| 1236 |
|
| 1237 |
/* we also want to load the firmware if fast_resume failed */ |
| 1238 |
if (!fast_resume || ret) |
| 1239 |
ret = iwl_mvm_up(mvm); |
| 1240 |
|
| 1241 |
iwl_dbg_tlv_time_point(&mvm->fwrt, IWL_FW_INI_TIME_POINT_POST_INIT, |
| 1242 |
NULL); |
| 1243 |
iwl_dbg_tlv_time_point(&mvm->fwrt, IWL_FW_INI_TIME_POINT_PERIODIC, |
| 1244 |
NULL); |
| 1245 |
|
| 1246 |
mvm->last_reset_or_resume_time_jiffies = jiffies; |
| 1247 |
|
| 1248 |
if (ret && test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) { |
| 1249 |
/* Something went wrong - we need to finish some cleanup |
| 1250 |
* that normally iwl_mvm_mac_restart_complete() below |
| 1251 |
* would do. |
| 1252 |
*/ |
| 1253 |
clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status); |
| 1254 |
} |
| 1255 |
|
| 1256 |
return ret; |
| 1257 |
} |
| 1258 |
|
| 1259 |
int iwl_mvm_mac_start(struct ieee80211_hw *hw) |
| 1260 |
{ |
| 1261 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1262 |
int ret; |
| 1263 |
int retry, max_retry = 0; |
| 1264 |
|
| 1265 |
mutex_lock(&mvm->mutex); |
| 1266 |
|
| 1267 |
/* we are starting the mac not in error flow, and restart is enabled */ |
| 1268 |
if (!test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, &mvm->status) && |
| 1269 |
iwlwifi_mod_params.fw_restart) |
| 1270 |
max_retry = IWL_MAX_INIT_RETRY; |
| 1271 |
|
| 1272 |
for (retry = 0; retry <= max_retry; retry++) { |
| 1273 |
ret = __iwl_mvm_mac_start(mvm); |
| 1274 |
if (ret != -ETIMEDOUT) |
| 1275 |
break; |
| 1276 |
|
| 1277 |
IWL_ERR(mvm, "mac start retry %d\n", retry); |
| 1278 |
} |
| 1279 |
|
| 1280 |
mutex_unlock(&mvm->mutex); |
| 1281 |
|
| 1282 |
iwl_mvm_mei_set_sw_rfkill_state(mvm); |
| 1283 |
|
| 1284 |
return ret; |
| 1285 |
} |
| 1286 |
|
| 1287 |
static void iwl_mvm_restart_complete(struct iwl_mvm *mvm) |
| 1288 |
{ |
| 1289 |
int ret; |
| 1290 |
|
| 1291 |
guard(mvm)(mvm); |
| 1292 |
|
| 1293 |
clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status); |
| 1294 |
|
| 1295 |
ret = iwl_mvm_update_quotas(mvm, true, NULL); |
| 1296 |
if (ret) |
| 1297 |
IWL_ERR(mvm, "Failed to update quotas after restart (%d)\n", |
| 1298 |
ret); |
| 1299 |
|
| 1300 |
iwl_mvm_send_recovery_cmd(mvm, ERROR_RECOVERY_END_OF_RECOVERY); |
| 1301 |
|
| 1302 |
/* |
| 1303 |
* If we have TDLS peers, remove them. We don't know the last seqno/PN |
| 1304 |
* of packets the FW sent out, so we must reconnect. |
| 1305 |
*/ |
| 1306 |
iwl_mvm_teardown_tdls_peers(mvm); |
| 1307 |
|
| 1308 |
IWL_INFO(mvm, "restart completed\n"); |
| 1309 |
iwl_trans_finish_sw_reset(mvm->trans); |
| 1310 |
|
| 1311 |
/* no need to lock, adding in parallel would schedule too */ |
| 1312 |
if (!list_empty(&mvm->add_stream_txqs)) |
| 1313 |
schedule_work(&mvm->add_stream_wk); |
| 1314 |
} |
| 1315 |
|
| 1316 |
void iwl_mvm_mac_reconfig_complete(struct ieee80211_hw *hw, |
| 1317 |
enum ieee80211_reconfig_type reconfig_type) |
| 1318 |
{ |
| 1319 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1320 |
|
| 1321 |
switch (reconfig_type) { |
| 1322 |
case IEEE80211_RECONFIG_TYPE_RESTART: |
| 1323 |
iwl_mvm_restart_complete(mvm); |
| 1324 |
break; |
| 1325 |
case IEEE80211_RECONFIG_TYPE_SUSPEND: |
| 1326 |
break; |
| 1327 |
} |
| 1328 |
} |
| 1329 |
|
| 1330 |
void __iwl_mvm_mac_stop(struct iwl_mvm *mvm, bool suspend) |
| 1331 |
{ |
| 1332 |
lockdep_assert_held(&mvm->mutex); |
| 1333 |
|
| 1334 |
iwl_mvm_ftm_initiator_smooth_stop(mvm); |
| 1335 |
|
| 1336 |
/* firmware counters are obviously reset now, but we shouldn't |
| 1337 |
* partially track so also clear the fw_reset_accu counters. |
| 1338 |
*/ |
| 1339 |
memset(&mvm->accu_radio_stats, 0, sizeof(mvm->accu_radio_stats)); |
| 1340 |
|
| 1341 |
/* async_handlers_wk is now blocked */ |
| 1342 |
|
| 1343 |
if (!iwl_mvm_has_new_station_api(mvm->fw)) |
| 1344 |
iwl_mvm_rm_aux_sta(mvm); |
| 1345 |
|
| 1346 |
if (suspend && |
| 1347 |
mvm->trans->mac_cfg->device_family >= IWL_DEVICE_FAMILY_22000) { |
| 1348 |
iwl_mvm_fast_suspend(mvm); |
| 1349 |
/* From this point on, we won't touch the device */ |
| 1350 |
iwl_mvm_mei_device_state(mvm, false); |
| 1351 |
} else { |
| 1352 |
iwl_mvm_stop_device(mvm); |
| 1353 |
} |
| 1354 |
|
| 1355 |
iwl_mvm_async_handlers_purge(mvm); |
| 1356 |
/* async_handlers_list is empty and will stay empty: HW is stopped */ |
| 1357 |
|
| 1358 |
/* |
| 1359 |
* Clear IN_HW_RESTART and HW_RESTART_REQUESTED flag when stopping the |
| 1360 |
* hw (as restart_complete() won't be called in this case) and mac80211 |
| 1361 |
* won't execute the restart. |
| 1362 |
* But make sure to cleanup interfaces that have gone down before/during |
| 1363 |
* HW restart was requested. |
| 1364 |
*/ |
| 1365 |
if (test_and_clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) || |
| 1366 |
test_and_clear_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, |
| 1367 |
&mvm->status)) |
| 1368 |
ieee80211_iterate_interfaces(mvm->hw, 0, |
| 1369 |
iwl_mvm_cleanup_iterator, mvm); |
| 1370 |
|
| 1371 |
/* We shouldn't have any UIDs still set. Loop over all the UIDs to |
| 1372 |
* make sure there's nothing left there and warn if any is found. |
| 1373 |
*/ |
| 1374 |
if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) { |
| 1375 |
int i; |
| 1376 |
|
| 1377 |
for (i = 0; i < mvm->max_scans; i++) { |
| 1378 |
if (WARN_ONCE(mvm->scan_uid_status[i], |
| 1379 |
"UMAC scan UID %d status was not cleaned\n", |
| 1380 |
i)) |
| 1381 |
mvm->scan_uid_status[i] = 0; |
| 1382 |
} |
| 1383 |
} |
| 1384 |
} |
| 1385 |
|
| 1386 |
void iwl_mvm_mac_stop(struct ieee80211_hw *hw, bool suspend) |
| 1387 |
{ |
| 1388 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1389 |
|
| 1390 |
wiphy_work_flush(mvm->hw->wiphy, &mvm->async_handlers_wiphy_wk); |
| 1391 |
flush_work(&mvm->async_handlers_wk); |
| 1392 |
flush_work(&mvm->add_stream_wk); |
| 1393 |
|
| 1394 |
/* |
| 1395 |
* Lock and clear the firmware running bit here already, so that |
| 1396 |
* new commands coming in elsewhere, e.g. from debugfs, will not |
| 1397 |
* be able to proceed. This is important here because one of those |
| 1398 |
* debugfs files causes the firmware dump to be triggered, and if we |
| 1399 |
* don't stop debugfs accesses before canceling that it could be |
| 1400 |
* retriggered after we flush it but before we've cleared the bit. |
| 1401 |
*/ |
| 1402 |
clear_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status); |
| 1403 |
|
| 1404 |
cancel_delayed_work_sync(&mvm->cs_tx_unblock_dwork); |
| 1405 |
cancel_delayed_work_sync(&mvm->scan_timeout_dwork); |
| 1406 |
|
| 1407 |
/* |
| 1408 |
* The work item could be running or queued if the |
| 1409 |
* ROC time event stops just as we get here. |
| 1410 |
*/ |
| 1411 |
flush_work(&mvm->roc_done_wk); |
| 1412 |
|
| 1413 |
iwl_mvm_mei_set_sw_rfkill_state(mvm); |
| 1414 |
|
| 1415 |
mutex_lock(&mvm->mutex); |
| 1416 |
__iwl_mvm_mac_stop(mvm, suspend); |
| 1417 |
mutex_unlock(&mvm->mutex); |
| 1418 |
|
| 1419 |
/* |
| 1420 |
* The worker might have been waiting for the mutex, let it run and |
| 1421 |
* discover that its list is now empty. |
| 1422 |
*/ |
| 1423 |
cancel_work_sync(&mvm->async_handlers_wk); |
| 1424 |
wiphy_work_cancel(hw->wiphy, &mvm->async_handlers_wiphy_wk); |
| 1425 |
} |
| 1426 |
|
| 1427 |
struct iwl_mvm_phy_ctxt *iwl_mvm_get_free_phy_ctxt(struct iwl_mvm *mvm) |
| 1428 |
{ |
| 1429 |
u16 i; |
| 1430 |
|
| 1431 |
lockdep_assert_held(&mvm->mutex); |
| 1432 |
|
| 1433 |
for (i = 0; i < NUM_PHY_CTX; i++) |
| 1434 |
if (!mvm->phy_ctxts[i].ref) |
| 1435 |
return &mvm->phy_ctxts[i]; |
| 1436 |
|
| 1437 |
IWL_ERR(mvm, "No available PHY context\n"); |
| 1438 |
return NULL; |
| 1439 |
} |
| 1440 |
|
| 1441 |
int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, |
| 1442 |
struct ieee80211_bss_conf *link_conf, |
| 1443 |
s16 tx_power) |
| 1444 |
{ |
| 1445 |
u32 cmd_id = REDUCE_TX_POWER_CMD; |
| 1446 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(link_conf->vif); |
| 1447 |
u32 mac_id = mvmvif->id; |
| 1448 |
int len; |
| 1449 |
struct iwl_dev_tx_power_cmd_v3_v8 cmd = { |
| 1450 |
.common.set_mode = cpu_to_le32(IWL_TX_POWER_MODE_SET_LINK), |
| 1451 |
.common.link_id = cpu_to_le32(mac_id), |
| 1452 |
}; |
| 1453 |
struct iwl_dev_tx_power_cmd cmd_v9_v10; |
| 1454 |
u8 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, cmd_id, 3); |
| 1455 |
u16 u_tx_power = tx_power == IWL_DEFAULT_MAX_TX_POWER ? |
| 1456 |
IWL_DEV_MAX_TX_POWER : 8 * tx_power; |
| 1457 |
void *cmd_data = &cmd; |
| 1458 |
|
| 1459 |
cmd.common.pwr_restriction = cpu_to_le16(u_tx_power); |
| 1460 |
|
| 1461 |
if (cmd_ver > 8) { |
| 1462 |
u32 link_id; |
| 1463 |
|
| 1464 |
if (WARN_ON(!mvmvif->link[link_conf->link_id])) |
| 1465 |
return -ENODEV; |
| 1466 |
|
| 1467 |
link_id = mvmvif->link[link_conf->link_id]->fw_link_id; |
| 1468 |
|
| 1469 |
/* Those fields sit on the same place for v9 and v10 */ |
| 1470 |
cmd_v9_v10.common.set_mode = cpu_to_le32(IWL_TX_POWER_MODE_SET_LINK); |
| 1471 |
cmd_v9_v10.common.link_id = cpu_to_le32(link_id); |
| 1472 |
cmd_v9_v10.common.pwr_restriction = cpu_to_le16(u_tx_power); |
| 1473 |
cmd_data = &cmd_v9_v10; |
| 1474 |
} |
| 1475 |
|
| 1476 |
if (cmd_ver == 10) |
| 1477 |
len = sizeof(cmd_v9_v10.v10); |
| 1478 |
else if (cmd_ver == 9) |
| 1479 |
len = sizeof(cmd_v9_v10.v9); |
| 1480 |
else if (cmd_ver == 8) |
| 1481 |
len = sizeof(cmd.v8); |
| 1482 |
else if (fw_has_api(&mvm->fw->ucode_capa, |
| 1483 |
IWL_UCODE_TLV_API_REDUCE_TX_POWER)) |
| 1484 |
len = sizeof(cmd.v5); |
| 1485 |
else if (fw_has_capa(&mvm->fw->ucode_capa, |
| 1486 |
IWL_UCODE_TLV_CAPA_TX_POWER_ACK)) |
| 1487 |
len = sizeof(cmd.v4); |
| 1488 |
else |
| 1489 |
len = sizeof(cmd.v3); |
| 1490 |
|
| 1491 |
/* all structs have the same common part, add its length */ |
| 1492 |
len += sizeof(cmd.common); |
| 1493 |
|
| 1494 |
if (cmd_ver < 9) |
| 1495 |
len += sizeof(cmd.per_band); |
| 1496 |
|
| 1497 |
return iwl_mvm_send_cmd_pdu(mvm, cmd_id, 0, len, cmd_data); |
| 1498 |
|
| 1499 |
} |
| 1500 |
|
| 1501 |
static void iwl_mvm_post_csa_tx(void *data, struct ieee80211_sta *sta) |
| 1502 |
{ |
| 1503 |
struct ieee80211_hw *hw = data; |
| 1504 |
int i; |
| 1505 |
|
| 1506 |
for (i = 0; i < ARRAY_SIZE(sta->txq); i++) { |
| 1507 |
struct iwl_mvm_txq *mvmtxq = |
| 1508 |
iwl_mvm_txq_from_mac80211(sta->txq[i]); |
| 1509 |
|
| 1510 |
clear_bit(IWL_MVM_TXQ_STATE_STOP_AP_CSA, &mvmtxq->state); |
| 1511 |
iwl_mvm_mac_itxq_xmit(hw, sta->txq[i]); |
| 1512 |
} |
| 1513 |
} |
| 1514 |
|
| 1515 |
int iwl_mvm_post_channel_switch(struct ieee80211_hw *hw, |
| 1516 |
struct ieee80211_vif *vif, |
| 1517 |
struct ieee80211_bss_conf *link_conf) |
| 1518 |
{ |
| 1519 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1520 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1521 |
int ret; |
| 1522 |
|
| 1523 |
mutex_lock(&mvm->mutex); |
| 1524 |
|
| 1525 |
if (vif->type == NL80211_IFTYPE_STATION) { |
| 1526 |
struct iwl_mvm_sta *mvmsta; |
| 1527 |
unsigned int link_id = link_conf->link_id; |
| 1528 |
u8 ap_sta_id = mvmvif->link[link_id]->ap_sta_id; |
| 1529 |
|
| 1530 |
mvmvif->csa_bcn_pending = false; |
| 1531 |
mvmvif->csa_blocks_tx = false; |
| 1532 |
mvmsta = iwl_mvm_sta_from_staid_protected(mvm, ap_sta_id); |
| 1533 |
|
| 1534 |
if (WARN_ON(!mvmsta)) { |
| 1535 |
ret = -EIO; |
| 1536 |
goto out_unlock; |
| 1537 |
} |
| 1538 |
|
| 1539 |
iwl_mvm_sta_modify_disable_tx(mvm, mvmsta, false); |
| 1540 |
if (mvm->mld_api_is_used) |
| 1541 |
iwl_mvm_mld_mac_ctxt_changed(mvm, vif, false); |
| 1542 |
else |
| 1543 |
iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL); |
| 1544 |
|
| 1545 |
if (!fw_has_capa(&mvm->fw->ucode_capa, |
| 1546 |
IWL_UCODE_TLV_CAPA_CHANNEL_SWITCH_CMD)) { |
| 1547 |
ret = iwl_mvm_enable_beacon_filter(mvm, vif); |
| 1548 |
if (ret) |
| 1549 |
goto out_unlock; |
| 1550 |
|
| 1551 |
iwl_mvm_stop_session_protection(mvm, vif); |
| 1552 |
} |
| 1553 |
} else if (vif->type == NL80211_IFTYPE_AP && mvmvif->csa_blocks_tx) { |
| 1554 |
struct iwl_mvm_txq *mvmtxq = |
| 1555 |
iwl_mvm_txq_from_mac80211(vif->txq); |
| 1556 |
|
| 1557 |
clear_bit(IWL_MVM_TXQ_STATE_STOP_AP_CSA, &mvmtxq->state); |
| 1558 |
|
| 1559 |
local_bh_disable(); |
| 1560 |
iwl_mvm_mac_itxq_xmit(hw, vif->txq); |
| 1561 |
ieee80211_iterate_stations_atomic(hw, iwl_mvm_post_csa_tx, hw); |
| 1562 |
local_bh_enable(); |
| 1563 |
|
| 1564 |
mvmvif->csa_blocks_tx = false; |
| 1565 |
} |
| 1566 |
|
| 1567 |
mvmvif->ps_disabled = false; |
| 1568 |
|
| 1569 |
ret = iwl_mvm_power_update_ps(mvm); |
| 1570 |
|
| 1571 |
out_unlock: |
| 1572 |
if (mvmvif->csa_failed) |
| 1573 |
ret = -EIO; |
| 1574 |
mutex_unlock(&mvm->mutex); |
| 1575 |
|
| 1576 |
return ret; |
| 1577 |
} |
| 1578 |
|
| 1579 |
void iwl_mvm_abort_channel_switch(struct ieee80211_hw *hw, |
| 1580 |
struct ieee80211_vif *vif, |
| 1581 |
struct ieee80211_bss_conf *link_conf) |
| 1582 |
{ |
| 1583 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1584 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1585 |
struct iwl_chan_switch_te_cmd cmd = { |
| 1586 |
.mac_id = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, |
| 1587 |
mvmvif->color)), |
| 1588 |
.action = cpu_to_le32(FW_CTXT_ACTION_REMOVE), |
| 1589 |
}; |
| 1590 |
|
| 1591 |
/* |
| 1592 |
* In the new flow since FW is in charge of the timing, |
| 1593 |
* if driver has canceled the channel switch he will receive the |
| 1594 |
* CHANNEL_SWITCH_START_NOTIF notification from FW and then cancel it |
| 1595 |
*/ |
| 1596 |
if (iwl_fw_lookup_notif_ver(mvm->fw, MAC_CONF_GROUP, |
| 1597 |
CHANNEL_SWITCH_ERROR_NOTIF, 0)) |
| 1598 |
return; |
| 1599 |
|
| 1600 |
IWL_DEBUG_MAC80211(mvm, "Abort CSA on mac %d\n", mvmvif->id); |
| 1601 |
|
| 1602 |
mutex_lock(&mvm->mutex); |
| 1603 |
if (!fw_has_capa(&mvm->fw->ucode_capa, |
| 1604 |
IWL_UCODE_TLV_CAPA_CHANNEL_SWITCH_CMD)) |
| 1605 |
iwl_mvm_remove_csa_period(mvm, vif); |
| 1606 |
else |
| 1607 |
WARN_ON(iwl_mvm_send_cmd_pdu(mvm, |
| 1608 |
WIDE_ID(MAC_CONF_GROUP, |
| 1609 |
CHANNEL_SWITCH_TIME_EVENT_CMD), |
| 1610 |
0, sizeof(cmd), &cmd)); |
| 1611 |
mvmvif->csa_failed = true; |
| 1612 |
mutex_unlock(&mvm->mutex); |
| 1613 |
|
| 1614 |
/* If we're here, we can't support MLD */ |
| 1615 |
iwl_mvm_post_channel_switch(hw, vif, &vif->bss_conf); |
| 1616 |
} |
| 1617 |
|
| 1618 |
void iwl_mvm_channel_switch_disconnect_wk(struct work_struct *wk) |
| 1619 |
{ |
| 1620 |
struct iwl_mvm_vif *mvmvif; |
| 1621 |
struct ieee80211_vif *vif; |
| 1622 |
|
| 1623 |
mvmvif = container_of(wk, struct iwl_mvm_vif, csa_work.work); |
| 1624 |
vif = container_of((void *)mvmvif, struct ieee80211_vif, drv_priv); |
| 1625 |
|
| 1626 |
/* Trigger disconnect (should clear the CSA state) */ |
| 1627 |
ieee80211_chswitch_done(vif, false, 0); |
| 1628 |
} |
| 1629 |
|
| 1630 |
static u8 |
| 1631 |
iwl_mvm_chandef_get_primary_80(struct cfg80211_chan_def *chandef) |
| 1632 |
{ |
| 1633 |
int data_start; |
| 1634 |
int control_start; |
| 1635 |
int bw; |
| 1636 |
|
| 1637 |
if (chandef->width == NL80211_CHAN_WIDTH_320) |
| 1638 |
bw = 320; |
| 1639 |
else if (chandef->width == NL80211_CHAN_WIDTH_160) |
| 1640 |
bw = 160; |
| 1641 |
else |
| 1642 |
return 0; |
| 1643 |
|
| 1644 |
/* data is bw wide so the start is half the width */ |
| 1645 |
data_start = chandef->center_freq1 - bw / 2; |
| 1646 |
/* control is 20Mhz width */ |
| 1647 |
control_start = chandef->chan->center_freq - 10; |
| 1648 |
|
| 1649 |
return (control_start - data_start) / 80; |
| 1650 |
} |
| 1651 |
|
| 1652 |
static int iwl_mvm_alloc_bcast_mcast_sta(struct iwl_mvm *mvm, |
| 1653 |
struct ieee80211_vif *vif) |
| 1654 |
{ |
| 1655 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1656 |
int ret; |
| 1657 |
|
| 1658 |
lockdep_assert_held(&mvm->mutex); |
| 1659 |
|
| 1660 |
ret = iwl_mvm_alloc_bcast_sta(mvm, vif); |
| 1661 |
if (ret) { |
| 1662 |
IWL_ERR(mvm, "Failed to allocate bcast sta\n"); |
| 1663 |
return ret; |
| 1664 |
} |
| 1665 |
|
| 1666 |
/* Only queue for this station is the mcast queue, |
| 1667 |
* which shouldn't be in TFD mask anyway |
| 1668 |
*/ |
| 1669 |
return iwl_mvm_allocate_int_sta(mvm, &mvmvif->deflink.mcast_sta, 0, |
| 1670 |
vif->type, |
| 1671 |
IWL_STA_MULTICAST); |
| 1672 |
} |
| 1673 |
|
| 1674 |
void iwl_mvm_mac_init_mvmvif(struct iwl_mvm *mvm, struct iwl_mvm_vif *mvmvif) |
| 1675 |
{ |
| 1676 |
lockdep_assert_held(&mvm->mutex); |
| 1677 |
|
| 1678 |
if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) |
| 1679 |
return; |
| 1680 |
|
| 1681 |
mvmvif->deflink.average_beacon_energy = 0; |
| 1682 |
|
| 1683 |
INIT_DELAYED_WORK(&mvmvif->csa_work, |
| 1684 |
iwl_mvm_channel_switch_disconnect_wk); |
| 1685 |
} |
| 1686 |
|
| 1687 |
static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw, |
| 1688 |
struct ieee80211_vif *vif) |
| 1689 |
{ |
| 1690 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1691 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1692 |
int ret; |
| 1693 |
int i; |
| 1694 |
|
| 1695 |
mutex_lock(&mvm->mutex); |
| 1696 |
|
| 1697 |
iwl_mvm_mac_init_mvmvif(mvm, mvmvif); |
| 1698 |
|
| 1699 |
mvmvif->mvm = mvm; |
| 1700 |
|
| 1701 |
/* the first link always points to the default one */ |
| 1702 |
mvmvif->deflink.fw_link_id = IWL_MVM_FW_LINK_ID_INVALID; |
| 1703 |
mvmvif->deflink.active = 0; |
| 1704 |
mvmvif->link[0] = &mvmvif->deflink; |
| 1705 |
|
| 1706 |
vif->driver_flags = IEEE80211_VIF_REMOVE_AP_AFTER_DISASSOC; |
| 1707 |
|
| 1708 |
iwl_mvm_set_link_fw_id(mvm, vif, &vif->bss_conf); |
| 1709 |
|
| 1710 |
/* |
| 1711 |
* Not much to do here. The stack will not allow interface |
| 1712 |
* types or combinations that we didn't advertise, so we |
| 1713 |
* don't really have to check the types. |
| 1714 |
*/ |
| 1715 |
|
| 1716 |
/* make sure that beacon statistics don't go backwards with FW reset */ |
| 1717 |
if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) |
| 1718 |
for_each_mvm_vif_valid_link(mvmvif, i) |
| 1719 |
mvmvif->link[i]->beacon_stats.accu_num_beacons += |
| 1720 |
mvmvif->link[i]->beacon_stats.num_beacons; |
| 1721 |
|
| 1722 |
/* Allocate resources for the MAC context, and add it to the fw */ |
| 1723 |
ret = iwl_mvm_mac_ctxt_init(mvm, vif); |
| 1724 |
if (ret) |
| 1725 |
goto out; |
| 1726 |
|
| 1727 |
rcu_assign_pointer(mvm->vif_id_to_mac[mvmvif->id], vif); |
| 1728 |
|
| 1729 |
/* |
| 1730 |
* The AP binding flow can be done only after the beacon |
| 1731 |
* template is configured (which happens only in the mac80211 |
| 1732 |
* start_ap() flow), and adding the broadcast station can happen |
| 1733 |
* only after the binding. |
| 1734 |
* In addition, since modifying the MAC before adding a bcast |
| 1735 |
* station is not allowed by the FW, delay the adding of MAC context to |
| 1736 |
* the point where we can also add the bcast station. |
| 1737 |
* In short: there's not much we can do at this point, other than |
| 1738 |
* allocating resources :) |
| 1739 |
*/ |
| 1740 |
if (vif->type == NL80211_IFTYPE_AP || |
| 1741 |
vif->type == NL80211_IFTYPE_ADHOC) { |
| 1742 |
if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) |
| 1743 |
iwl_mvm_vif_dbgfs_add_link(mvm, vif); |
| 1744 |
ret = 0; |
| 1745 |
goto out; |
| 1746 |
} |
| 1747 |
|
| 1748 |
mvmvif->features |= hw->netdev_features; |
| 1749 |
|
| 1750 |
ret = iwl_mvm_mac_ctxt_add(mvm, vif); |
| 1751 |
if (ret) |
| 1752 |
goto out_unlock; |
| 1753 |
|
| 1754 |
ret = iwl_mvm_power_update_mac(mvm); |
| 1755 |
if (ret) |
| 1756 |
goto out_remove_mac; |
| 1757 |
|
| 1758 |
/* beacon filtering */ |
| 1759 |
ret = iwl_mvm_disable_beacon_filter(mvm, vif); |
| 1760 |
if (ret) |
| 1761 |
goto out_remove_mac; |
| 1762 |
|
| 1763 |
if (!mvm->bf_allowed_vif && |
| 1764 |
vif->type == NL80211_IFTYPE_STATION && !vif->p2p) { |
| 1765 |
mvm->bf_allowed_vif = mvmvif; |
| 1766 |
vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER | |
| 1767 |
IEEE80211_VIF_SUPPORTS_CQM_RSSI; |
| 1768 |
} |
| 1769 |
|
| 1770 |
if (vif->type == NL80211_IFTYPE_P2P_DEVICE) |
| 1771 |
mvm->p2p_device_vif = vif; |
| 1772 |
|
| 1773 |
iwl_mvm_tcm_add_vif(mvm, vif); |
| 1774 |
|
| 1775 |
if (vif->type == NL80211_IFTYPE_MONITOR) { |
| 1776 |
mvm->monitor_on = true; |
| 1777 |
mvm->monitor_p80 = |
| 1778 |
iwl_mvm_chandef_get_primary_80(&vif->bss_conf.chanreq.oper); |
| 1779 |
} |
| 1780 |
|
| 1781 |
if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) |
| 1782 |
iwl_mvm_vif_dbgfs_add_link(mvm, vif); |
| 1783 |
|
| 1784 |
if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) && |
| 1785 |
vif->type == NL80211_IFTYPE_STATION && !vif->p2p && |
| 1786 |
!mvm->csme_vif && mvm->mei_registered) { |
| 1787 |
iwl_mei_set_nic_info(vif->addr, mvm->nvm_data->hw_addr); |
| 1788 |
iwl_mei_set_netdev(ieee80211_vif_to_wdev(vif)->netdev); |
| 1789 |
mvm->csme_vif = vif; |
| 1790 |
} |
| 1791 |
|
| 1792 |
out: |
| 1793 |
if (!ret && (vif->type == NL80211_IFTYPE_AP || |
| 1794 |
vif->type == NL80211_IFTYPE_ADHOC)) |
| 1795 |
ret = iwl_mvm_alloc_bcast_mcast_sta(mvm, vif); |
| 1796 |
|
| 1797 |
goto out_unlock; |
| 1798 |
|
| 1799 |
out_remove_mac: |
| 1800 |
mvmvif->deflink.phy_ctxt = NULL; |
| 1801 |
iwl_mvm_mac_ctxt_remove(mvm, vif); |
| 1802 |
out_unlock: |
| 1803 |
mutex_unlock(&mvm->mutex); |
| 1804 |
|
| 1805 |
return ret; |
| 1806 |
} |
| 1807 |
|
| 1808 |
void iwl_mvm_prepare_mac_removal(struct iwl_mvm *mvm, |
| 1809 |
struct ieee80211_vif *vif) |
| 1810 |
{ |
| 1811 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1812 |
|
| 1813 |
if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { |
| 1814 |
/* |
| 1815 |
* Flush the ROC worker which will flush the OFFCHANNEL queue. |
| 1816 |
* We assume here that all the packets sent to the OFFCHANNEL |
| 1817 |
* queue are sent in ROC session. |
| 1818 |
*/ |
| 1819 |
flush_work(&mvm->roc_done_wk); |
| 1820 |
} |
| 1821 |
|
| 1822 |
cancel_delayed_work_sync(&mvmvif->csa_work); |
| 1823 |
} |
| 1824 |
|
| 1825 |
static void iwl_mvm_mac_remove_interface(struct ieee80211_hw *hw, |
| 1826 |
struct ieee80211_vif *vif) |
| 1827 |
{ |
| 1828 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1829 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1830 |
struct iwl_probe_resp_data *probe_data; |
| 1831 |
|
| 1832 |
iwl_mvm_prepare_mac_removal(mvm, vif); |
| 1833 |
|
| 1834 |
if (!(vif->type == NL80211_IFTYPE_AP || |
| 1835 |
vif->type == NL80211_IFTYPE_ADHOC)) |
| 1836 |
iwl_mvm_tcm_rm_vif(mvm, vif); |
| 1837 |
|
| 1838 |
mutex_lock(&mvm->mutex); |
| 1839 |
|
| 1840 |
if (vif == mvm->csme_vif) { |
| 1841 |
iwl_mei_set_netdev(NULL); |
| 1842 |
mvm->csme_vif = NULL; |
| 1843 |
} |
| 1844 |
|
| 1845 |
probe_data = rcu_dereference_protected(mvmvif->deflink.probe_resp_data, |
| 1846 |
lockdep_is_held(&mvm->mutex)); |
| 1847 |
RCU_INIT_POINTER(mvmvif->deflink.probe_resp_data, NULL); |
| 1848 |
if (probe_data) |
| 1849 |
kfree_rcu(probe_data, rcu_head); |
| 1850 |
|
| 1851 |
if (mvm->bf_allowed_vif == mvmvif) { |
| 1852 |
mvm->bf_allowed_vif = NULL; |
| 1853 |
vif->driver_flags &= ~(IEEE80211_VIF_BEACON_FILTER | |
| 1854 |
IEEE80211_VIF_SUPPORTS_CQM_RSSI); |
| 1855 |
} |
| 1856 |
|
| 1857 |
if (vif->bss_conf.ftm_responder) |
| 1858 |
memset(&mvm->ftm_resp_stats, 0, sizeof(mvm->ftm_resp_stats)); |
| 1859 |
|
| 1860 |
iwl_mvm_vif_dbgfs_rm_link(mvm, vif); |
| 1861 |
|
| 1862 |
/* |
| 1863 |
* For AP/GO interface, the tear down of the resources allocated to the |
| 1864 |
* interface is be handled as part of the stop_ap flow. |
| 1865 |
*/ |
| 1866 |
if (vif->type == NL80211_IFTYPE_AP || |
| 1867 |
vif->type == NL80211_IFTYPE_ADHOC) |
| 1868 |
goto out; |
| 1869 |
|
| 1870 |
iwl_mvm_power_update_mac(mvm); |
| 1871 |
|
| 1872 |
/* Before the interface removal, mac80211 would cancel the ROC, and the |
| 1873 |
* ROC worker would be scheduled if needed. The worker would be flushed |
| 1874 |
* in iwl_mvm_prepare_mac_removal() and thus at this point there is no |
| 1875 |
* binding etc. so nothing needs to be done here. |
| 1876 |
*/ |
| 1877 |
if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { |
| 1878 |
if (mvmvif->deflink.phy_ctxt) { |
| 1879 |
iwl_mvm_phy_ctxt_unref(mvm, mvmvif->deflink.phy_ctxt); |
| 1880 |
mvmvif->deflink.phy_ctxt = NULL; |
| 1881 |
} |
| 1882 |
mvm->p2p_device_vif = NULL; |
| 1883 |
} |
| 1884 |
|
| 1885 |
iwl_mvm_mac_ctxt_remove(mvm, vif); |
| 1886 |
|
| 1887 |
RCU_INIT_POINTER(mvm->vif_id_to_mac[mvmvif->id], NULL); |
| 1888 |
|
| 1889 |
if (vif->type == NL80211_IFTYPE_MONITOR) |
| 1890 |
mvm->monitor_on = false; |
| 1891 |
|
| 1892 |
out: |
| 1893 |
if (vif->type == NL80211_IFTYPE_AP || |
| 1894 |
vif->type == NL80211_IFTYPE_ADHOC) { |
| 1895 |
iwl_mvm_dealloc_int_sta(mvm, &mvmvif->deflink.mcast_sta); |
| 1896 |
iwl_mvm_dealloc_bcast_sta(mvm, vif); |
| 1897 |
} |
| 1898 |
|
| 1899 |
mutex_unlock(&mvm->mutex); |
| 1900 |
} |
| 1901 |
|
| 1902 |
struct iwl_mvm_mc_iter_data { |
| 1903 |
struct iwl_mvm *mvm; |
| 1904 |
int port_id; |
| 1905 |
}; |
| 1906 |
|
| 1907 |
static void iwl_mvm_mc_iface_iterator(void *_data, u8 *mac, |
| 1908 |
struct ieee80211_vif *vif) |
| 1909 |
{ |
| 1910 |
struct iwl_mvm_mc_iter_data *data = _data; |
| 1911 |
struct iwl_mvm *mvm = data->mvm; |
| 1912 |
struct iwl_mcast_filter_cmd *cmd = mvm->mcast_filter_cmd; |
| 1913 |
struct iwl_host_cmd hcmd = { |
| 1914 |
.id = MCAST_FILTER_CMD, |
| 1915 |
.flags = CMD_ASYNC, |
| 1916 |
.dataflags[0] = IWL_HCMD_DFL_NOCOPY, |
| 1917 |
}; |
| 1918 |
int ret, len; |
| 1919 |
|
| 1920 |
/* if we don't have free ports, mcast frames will be dropped */ |
| 1921 |
if (WARN_ON_ONCE(data->port_id >= MAX_PORT_ID_NUM)) |
| 1922 |
return; |
| 1923 |
|
| 1924 |
if (vif->type != NL80211_IFTYPE_STATION || |
| 1925 |
!vif->cfg.assoc) |
| 1926 |
return; |
| 1927 |
|
| 1928 |
cmd->port_id = data->port_id++; |
| 1929 |
memcpy(cmd->bssid, vif->bss_conf.bssid, ETH_ALEN); |
| 1930 |
len = roundup(sizeof(*cmd) + cmd->count * ETH_ALEN, 4); |
| 1931 |
|
| 1932 |
hcmd.len[0] = len; |
| 1933 |
hcmd.data[0] = cmd; |
| 1934 |
|
| 1935 |
ret = iwl_mvm_send_cmd(mvm, &hcmd); |
| 1936 |
if (ret) |
| 1937 |
IWL_ERR(mvm, "mcast filter cmd error. ret=%d\n", ret); |
| 1938 |
} |
| 1939 |
|
| 1940 |
static void iwl_mvm_recalc_multicast(struct iwl_mvm *mvm) |
| 1941 |
{ |
| 1942 |
struct iwl_mvm_mc_iter_data iter_data = { |
| 1943 |
.mvm = mvm, |
| 1944 |
}; |
| 1945 |
int ret; |
| 1946 |
|
| 1947 |
lockdep_assert_held(&mvm->mutex); |
| 1948 |
|
| 1949 |
if (WARN_ON_ONCE(!mvm->mcast_filter_cmd)) |
| 1950 |
return; |
| 1951 |
|
| 1952 |
ieee80211_iterate_active_interfaces_atomic( |
| 1953 |
mvm->hw, IEEE80211_IFACE_ITER_NORMAL, |
| 1954 |
iwl_mvm_mc_iface_iterator, &iter_data); |
| 1955 |
|
| 1956 |
/* |
| 1957 |
* Send a (synchronous) ech command so that we wait for the |
| 1958 |
* multiple asynchronous MCAST_FILTER_CMD commands sent by |
| 1959 |
* the interface iterator. Otherwise, we might get here over |
| 1960 |
* and over again (by userspace just sending a lot of these) |
| 1961 |
* and the CPU can send them faster than the firmware can |
| 1962 |
* process them. |
| 1963 |
* Note that the CPU is still faster - but with this we'll |
| 1964 |
* actually send fewer commands overall because the CPU will |
| 1965 |
* not schedule the work in mac80211 as frequently if it's |
| 1966 |
* still running when rescheduled (possibly multiple times). |
| 1967 |
*/ |
| 1968 |
ret = iwl_mvm_send_cmd_pdu(mvm, ECHO_CMD, 0, 0, NULL); |
| 1969 |
if (ret) |
| 1970 |
IWL_ERR(mvm, "Failed to synchronize multicast groups update\n"); |
| 1971 |
} |
| 1972 |
|
| 1973 |
u64 iwl_mvm_prepare_multicast(struct ieee80211_hw *hw, |
| 1974 |
struct netdev_hw_addr_list *mc_list) |
| 1975 |
{ |
| 1976 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1977 |
struct iwl_mcast_filter_cmd *cmd; |
| 1978 |
struct netdev_hw_addr *addr; |
| 1979 |
int addr_count; |
| 1980 |
bool pass_all; |
| 1981 |
int len; |
| 1982 |
|
| 1983 |
addr_count = netdev_hw_addr_list_count(mc_list); |
| 1984 |
pass_all = addr_count > MAX_MCAST_FILTERING_ADDRESSES || |
| 1985 |
IWL_MVM_FW_MCAST_FILTER_PASS_ALL; |
| 1986 |
if (pass_all) |
| 1987 |
addr_count = 0; |
| 1988 |
|
| 1989 |
len = roundup(sizeof(*cmd) + addr_count * ETH_ALEN, 4); |
| 1990 |
cmd = kzalloc(len, GFP_ATOMIC); |
| 1991 |
if (!cmd) |
| 1992 |
return 0; |
| 1993 |
|
| 1994 |
if (pass_all) { |
| 1995 |
cmd->pass_all = 1; |
| 1996 |
return (u64)(unsigned long)cmd; |
| 1997 |
} |
| 1998 |
|
| 1999 |
netdev_hw_addr_list_for_each(addr, mc_list) { |
| 2000 |
IWL_DEBUG_MAC80211(mvm, "mcast addr (%d): %pM\n", |
| 2001 |
cmd->count, addr->addr); |
| 2002 |
memcpy(&cmd->addr_list[cmd->count * ETH_ALEN], |
| 2003 |
addr->addr, ETH_ALEN); |
| 2004 |
cmd->count++; |
| 2005 |
} |
| 2006 |
|
| 2007 |
return (u64)(unsigned long)cmd; |
| 2008 |
} |
| 2009 |
|
| 2010 |
void iwl_mvm_configure_filter(struct ieee80211_hw *hw, |
| 2011 |
unsigned int changed_flags, |
| 2012 |
unsigned int *total_flags, u64 multicast) |
| 2013 |
{ |
| 2014 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 2015 |
struct iwl_mcast_filter_cmd *cmd = (void *)(unsigned long)multicast; |
| 2016 |
|
| 2017 |
guard(mvm)(mvm); |
| 2018 |
|
| 2019 |
/* replace previous configuration */ |
| 2020 |
kfree(mvm->mcast_filter_cmd); |
| 2021 |
mvm->mcast_filter_cmd = cmd; |
| 2022 |
|
| 2023 |
if (!cmd) |
| 2024 |
goto out; |
| 2025 |
|
| 2026 |
if (changed_flags & FIF_ALLMULTI) |
| 2027 |
cmd->pass_all = !!(*total_flags & FIF_ALLMULTI); |
| 2028 |
|
| 2029 |
if (cmd->pass_all) |
| 2030 |
cmd->count = 0; |
| 2031 |
|
| 2032 |
iwl_mvm_recalc_multicast(mvm); |
| 2033 |
out: |
| 2034 |
*total_flags = 0; |
| 2035 |
} |
| 2036 |
|
| 2037 |
static void iwl_mvm_config_iface_filter(struct ieee80211_hw *hw, |
| 2038 |
struct ieee80211_vif *vif, |
| 2039 |
unsigned int filter_flags, |
| 2040 |
unsigned int changed_flags) |
| 2041 |
{ |
| 2042 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 2043 |
|
| 2044 |
/* We support only filter for probe requests */ |
| 2045 |
if (!(changed_flags & FIF_PROBE_REQ)) |
| 2046 |
return; |
| 2047 |
|
| 2048 |
/* Supported only for p2p client interfaces */ |
| 2049 |
if (vif->type != NL80211_IFTYPE_STATION || !vif->cfg.assoc || |
| 2050 |
!vif->p2p) |
| 2051 |
return; |
| 2052 |
|
| 2053 |
guard(mvm)(mvm); |
| 2054 |
iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL); |
| 2055 |
} |
| 2056 |
|
| 2057 |
int iwl_mvm_update_mu_groups(struct iwl_mvm *mvm, struct ieee80211_vif *vif) |
| 2058 |
{ |
| 2059 |
struct iwl_mu_group_mgmt_cmd cmd = {}; |
| 2060 |
|
| 2061 |
memcpy(cmd.membership_status, vif->bss_conf.mu_group.membership, |
| 2062 |
WLAN_MEMBERSHIP_LEN); |
| 2063 |
memcpy(cmd.user_position, vif->bss_conf.mu_group.position, |
| 2064 |
WLAN_USER_POSITION_LEN); |
| 2065 |
|
| 2066 |
return iwl_mvm_send_cmd_pdu(mvm, |
| 2067 |
WIDE_ID(DATA_PATH_GROUP, |
| 2068 |
UPDATE_MU_GROUPS_CMD), |
| 2069 |
0, sizeof(cmd), &cmd); |
| 2070 |
} |
| 2071 |
|
| 2072 |
static void iwl_mvm_mu_mimo_iface_iterator(void *_data, u8 *mac, |
| 2073 |
struct ieee80211_vif *vif) |
| 2074 |
{ |
| 2075 |
if (vif->bss_conf.mu_mimo_owner) { |
| 2076 |
struct iwl_mu_group_mgmt_notif *notif = _data; |
| 2077 |
|
| 2078 |
/* |
| 2079 |
* MU-MIMO Group Id action frame is little endian. We treat |
| 2080 |
* the data received from firmware as if it came from the |
| 2081 |
* action frame, so no conversion is needed. |
| 2082 |
*/ |
| 2083 |
ieee80211_update_mu_groups(vif, 0, |
| 2084 |
(u8 *)¬if->membership_status, |
| 2085 |
(u8 *)¬if->user_position); |
| 2086 |
} |
| 2087 |
} |
| 2088 |
|
| 2089 |
void iwl_mvm_mu_mimo_grp_notif(struct iwl_mvm *mvm, |
| 2090 |
struct iwl_rx_cmd_buffer *rxb) |
| 2091 |
{ |
| 2092 |
struct iwl_rx_packet *pkt = rxb_addr(rxb); |
| 2093 |
struct iwl_mu_group_mgmt_notif *notif = (void *)pkt->data; |
| 2094 |
|
| 2095 |
ieee80211_iterate_active_interfaces_atomic( |
| 2096 |
mvm->hw, IEEE80211_IFACE_ITER_NORMAL, |
| 2097 |
iwl_mvm_mu_mimo_iface_iterator, notif); |
| 2098 |
} |
| 2099 |
|
| 2100 |
static u8 iwl_mvm_he_get_ppe_val(u8 *ppe, u8 ppe_pos_bit) |
| 2101 |
{ |
| 2102 |
u8 byte_num = ppe_pos_bit / 8; |
| 2103 |
u8 bit_num = ppe_pos_bit % 8; |
| 2104 |
u8 residue_bits; |
| 2105 |
u8 res; |
| 2106 |
|
| 2107 |
if (bit_num <= 5) |
| 2108 |
return (ppe[byte_num] >> bit_num) & |
| 2109 |
(BIT(IEEE80211_PPE_THRES_INFO_PPET_SIZE) - 1); |
| 2110 |
|
| 2111 |
/* |
| 2112 |
* If bit_num > 5, we have to combine bits with next byte. |
| 2113 |
* Calculate how many bits we need to take from current byte (called |
| 2114 |
* here "residue_bits"), and add them to bits from next byte. |
| 2115 |
*/ |
| 2116 |
|
| 2117 |
residue_bits = 8 - bit_num; |
| 2118 |
|
| 2119 |
res = (ppe[byte_num + 1] & |
| 2120 |
(BIT(IEEE80211_PPE_THRES_INFO_PPET_SIZE - residue_bits) - 1)) << |
| 2121 |
residue_bits; |
| 2122 |
res += (ppe[byte_num] >> bit_num) & (BIT(residue_bits) - 1); |
| 2123 |
|
| 2124 |
return res; |
| 2125 |
} |
| 2126 |
|
| 2127 |
static void iwl_mvm_parse_ppe(struct iwl_mvm *mvm, |
| 2128 |
struct iwl_he_pkt_ext_v2 *pkt_ext, u8 nss, |
| 2129 |
u8 ru_index_bitmap, u8 *ppe, u8 ppe_pos_bit, |
| 2130 |
bool inheritance) |
| 2131 |
{ |
| 2132 |
int i; |
| 2133 |
|
| 2134 |
/* |
| 2135 |
* FW currently supports only nss == MAX_HE_SUPP_NSS |
| 2136 |
* |
| 2137 |
* If nss > MAX: we can ignore values we don't support |
| 2138 |
* If nss < MAX: we can set zeros in other streams |
| 2139 |
*/ |
| 2140 |
if (nss > MAX_HE_SUPP_NSS) { |
| 2141 |
IWL_DEBUG_INFO(mvm, "Got NSS = %d - trimming to %d\n", nss, |
| 2142 |
MAX_HE_SUPP_NSS); |
| 2143 |
nss = MAX_HE_SUPP_NSS; |
| 2144 |
} |
| 2145 |
|
| 2146 |
for (i = 0; i < nss; i++) { |
| 2147 |
u8 ru_index_tmp = ru_index_bitmap << 1; |
| 2148 |
u8 low_th = IWL_HE_PKT_EXT_NONE, high_th = IWL_HE_PKT_EXT_NONE; |
| 2149 |
u8 bw; |
| 2150 |
|
| 2151 |
for (bw = 0; |
| 2152 |
bw < ARRAY_SIZE(pkt_ext->pkt_ext_qam_th[i]); |
| 2153 |
bw++) { |
| 2154 |
ru_index_tmp >>= 1; |
| 2155 |
|
| 2156 |
/* |
| 2157 |
* According to the 11be spec, if for a specific BW the PPE Thresholds |
| 2158 |
* isn't present - it should inherit the thresholds from the last |
| 2159 |
* BW for which we had PPE Thresholds. In 11ax though, we don't have |
| 2160 |
* this inheritance - continue in this case |
| 2161 |
*/ |
| 2162 |
if (!(ru_index_tmp & 1)) { |
| 2163 |
if (inheritance) |
| 2164 |
goto set_thresholds; |
| 2165 |
else |
| 2166 |
continue; |
| 2167 |
} |
| 2168 |
|
| 2169 |
high_th = iwl_mvm_he_get_ppe_val(ppe, ppe_pos_bit); |
| 2170 |
ppe_pos_bit += IEEE80211_PPE_THRES_INFO_PPET_SIZE; |
| 2171 |
low_th = iwl_mvm_he_get_ppe_val(ppe, ppe_pos_bit); |
| 2172 |
ppe_pos_bit += IEEE80211_PPE_THRES_INFO_PPET_SIZE; |
| 2173 |
|
| 2174 |
set_thresholds: |
| 2175 |
pkt_ext->pkt_ext_qam_th[i][bw][0] = low_th; |
| 2176 |
pkt_ext->pkt_ext_qam_th[i][bw][1] = high_th; |
| 2177 |
} |
| 2178 |
} |
| 2179 |
} |
| 2180 |
|
| 2181 |
static void iwl_mvm_set_pkt_ext_from_he_ppe(struct iwl_mvm *mvm, |
| 2182 |
struct ieee80211_link_sta *link_sta, |
| 2183 |
struct iwl_he_pkt_ext_v2 *pkt_ext, |
| 2184 |
bool inheritance) |
| 2185 |
{ |
| 2186 |
u8 nss = (link_sta->he_cap.ppe_thres[0] & |
| 2187 |
IEEE80211_PPE_THRES_NSS_MASK) + 1; |
| 2188 |
u8 *ppe = &link_sta->he_cap.ppe_thres[0]; |
| 2189 |
u8 ru_index_bitmap = |
| 2190 |
u8_get_bits(*ppe, |
| 2191 |
IEEE80211_PPE_THRES_RU_INDEX_BITMASK_MASK); |
| 2192 |
/* Starting after PPE header */ |
| 2193 |
u8 ppe_pos_bit = IEEE80211_HE_PPE_THRES_INFO_HEADER_SIZE; |
| 2194 |
|
| 2195 |
iwl_mvm_parse_ppe(mvm, pkt_ext, nss, ru_index_bitmap, ppe, ppe_pos_bit, |
| 2196 |
inheritance); |
| 2197 |
} |
| 2198 |
|
| 2199 |
static int |
| 2200 |
iwl_mvm_set_pkt_ext_from_nominal_padding(struct iwl_he_pkt_ext_v2 *pkt_ext, |
| 2201 |
u8 nominal_padding) |
| 2202 |
{ |
| 2203 |
int low_th = -1; |
| 2204 |
int high_th = -1; |
| 2205 |
int i; |
| 2206 |
|
| 2207 |
/* all the macros are the same for EHT and HE */ |
| 2208 |
switch (nominal_padding) { |
| 2209 |
case IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_0US: |
| 2210 |
low_th = IWL_HE_PKT_EXT_NONE; |
| 2211 |
high_th = IWL_HE_PKT_EXT_NONE; |
| 2212 |
break; |
| 2213 |
case IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_8US: |
| 2214 |
low_th = IWL_HE_PKT_EXT_BPSK; |
| 2215 |
high_th = IWL_HE_PKT_EXT_NONE; |
| 2216 |
break; |
| 2217 |
case IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_16US: |
| 2218 |
case IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_20US: |
| 2219 |
low_th = IWL_HE_PKT_EXT_NONE; |
| 2220 |
high_th = IWL_HE_PKT_EXT_BPSK; |
| 2221 |
break; |
| 2222 |
} |
| 2223 |
|
| 2224 |
if (low_th < 0 || high_th < 0) |
| 2225 |
return -EINVAL; |
| 2226 |
|
| 2227 |
/* Set the PPE thresholds accordingly */ |
| 2228 |
for (i = 0; i < MAX_HE_SUPP_NSS; i++) { |
| 2229 |
u8 bw; |
| 2230 |
|
| 2231 |
for (bw = 0; |
| 2232 |
bw < ARRAY_SIZE(pkt_ext->pkt_ext_qam_th[i]); |
| 2233 |
bw++) { |
| 2234 |
pkt_ext->pkt_ext_qam_th[i][bw][0] = low_th; |
| 2235 |
pkt_ext->pkt_ext_qam_th[i][bw][1] = high_th; |
| 2236 |
} |
| 2237 |
} |
| 2238 |
|
| 2239 |
return 0; |
| 2240 |
} |
| 2241 |
|
| 2242 |
static void iwl_mvm_get_optimal_ppe_info(struct iwl_he_pkt_ext_v2 *pkt_ext, |
| 2243 |
u8 nominal_padding) |
| 2244 |
{ |
| 2245 |
int i; |
| 2246 |
|
| 2247 |
for (i = 0; i < MAX_HE_SUPP_NSS; i++) { |
| 2248 |
u8 bw; |
| 2249 |
|
| 2250 |
for (bw = 0; bw < ARRAY_SIZE(pkt_ext->pkt_ext_qam_th[i]); |
| 2251 |
bw++) { |
| 2252 |
u8 *qam_th = &pkt_ext->pkt_ext_qam_th[i][bw][0]; |
| 2253 |
|
| 2254 |
if (nominal_padding > |
| 2255 |
IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_8US && |
| 2256 |
qam_th[1] == IWL_HE_PKT_EXT_NONE) |
| 2257 |
qam_th[1] = IWL_HE_PKT_EXT_4096QAM; |
| 2258 |
else if (nominal_padding == |
| 2259 |
IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_8US && |
| 2260 |
qam_th[0] == IWL_HE_PKT_EXT_NONE && |
| 2261 |
qam_th[1] == IWL_HE_PKT_EXT_NONE) |
| 2262 |
qam_th[0] = IWL_HE_PKT_EXT_4096QAM; |
| 2263 |
} |
| 2264 |
} |
| 2265 |
} |
| 2266 |
|
| 2267 |
/* Set the pkt_ext field according to PPE Thresholds element */ |
| 2268 |
int iwl_mvm_set_sta_pkt_ext(struct iwl_mvm *mvm, |
| 2269 |
struct ieee80211_link_sta *link_sta, |
| 2270 |
struct iwl_he_pkt_ext_v2 *pkt_ext) |
| 2271 |
{ |
| 2272 |
u8 nominal_padding; |
| 2273 |
int i, ret = 0; |
| 2274 |
|
| 2275 |
if (WARN_ON(!link_sta)) |
| 2276 |
return -EINVAL; |
| 2277 |
|
| 2278 |
/* Initialize the PPE thresholds to "None" (7), as described in Table |
| 2279 |
* 9-262ac of 80211.ax/D3.0. |
| 2280 |
*/ |
| 2281 |
memset(pkt_ext, IWL_HE_PKT_EXT_NONE, |
| 2282 |
sizeof(struct iwl_he_pkt_ext_v2)); |
| 2283 |
|
| 2284 |
if (link_sta->eht_cap.has_eht) { |
| 2285 |
nominal_padding = |
| 2286 |
u8_get_bits(link_sta->eht_cap.eht_cap_elem.phy_cap_info[5], |
| 2287 |
IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_MASK); |
| 2288 |
|
| 2289 |
/* If PPE Thresholds exists, parse them into a FW-familiar |
| 2290 |
* format. |
| 2291 |
*/ |
| 2292 |
if (link_sta->eht_cap.eht_cap_elem.phy_cap_info[5] & |
| 2293 |
IEEE80211_EHT_PHY_CAP5_PPE_THRESHOLD_PRESENT) { |
| 2294 |
u8 nss = (link_sta->eht_cap.eht_ppe_thres[0] & |
| 2295 |
IEEE80211_EHT_PPE_THRES_NSS_MASK) + 1; |
| 2296 |
u8 *ppe = &link_sta->eht_cap.eht_ppe_thres[0]; |
| 2297 |
u8 ru_index_bitmap = |
| 2298 |
u16_get_bits(*ppe, |
| 2299 |
IEEE80211_EHT_PPE_THRES_RU_INDEX_BITMASK_MASK); |
| 2300 |
/* Starting after PPE header */ |
| 2301 |
u8 ppe_pos_bit = IEEE80211_EHT_PPE_THRES_INFO_HEADER_SIZE; |
| 2302 |
|
| 2303 |
iwl_mvm_parse_ppe(mvm, pkt_ext, nss, ru_index_bitmap, |
| 2304 |
ppe, ppe_pos_bit, true); |
| 2305 |
/* EHT PPE Thresholds doesn't exist - set the API according to |
| 2306 |
* HE PPE Tresholds |
| 2307 |
*/ |
| 2308 |
} else if (link_sta->he_cap.he_cap_elem.phy_cap_info[6] & |
| 2309 |
IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT) { |
| 2310 |
/* Even though HE Capabilities IE doesn't contain PPE |
| 2311 |
* Thresholds for BW 320Mhz, thresholds for this BW will |
| 2312 |
* be filled in with the same values as 160Mhz, due to |
| 2313 |
* the inheritance, as required. |
| 2314 |
*/ |
| 2315 |
iwl_mvm_set_pkt_ext_from_he_ppe(mvm, link_sta, pkt_ext, |
| 2316 |
true); |
| 2317 |
|
| 2318 |
/* According to the requirements, for MCSs 12-13 the |
| 2319 |
* maximum value between HE PPE Threshold and Common |
| 2320 |
* Nominal Packet Padding needs to be taken |
| 2321 |
*/ |
| 2322 |
iwl_mvm_get_optimal_ppe_info(pkt_ext, nominal_padding); |
| 2323 |
|
| 2324 |
/* if PPE Thresholds doesn't present in both EHT IE and HE IE - |
| 2325 |
* take the Thresholds from Common Nominal Packet Padding field |
| 2326 |
*/ |
| 2327 |
} else { |
| 2328 |
ret = iwl_mvm_set_pkt_ext_from_nominal_padding(pkt_ext, |
| 2329 |
nominal_padding); |
| 2330 |
} |
| 2331 |
} else if (link_sta->he_cap.has_he) { |
| 2332 |
/* If PPE Thresholds exist, parse them into a FW-familiar format. */ |
| 2333 |
if (link_sta->he_cap.he_cap_elem.phy_cap_info[6] & |
| 2334 |
IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT) { |
| 2335 |
iwl_mvm_set_pkt_ext_from_he_ppe(mvm, link_sta, pkt_ext, |
| 2336 |
false); |
| 2337 |
/* PPE Thresholds doesn't exist - set the API PPE values |
| 2338 |
* according to Common Nominal Packet Padding field. |
| 2339 |
*/ |
| 2340 |
} else { |
| 2341 |
nominal_padding = |
| 2342 |
u8_get_bits(link_sta->he_cap.he_cap_elem.phy_cap_info[9], |
| 2343 |
IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_MASK); |
| 2344 |
if (nominal_padding != IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_RESERVED) |
| 2345 |
ret = iwl_mvm_set_pkt_ext_from_nominal_padding(pkt_ext, |
| 2346 |
nominal_padding); |
| 2347 |
} |
| 2348 |
} |
| 2349 |
|
| 2350 |
for (i = 0; i < MAX_HE_SUPP_NSS; i++) { |
| 2351 |
int bw; |
| 2352 |
|
| 2353 |
for (bw = 0; |
| 2354 |
bw < ARRAY_SIZE(*pkt_ext->pkt_ext_qam_th[i]); |
| 2355 |
bw++) { |
| 2356 |
u8 *qam_th = |
| 2357 |
&pkt_ext->pkt_ext_qam_th[i][bw][0]; |
| 2358 |
|
| 2359 |
IWL_DEBUG_HT(mvm, |
| 2360 |
"PPE table: nss[%d] bw[%d] PPET8 = %d, PPET16 = %d\n", |
| 2361 |
i, bw, qam_th[0], qam_th[1]); |
| 2362 |
} |
| 2363 |
} |
| 2364 |
return ret; |
| 2365 |
} |
| 2366 |
|
| 2367 |
/* |
| 2368 |
* This function sets the MU EDCA parameters ans returns whether MU EDCA |
| 2369 |
* is enabled or not |
| 2370 |
*/ |
| 2371 |
bool iwl_mvm_set_fw_mu_edca_params(struct iwl_mvm *mvm, |
| 2372 |
const struct iwl_mvm_vif_link_info *link_info, |
| 2373 |
struct iwl_he_backoff_conf *trig_based_txf) |
| 2374 |
{ |
| 2375 |
int i; |
| 2376 |
/* Mark MU EDCA as enabled, unless none detected on some AC */ |
| 2377 |
bool mu_edca_enabled = true; |
| 2378 |
|
| 2379 |
for (i = 0; i < IEEE80211_NUM_ACS; i++) { |
| 2380 |
const struct ieee80211_he_mu_edca_param_ac_rec *mu_edca = |
| 2381 |
&link_info->queue_params[i].mu_edca_param_rec; |
| 2382 |
u8 ac = iwl_mvm_mac80211_ac_to_ucode_ac(i); |
| 2383 |
|
| 2384 |
if (!link_info->queue_params[i].mu_edca) { |
| 2385 |
mu_edca_enabled = false; |
| 2386 |
break; |
| 2387 |
} |
| 2388 |
|
| 2389 |
trig_based_txf[ac].cwmin = |
| 2390 |
cpu_to_le16(mu_edca->ecw_min_max & 0xf); |
| 2391 |
trig_based_txf[ac].cwmax = |
| 2392 |
cpu_to_le16((mu_edca->ecw_min_max & 0xf0) >> 4); |
| 2393 |
trig_based_txf[ac].aifsn = |
| 2394 |
cpu_to_le16(mu_edca->aifsn & 0xf); |
| 2395 |
trig_based_txf[ac].mu_time = |
| 2396 |
cpu_to_le16(mu_edca->mu_edca_timer); |
| 2397 |
} |
| 2398 |
|
| 2399 |
return mu_edca_enabled; |
| 2400 |
} |
| 2401 |
|
| 2402 |
bool iwl_mvm_is_nic_ack_enabled(struct iwl_mvm *mvm, struct ieee80211_vif *vif) |
| 2403 |
{ |
| 2404 |
const struct ieee80211_supported_band *sband; |
| 2405 |
const struct ieee80211_sta_he_cap *own_he_cap = NULL; |
| 2406 |
|
| 2407 |
/* This capability is the same for all bands, |
| 2408 |
* so take it from one of them. |
| 2409 |
*/ |
| 2410 |
sband = mvm->hw->wiphy->bands[NL80211_BAND_2GHZ]; |
| 2411 |
own_he_cap = ieee80211_get_he_iftype_cap_vif(sband, vif); |
| 2412 |
|
| 2413 |
return (own_he_cap && (own_he_cap->he_cap_elem.mac_cap_info[2] & |
| 2414 |
IEEE80211_HE_MAC_CAP2_ACK_EN)); |
| 2415 |
} |
| 2416 |
|
| 2417 |
__le32 iwl_mvm_get_sta_htc_flags(struct ieee80211_sta *sta, |
| 2418 |
struct ieee80211_link_sta *link_sta) |
| 2419 |
{ |
| 2420 |
u8 *mac_cap_info = |
| 2421 |
&link_sta->he_cap.he_cap_elem.mac_cap_info[0]; |
| 2422 |
__le32 htc_flags = 0; |
| 2423 |
|
| 2424 |
if (mac_cap_info[0] & IEEE80211_HE_MAC_CAP0_HTC_HE) |
| 2425 |
htc_flags |= cpu_to_le32(IWL_HE_HTC_SUPPORT); |
| 2426 |
if ((mac_cap_info[1] & IEEE80211_HE_MAC_CAP1_LINK_ADAPTATION) || |
| 2427 |
(mac_cap_info[2] & IEEE80211_HE_MAC_CAP2_LINK_ADAPTATION)) { |
| 2428 |
u8 link_adap = |
| 2429 |
((mac_cap_info[2] & |
| 2430 |
IEEE80211_HE_MAC_CAP2_LINK_ADAPTATION) << 1) + |
| 2431 |
(mac_cap_info[1] & |
| 2432 |
IEEE80211_HE_MAC_CAP1_LINK_ADAPTATION); |
| 2433 |
|
| 2434 |
if (link_adap == 2) |
| 2435 |
htc_flags |= |
| 2436 |
cpu_to_le32(IWL_HE_HTC_LINK_ADAP_UNSOLICITED); |
| 2437 |
else if (link_adap == 3) |
| 2438 |
htc_flags |= cpu_to_le32(IWL_HE_HTC_LINK_ADAP_BOTH); |
| 2439 |
} |
| 2440 |
if (mac_cap_info[2] & IEEE80211_HE_MAC_CAP2_BSR) |
| 2441 |
htc_flags |= cpu_to_le32(IWL_HE_HTC_BSR_SUPP); |
| 2442 |
if (mac_cap_info[3] & IEEE80211_HE_MAC_CAP3_OMI_CONTROL) |
| 2443 |
htc_flags |= cpu_to_le32(IWL_HE_HTC_OMI_SUPP); |
| 2444 |
if (mac_cap_info[4] & IEEE80211_HE_MAC_CAP4_BQR) |
| 2445 |
htc_flags |= cpu_to_le32(IWL_HE_HTC_BQR_SUPP); |
| 2446 |
|
| 2447 |
return htc_flags; |
| 2448 |
} |
| 2449 |
|
| 2450 |
static void iwl_mvm_cfg_he_sta(struct iwl_mvm *mvm, |
| 2451 |
struct ieee80211_vif *vif, u8 sta_id) |
| 2452 |
{ |
| 2453 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 2454 |
struct iwl_he_sta_context_cmd_v3 sta_ctxt_cmd = { |
| 2455 |
.sta_id = sta_id, |
| 2456 |
.tid_limit = IWL_MAX_TID_COUNT, |
| 2457 |
.bss_color = vif->bss_conf.he_bss_color.color, |
| 2458 |
.htc_trig_based_pkt_ext = vif->bss_conf.htc_trig_based_pkt_ext, |
| 2459 |
.frame_time_rts_th = |
| 2460 |
cpu_to_le16(vif->bss_conf.frame_time_rts_th), |
| 2461 |
}; |
| 2462 |
struct iwl_he_sta_context_cmd_v2 sta_ctxt_cmd_v2 = {}; |
| 2463 |
u32 cmd_id = WIDE_ID(DATA_PATH_GROUP, STA_HE_CTXT_CMD); |
| 2464 |
u8 ver = iwl_fw_lookup_cmd_ver(mvm->fw, cmd_id, 2); |
| 2465 |
int size; |
| 2466 |
struct ieee80211_sta *sta; |
| 2467 |
u32 flags; |
| 2468 |
int i; |
| 2469 |
void *cmd; |
| 2470 |
|
| 2471 |
if (!fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_MBSSID_HE)) |
| 2472 |
ver = 1; |
| 2473 |
|
| 2474 |
switch (ver) { |
| 2475 |
case 1: |
| 2476 |
/* same layout as v2 except some data at the end */ |
| 2477 |
cmd = &sta_ctxt_cmd_v2; |
| 2478 |
size = sizeof(struct iwl_he_sta_context_cmd_v1); |
| 2479 |
break; |
| 2480 |
case 2: |
| 2481 |
cmd = &sta_ctxt_cmd_v2; |
| 2482 |
size = sizeof(struct iwl_he_sta_context_cmd_v2); |
| 2483 |
break; |
| 2484 |
case 3: |
| 2485 |
cmd = &sta_ctxt_cmd; |
| 2486 |
size = sizeof(struct iwl_he_sta_context_cmd_v3); |
| 2487 |
break; |
| 2488 |
default: |
| 2489 |
IWL_ERR(mvm, "bad STA_HE_CTXT_CMD version %d\n", ver); |
| 2490 |
return; |
| 2491 |
} |
| 2492 |
|
| 2493 |
rcu_read_lock(); |
| 2494 |
|
| 2495 |
sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_ctxt_cmd.sta_id]); |
| 2496 |
if (IS_ERR_OR_NULL(sta)) { |
| 2497 |
rcu_read_unlock(); |
| 2498 |
WARN(1, "Can't find STA to configure HE\n"); |
| 2499 |
return; |
| 2500 |
} |
| 2501 |
|
| 2502 |
if (!sta->deflink.he_cap.has_he) { |
| 2503 |
rcu_read_unlock(); |
| 2504 |
return; |
| 2505 |
} |
| 2506 |
|
| 2507 |
flags = 0; |
| 2508 |
|
| 2509 |
/* Block 26-tone RU OFDMA transmissions */ |
| 2510 |
if (mvmvif->deflink.he_ru_2mhz_block) |
| 2511 |
flags |= STA_CTXT_HE_RU_2MHZ_BLOCK; |
| 2512 |
|
| 2513 |
/* HTC flags */ |
| 2514 |
sta_ctxt_cmd.htc_flags = iwl_mvm_get_sta_htc_flags(sta, &sta->deflink); |
| 2515 |
|
| 2516 |
/* PPE Thresholds */ |
| 2517 |
if (!iwl_mvm_set_sta_pkt_ext(mvm, &sta->deflink, &sta_ctxt_cmd.pkt_ext)) |
| 2518 |
flags |= STA_CTXT_HE_PACKET_EXT; |
| 2519 |
|
| 2520 |
if (sta->deflink.he_cap.he_cap_elem.mac_cap_info[2] & |
| 2521 |
IEEE80211_HE_MAC_CAP2_32BIT_BA_BITMAP) |
| 2522 |
flags |= STA_CTXT_HE_32BIT_BA_BITMAP; |
| 2523 |
|
| 2524 |
if (sta->deflink.he_cap.he_cap_elem.mac_cap_info[2] & |
| 2525 |
IEEE80211_HE_MAC_CAP2_ACK_EN) |
| 2526 |
flags |= STA_CTXT_HE_ACK_ENABLED; |
| 2527 |
|
| 2528 |
rcu_read_unlock(); |
| 2529 |
|
| 2530 |
if (iwl_mvm_set_fw_mu_edca_params(mvm, &mvmvif->deflink, |
| 2531 |
&sta_ctxt_cmd.trig_based_txf[0])) |
| 2532 |
flags |= STA_CTXT_HE_MU_EDCA_CW; |
| 2533 |
|
| 2534 |
if (vif->bss_conf.uora_exists) { |
| 2535 |
flags |= STA_CTXT_HE_TRIG_RND_ALLOC; |
| 2536 |
|
| 2537 |
sta_ctxt_cmd.rand_alloc_ecwmin = |
| 2538 |
vif->bss_conf.uora_ocw_range & 0x7; |
| 2539 |
sta_ctxt_cmd.rand_alloc_ecwmax = |
| 2540 |
(vif->bss_conf.uora_ocw_range >> 3) & 0x7; |
| 2541 |
} |
| 2542 |
|
| 2543 |
if (!iwl_mvm_is_nic_ack_enabled(mvm, vif)) |
| 2544 |
flags |= STA_CTXT_HE_NIC_NOT_ACK_ENABLED; |
| 2545 |
|
| 2546 |
if (vif->bss_conf.nontransmitted) { |
| 2547 |
flags |= STA_CTXT_HE_REF_BSSID_VALID; |
| 2548 |
ether_addr_copy(sta_ctxt_cmd.ref_bssid_addr, |
| 2549 |
vif->bss_conf.transmitter_bssid); |
| 2550 |
sta_ctxt_cmd.max_bssid_indicator = |
| 2551 |
vif->bss_conf.bssid_indicator; |
| 2552 |
sta_ctxt_cmd.bssid_index = vif->bss_conf.bssid_index; |
| 2553 |
sta_ctxt_cmd.ema_ap = vif->bss_conf.ema_ap; |
| 2554 |
sta_ctxt_cmd.profile_periodicity = |
| 2555 |
vif->bss_conf.profile_periodicity; |
| 2556 |
} |
| 2557 |
|
| 2558 |
sta_ctxt_cmd.flags = cpu_to_le32(flags); |
| 2559 |
|
| 2560 |
if (ver < 3) { |
| 2561 |
/* fields before pkt_ext */ |
| 2562 |
BUILD_BUG_ON(offsetof(typeof(sta_ctxt_cmd), pkt_ext) != |
| 2563 |
offsetof(typeof(sta_ctxt_cmd_v2), pkt_ext)); |
| 2564 |
memcpy(&sta_ctxt_cmd_v2, &sta_ctxt_cmd, |
| 2565 |
offsetof(typeof(sta_ctxt_cmd), pkt_ext)); |
| 2566 |
|
| 2567 |
/* pkt_ext */ |
| 2568 |
for (i = 0; |
| 2569 |
i < ARRAY_SIZE(sta_ctxt_cmd_v2.pkt_ext.pkt_ext_qam_th); |
| 2570 |
i++) { |
| 2571 |
u8 bw; |
| 2572 |
|
| 2573 |
for (bw = 0; |
| 2574 |
bw < ARRAY_SIZE(sta_ctxt_cmd_v2.pkt_ext.pkt_ext_qam_th[i]); |
| 2575 |
bw++) { |
| 2576 |
BUILD_BUG_ON(sizeof(sta_ctxt_cmd.pkt_ext.pkt_ext_qam_th[i][bw]) != |
| 2577 |
sizeof(sta_ctxt_cmd_v2.pkt_ext.pkt_ext_qam_th[i][bw])); |
| 2578 |
|
| 2579 |
memcpy(&sta_ctxt_cmd_v2.pkt_ext.pkt_ext_qam_th[i][bw], |
| 2580 |
&sta_ctxt_cmd.pkt_ext.pkt_ext_qam_th[i][bw], |
| 2581 |
sizeof(sta_ctxt_cmd.pkt_ext.pkt_ext_qam_th[i][bw])); |
| 2582 |
} |
| 2583 |
} |
| 2584 |
|
| 2585 |
/* fields after pkt_ext */ |
| 2586 |
BUILD_BUG_ON(sizeof(sta_ctxt_cmd) - |
| 2587 |
offsetofend(typeof(sta_ctxt_cmd), pkt_ext) != |
| 2588 |
sizeof(sta_ctxt_cmd_v2) - |
| 2589 |
offsetofend(typeof(sta_ctxt_cmd_v2), pkt_ext)); |
| 2590 |
memcpy((u8 *)&sta_ctxt_cmd_v2 + |
| 2591 |
offsetofend(typeof(sta_ctxt_cmd_v2), pkt_ext), |
| 2592 |
(u8 *)&sta_ctxt_cmd + |
| 2593 |
offsetofend(typeof(sta_ctxt_cmd), pkt_ext), |
| 2594 |
sizeof(sta_ctxt_cmd) - |
| 2595 |
offsetofend(typeof(sta_ctxt_cmd), pkt_ext)); |
| 2596 |
sta_ctxt_cmd_v2.reserved3 = 0; |
| 2597 |
} |
| 2598 |
|
| 2599 |
if (iwl_mvm_send_cmd_pdu(mvm, cmd_id, 0, size, cmd)) |
| 2600 |
IWL_ERR(mvm, "Failed to config FW to work HE!\n"); |
| 2601 |
} |
| 2602 |
|
| 2603 |
void iwl_mvm_protect_assoc(struct iwl_mvm *mvm, struct ieee80211_vif *vif, |
| 2604 |
u32 duration_override) |
| 2605 |
{ |
| 2606 |
u32 duration = IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS; |
| 2607 |
u32 min_duration = IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS; |
| 2608 |
|
| 2609 |
if (duration_override > duration) |
| 2610 |
duration = duration_override; |
| 2611 |
|
| 2612 |
/* Try really hard to protect the session and hear a beacon |
| 2613 |
* The new session protection command allows us to protect the |
| 2614 |
* session for a much longer time since the firmware will internally |
| 2615 |
* create two events: a 300TU one with a very high priority that |
| 2616 |
* won't be fragmented which should be enough for 99% of the cases, |
| 2617 |
* and another one (which we configure here to be 900TU long) which |
| 2618 |
* will have a slightly lower priority, but more importantly, can be |
| 2619 |
* fragmented so that it'll allow other activities to run. |
| 2620 |
*/ |
| 2621 |
if (fw_has_capa(&mvm->fw->ucode_capa, |
| 2622 |
IWL_UCODE_TLV_CAPA_SESSION_PROT_CMD)) |
| 2623 |
iwl_mvm_schedule_session_protection(mvm, vif, 900, |
| 2624 |
min_duration, false); |
| 2625 |
else |
| 2626 |
iwl_mvm_protect_session(mvm, vif, duration, |
| 2627 |
min_duration, 500, false); |
| 2628 |
} |
| 2629 |
|
| 2630 |
/* Handle association common part to MLD and non-MLD modes */ |
| 2631 |
void iwl_mvm_bss_info_changed_station_assoc(struct iwl_mvm *mvm, |
| 2632 |
struct ieee80211_vif *vif, |
| 2633 |
u64 changes) |
| 2634 |
{ |
| 2635 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 2636 |
int ret; |
| 2637 |
int link_id; |
| 2638 |
|
| 2639 |
/* The firmware tracks the MU-MIMO group on its own. |
| 2640 |
* However, on HW restart we should restore this data. |
| 2641 |
*/ |
| 2642 |
if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) && |
| 2643 |
(changes & BSS_CHANGED_MU_GROUPS) && vif->bss_conf.mu_mimo_owner) { |
| 2644 |
ret = iwl_mvm_update_mu_groups(mvm, vif); |
| 2645 |
if (ret) |
| 2646 |
IWL_ERR(mvm, |
| 2647 |
"failed to update VHT MU_MIMO groups\n"); |
| 2648 |
} |
| 2649 |
|
| 2650 |
iwl_mvm_recalc_multicast(mvm); |
| 2651 |
|
| 2652 |
/* reset rssi values */ |
| 2653 |
for_each_mvm_vif_valid_link(mvmvif, link_id) |
| 2654 |
mvmvif->link[link_id]->bf_data.ave_beacon_signal = 0; |
| 2655 |
|
| 2656 |
iwl_mvm_bt_coex_vif_change(mvm); |
| 2657 |
iwl_mvm_update_smps_on_active_links(mvm, vif, IWL_MVM_SMPS_REQ_TT, |
| 2658 |
IEEE80211_SMPS_AUTOMATIC); |
| 2659 |
if (fw_has_capa(&mvm->fw->ucode_capa, |
| 2660 |
IWL_UCODE_TLV_CAPA_UMAC_SCAN)) |
| 2661 |
iwl_mvm_config_scan(mvm); |
| 2662 |
} |
| 2663 |
|
| 2664 |
/* Execute the common part for MLD and non-MLD modes */ |
| 2665 |
void |
| 2666 |
iwl_mvm_bss_info_changed_station_common(struct iwl_mvm *mvm, |
| 2667 |
struct ieee80211_vif *vif, |
| 2668 |
struct ieee80211_bss_conf *link_conf, |
| 2669 |
u64 changes) |
| 2670 |
{ |
| 2671 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 2672 |
int ret; |
| 2673 |
|
| 2674 |
if (changes & BSS_CHANGED_BEACON_INFO) { |
| 2675 |
/* We received a beacon from the associated AP so |
| 2676 |
* remove the session protection. |
| 2677 |
*/ |
| 2678 |
iwl_mvm_stop_session_protection(mvm, vif); |
| 2679 |
|
| 2680 |
iwl_mvm_sf_update(mvm, vif, false); |
| 2681 |
WARN_ON(iwl_mvm_enable_beacon_filter(mvm, vif)); |
| 2682 |
} |
| 2683 |
|
| 2684 |
if (changes & (BSS_CHANGED_PS | BSS_CHANGED_P2P_PS | BSS_CHANGED_QOS | |
| 2685 |
/* Send power command on every beacon change, |
| 2686 |
* because we may have not enabled beacon abort yet. |
| 2687 |
*/ |
| 2688 |
BSS_CHANGED_BEACON_INFO)) { |
| 2689 |
ret = iwl_mvm_power_update_mac(mvm); |
| 2690 |
if (ret) |
| 2691 |
IWL_ERR(mvm, "failed to update power mode\n"); |
| 2692 |
} |
| 2693 |
|
| 2694 |
if (changes & BSS_CHANGED_CQM) { |
| 2695 |
struct iwl_mvm_vif_link_info *link_info = |
| 2696 |
mvmvif->link[link_conf->link_id]; |
| 2697 |
|
| 2698 |
IWL_DEBUG_MAC80211(mvm, "CQM info_changed\n"); |
| 2699 |
if (link_info) |
| 2700 |
link_info->bf_data.last_cqm_event = 0; |
| 2701 |
|
| 2702 |
if (mvmvif->bf_enabled) { |
| 2703 |
/* FIXME: need to update per link when FW API will |
| 2704 |
* support it |
| 2705 |
*/ |
| 2706 |
ret = iwl_mvm_enable_beacon_filter(mvm, vif); |
| 2707 |
if (ret) |
| 2708 |
IWL_ERR(mvm, |
| 2709 |
"failed to update CQM thresholds\n"); |
| 2710 |
} |
| 2711 |
} |
| 2712 |
|
| 2713 |
if (changes & BSS_CHANGED_BANDWIDTH) |
| 2714 |
iwl_mvm_update_link_smps(vif, link_conf); |
| 2715 |
|
| 2716 |
if (changes & BSS_CHANGED_TPE) { |
| 2717 |
IWL_DEBUG_CALIB(mvm, "Changing TPE\n"); |
| 2718 |
iwl_mvm_send_ap_tx_power_constraint_cmd(mvm, vif, |
| 2719 |
link_conf, |
| 2720 |
false); |
| 2721 |
} |
| 2722 |
} |
| 2723 |
|
| 2724 |
static void iwl_mvm_bss_info_changed_station(struct iwl_mvm *mvm, |
| 2725 |
struct ieee80211_vif *vif, |
| 2726 |
struct ieee80211_bss_conf *bss_conf, |
| 2727 |
u64 changes) |
| 2728 |
{ |
| 2729 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 2730 |
int ret; |
| 2731 |
int i; |
| 2732 |
|
| 2733 |
/* |
| 2734 |
* Re-calculate the tsf id, as the leader-follower relations depend |
| 2735 |
* on the beacon interval, which was not known when the station |
| 2736 |
* interface was added. |
| 2737 |
*/ |
| 2738 |
if (changes & BSS_CHANGED_ASSOC && vif->cfg.assoc) { |
| 2739 |
if ((vif->bss_conf.he_support && |
| 2740 |
!iwlwifi_mod_params.disable_11ax)) |
| 2741 |
iwl_mvm_cfg_he_sta(mvm, vif, mvmvif->deflink.ap_sta_id); |
| 2742 |
|
| 2743 |
iwl_mvm_mac_ctxt_recalc_tsf_id(mvm, vif); |
| 2744 |
} |
| 2745 |
|
| 2746 |
/* Update MU EDCA params */ |
| 2747 |
if (changes & BSS_CHANGED_QOS && mvmvif->associated && |
| 2748 |
vif->cfg.assoc && |
| 2749 |
(vif->bss_conf.he_support && !iwlwifi_mod_params.disable_11ax)) |
| 2750 |
iwl_mvm_cfg_he_sta(mvm, vif, mvmvif->deflink.ap_sta_id); |
| 2751 |
|
| 2752 |
/* |
| 2753 |
* If we're not associated yet, take the (new) BSSID before associating |
| 2754 |
* so the firmware knows. If we're already associated, then use the old |
| 2755 |
* BSSID here, and we'll send a cleared one later in the CHANGED_ASSOC |
| 2756 |
* branch for disassociation below. |
| 2757 |
*/ |
| 2758 |
if (changes & BSS_CHANGED_BSSID && !mvmvif->associated) |
| 2759 |
memcpy(mvmvif->deflink.bssid, bss_conf->bssid, ETH_ALEN); |
| 2760 |
|
| 2761 |
ret = iwl_mvm_mac_ctxt_changed(mvm, vif, false, mvmvif->deflink.bssid); |
| 2762 |
if (ret) |
| 2763 |
IWL_ERR(mvm, "failed to update MAC %pM\n", vif->addr); |
| 2764 |
|
| 2765 |
/* after sending it once, adopt mac80211 data */ |
| 2766 |
memcpy(mvmvif->deflink.bssid, bss_conf->bssid, ETH_ALEN); |
| 2767 |
mvmvif->associated = vif->cfg.assoc; |
| 2768 |
|
| 2769 |
if (changes & BSS_CHANGED_ASSOC) { |
| 2770 |
if (vif->cfg.assoc) { |
| 2771 |
mvmvif->session_prot_connection_loss = false; |
| 2772 |
|
| 2773 |
/* clear statistics to get clean beacon counter */ |
| 2774 |
iwl_mvm_request_statistics(mvm, true); |
| 2775 |
for_each_mvm_vif_valid_link(mvmvif, i) |
| 2776 |
memset(&mvmvif->link[i]->beacon_stats, 0, |
| 2777 |
sizeof(mvmvif->link[i]->beacon_stats)); |
| 2778 |
|
| 2779 |
/* add quota for this interface */ |
| 2780 |
ret = iwl_mvm_update_quotas(mvm, true, NULL); |
| 2781 |
if (ret) { |
| 2782 |
IWL_ERR(mvm, "failed to update quotas\n"); |
| 2783 |
return; |
| 2784 |
} |
| 2785 |
|
| 2786 |
if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, |
| 2787 |
&mvm->status) && |
| 2788 |
!fw_has_capa(&mvm->fw->ucode_capa, |
| 2789 |
IWL_UCODE_TLV_CAPA_SESSION_PROT_CMD)) { |
| 2790 |
/* |
| 2791 |
* If we're restarting then the firmware will |
| 2792 |
* obviously have lost synchronisation with |
| 2793 |
* the AP. It will attempt to synchronise by |
| 2794 |
* itself, but we can make it more reliable by |
| 2795 |
* scheduling a session protection time event. |
| 2796 |
* |
| 2797 |
* The firmware needs to receive a beacon to |
| 2798 |
* catch up with synchronisation, use 110% of |
| 2799 |
* the beacon interval. |
| 2800 |
* |
| 2801 |
* Set a large maximum delay to allow for more |
| 2802 |
* than a single interface. |
| 2803 |
* |
| 2804 |
* For new firmware versions, rely on the |
| 2805 |
* firmware. This is relevant for DCM scenarios |
| 2806 |
* only anyway. |
| 2807 |
*/ |
| 2808 |
u32 dur = (11 * vif->bss_conf.beacon_int) / 10; |
| 2809 |
iwl_mvm_protect_session(mvm, vif, dur, dur, |
| 2810 |
5 * dur, false); |
| 2811 |
} else if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, |
| 2812 |
&mvm->status) && |
| 2813 |
!vif->bss_conf.dtim_period) { |
| 2814 |
/* |
| 2815 |
* If we're not restarting and still haven't |
| 2816 |
* heard a beacon (dtim period unknown) then |
| 2817 |
* make sure we still have enough minimum time |
| 2818 |
* remaining in the time event, since the auth |
| 2819 |
* might actually have taken quite a while |
| 2820 |
* (especially for SAE) and so the remaining |
| 2821 |
* time could be small without us having heard |
| 2822 |
* a beacon yet. |
| 2823 |
*/ |
| 2824 |
iwl_mvm_protect_assoc(mvm, vif, 0); |
| 2825 |
} |
| 2826 |
|
| 2827 |
iwl_mvm_sf_update(mvm, vif, false); |
| 2828 |
iwl_mvm_power_vif_assoc(mvm, vif); |
| 2829 |
if (vif->p2p) { |
| 2830 |
iwl_mvm_update_smps(mvm, vif, |
| 2831 |
IWL_MVM_SMPS_REQ_PROT, |
| 2832 |
IEEE80211_SMPS_DYNAMIC, 0); |
| 2833 |
} |
| 2834 |
} else if (mvmvif->deflink.ap_sta_id != IWL_INVALID_STA) { |
| 2835 |
iwl_mvm_mei_host_disassociated(mvm); |
| 2836 |
/* |
| 2837 |
* If update fails - SF might be running in associated |
| 2838 |
* mode while disassociated - which is forbidden. |
| 2839 |
*/ |
| 2840 |
ret = iwl_mvm_sf_update(mvm, vif, false); |
| 2841 |
WARN_ONCE(ret && |
| 2842 |
!test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, |
| 2843 |
&mvm->status), |
| 2844 |
"Failed to update SF upon disassociation\n"); |
| 2845 |
|
| 2846 |
/* remove quota for this interface */ |
| 2847 |
ret = iwl_mvm_update_quotas(mvm, false, NULL); |
| 2848 |
if (ret) |
| 2849 |
IWL_ERR(mvm, "failed to update quotas\n"); |
| 2850 |
|
| 2851 |
/* this will take the cleared BSSID from bss_conf */ |
| 2852 |
ret = iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL); |
| 2853 |
if (ret) |
| 2854 |
IWL_ERR(mvm, |
| 2855 |
"failed to update MAC %pM (clear after unassoc)\n", |
| 2856 |
vif->addr); |
| 2857 |
} |
| 2858 |
|
| 2859 |
iwl_mvm_bss_info_changed_station_assoc(mvm, vif, changes); |
| 2860 |
} |
| 2861 |
|
| 2862 |
iwl_mvm_bss_info_changed_station_common(mvm, vif, &vif->bss_conf, |
| 2863 |
changes); |
| 2864 |
} |
| 2865 |
|
| 2866 |
bool iwl_mvm_start_ap_ibss_common(struct ieee80211_hw *hw, |
| 2867 |
struct ieee80211_vif *vif, |
| 2868 |
int *ret) |
| 2869 |
{ |
| 2870 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 2871 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 2872 |
int i; |
| 2873 |
|
| 2874 |
lockdep_assert_held(&mvm->mutex); |
| 2875 |
|
| 2876 |
mvmvif->ap_assoc_sta_count = 0; |
| 2877 |
|
| 2878 |
/* must be set before quota calculations */ |
| 2879 |
mvmvif->ap_ibss_active = true; |
| 2880 |
|
| 2881 |
/* send all the early keys to the device now */ |
| 2882 |
for (i = 0; i < ARRAY_SIZE(mvmvif->ap_early_keys); i++) { |
| 2883 |
struct ieee80211_key_conf *key = mvmvif->ap_early_keys[i]; |
| 2884 |
|
| 2885 |
if (!key) |
| 2886 |
continue; |
| 2887 |
|
| 2888 |
mvmvif->ap_early_keys[i] = NULL; |
| 2889 |
|
| 2890 |
*ret = __iwl_mvm_mac_set_key(hw, SET_KEY, vif, NULL, key); |
| 2891 |
if (*ret) |
| 2892 |
return true; |
| 2893 |
} |
| 2894 |
|
| 2895 |
if (vif->type == NL80211_IFTYPE_AP && !vif->p2p) { |
| 2896 |
iwl_mvm_vif_set_low_latency(mvmvif, true, |
| 2897 |
LOW_LATENCY_VIF_TYPE); |
| 2898 |
iwl_mvm_send_low_latency_cmd(mvm, true, mvmvif->id); |
| 2899 |
} |
| 2900 |
|
| 2901 |
/* power updated needs to be done before quotas */ |
| 2902 |
iwl_mvm_power_update_mac(mvm); |
| 2903 |
|
| 2904 |
return false; |
| 2905 |
} |
| 2906 |
|
| 2907 |
static int iwl_mvm_start_ap_ibss(struct ieee80211_hw *hw, |
| 2908 |
struct ieee80211_vif *vif, |
| 2909 |
struct ieee80211_bss_conf *link_conf) |
| 2910 |
{ |
| 2911 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 2912 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 2913 |
int ret; |
| 2914 |
|
| 2915 |
mutex_lock(&mvm->mutex); |
| 2916 |
|
| 2917 |
/* |
| 2918 |
* Re-calculate the tsf id, as the leader-follower relations depend on |
| 2919 |
* the beacon interval, which was not known when the AP interface |
| 2920 |
* was added. |
| 2921 |
*/ |
| 2922 |
if (vif->type == NL80211_IFTYPE_AP) |
| 2923 |
iwl_mvm_mac_ctxt_recalc_tsf_id(mvm, vif); |
| 2924 |
|
| 2925 |
/* For older devices need to send beacon template before adding mac |
| 2926 |
* context. For the newer, the beacon is a resource that belongs to a |
| 2927 |
* MAC, so need to send beacon template after adding the mac. |
| 2928 |
*/ |
| 2929 |
if (mvm->trans->mac_cfg->device_family > IWL_DEVICE_FAMILY_22000) { |
| 2930 |
/* Add the mac context */ |
| 2931 |
ret = iwl_mvm_mac_ctxt_add(mvm, vif); |
| 2932 |
if (ret) |
| 2933 |
goto out_unlock; |
| 2934 |
|
| 2935 |
/* Send the beacon template */ |
| 2936 |
ret = iwl_mvm_mac_ctxt_beacon_changed(mvm, vif, link_conf); |
| 2937 |
if (ret) |
| 2938 |
goto out_unlock; |
| 2939 |
} else { |
| 2940 |
/* Send the beacon template */ |
| 2941 |
ret = iwl_mvm_mac_ctxt_beacon_changed(mvm, vif, link_conf); |
| 2942 |
if (ret) |
| 2943 |
goto out_unlock; |
| 2944 |
|
| 2945 |
/* Add the mac context */ |
| 2946 |
ret = iwl_mvm_mac_ctxt_add(mvm, vif); |
| 2947 |
if (ret) |
| 2948 |
goto out_unlock; |
| 2949 |
} |
| 2950 |
|
| 2951 |
/* Perform the binding */ |
| 2952 |
ret = iwl_mvm_binding_add_vif(mvm, vif); |
| 2953 |
if (ret) |
| 2954 |
goto out_remove; |
| 2955 |
|
| 2956 |
/* |
| 2957 |
* This is not very nice, but the simplest: |
| 2958 |
* For older FWs adding the mcast sta before the bcast station may |
| 2959 |
* cause assert 0x2b00. |
| 2960 |
* This is fixed in later FW so make the order of removal depend on |
| 2961 |
* the TLV |
| 2962 |
*/ |
| 2963 |
if (fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_STA_TYPE)) { |
| 2964 |
ret = iwl_mvm_add_mcast_sta(mvm, vif); |
| 2965 |
if (ret) |
| 2966 |
goto out_unbind; |
| 2967 |
/* |
| 2968 |
* Send the bcast station. At this stage the TBTT and DTIM time |
| 2969 |
* events are added and applied to the scheduler |
| 2970 |
*/ |
| 2971 |
ret = iwl_mvm_send_add_bcast_sta(mvm, vif); |
| 2972 |
if (ret) { |
| 2973 |
iwl_mvm_rm_mcast_sta(mvm, vif); |
| 2974 |
goto out_unbind; |
| 2975 |
} |
| 2976 |
} else { |
| 2977 |
/* |
| 2978 |
* Send the bcast station. At this stage the TBTT and DTIM time |
| 2979 |
* events are added and applied to the scheduler |
| 2980 |
*/ |
| 2981 |
ret = iwl_mvm_send_add_bcast_sta(mvm, vif); |
| 2982 |
if (ret) |
| 2983 |
goto out_unbind; |
| 2984 |
ret = iwl_mvm_add_mcast_sta(mvm, vif); |
| 2985 |
if (ret) { |
| 2986 |
iwl_mvm_send_rm_bcast_sta(mvm, vif); |
| 2987 |
goto out_unbind; |
| 2988 |
} |
| 2989 |
} |
| 2990 |
|
| 2991 |
if (iwl_mvm_start_ap_ibss_common(hw, vif, &ret)) |
| 2992 |
goto out_failed; |
| 2993 |
|
| 2994 |
ret = iwl_mvm_update_quotas(mvm, false, NULL); |
| 2995 |
if (ret) |
| 2996 |
goto out_failed; |
| 2997 |
|
| 2998 |
/* Need to update the P2P Device MAC (only GO, IBSS is single vif) */ |
| 2999 |
if (vif->p2p && mvm->p2p_device_vif) |
| 3000 |
iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif, false, NULL); |
| 3001 |
|
| 3002 |
iwl_mvm_bt_coex_vif_change(mvm); |
| 3003 |
|
| 3004 |
/* we don't support TDLS during DCM */ |
| 3005 |
if (iwl_mvm_phy_ctx_count(mvm) > 1) |
| 3006 |
iwl_mvm_teardown_tdls_peers(mvm); |
| 3007 |
|
| 3008 |
iwl_mvm_ftm_restart_responder(mvm, vif, &vif->bss_conf); |
| 3009 |
|
| 3010 |
goto out_unlock; |
| 3011 |
|
| 3012 |
out_failed: |
| 3013 |
iwl_mvm_power_update_mac(mvm); |
| 3014 |
mvmvif->ap_ibss_active = false; |
| 3015 |
iwl_mvm_send_rm_bcast_sta(mvm, vif); |
| 3016 |
iwl_mvm_rm_mcast_sta(mvm, vif); |
| 3017 |
out_unbind: |
| 3018 |
iwl_mvm_binding_remove_vif(mvm, vif); |
| 3019 |
out_remove: |
| 3020 |
iwl_mvm_mac_ctxt_remove(mvm, vif); |
| 3021 |
out_unlock: |
| 3022 |
mutex_unlock(&mvm->mutex); |
| 3023 |
return ret; |
| 3024 |
} |
| 3025 |
|
| 3026 |
static int iwl_mvm_start_ap(struct ieee80211_hw *hw, |
| 3027 |
struct ieee80211_vif *vif, |
| 3028 |
struct ieee80211_bss_conf *link_conf) |
| 3029 |
{ |
| 3030 |
return iwl_mvm_start_ap_ibss(hw, vif, link_conf); |
| 3031 |
} |
| 3032 |
|
| 3033 |
static int iwl_mvm_start_ibss(struct ieee80211_hw *hw, |
| 3034 |
struct ieee80211_vif *vif) |
| 3035 |
{ |
| 3036 |
return iwl_mvm_start_ap_ibss(hw, vif, &vif->bss_conf); |
| 3037 |
} |
| 3038 |
|
| 3039 |
/* Common part for MLD and non-MLD ops */ |
| 3040 |
void iwl_mvm_stop_ap_ibss_common(struct iwl_mvm *mvm, |
| 3041 |
struct ieee80211_vif *vif) |
| 3042 |
{ |
| 3043 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 3044 |
|
| 3045 |
lockdep_assert_held(&mvm->mutex); |
| 3046 |
|
| 3047 |
iwl_mvm_prepare_mac_removal(mvm, vif); |
| 3048 |
|
| 3049 |
/* Handle AP stop while in CSA */ |
| 3050 |
if (rcu_access_pointer(mvm->csa_vif) == vif) { |
| 3051 |
iwl_mvm_remove_time_event(mvm, mvmvif, |
| 3052 |
&mvmvif->time_event_data); |
| 3053 |
RCU_INIT_POINTER(mvm->csa_vif, NULL); |
| 3054 |
mvmvif->csa_countdown = false; |
| 3055 |
} |
| 3056 |
|
| 3057 |
if (rcu_access_pointer(mvm->csa_tx_blocked_vif) == vif) { |
| 3058 |
RCU_INIT_POINTER(mvm->csa_tx_blocked_vif, NULL); |
| 3059 |
mvm->csa_tx_block_bcn_timeout = 0; |
| 3060 |
} |
| 3061 |
|
| 3062 |
mvmvif->ap_ibss_active = false; |
| 3063 |
mvm->ap_last_beacon_gp2 = 0; |
| 3064 |
|
| 3065 |
if (vif->type == NL80211_IFTYPE_AP && !vif->p2p) { |
| 3066 |
iwl_mvm_vif_set_low_latency(mvmvif, false, |
| 3067 |
LOW_LATENCY_VIF_TYPE); |
| 3068 |
iwl_mvm_send_low_latency_cmd(mvm, false, mvmvif->id); |
| 3069 |
} |
| 3070 |
|
| 3071 |
iwl_mvm_bt_coex_vif_change(mvm); |
| 3072 |
} |
| 3073 |
|
| 3074 |
static void iwl_mvm_stop_ap_ibss(struct ieee80211_hw *hw, |
| 3075 |
struct ieee80211_vif *vif, |
| 3076 |
struct ieee80211_bss_conf *link_conf) |
| 3077 |
{ |
| 3078 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 3079 |
|
| 3080 |
guard(mvm)(mvm); |
| 3081 |
|
| 3082 |
iwl_mvm_stop_ap_ibss_common(mvm, vif); |
| 3083 |
|
| 3084 |
/* Need to update the P2P Device MAC (only GO, IBSS is single vif) */ |
| 3085 |
if (vif->p2p && mvm->p2p_device_vif) |
| 3086 |
iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif, false, NULL); |
| 3087 |
|
| 3088 |
iwl_mvm_update_quotas(mvm, false, NULL); |
| 3089 |
|
| 3090 |
iwl_mvm_ftm_responder_clear(mvm, vif); |
| 3091 |
|
| 3092 |
/* |
| 3093 |
* This is not very nice, but the simplest: |
| 3094 |
* For older FWs removing the mcast sta before the bcast station may |
| 3095 |
* cause assert 0x2b00. |
| 3096 |
* This is fixed in later FW (which will stop beaconing when removing |
| 3097 |
* bcast station). |
| 3098 |
* So make the order of removal depend on the TLV |
| 3099 |
*/ |
| 3100 |
if (!fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_STA_TYPE)) |
| 3101 |
iwl_mvm_rm_mcast_sta(mvm, vif); |
| 3102 |
iwl_mvm_send_rm_bcast_sta(mvm, vif); |
| 3103 |
if (fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_STA_TYPE)) |
| 3104 |
iwl_mvm_rm_mcast_sta(mvm, vif); |
| 3105 |
iwl_mvm_binding_remove_vif(mvm, vif); |
| 3106 |
|
| 3107 |
iwl_mvm_power_update_mac(mvm); |
| 3108 |
|
| 3109 |
iwl_mvm_mac_ctxt_remove(mvm, vif); |
| 3110 |
} |
| 3111 |
|
| 3112 |
static void iwl_mvm_stop_ap(struct ieee80211_hw *hw, |
| 3113 |
struct ieee80211_vif *vif, |
| 3114 |
struct ieee80211_bss_conf *link_conf) |
| 3115 |
{ |
| 3116 |
iwl_mvm_stop_ap_ibss(hw, vif, link_conf); |
| 3117 |
} |
| 3118 |
|
| 3119 |
static void iwl_mvm_stop_ibss(struct ieee80211_hw *hw, |
| 3120 |
struct ieee80211_vif *vif) |
| 3121 |
{ |
| 3122 |
iwl_mvm_stop_ap_ibss(hw, vif, &vif->bss_conf); |
| 3123 |
} |
| 3124 |
|
| 3125 |
static void |
| 3126 |
iwl_mvm_bss_info_changed_ap_ibss(struct iwl_mvm *mvm, |
| 3127 |
struct ieee80211_vif *vif, |
| 3128 |
struct ieee80211_bss_conf *bss_conf, |
| 3129 |
u64 changes) |
| 3130 |
{ |
| 3131 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 3132 |
|
| 3133 |
/* Changes will be applied when the AP/IBSS is started */ |
| 3134 |
if (!mvmvif->ap_ibss_active) |
| 3135 |
return; |
| 3136 |
|
| 3137 |
if (changes & (BSS_CHANGED_ERP_CTS_PROT | BSS_CHANGED_HT | |
| 3138 |
BSS_CHANGED_BANDWIDTH | BSS_CHANGED_QOS) && |
| 3139 |
iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL)) |
| 3140 |
IWL_ERR(mvm, "failed to update MAC %pM\n", vif->addr); |
| 3141 |
|
| 3142 |
/* Need to send a new beacon template to the FW */ |
| 3143 |
if (changes & BSS_CHANGED_BEACON && |
| 3144 |
iwl_mvm_mac_ctxt_beacon_changed(mvm, vif, &vif->bss_conf)) |
| 3145 |
IWL_WARN(mvm, "Failed updating beacon data\n"); |
| 3146 |
|
| 3147 |
if (changes & BSS_CHANGED_FTM_RESPONDER) { |
| 3148 |
int ret = iwl_mvm_ftm_start_responder(mvm, vif, &vif->bss_conf); |
| 3149 |
|
| 3150 |
if (ret) |
| 3151 |
IWL_WARN(mvm, "Failed to enable FTM responder (%d)\n", |
| 3152 |
ret); |
| 3153 |
} |
| 3154 |
|
| 3155 |
} |
| 3156 |
|
| 3157 |
static void iwl_mvm_bss_info_changed(struct ieee80211_hw *hw, |
| 3158 |
struct ieee80211_vif *vif, |
| 3159 |
struct ieee80211_bss_conf *bss_conf, |
| 3160 |
u64 changes) |
| 3161 |
{ |
| 3162 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 3163 |
|
| 3164 |
guard(mvm)(mvm); |
| 3165 |
|
| 3166 |
if (changes & BSS_CHANGED_IDLE && !vif->cfg.idle) |
| 3167 |
iwl_mvm_scan_stop(mvm, IWL_MVM_SCAN_SCHED, true); |
| 3168 |
|
| 3169 |
switch (vif->type) { |
| 3170 |
case NL80211_IFTYPE_STATION: |
| 3171 |
iwl_mvm_bss_info_changed_station(mvm, vif, bss_conf, changes); |
| 3172 |
break; |
| 3173 |
case NL80211_IFTYPE_AP: |
| 3174 |
case NL80211_IFTYPE_ADHOC: |
| 3175 |
iwl_mvm_bss_info_changed_ap_ibss(mvm, vif, bss_conf, changes); |
| 3176 |
break; |
| 3177 |
case NL80211_IFTYPE_MONITOR: |
| 3178 |
if (changes & BSS_CHANGED_MU_GROUPS) |
| 3179 |
iwl_mvm_update_mu_groups(mvm, vif); |
| 3180 |
break; |
| 3181 |
default: |
| 3182 |
/* shouldn't happen */ |
| 3183 |
WARN_ON_ONCE(1); |
| 3184 |
} |
| 3185 |
|
| 3186 |
if (changes & BSS_CHANGED_TXPOWER) { |
| 3187 |
IWL_DEBUG_CALIB(mvm, "Changing TX Power to %d dBm\n", |
| 3188 |
bss_conf->txpower); |
| 3189 |
iwl_mvm_set_tx_power(mvm, bss_conf, bss_conf->txpower); |
| 3190 |
} |
| 3191 |
} |
| 3192 |
|
| 3193 |
int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 3194 |
struct ieee80211_scan_request *hw_req) |
| 3195 |
{ |
| 3196 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 3197 |
|
| 3198 |
if (hw_req->req.n_channels == 0 || |
| 3199 |
hw_req->req.n_channels > mvm->fw->ucode_capa.n_scan_channels) |
| 3200 |
return -EINVAL; |
| 3201 |
|
| 3202 |
guard(mvm)(mvm); |
| 3203 |
return iwl_mvm_reg_scan_start(mvm, vif, &hw_req->req, &hw_req->ies); |
| 3204 |
} |
| 3205 |
|
| 3206 |
void iwl_mvm_mac_cancel_hw_scan(struct ieee80211_hw *hw, |
| 3207 |
struct ieee80211_vif *vif) |
| 3208 |
{ |
| 3209 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 3210 |
|
| 3211 |
guard(mvm)(mvm); |
| 3212 |
|
| 3213 |
/* Due to a race condition, it's possible that mac80211 asks |
| 3214 |
* us to stop a hw_scan when it's already stopped. This can |
| 3215 |
* happen, for instance, if we stopped the scan ourselves, |
| 3216 |
* called ieee80211_scan_completed() and the userspace called |
| 3217 |
* cancel scan before ieee80211_scan_work() could run. |
| 3218 |
* To handle that, simply return if the scan is not running. |
| 3219 |
*/ |
| 3220 |
if (mvm->scan_status & IWL_MVM_SCAN_REGULAR) |
| 3221 |
iwl_mvm_scan_stop(mvm, IWL_MVM_SCAN_REGULAR, true); |
| 3222 |
} |
| 3223 |
|
| 3224 |
void |
| 3225 |
iwl_mvm_mac_allow_buffered_frames(struct ieee80211_hw *hw, |
| 3226 |
struct ieee80211_sta *sta, u16 tids, |
| 3227 |
int num_frames, |
| 3228 |
enum ieee80211_frame_release_type reason, |
| 3229 |
bool more_data) |
| 3230 |
{ |
| 3231 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 3232 |
|
| 3233 |
/* Called when we need to transmit (a) frame(s) from mac80211 */ |
| 3234 |
|
| 3235 |
iwl_mvm_sta_modify_sleep_tx_count(mvm, sta, reason, num_frames, |
| 3236 |
tids, more_data, false); |
| 3237 |
} |
| 3238 |
|
| 3239 |
void |
| 3240 |
iwl_mvm_mac_release_buffered_frames(struct ieee80211_hw *hw, |
| 3241 |
struct ieee80211_sta *sta, u16 tids, |
| 3242 |
int num_frames, |
| 3243 |
enum ieee80211_frame_release_type reason, |
| 3244 |
bool more_data) |
| 3245 |
{ |
| 3246 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 3247 |
|
| 3248 |
/* Called when we need to transmit (a) frame(s) from agg or dqa queue */ |
| 3249 |
|
| 3250 |
iwl_mvm_sta_modify_sleep_tx_count(mvm, sta, reason, num_frames, |
| 3251 |
tids, more_data, true); |
| 3252 |
} |
| 3253 |
|
| 3254 |
static void __iwl_mvm_mac_sta_notify(struct ieee80211_hw *hw, |
| 3255 |
enum sta_notify_cmd cmd, |
| 3256 |
struct ieee80211_sta *sta) |
| 3257 |
{ |
| 3258 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 3259 |
struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); |
| 3260 |
unsigned long txqs = 0, tids = 0; |
| 3261 |
int tid; |
| 3262 |
|
| 3263 |
/* |
| 3264 |
* If we have TVQM then we get too high queue numbers - luckily |
| 3265 |
* we really shouldn't get here with that because such hardware |
| 3266 |
* should have firmware supporting buffer station offload. |
| 3267 |
*/ |
| 3268 |
if (WARN_ON(iwl_mvm_has_new_tx_api(mvm))) |
| 3269 |
return; |
| 3270 |
|
| 3271 |
spin_lock_bh(&mvmsta->lock); |
| 3272 |
for (tid = 0; tid < ARRAY_SIZE(mvmsta->tid_data); tid++) { |
| 3273 |
struct iwl_mvm_tid_data *tid_data = &mvmsta->tid_data[tid]; |
| 3274 |
|
| 3275 |
if (tid_data->txq_id == IWL_MVM_INVALID_QUEUE) |
| 3276 |
continue; |
| 3277 |
|
| 3278 |
__set_bit(tid_data->txq_id, &txqs); |
| 3279 |
|
| 3280 |
if (iwl_mvm_tid_queued(mvm, tid_data) == 0) |
| 3281 |
continue; |
| 3282 |
|
| 3283 |
__set_bit(tid, &tids); |
| 3284 |
} |
| 3285 |
|
| 3286 |
switch (cmd) { |
| 3287 |
case STA_NOTIFY_SLEEP: |
| 3288 |
for_each_set_bit(tid, &tids, IWL_MAX_TID_COUNT) |
| 3289 |
ieee80211_sta_set_buffered(sta, tid, true); |
| 3290 |
|
| 3291 |
if (txqs) |
| 3292 |
iwl_trans_freeze_txq_timer(mvm->trans, txqs, true); |
| 3293 |
/* |
| 3294 |
* The fw updates the STA to be asleep. Tx packets on the Tx |
| 3295 |
* queues to this station will not be transmitted. The fw will |
| 3296 |
* send a Tx response with TX_STATUS_FAIL_DEST_PS. |
| 3297 |
*/ |
| 3298 |
break; |
| 3299 |
case STA_NOTIFY_AWAKE: |
| 3300 |
if (WARN_ON(mvmsta->deflink.sta_id == IWL_INVALID_STA)) |
| 3301 |
break; |
| 3302 |
|
| 3303 |
if (txqs) |
| 3304 |
iwl_trans_freeze_txq_timer(mvm->trans, txqs, false); |
| 3305 |
iwl_mvm_sta_modify_ps_wake(mvm, sta); |
| 3306 |
break; |
| 3307 |
default: |
| 3308 |
break; |
| 3309 |
} |
| 3310 |
spin_unlock_bh(&mvmsta->lock); |
| 3311 |
} |
| 3312 |
|
| 3313 |
void iwl_mvm_mac_sta_notify(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 3314 |
enum sta_notify_cmd cmd, struct ieee80211_sta *sta) |
| 3315 |
{ |
| 3316 |
__iwl_mvm_mac_sta_notify(hw, cmd, sta); |
| 3317 |
} |
| 3318 |
|
| 3319 |
void iwl_mvm_sta_pm_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb) |
| 3320 |
{ |
| 3321 |
struct iwl_rx_packet *pkt = rxb_addr(rxb); |
| 3322 |
struct iwl_mvm_pm_state_notification *notif = (void *)pkt->data; |
| 3323 |
struct ieee80211_sta *sta; |
| 3324 |
struct iwl_mvm_sta *mvmsta; |
| 3325 |
bool sleeping = (notif->type != IWL_MVM_PM_EVENT_AWAKE); |
| 3326 |
|
| 3327 |
if (WARN_ON(notif->sta_id >= mvm->fw->ucode_capa.num_stations)) |
| 3328 |
return; |
| 3329 |
|
| 3330 |
rcu_read_lock(); |
| 3331 |
sta = rcu_dereference(mvm->fw_id_to_mac_id[notif->sta_id]); |
| 3332 |
if (WARN_ON(IS_ERR_OR_NULL(sta))) { |
| 3333 |
rcu_read_unlock(); |
| 3334 |
return; |
| 3335 |
} |
| 3336 |
|
| 3337 |
mvmsta = iwl_mvm_sta_from_mac80211(sta); |
| 3338 |
|
| 3339 |
if (!mvmsta->vif || |
| 3340 |
mvmsta->vif->type != NL80211_IFTYPE_AP) { |
| 3341 |
rcu_read_unlock(); |
| 3342 |
return; |
| 3343 |
} |
| 3344 |
|
| 3345 |
if (mvmsta->sleeping != sleeping) { |
| 3346 |
mvmsta->sleeping = sleeping; |
| 3347 |
__iwl_mvm_mac_sta_notify(mvm->hw, |
| 3348 |
sleeping ? STA_NOTIFY_SLEEP : STA_NOTIFY_AWAKE, |
| 3349 |
sta); |
| 3350 |
ieee80211_sta_ps_transition(sta, sleeping); |
| 3351 |
} |
| 3352 |
|
| 3353 |
if (sleeping) { |
| 3354 |
switch (notif->type) { |
| 3355 |
case IWL_MVM_PM_EVENT_AWAKE: |
| 3356 |
case IWL_MVM_PM_EVENT_ASLEEP: |
| 3357 |
break; |
| 3358 |
case IWL_MVM_PM_EVENT_UAPSD: |
| 3359 |
ieee80211_sta_uapsd_trigger(sta, IEEE80211_NUM_TIDS); |
| 3360 |
break; |
| 3361 |
case IWL_MVM_PM_EVENT_PS_POLL: |
| 3362 |
ieee80211_sta_pspoll(sta); |
| 3363 |
break; |
| 3364 |
default: |
| 3365 |
break; |
| 3366 |
} |
| 3367 |
} |
| 3368 |
|
| 3369 |
rcu_read_unlock(); |
| 3370 |
} |
| 3371 |
|
| 3372 |
void iwl_mvm_sta_pre_rcu_remove(struct ieee80211_hw *hw, |
| 3373 |
struct ieee80211_vif *vif, |
| 3374 |
struct ieee80211_sta *sta) |
| 3375 |
{ |
| 3376 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 3377 |
struct iwl_mvm_sta *mvm_sta = iwl_mvm_sta_from_mac80211(sta); |
| 3378 |
unsigned int link_id; |
| 3379 |
|
| 3380 |
lockdep_assert_wiphy(mvm->hw->wiphy); |
| 3381 |
|
| 3382 |
/* |
| 3383 |
* This is called before mac80211 does RCU synchronisation, |
| 3384 |
* so here we already invalidate our internal RCU-protected |
| 3385 |
* station pointer. The rest of the code will thus no longer |
| 3386 |
* be able to find the station this way, and we don't rely |
| 3387 |
* on further RCU synchronisation after the sta_state() |
| 3388 |
* callback deleted the station. |
| 3389 |
* Since there's mvm->mutex here, no need to have RCU lock for |
| 3390 |
* mvm_sta->link access. |
| 3391 |
*/ |
| 3392 |
guard(mvm)(mvm); |
| 3393 |
for (link_id = 0; link_id < ARRAY_SIZE(mvm_sta->link); link_id++) { |
| 3394 |
struct iwl_mvm_link_sta *link_sta; |
| 3395 |
u32 sta_id; |
| 3396 |
|
| 3397 |
if (!mvm_sta->link[link_id]) |
| 3398 |
continue; |
| 3399 |
|
| 3400 |
link_sta = rcu_dereference_protected(mvm_sta->link[link_id], |
| 3401 |
lockdep_is_held(&mvm->mutex)); |
| 3402 |
sta_id = link_sta->sta_id; |
| 3403 |
if (sta == rcu_access_pointer(mvm->fw_id_to_mac_id[sta_id])) { |
| 3404 |
RCU_INIT_POINTER(mvm->fw_id_to_mac_id[sta_id], |
| 3405 |
ERR_PTR(-ENOENT)); |
| 3406 |
RCU_INIT_POINTER(mvm->fw_id_to_link_sta[sta_id], NULL); |
| 3407 |
} |
| 3408 |
} |
| 3409 |
} |
| 3410 |
|
| 3411 |
static void iwl_mvm_check_uapsd(struct iwl_mvm *mvm, struct ieee80211_vif *vif, |
| 3412 |
const u8 *bssid) |
| 3413 |
{ |
| 3414 |
int i; |
| 3415 |
|
| 3416 |
if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) { |
| 3417 |
struct iwl_mvm_tcm_mac *mdata; |
| 3418 |
|
| 3419 |
mdata = &mvm->tcm.data[iwl_mvm_vif_from_mac80211(vif)->id]; |
| 3420 |
ewma_rate_init(&mdata->uapsd_nonagg_detect.rate); |
| 3421 |
mdata->opened_rx_ba_sessions = false; |
| 3422 |
} |
| 3423 |
|
| 3424 |
if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT)) |
| 3425 |
return; |
| 3426 |
|
| 3427 |
if (vif->p2p && !iwl_mvm_is_p2p_scm_uapsd_supported(mvm)) { |
| 3428 |
vif->driver_flags &= ~IEEE80211_VIF_SUPPORTS_UAPSD; |
| 3429 |
return; |
| 3430 |
} |
| 3431 |
|
| 3432 |
if (!vif->p2p && |
| 3433 |
(iwlwifi_mod_params.uapsd_disable & IWL_DISABLE_UAPSD_BSS)) { |
| 3434 |
vif->driver_flags &= ~IEEE80211_VIF_SUPPORTS_UAPSD; |
| 3435 |
return; |
| 3436 |
} |
| 3437 |
|
| 3438 |
for (i = 0; i < IWL_MVM_UAPSD_NOAGG_LIST_LEN; i++) { |
| 3439 |
if (ether_addr_equal(mvm->uapsd_noagg_bssids[i].addr, bssid)) { |
| 3440 |
vif->driver_flags &= ~IEEE80211_VIF_SUPPORTS_UAPSD; |
| 3441 |
return; |
| 3442 |
} |
| 3443 |
} |
| 3444 |
|
| 3445 |
vif->driver_flags |= IEEE80211_VIF_SUPPORTS_UAPSD; |
| 3446 |
} |
| 3447 |
|
| 3448 |
static void |
| 3449 |
iwl_mvm_tdls_check_trigger(struct iwl_mvm *mvm, |
| 3450 |
struct ieee80211_vif *vif, u8 *peer_addr, |
| 3451 |
enum nl80211_tdls_operation action) |
| 3452 |
{ |
| 3453 |
struct iwl_fw_dbg_trigger_tlv *trig; |
| 3454 |
struct iwl_fw_dbg_trigger_tdls *tdls_trig; |
| 3455 |
|
| 3456 |
trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif), |
| 3457 |
FW_DBG_TRIGGER_TDLS); |
| 3458 |
if (!trig) |
| 3459 |
return; |
| 3460 |
|
| 3461 |
tdls_trig = (void *)trig->data; |
| 3462 |
|
| 3463 |
if (!(tdls_trig->action_bitmap & BIT(action))) |
| 3464 |
return; |
| 3465 |
|
| 3466 |
if (tdls_trig->peer_mode && |
| 3467 |
memcmp(tdls_trig->peer, peer_addr, ETH_ALEN) != 0) |
| 3468 |
return; |
| 3469 |
|
| 3470 |
iwl_fw_dbg_collect_trig(&mvm->fwrt, trig, |
| 3471 |
"TDLS event occurred, peer %pM, action %d", |
| 3472 |
peer_addr, action); |
| 3473 |
} |
| 3474 |
|
| 3475 |
struct iwl_mvm_he_obss_narrow_bw_ru_data { |
| 3476 |
bool tolerated; |
| 3477 |
}; |
| 3478 |
|
| 3479 |
static void iwl_mvm_check_he_obss_narrow_bw_ru_iter(struct wiphy *wiphy, |
| 3480 |
struct cfg80211_bss *bss, |
| 3481 |
void *_data) |
| 3482 |
{ |
| 3483 |
struct iwl_mvm_he_obss_narrow_bw_ru_data *data = _data; |
| 3484 |
const struct cfg80211_bss_ies *ies; |
| 3485 |
const struct element *elem; |
| 3486 |
|
| 3487 |
rcu_read_lock(); |
| 3488 |
ies = rcu_dereference(bss->ies); |
| 3489 |
elem = cfg80211_find_elem(WLAN_EID_EXT_CAPABILITY, ies->data, |
| 3490 |
ies->len); |
| 3491 |
|
| 3492 |
if (!elem || elem->datalen < 10 || |
| 3493 |
!(elem->data[10] & |
| 3494 |
WLAN_EXT_CAPA10_OBSS_NARROW_BW_RU_TOLERANCE_SUPPORT)) { |
| 3495 |
data->tolerated = false; |
| 3496 |
} |
| 3497 |
rcu_read_unlock(); |
| 3498 |
} |
| 3499 |
|
| 3500 |
static void |
| 3501 |
iwl_mvm_check_he_obss_narrow_bw_ru(struct ieee80211_hw *hw, |
| 3502 |
struct ieee80211_vif *vif, |
| 3503 |
unsigned int link_id, |
| 3504 |
struct ieee80211_bss_conf *link_conf) |
| 3505 |
{ |
| 3506 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 3507 |
struct iwl_mvm_he_obss_narrow_bw_ru_data iter_data = { |
| 3508 |
.tolerated = true, |
| 3509 |
}; |
| 3510 |
|
| 3511 |
if (WARN_ON_ONCE(!link_conf->chanreq.oper.chan || |
| 3512 |
!mvmvif->link[link_id])) |
| 3513 |
return; |
| 3514 |
|
| 3515 |
if (!(link_conf->chanreq.oper.chan->flags & IEEE80211_CHAN_RADAR)) { |
| 3516 |
mvmvif->link[link_id]->he_ru_2mhz_block = false; |
| 3517 |
return; |
| 3518 |
} |
| 3519 |
|
| 3520 |
cfg80211_bss_iter(hw->wiphy, &link_conf->chanreq.oper, |
| 3521 |
iwl_mvm_check_he_obss_narrow_bw_ru_iter, |
| 3522 |
&iter_data); |
| 3523 |
|
| 3524 |
/* |
| 3525 |
* If there is at least one AP on radar channel that cannot |
| 3526 |
* tolerate 26-tone RU UL OFDMA transmissions using HE TB PPDU. |
| 3527 |
*/ |
| 3528 |
mvmvif->link[link_id]->he_ru_2mhz_block = !iter_data.tolerated; |
| 3529 |
} |
| 3530 |
|
| 3531 |
static void iwl_mvm_reset_cca_40mhz_workaround(struct iwl_mvm *mvm, |
| 3532 |
struct ieee80211_vif *vif) |
| 3533 |
{ |
| 3534 |
struct ieee80211_supported_band *sband; |
| 3535 |
const struct ieee80211_sta_he_cap *he_cap; |
| 3536 |
|
| 3537 |
if (vif->type != NL80211_IFTYPE_STATION) |
| 3538 |
return; |
| 3539 |
|
| 3540 |
if (!mvm->cca_40mhz_workaround) |
| 3541 |
return; |
| 3542 |
|
| 3543 |
/* decrement and check that we reached zero */ |
| 3544 |
mvm->cca_40mhz_workaround--; |
| 3545 |
if (mvm->cca_40mhz_workaround) |
| 3546 |
return; |
| 3547 |
|
| 3548 |
sband = mvm->hw->wiphy->bands[NL80211_BAND_2GHZ]; |
| 3549 |
|
| 3550 |
sband->ht_cap.cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 3551 |
|
| 3552 |
he_cap = ieee80211_get_he_iftype_cap_vif(sband, vif); |
| 3553 |
|
| 3554 |
if (he_cap) { |
| 3555 |
/* we know that ours is writable */ |
| 3556 |
struct ieee80211_sta_he_cap *he = (void *)(uintptr_t)he_cap; |
| 3557 |
|
| 3558 |
he->he_cap_elem.phy_cap_info[0] |= |
| 3559 |
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G; |
| 3560 |
} |
| 3561 |
} |
| 3562 |
|
| 3563 |
static void iwl_mvm_mei_host_associated(struct iwl_mvm *mvm, |
| 3564 |
struct ieee80211_vif *vif, |
| 3565 |
struct iwl_mvm_sta *mvm_sta) |
| 3566 |
{ |
| 3567 |
#if IS_ENABLED(CONFIG_IWLMEI) |
| 3568 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 3569 |
struct iwl_mei_conn_info conn_info = { |
| 3570 |
.ssid_len = vif->cfg.ssid_len, |
| 3571 |
}; |
| 3572 |
|
| 3573 |
if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) |
| 3574 |
return; |
| 3575 |
|
| 3576 |
if (!mvm->mei_registered) |
| 3577 |
return; |
| 3578 |
|
| 3579 |
/* FIXME: MEI needs to be updated for MLO */ |
| 3580 |
if (!vif->bss_conf.chanreq.oper.chan) |
| 3581 |
return; |
| 3582 |
|
| 3583 |
conn_info.channel = vif->bss_conf.chanreq.oper.chan->hw_value; |
| 3584 |
|
| 3585 |
switch (mvm_sta->pairwise_cipher) { |
| 3586 |
case WLAN_CIPHER_SUITE_TKIP: |
| 3587 |
conn_info.pairwise_cipher = IWL_MEI_CIPHER_TKIP; |
| 3588 |
break; |
| 3589 |
case WLAN_CIPHER_SUITE_CCMP: |
| 3590 |
conn_info.pairwise_cipher = IWL_MEI_CIPHER_CCMP; |
| 3591 |
break; |
| 3592 |
case WLAN_CIPHER_SUITE_GCMP: |
| 3593 |
conn_info.pairwise_cipher = IWL_MEI_CIPHER_GCMP; |
| 3594 |
break; |
| 3595 |
case WLAN_CIPHER_SUITE_GCMP_256: |
| 3596 |
conn_info.pairwise_cipher = IWL_MEI_CIPHER_GCMP_256; |
| 3597 |
break; |
| 3598 |
case 0: |
| 3599 |
/* open profile */ |
| 3600 |
break; |
| 3601 |
default: |
| 3602 |
/* cipher not supported, don't send anything to iwlmei */ |
| 3603 |
return; |
| 3604 |
} |
| 3605 |
|
| 3606 |
switch (mvmvif->rekey_data.akm) { |
| 3607 |
case WLAN_AKM_SUITE_SAE & 0xff: |
| 3608 |
conn_info.auth_mode = IWL_MEI_AKM_AUTH_SAE; |
| 3609 |
break; |
| 3610 |
case WLAN_AKM_SUITE_PSK & 0xff: |
| 3611 |
conn_info.auth_mode = IWL_MEI_AKM_AUTH_RSNA_PSK; |
| 3612 |
break; |
| 3613 |
case WLAN_AKM_SUITE_8021X & 0xff: |
| 3614 |
conn_info.auth_mode = IWL_MEI_AKM_AUTH_RSNA; |
| 3615 |
break; |
| 3616 |
case 0: |
| 3617 |
/* open profile */ |
| 3618 |
conn_info.auth_mode = IWL_MEI_AKM_AUTH_OPEN; |
| 3619 |
break; |
| 3620 |
default: |
| 3621 |
/* auth method / AKM not supported */ |
| 3622 |
/* TODO: All the FT vesions of these? */ |
| 3623 |
return; |
| 3624 |
} |
| 3625 |
|
| 3626 |
memcpy(conn_info.ssid, vif->cfg.ssid, vif->cfg.ssid_len); |
| 3627 |
memcpy(conn_info.bssid, vif->bss_conf.bssid, ETH_ALEN); |
| 3628 |
|
| 3629 |
/* TODO: add support for collocated AP data */ |
| 3630 |
iwl_mei_host_associated(&conn_info, NULL); |
| 3631 |
#endif |
| 3632 |
} |
| 3633 |
|
| 3634 |
static int iwl_mvm_mac_ctxt_changed_wrapper(struct iwl_mvm *mvm, |
| 3635 |
struct ieee80211_vif *vif, |
| 3636 |
bool force_assoc_off) |
| 3637 |
{ |
| 3638 |
return iwl_mvm_mac_ctxt_changed(mvm, vif, force_assoc_off, NULL); |
| 3639 |
} |
| 3640 |
|
| 3641 |
static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw, |
| 3642 |
struct ieee80211_vif *vif, |
| 3643 |
struct ieee80211_sta *sta, |
| 3644 |
enum ieee80211_sta_state old_state, |
| 3645 |
enum ieee80211_sta_state new_state) |
| 3646 |
{ |
| 3647 |
static const struct iwl_mvm_sta_state_ops callbacks = { |
| 3648 |
.add_sta = iwl_mvm_add_sta, |
| 3649 |
.update_sta = iwl_mvm_update_sta, |
| 3650 |
.rm_sta = iwl_mvm_rm_sta, |
| 3651 |
.mac_ctxt_changed = iwl_mvm_mac_ctxt_changed_wrapper, |
| 3652 |
}; |
| 3653 |
|
| 3654 |
return iwl_mvm_mac_sta_state_common(hw, vif, sta, old_state, new_state, |
| 3655 |
&callbacks); |
| 3656 |
} |
| 3657 |
|
| 3658 |
/* FIXME: temporary making two assumptions in all sta handling functions: |
| 3659 |
* (1) when setting sta state, the link exists and protected |
| 3660 |
* (2) if a link is valid in sta then it's valid in vif (can |
| 3661 |
* use same index in the link array) |
| 3662 |
*/ |
| 3663 |
static void iwl_mvm_rs_rate_init_all_links(struct iwl_mvm *mvm, |
| 3664 |
struct ieee80211_vif *vif, |
| 3665 |
struct ieee80211_sta *sta) |
| 3666 |
{ |
| 3667 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 3668 |
unsigned int link_id; |
| 3669 |
|
| 3670 |
for_each_mvm_vif_valid_link(mvmvif, link_id) { |
| 3671 |
struct ieee80211_bss_conf *conf = |
| 3672 |
link_conf_dereference_check(vif, link_id); |
| 3673 |
struct ieee80211_link_sta *link_sta = |
| 3674 |
link_sta_dereference_check(sta, link_id); |
| 3675 |
|
| 3676 |
if (!conf || !link_sta || !mvmvif->link[link_id]->phy_ctxt) |
| 3677 |
continue; |
| 3678 |
|
| 3679 |
iwl_mvm_rs_rate_init(mvm, vif, sta, conf, link_sta, |
| 3680 |
mvmvif->link[link_id]->phy_ctxt->channel->band); |
| 3681 |
} |
| 3682 |
} |
| 3683 |
|
| 3684 |
static bool iwl_mvm_vif_conf_from_sta(struct iwl_mvm *mvm, |
| 3685 |
struct ieee80211_vif *vif, |
| 3686 |
struct ieee80211_sta *sta) |
| 3687 |
{ |
| 3688 |
struct ieee80211_link_sta *link_sta; |
| 3689 |
unsigned int link_id; |
| 3690 |
|
| 3691 |
/* Beacon interval check - firmware will crash if the beacon |
| 3692 |
* interval is less than 16. We can't avoid connecting at all, |
| 3693 |
* so refuse the station state change, this will cause mac80211 |
| 3694 |
* to abandon attempts to connect to this AP, and eventually |
| 3695 |
* wpa_s will blocklist the AP... |
| 3696 |
*/ |
| 3697 |
|
| 3698 |
for_each_sta_active_link(vif, sta, link_sta, link_id) { |
| 3699 |
struct ieee80211_bss_conf *link_conf = |
| 3700 |
link_conf_dereference_protected(vif, link_id); |
| 3701 |
|
| 3702 |
if (!link_conf) |
| 3703 |
continue; |
| 3704 |
|
| 3705 |
if (link_conf->beacon_int < IWL_MVM_MIN_BEACON_INTERVAL_TU) { |
| 3706 |
IWL_ERR(mvm, |
| 3707 |
"Beacon interval %d for AP %pM is too small\n", |
| 3708 |
link_conf->beacon_int, link_sta->addr); |
| 3709 |
return false; |
| 3710 |
} |
| 3711 |
|
| 3712 |
link_conf->he_support = link_sta->he_cap.has_he; |
| 3713 |
} |
| 3714 |
|
| 3715 |
return true; |
| 3716 |
} |
| 3717 |
|
| 3718 |
static void iwl_mvm_vif_set_he_support(struct ieee80211_hw *hw, |
| 3719 |
struct ieee80211_vif *vif, |
| 3720 |
struct ieee80211_sta *sta, |
| 3721 |
bool is_sta) |
| 3722 |
{ |
| 3723 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 3724 |
struct ieee80211_link_sta *link_sta; |
| 3725 |
unsigned int link_id; |
| 3726 |
|
| 3727 |
for_each_sta_active_link(vif, sta, link_sta, link_id) { |
| 3728 |
struct ieee80211_bss_conf *link_conf = |
| 3729 |
link_conf_dereference_protected(vif, link_id); |
| 3730 |
|
| 3731 |
if (!link_conf || !mvmvif->link[link_id]) |
| 3732 |
continue; |
| 3733 |
|
| 3734 |
link_conf->he_support = link_sta->he_cap.has_he; |
| 3735 |
|
| 3736 |
if (is_sta) { |
| 3737 |
mvmvif->link[link_id]->he_ru_2mhz_block = false; |
| 3738 |
if (link_sta->he_cap.has_he) |
| 3739 |
iwl_mvm_check_he_obss_narrow_bw_ru(hw, vif, |
| 3740 |
link_id, |
| 3741 |
link_conf); |
| 3742 |
} |
| 3743 |
} |
| 3744 |
} |
| 3745 |
|
| 3746 |
static int |
| 3747 |
iwl_mvm_sta_state_notexist_to_none(struct iwl_mvm *mvm, |
| 3748 |
struct ieee80211_vif *vif, |
| 3749 |
struct ieee80211_sta *sta, |
| 3750 |
const struct iwl_mvm_sta_state_ops *callbacks) |
| 3751 |
{ |
| 3752 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 3753 |
struct ieee80211_link_sta *link_sta; |
| 3754 |
unsigned int i; |
| 3755 |
int ret; |
| 3756 |
|
| 3757 |
lockdep_assert_held(&mvm->mutex); |
| 3758 |
|
| 3759 |
if (vif->type == NL80211_IFTYPE_STATION && |
| 3760 |
!iwl_mvm_vif_conf_from_sta(mvm, vif, sta)) |
| 3761 |
return -EINVAL; |
| 3762 |
|
| 3763 |
if (sta->tdls && |
| 3764 |
(vif->p2p || |
| 3765 |
iwl_mvm_tdls_sta_count(mvm, NULL) == IWL_TDLS_STA_COUNT || |
| 3766 |
iwl_mvm_phy_ctx_count(mvm) > 1)) { |
| 3767 |
IWL_DEBUG_MAC80211(mvm, "refusing TDLS sta\n"); |
| 3768 |
return -EBUSY; |
| 3769 |
} |
| 3770 |
|
| 3771 |
ret = callbacks->add_sta(mvm, vif, sta); |
| 3772 |
if (sta->tdls && ret == 0) { |
| 3773 |
iwl_mvm_recalc_tdls_state(mvm, vif, true); |
| 3774 |
iwl_mvm_tdls_check_trigger(mvm, vif, sta->addr, |
| 3775 |
NL80211_TDLS_SETUP); |
| 3776 |
} |
| 3777 |
|
| 3778 |
if (ret) |
| 3779 |
return ret; |
| 3780 |
|
| 3781 |
for_each_sta_active_link(vif, sta, link_sta, i) |
| 3782 |
link_sta->agg.max_rc_amsdu_len = 1; |
| 3783 |
|
| 3784 |
ieee80211_sta_recalc_aggregates(sta); |
| 3785 |
|
| 3786 |
if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls) |
| 3787 |
mvmvif->ap_sta = sta; |
| 3788 |
|
| 3789 |
/* |
| 3790 |
* Initialize the rates here already - this really tells |
| 3791 |
* the firmware only what the supported legacy rates are |
| 3792 |
* (may be) since it's initialized already from what the |
| 3793 |
* AP advertised in the beacon/probe response. This will |
| 3794 |
* allow the firmware to send auth/assoc frames with one |
| 3795 |
* of the supported rates already, rather than having to |
| 3796 |
* use a mandatory rate. |
| 3797 |
* If we're the AP, we'll just assume mandatory rates at |
| 3798 |
* this point, but we know nothing about the STA anyway. |
| 3799 |
*/ |
| 3800 |
iwl_mvm_rs_rate_init_all_links(mvm, vif, sta); |
| 3801 |
|
| 3802 |
return 0; |
| 3803 |
} |
| 3804 |
|
| 3805 |
static int |
| 3806 |
iwl_mvm_sta_state_auth_to_assoc(struct ieee80211_hw *hw, |
| 3807 |
struct iwl_mvm *mvm, |
| 3808 |
struct ieee80211_vif *vif, |
| 3809 |
struct ieee80211_sta *sta, |
| 3810 |
const struct iwl_mvm_sta_state_ops *callbacks) |
| 3811 |
{ |
| 3812 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 3813 |
struct iwl_mvm_sta *mvm_sta = iwl_mvm_sta_from_mac80211(sta); |
| 3814 |
struct ieee80211_link_sta *link_sta; |
| 3815 |
unsigned int link_id; |
| 3816 |
|
| 3817 |
lockdep_assert_held(&mvm->mutex); |
| 3818 |
|
| 3819 |
if (vif->type == NL80211_IFTYPE_AP) { |
| 3820 |
iwl_mvm_vif_set_he_support(hw, vif, sta, false); |
| 3821 |
mvmvif->ap_assoc_sta_count++; |
| 3822 |
callbacks->mac_ctxt_changed(mvm, vif, false); |
| 3823 |
|
| 3824 |
/* since the below is not for MLD API, it's ok to use |
| 3825 |
* the default bss_conf |
| 3826 |
*/ |
| 3827 |
if (!mvm->mld_api_is_used && |
| 3828 |
(vif->bss_conf.he_support && |
| 3829 |
!iwlwifi_mod_params.disable_11ax)) |
| 3830 |
iwl_mvm_cfg_he_sta(mvm, vif, mvm_sta->deflink.sta_id); |
| 3831 |
} else if (vif->type == NL80211_IFTYPE_STATION) { |
| 3832 |
iwl_mvm_vif_set_he_support(hw, vif, sta, true); |
| 3833 |
|
| 3834 |
callbacks->mac_ctxt_changed(mvm, vif, false); |
| 3835 |
|
| 3836 |
if (!mvm->mld_api_is_used) |
| 3837 |
goto out; |
| 3838 |
|
| 3839 |
for_each_sta_active_link(vif, sta, link_sta, link_id) { |
| 3840 |
struct ieee80211_bss_conf *link_conf = |
| 3841 |
link_conf_dereference_protected(vif, link_id); |
| 3842 |
|
| 3843 |
if (WARN_ON(!link_conf)) |
| 3844 |
return -EINVAL; |
| 3845 |
if (!mvmvif->link[link_id]) |
| 3846 |
continue; |
| 3847 |
|
| 3848 |
iwl_mvm_link_changed(mvm, vif, link_conf, |
| 3849 |
LINK_CONTEXT_MODIFY_ALL & |
| 3850 |
~LINK_CONTEXT_MODIFY_ACTIVE, |
| 3851 |
true); |
| 3852 |
} |
| 3853 |
} |
| 3854 |
|
| 3855 |
out: |
| 3856 |
iwl_mvm_rs_rate_init_all_links(mvm, vif, sta); |
| 3857 |
|
| 3858 |
return callbacks->update_sta(mvm, vif, sta); |
| 3859 |
} |
| 3860 |
|
| 3861 |
static int |
| 3862 |
iwl_mvm_sta_state_assoc_to_authorized(struct iwl_mvm *mvm, |
| 3863 |
struct ieee80211_vif *vif, |
| 3864 |
struct ieee80211_sta *sta, |
| 3865 |
const struct iwl_mvm_sta_state_ops *callbacks) |
| 3866 |
{ |
| 3867 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 3868 |
struct iwl_mvm_sta *mvm_sta = iwl_mvm_sta_from_mac80211(sta); |
| 3869 |
|
| 3870 |
lockdep_assert_held(&mvm->mutex); |
| 3871 |
|
| 3872 |
/* we don't support TDLS during DCM */ |
| 3873 |
if (iwl_mvm_phy_ctx_count(mvm) > 1) |
| 3874 |
iwl_mvm_teardown_tdls_peers(mvm); |
| 3875 |
|
| 3876 |
if (sta->tdls) { |
| 3877 |
iwl_mvm_tdls_check_trigger(mvm, vif, sta->addr, |
| 3878 |
NL80211_TDLS_ENABLE_LINK); |
| 3879 |
} else { |
| 3880 |
/* enable beacon filtering */ |
| 3881 |
WARN_ON(iwl_mvm_enable_beacon_filter(mvm, vif)); |
| 3882 |
|
| 3883 |
mvmvif->authorized = 1; |
| 3884 |
|
| 3885 |
callbacks->mac_ctxt_changed(mvm, vif, false); |
| 3886 |
iwl_mvm_mei_host_associated(mvm, vif, mvm_sta); |
| 3887 |
} |
| 3888 |
|
| 3889 |
mvm_sta->authorized = true; |
| 3890 |
|
| 3891 |
/* MFP is set by default before the station is authorized. |
| 3892 |
* Clear it here in case it's not used. |
| 3893 |
*/ |
| 3894 |
if (!sta->mfp) { |
| 3895 |
int ret = callbacks->update_sta(mvm, vif, sta); |
| 3896 |
|
| 3897 |
if (ret) |
| 3898 |
return ret; |
| 3899 |
} |
| 3900 |
|
| 3901 |
iwl_mvm_rs_rate_init_all_links(mvm, vif, sta); |
| 3902 |
|
| 3903 |
return 0; |
| 3904 |
} |
| 3905 |
|
| 3906 |
static int |
| 3907 |
iwl_mvm_sta_state_authorized_to_assoc(struct iwl_mvm *mvm, |
| 3908 |
struct ieee80211_vif *vif, |
| 3909 |
struct ieee80211_sta *sta, |
| 3910 |
const struct iwl_mvm_sta_state_ops *callbacks) |
| 3911 |
{ |
| 3912 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 3913 |
struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); |
| 3914 |
|
| 3915 |
lockdep_assert_held(&mvm->mutex); |
| 3916 |
|
| 3917 |
mvmsta->authorized = false; |
| 3918 |
|
| 3919 |
/* once we move into assoc state, need to update rate scale to |
| 3920 |
* disable using wide bandwidth |
| 3921 |
*/ |
| 3922 |
iwl_mvm_rs_rate_init_all_links(mvm, vif, sta); |
| 3923 |
|
| 3924 |
if (!sta->tdls) { |
| 3925 |
/* Set this but don't call iwl_mvm_mac_ctxt_changed() |
| 3926 |
* yet to avoid sending high prio again for a little |
| 3927 |
* time. |
| 3928 |
*/ |
| 3929 |
mvmvif->authorized = 0; |
| 3930 |
|
| 3931 |
/* disable beacon filtering */ |
| 3932 |
iwl_mvm_disable_beacon_filter(mvm, vif); |
| 3933 |
} |
| 3934 |
|
| 3935 |
return 0; |
| 3936 |
} |
| 3937 |
|
| 3938 |
void iwl_mvm_smps_workaround(struct iwl_mvm *mvm, struct ieee80211_vif *vif, |
| 3939 |
bool update) |
| 3940 |
{ |
| 3941 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 3942 |
|
| 3943 |
if (!iwl_mvm_has_rlc_offload(mvm) || |
| 3944 |
iwl_fw_lookup_cmd_ver(mvm->fw, MAC_PM_POWER_TABLE, 0) >= 2) |
| 3945 |
return; |
| 3946 |
|
| 3947 |
mvmvif->ps_disabled = !vif->cfg.ps; |
| 3948 |
|
| 3949 |
if (update) |
| 3950 |
iwl_mvm_power_update_mac(mvm); |
| 3951 |
} |
| 3952 |
|
| 3953 |
/* Common part for MLD and non-MLD modes */ |
| 3954 |
int iwl_mvm_mac_sta_state_common(struct ieee80211_hw *hw, |
| 3955 |
struct ieee80211_vif *vif, |
| 3956 |
struct ieee80211_sta *sta, |
| 3957 |
enum ieee80211_sta_state old_state, |
| 3958 |
enum ieee80211_sta_state new_state, |
| 3959 |
const struct iwl_mvm_sta_state_ops *callbacks) |
| 3960 |
{ |
| 3961 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 3962 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 3963 |
struct iwl_mvm_sta *mvm_sta = iwl_mvm_sta_from_mac80211(sta); |
| 3964 |
struct ieee80211_link_sta *link_sta; |
| 3965 |
unsigned int link_id; |
| 3966 |
int ret; |
| 3967 |
|
| 3968 |
IWL_DEBUG_MAC80211(mvm, "station %pM state change %d->%d\n", |
| 3969 |
sta->addr, old_state, new_state); |
| 3970 |
|
| 3971 |
/* |
| 3972 |
* If we are in a STA removal flow and in DQA mode: |
| 3973 |
* |
| 3974 |
* This is after the sync_rcu part, so the queues have already been |
| 3975 |
* flushed. No more TXs on their way in mac80211's path, and no more in |
| 3976 |
* the queues. |
| 3977 |
* Also, we won't be getting any new TX frames for this station. |
| 3978 |
* What we might have are deferred TX frames that need to be taken care |
| 3979 |
* of. |
| 3980 |
* |
| 3981 |
* Drop any still-queued deferred-frame before removing the STA, and |
| 3982 |
* make sure the worker is no longer handling frames for this STA. |
| 3983 |
*/ |
| 3984 |
if (old_state == IEEE80211_STA_NONE && |
| 3985 |
new_state == IEEE80211_STA_NOTEXIST) { |
| 3986 |
flush_work(&mvm->add_stream_wk); |
| 3987 |
|
| 3988 |
/* |
| 3989 |
* No need to make sure deferred TX indication is off since the |
| 3990 |
* worker will already remove it if it was on |
| 3991 |
*/ |
| 3992 |
|
| 3993 |
/* |
| 3994 |
* Additionally, reset the 40 MHz capability if we disconnected |
| 3995 |
* from the AP now. |
| 3996 |
*/ |
| 3997 |
iwl_mvm_reset_cca_40mhz_workaround(mvm, vif); |
| 3998 |
|
| 3999 |
/* Also free dup data just in case any assertions below fail */ |
| 4000 |
kfree(mvm_sta->dup_data); |
| 4001 |
} |
| 4002 |
|
| 4003 |
mutex_lock(&mvm->mutex); |
| 4004 |
|
| 4005 |
/* this would be a mac80211 bug ... but don't crash, unless we had a |
| 4006 |
* firmware crash while we were activating a link, in which case it is |
| 4007 |
* legit to have phy_ctxt = NULL. Don't bother not to WARN if we are in |
| 4008 |
* recovery flow since we spit tons of error messages anyway. |
| 4009 |
*/ |
| 4010 |
for_each_sta_active_link(vif, sta, link_sta, link_id) { |
| 4011 |
if (WARN_ON_ONCE(!mvmvif->link[link_id] || |
| 4012 |
!mvmvif->link[link_id]->phy_ctxt)) { |
| 4013 |
mutex_unlock(&mvm->mutex); |
| 4014 |
return test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, |
| 4015 |
&mvm->status) ? 0 : -EINVAL; |
| 4016 |
} |
| 4017 |
} |
| 4018 |
|
| 4019 |
/* track whether or not the station is associated */ |
| 4020 |
mvm_sta->sta_state = new_state; |
| 4021 |
|
| 4022 |
if (old_state == IEEE80211_STA_NOTEXIST && |
| 4023 |
new_state == IEEE80211_STA_NONE) { |
| 4024 |
ret = iwl_mvm_sta_state_notexist_to_none(mvm, vif, sta, |
| 4025 |
callbacks); |
| 4026 |
if (ret < 0) |
| 4027 |
goto out_unlock; |
| 4028 |
} else if (old_state == IEEE80211_STA_NONE && |
| 4029 |
new_state == IEEE80211_STA_AUTH) { |
| 4030 |
/* |
| 4031 |
* EBS may be disabled due to previous failures reported by FW. |
| 4032 |
* Reset EBS status here assuming environment has been changed. |
| 4033 |
*/ |
| 4034 |
mvm->last_ebs_successful = true; |
| 4035 |
iwl_mvm_check_uapsd(mvm, vif, sta->addr); |
| 4036 |
ret = 0; |
| 4037 |
} else if (old_state == IEEE80211_STA_AUTH && |
| 4038 |
new_state == IEEE80211_STA_ASSOC) { |
| 4039 |
ret = iwl_mvm_sta_state_auth_to_assoc(hw, mvm, vif, sta, |
| 4040 |
callbacks); |
| 4041 |
} else if (old_state == IEEE80211_STA_ASSOC && |
| 4042 |
new_state == IEEE80211_STA_AUTHORIZED) { |
| 4043 |
ret = iwl_mvm_sta_state_assoc_to_authorized(mvm, vif, sta, |
| 4044 |
callbacks); |
| 4045 |
iwl_mvm_smps_workaround(mvm, vif, true); |
| 4046 |
} else if (old_state == IEEE80211_STA_AUTHORIZED && |
| 4047 |
new_state == IEEE80211_STA_ASSOC) { |
| 4048 |
ret = iwl_mvm_sta_state_authorized_to_assoc(mvm, vif, sta, |
| 4049 |
callbacks); |
| 4050 |
} else if (old_state == IEEE80211_STA_ASSOC && |
| 4051 |
new_state == IEEE80211_STA_AUTH) { |
| 4052 |
if (vif->type == NL80211_IFTYPE_AP) { |
| 4053 |
mvmvif->ap_assoc_sta_count--; |
| 4054 |
callbacks->mac_ctxt_changed(mvm, vif, false); |
| 4055 |
} else if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls) |
| 4056 |
iwl_mvm_stop_session_protection(mvm, vif); |
| 4057 |
ret = 0; |
| 4058 |
} else if (old_state == IEEE80211_STA_AUTH && |
| 4059 |
new_state == IEEE80211_STA_NONE) { |
| 4060 |
ret = 0; |
| 4061 |
} else if (old_state == IEEE80211_STA_NONE && |
| 4062 |
new_state == IEEE80211_STA_NOTEXIST) { |
| 4063 |
if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls) { |
| 4064 |
iwl_mvm_stop_session_protection(mvm, vif); |
| 4065 |
mvmvif->ap_sta = NULL; |
| 4066 |
} |
| 4067 |
ret = callbacks->rm_sta(mvm, vif, sta); |
| 4068 |
if (sta->tdls) { |
| 4069 |
iwl_mvm_recalc_tdls_state(mvm, vif, false); |
| 4070 |
iwl_mvm_tdls_check_trigger(mvm, vif, sta->addr, |
| 4071 |
NL80211_TDLS_DISABLE_LINK); |
| 4072 |
} |
| 4073 |
|
| 4074 |
if (unlikely(ret && |
| 4075 |
test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, |
| 4076 |
&mvm->status))) |
| 4077 |
ret = 0; |
| 4078 |
} else { |
| 4079 |
ret = -EIO; |
| 4080 |
} |
| 4081 |
out_unlock: |
| 4082 |
mutex_unlock(&mvm->mutex); |
| 4083 |
|
| 4084 |
if (sta->tdls && ret == 0) { |
| 4085 |
if (old_state == IEEE80211_STA_NOTEXIST && |
| 4086 |
new_state == IEEE80211_STA_NONE) |
| 4087 |
ieee80211_reserve_tid(sta, IWL_MVM_TDLS_FW_TID); |
| 4088 |
else if (old_state == IEEE80211_STA_NONE && |
| 4089 |
new_state == IEEE80211_STA_NOTEXIST) |
| 4090 |
ieee80211_unreserve_tid(sta, IWL_MVM_TDLS_FW_TID); |
| 4091 |
} |
| 4092 |
|
| 4093 |
return ret; |
| 4094 |
} |
| 4095 |
|
| 4096 |
int iwl_mvm_mac_set_rts_threshold(struct ieee80211_hw *hw, int radio_idx, |
| 4097 |
u32 value) |
| 4098 |
{ |
| 4099 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 4100 |
|
| 4101 |
mvm->rts_threshold = value; |
| 4102 |
|
| 4103 |
return 0; |
| 4104 |
} |
| 4105 |
|
| 4106 |
void iwl_mvm_sta_rc_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 4107 |
struct ieee80211_link_sta *link_sta, u32 changed) |
| 4108 |
{ |
| 4109 |
struct ieee80211_sta *sta = link_sta->sta; |
| 4110 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 4111 |
|
| 4112 |
if (changed & (IEEE80211_RC_BW_CHANGED | |
| 4113 |
IEEE80211_RC_SUPP_RATES_CHANGED | |
| 4114 |
IEEE80211_RC_NSS_CHANGED)) |
| 4115 |
iwl_mvm_rs_rate_init_all_links(mvm, vif, sta); |
| 4116 |
|
| 4117 |
if (vif->type == NL80211_IFTYPE_STATION && |
| 4118 |
changed & IEEE80211_RC_NSS_CHANGED) |
| 4119 |
iwl_mvm_sf_update(mvm, vif, false); |
| 4120 |
} |
| 4121 |
|
| 4122 |
static int iwl_mvm_mac_conf_tx(struct ieee80211_hw *hw, |
| 4123 |
struct ieee80211_vif *vif, |
| 4124 |
unsigned int link_id, u16 ac, |
| 4125 |
const struct ieee80211_tx_queue_params *params) |
| 4126 |
{ |
| 4127 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 4128 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 4129 |
|
| 4130 |
mvmvif->deflink.queue_params[ac] = *params; |
| 4131 |
|
| 4132 |
/* |
| 4133 |
* No need to update right away, we'll get BSS_CHANGED_QOS |
| 4134 |
* The exception is P2P_DEVICE interface which needs immediate update. |
| 4135 |
*/ |
| 4136 |
if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { |
| 4137 |
guard(mvm)(mvm); |
| 4138 |
return iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL); |
| 4139 |
} |
| 4140 |
return 0; |
| 4141 |
} |
| 4142 |
|
| 4143 |
void iwl_mvm_mac_mgd_prepare_tx(struct ieee80211_hw *hw, |
| 4144 |
struct ieee80211_vif *vif, |
| 4145 |
struct ieee80211_prep_tx_info *info) |
| 4146 |
{ |
| 4147 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 4148 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 4149 |
|
| 4150 |
if (info->was_assoc && !mvmvif->session_prot_connection_loss) |
| 4151 |
return; |
| 4152 |
|
| 4153 |
guard(mvm)(mvm); |
| 4154 |
iwl_mvm_protect_assoc(mvm, vif, info->duration); |
| 4155 |
} |
| 4156 |
|
| 4157 |
void iwl_mvm_mac_mgd_complete_tx(struct ieee80211_hw *hw, |
| 4158 |
struct ieee80211_vif *vif, |
| 4159 |
struct ieee80211_prep_tx_info *info) |
| 4160 |
{ |
| 4161 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 4162 |
|
| 4163 |
/* for successful cases (auth/assoc), don't cancel session protection */ |
| 4164 |
if (info->success) |
| 4165 |
return; |
| 4166 |
|
| 4167 |
guard(mvm)(mvm); |
| 4168 |
iwl_mvm_stop_session_protection(mvm, vif); |
| 4169 |
} |
| 4170 |
|
| 4171 |
int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw *hw, |
| 4172 |
struct ieee80211_vif *vif, |
| 4173 |
struct cfg80211_sched_scan_request *req, |
| 4174 |
struct ieee80211_scan_ies *ies) |
| 4175 |
{ |
| 4176 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 4177 |
|
| 4178 |
guard(mvm)(mvm); |
| 4179 |
|
| 4180 |
if (!vif->cfg.idle) |
| 4181 |
return -EBUSY; |
| 4182 |
|
| 4183 |
return iwl_mvm_sched_scan_start(mvm, vif, req, ies, IWL_MVM_SCAN_SCHED); |
| 4184 |
} |
| 4185 |
|
| 4186 |
int iwl_mvm_mac_sched_scan_stop(struct ieee80211_hw *hw, |
| 4187 |
struct ieee80211_vif *vif) |
| 4188 |
{ |
| 4189 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 4190 |
int ret; |
| 4191 |
|
| 4192 |
mutex_lock(&mvm->mutex); |
| 4193 |
|
| 4194 |
/* Due to a race condition, it's possible that mac80211 asks |
| 4195 |
* us to stop a sched_scan when it's already stopped. This |
| 4196 |
* can happen, for instance, if we stopped the scan ourselves, |
| 4197 |
* called ieee80211_sched_scan_stopped() and the userspace called |
| 4198 |
* stop sched scan before ieee80211_sched_scan_stopped_work() |
| 4199 |
* could run. To handle this, simply return if the scan is |
| 4200 |
* not running. |
| 4201 |
*/ |
| 4202 |
if (!(mvm->scan_status & IWL_MVM_SCAN_SCHED)) { |
| 4203 |
mutex_unlock(&mvm->mutex); |
| 4204 |
return 0; |
| 4205 |
} |
| 4206 |
|
| 4207 |
ret = iwl_mvm_scan_stop(mvm, IWL_MVM_SCAN_SCHED, false); |
| 4208 |
mutex_unlock(&mvm->mutex); |
| 4209 |
iwl_mvm_wait_for_async_handlers(mvm); |
| 4210 |
|
| 4211 |
return ret; |
| 4212 |
} |
| 4213 |
|
| 4214 |
static int __iwl_mvm_mac_set_key(struct ieee80211_hw *hw, |
| 4215 |
enum set_key_cmd cmd, |
| 4216 |
struct ieee80211_vif *vif, |
| 4217 |
struct ieee80211_sta *sta, |
| 4218 |
struct ieee80211_key_conf *key) |
| 4219 |
{ |
| 4220 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 4221 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 4222 |
struct iwl_mvm_sta *mvmsta = NULL; |
| 4223 |
struct iwl_mvm_key_pn *ptk_pn = NULL; |
| 4224 |
int keyidx = key->keyidx; |
| 4225 |
u32 sec_key_id = WIDE_ID(DATA_PATH_GROUP, SEC_KEY_CMD); |
| 4226 |
u8 sec_key_ver = iwl_fw_lookup_cmd_ver(mvm->fw, sec_key_id, 0); |
| 4227 |
int ret, i; |
| 4228 |
u8 key_offset; |
| 4229 |
|
| 4230 |
if (sta) |
| 4231 |
mvmsta = iwl_mvm_sta_from_mac80211(sta); |
| 4232 |
|
| 4233 |
switch (key->cipher) { |
| 4234 |
case WLAN_CIPHER_SUITE_TKIP: |
| 4235 |
if (!mvm->trans->mac_cfg->gen2) { |
| 4236 |
key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; |
| 4237 |
key->flags |= IEEE80211_KEY_FLAG_PUT_IV_SPACE; |
| 4238 |
} else if (vif->type == NL80211_IFTYPE_STATION) { |
| 4239 |
key->flags |= IEEE80211_KEY_FLAG_PUT_MIC_SPACE; |
| 4240 |
} else { |
| 4241 |
IWL_DEBUG_MAC80211(mvm, "Use SW encryption for TKIP\n"); |
| 4242 |
return -EOPNOTSUPP; |
| 4243 |
} |
| 4244 |
break; |
| 4245 |
case WLAN_CIPHER_SUITE_CCMP: |
| 4246 |
case WLAN_CIPHER_SUITE_GCMP: |
| 4247 |
case WLAN_CIPHER_SUITE_GCMP_256: |
| 4248 |
if (!iwl_mvm_has_new_tx_api(mvm)) |
| 4249 |
key->flags |= IEEE80211_KEY_FLAG_PUT_IV_SPACE; |
| 4250 |
break; |
| 4251 |
case WLAN_CIPHER_SUITE_AES_CMAC: |
| 4252 |
case WLAN_CIPHER_SUITE_BIP_GMAC_128: |
| 4253 |
case WLAN_CIPHER_SUITE_BIP_GMAC_256: |
| 4254 |
WARN_ON_ONCE(!ieee80211_hw_check(hw, MFP_CAPABLE)); |
| 4255 |
break; |
| 4256 |
case WLAN_CIPHER_SUITE_WEP40: |
| 4257 |
case WLAN_CIPHER_SUITE_WEP104: |
| 4258 |
if (vif->type == NL80211_IFTYPE_STATION) |
| 4259 |
break; |
| 4260 |
if (iwl_mvm_has_new_tx_api(mvm)) |
| 4261 |
return -EOPNOTSUPP; |
| 4262 |
/* support HW crypto on TX */ |
| 4263 |
return 0; |
| 4264 |
default: |
| 4265 |
return -EOPNOTSUPP; |
| 4266 |
} |
| 4267 |
|
| 4268 |
switch (cmd) { |
| 4269 |
case SET_KEY: |
| 4270 |
if (vif->type == NL80211_IFTYPE_STATION && |
| 4271 |
(keyidx == 6 || keyidx == 7)) |
| 4272 |
rcu_assign_pointer(mvmvif->bcn_prot.keys[keyidx - 6], |
| 4273 |
key); |
| 4274 |
|
| 4275 |
if ((vif->type == NL80211_IFTYPE_ADHOC || |
| 4276 |
vif->type == NL80211_IFTYPE_AP) && !sta) { |
| 4277 |
/* |
| 4278 |
* GTK on AP interface is a TX-only key, return 0; |
| 4279 |
* on IBSS they're per-station and because we're lazy |
| 4280 |
* we don't support them for RX, so do the same. |
| 4281 |
* CMAC/GMAC in AP/IBSS modes must be done in software |
| 4282 |
* on older NICs. |
| 4283 |
* |
| 4284 |
* Except, of course, beacon protection - it must be |
| 4285 |
* offloaded since we just set a beacon template, and |
| 4286 |
* then we must also offload the IGTK (not just BIGTK) |
| 4287 |
* for firmware reasons. |
| 4288 |
* |
| 4289 |
* So just check for beacon protection - if we don't |
| 4290 |
* have it we cannot get here with keyidx >= 6, and |
| 4291 |
* if we do have it we need to send the key to FW in |
| 4292 |
* all cases (CMAC/GMAC). |
| 4293 |
*/ |
| 4294 |
if (!wiphy_ext_feature_isset(hw->wiphy, |
| 4295 |
NL80211_EXT_FEATURE_BEACON_PROTECTION) && |
| 4296 |
(key->cipher == WLAN_CIPHER_SUITE_AES_CMAC || |
| 4297 |
key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_128 || |
| 4298 |
key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_256)) { |
| 4299 |
ret = -EOPNOTSUPP; |
| 4300 |
break; |
| 4301 |
} |
| 4302 |
|
| 4303 |
if (key->cipher != WLAN_CIPHER_SUITE_GCMP && |
| 4304 |
key->cipher != WLAN_CIPHER_SUITE_GCMP_256 && |
| 4305 |
!iwl_mvm_has_new_tx_api(mvm)) { |
| 4306 |
key->hw_key_idx = STA_KEY_IDX_INVALID; |
| 4307 |
ret = 0; |
| 4308 |
break; |
| 4309 |
} |
| 4310 |
|
| 4311 |
if (!mvmvif->ap_ibss_active) { |
| 4312 |
for (i = 0; |
| 4313 |
i < ARRAY_SIZE(mvmvif->ap_early_keys); |
| 4314 |
i++) { |
| 4315 |
if (!mvmvif->ap_early_keys[i]) { |
| 4316 |
mvmvif->ap_early_keys[i] = key; |
| 4317 |
break; |
| 4318 |
} |
| 4319 |
} |
| 4320 |
|
| 4321 |
if (i >= ARRAY_SIZE(mvmvif->ap_early_keys)) |
| 4322 |
ret = -ENOSPC; |
| 4323 |
else |
| 4324 |
ret = 0; |
| 4325 |
|
| 4326 |
break; |
| 4327 |
} |
| 4328 |
} |
| 4329 |
|
| 4330 |
/* During FW restart, in order to restore the state as it was, |
| 4331 |
* don't try to reprogram keys we previously failed for. |
| 4332 |
*/ |
| 4333 |
if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) && |
| 4334 |
key->hw_key_idx == STA_KEY_IDX_INVALID) { |
| 4335 |
IWL_DEBUG_MAC80211(mvm, |
| 4336 |
"skip invalid idx key programming during restart\n"); |
| 4337 |
ret = 0; |
| 4338 |
break; |
| 4339 |
} |
| 4340 |
|
| 4341 |
if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) && |
| 4342 |
mvmsta && iwl_mvm_has_new_rx_api(mvm) && |
| 4343 |
key->flags & IEEE80211_KEY_FLAG_PAIRWISE && |
| 4344 |
(key->cipher == WLAN_CIPHER_SUITE_CCMP || |
| 4345 |
key->cipher == WLAN_CIPHER_SUITE_GCMP || |
| 4346 |
key->cipher == WLAN_CIPHER_SUITE_GCMP_256)) { |
| 4347 |
struct ieee80211_key_seq seq; |
| 4348 |
int tid, q; |
| 4349 |
|
| 4350 |
WARN_ON(rcu_access_pointer(mvmsta->ptk_pn[keyidx])); |
| 4351 |
ptk_pn = kzalloc_flex(*ptk_pn, q, |
| 4352 |
mvm->trans->info.num_rxqs); |
| 4353 |
if (!ptk_pn) { |
| 4354 |
ret = -ENOMEM; |
| 4355 |
break; |
| 4356 |
} |
| 4357 |
|
| 4358 |
for (tid = 0; tid < IWL_MAX_TID_COUNT; tid++) { |
| 4359 |
ieee80211_get_key_rx_seq(key, tid, &seq); |
| 4360 |
for (q = 0; q < mvm->trans->info.num_rxqs; q++) |
| 4361 |
memcpy(ptk_pn->q[q].pn[tid], |
| 4362 |
seq.ccmp.pn, |
| 4363 |
IEEE80211_CCMP_PN_LEN); |
| 4364 |
} |
| 4365 |
|
| 4366 |
rcu_assign_pointer(mvmsta->ptk_pn[keyidx], ptk_pn); |
| 4367 |
} |
| 4368 |
|
| 4369 |
/* in HW restart reuse the index, otherwise request a new one */ |
| 4370 |
if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) |
| 4371 |
key_offset = key->hw_key_idx; |
| 4372 |
else |
| 4373 |
key_offset = STA_KEY_IDX_INVALID; |
| 4374 |
|
| 4375 |
if (mvmsta && key->flags & IEEE80211_KEY_FLAG_PAIRWISE) |
| 4376 |
mvmsta->pairwise_cipher = key->cipher; |
| 4377 |
|
| 4378 |
IWL_DEBUG_MAC80211(mvm, "set hwcrypto key (sta:%pM, id:%d)\n", |
| 4379 |
sta ? sta->addr : NULL, key->keyidx); |
| 4380 |
|
| 4381 |
if (sec_key_ver) |
| 4382 |
ret = iwl_mvm_sec_key_add(mvm, vif, sta, key); |
| 4383 |
else |
| 4384 |
ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, key_offset); |
| 4385 |
|
| 4386 |
if (ret) { |
| 4387 |
IWL_WARN(mvm, "set key failed\n"); |
| 4388 |
key->hw_key_idx = STA_KEY_IDX_INVALID; |
| 4389 |
if (ptk_pn) { |
| 4390 |
RCU_INIT_POINTER(mvmsta->ptk_pn[keyidx], NULL); |
| 4391 |
kfree(ptk_pn); |
| 4392 |
} |
| 4393 |
/* |
| 4394 |
* can't add key for RX, but we don't need it |
| 4395 |
* in the device for TX so still return 0, |
| 4396 |
* unless we have new TX API where we cannot |
| 4397 |
* put key material into the TX_CMD |
| 4398 |
*/ |
| 4399 |
if (iwl_mvm_has_new_tx_api(mvm)) |
| 4400 |
ret = -EOPNOTSUPP; |
| 4401 |
else |
| 4402 |
ret = 0; |
| 4403 |
} |
| 4404 |
|
| 4405 |
break; |
| 4406 |
case DISABLE_KEY: |
| 4407 |
if (vif->type == NL80211_IFTYPE_STATION && |
| 4408 |
(keyidx == 6 || keyidx == 7)) |
| 4409 |
RCU_INIT_POINTER(mvmvif->bcn_prot.keys[keyidx - 6], |
| 4410 |
NULL); |
| 4411 |
|
| 4412 |
ret = -ENOENT; |
| 4413 |
for (i = 0; i < ARRAY_SIZE(mvmvif->ap_early_keys); i++) { |
| 4414 |
if (mvmvif->ap_early_keys[i] == key) { |
| 4415 |
mvmvif->ap_early_keys[i] = NULL; |
| 4416 |
ret = 0; |
| 4417 |
} |
| 4418 |
} |
| 4419 |
|
| 4420 |
/* found in pending list - don't do anything else */ |
| 4421 |
if (ret == 0) |
| 4422 |
break; |
| 4423 |
|
| 4424 |
if (key->hw_key_idx == STA_KEY_IDX_INVALID) { |
| 4425 |
ret = 0; |
| 4426 |
break; |
| 4427 |
} |
| 4428 |
|
| 4429 |
if (mvmsta && iwl_mvm_has_new_rx_api(mvm) && |
| 4430 |
key->flags & IEEE80211_KEY_FLAG_PAIRWISE && |
| 4431 |
(key->cipher == WLAN_CIPHER_SUITE_CCMP || |
| 4432 |
key->cipher == WLAN_CIPHER_SUITE_GCMP || |
| 4433 |
key->cipher == WLAN_CIPHER_SUITE_GCMP_256)) { |
| 4434 |
ptk_pn = rcu_dereference_protected( |
| 4435 |
mvmsta->ptk_pn[keyidx], |
| 4436 |
lockdep_is_held(&mvm->mutex)); |
| 4437 |
RCU_INIT_POINTER(mvmsta->ptk_pn[keyidx], NULL); |
| 4438 |
if (ptk_pn) |
| 4439 |
kfree_rcu(ptk_pn, rcu_head); |
| 4440 |
} |
| 4441 |
|
| 4442 |
IWL_DEBUG_MAC80211(mvm, "disable hwcrypto key\n"); |
| 4443 |
if (sec_key_ver) |
| 4444 |
ret = iwl_mvm_sec_key_del(mvm, vif, sta, key); |
| 4445 |
else |
| 4446 |
ret = iwl_mvm_remove_sta_key(mvm, vif, sta, key); |
| 4447 |
break; |
| 4448 |
default: |
| 4449 |
ret = -EINVAL; |
| 4450 |
} |
| 4451 |
|
| 4452 |
return ret; |
| 4453 |
} |
| 4454 |
|
| 4455 |
int iwl_mvm_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, |
| 4456 |
struct ieee80211_vif *vif, struct ieee80211_sta *sta, |
| 4457 |
struct ieee80211_key_conf *key) |
| 4458 |
{ |
| 4459 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 4460 |
|
| 4461 |
/* When resuming from wowlan, FW already knows about the newest keys */ |
| 4462 |
if (test_bit(IWL_MVM_STATUS_IN_D3, &mvm->status)) |
| 4463 |
return 0; |
| 4464 |
|
| 4465 |
guard(mvm)(mvm); |
| 4466 |
return __iwl_mvm_mac_set_key(hw, cmd, vif, sta, key); |
| 4467 |
} |
| 4468 |
|
| 4469 |
void iwl_mvm_mac_update_tkip_key(struct ieee80211_hw *hw, |
| 4470 |
struct ieee80211_vif *vif, |
| 4471 |
struct ieee80211_key_conf *keyconf, |
| 4472 |
struct ieee80211_sta *sta, |
| 4473 |
u32 iv32, u16 *phase1key) |
| 4474 |
{ |
| 4475 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 4476 |
|
| 4477 |
if (keyconf->hw_key_idx == STA_KEY_IDX_INVALID) |
| 4478 |
return; |
| 4479 |
|
| 4480 |
iwl_mvm_update_tkip_key(mvm, vif, keyconf, sta, iv32, phase1key); |
| 4481 |
} |
| 4482 |
|
| 4483 |
|
| 4484 |
static bool iwl_mvm_rx_aux_roc(struct iwl_notif_wait_data *notif_wait, |
| 4485 |
struct iwl_rx_packet *pkt, void *data) |
| 4486 |
{ |
| 4487 |
struct iwl_mvm *mvm = |
| 4488 |
container_of(notif_wait, struct iwl_mvm, notif_wait); |
| 4489 |
struct iwl_hs20_roc_res *resp; |
| 4490 |
int resp_len = iwl_rx_packet_payload_len(pkt); |
| 4491 |
struct iwl_mvm_time_event_data *te_data = data; |
| 4492 |
|
| 4493 |
if (WARN_ON(pkt->hdr.cmd != HOT_SPOT_CMD)) |
| 4494 |
return true; |
| 4495 |
|
| 4496 |
if (WARN_ON_ONCE(resp_len != sizeof(*resp))) { |
| 4497 |
IWL_ERR(mvm, "Invalid HOT_SPOT_CMD response\n"); |
| 4498 |
return true; |
| 4499 |
} |
| 4500 |
|
| 4501 |
resp = (void *)pkt->data; |
| 4502 |
|
| 4503 |
IWL_DEBUG_TE(mvm, |
| 4504 |
"Aux ROC: Received response from ucode: status=%d uid=%d\n", |
| 4505 |
resp->status, resp->event_unique_id); |
| 4506 |
|
| 4507 |
te_data->uid = le32_to_cpu(resp->event_unique_id); |
| 4508 |
IWL_DEBUG_TE(mvm, "TIME_EVENT_CMD response - UID = 0x%x\n", |
| 4509 |
te_data->uid); |
| 4510 |
|
| 4511 |
spin_lock_bh(&mvm->time_event_lock); |
| 4512 |
list_add_tail(&te_data->list, &mvm->aux_roc_te_list); |
| 4513 |
spin_unlock_bh(&mvm->time_event_lock); |
| 4514 |
|
| 4515 |
return true; |
| 4516 |
} |
| 4517 |
|
| 4518 |
static int iwl_mvm_send_aux_roc_cmd(struct iwl_mvm *mvm, |
| 4519 |
struct ieee80211_channel *channel, |
| 4520 |
struct ieee80211_vif *vif, |
| 4521 |
int duration) |
| 4522 |
{ |
| 4523 |
int res; |
| 4524 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 4525 |
struct iwl_mvm_time_event_data *te_data = &mvmvif->hs_time_event_data; |
| 4526 |
static const u16 time_event_response[] = { HOT_SPOT_CMD }; |
| 4527 |
struct iwl_notification_wait wait_time_event; |
| 4528 |
u32 req_dur, delay; |
| 4529 |
struct iwl_hs20_roc_req aux_roc_req = { |
| 4530 |
.action = cpu_to_le32(FW_CTXT_ACTION_ADD), |
| 4531 |
.id_and_color = |
| 4532 |
cpu_to_le32(FW_CMD_ID_AND_COLOR(MAC_INDEX_AUX, 0)), |
| 4533 |
.sta_id_and_color = cpu_to_le32(mvm->aux_sta.sta_id), |
| 4534 |
}; |
| 4535 |
struct iwl_hs20_roc_req_tail *tail = iwl_mvm_chan_info_cmd_tail(mvm, |
| 4536 |
&aux_roc_req.channel_info); |
| 4537 |
u16 len = sizeof(aux_roc_req) - iwl_mvm_chan_info_padding(mvm); |
| 4538 |
|
| 4539 |
/* Set the channel info data */ |
| 4540 |
iwl_mvm_set_chan_info(mvm, &aux_roc_req.channel_info, channel->hw_value, |
| 4541 |
iwl_mvm_phy_band_from_nl80211(channel->band), |
| 4542 |
IWL_PHY_CHANNEL_MODE20, |
| 4543 |
0); |
| 4544 |
|
| 4545 |
/* Set the time and duration */ |
| 4546 |
tail->apply_time = cpu_to_le32(iwl_mvm_get_systime(mvm)); |
| 4547 |
|
| 4548 |
iwl_mvm_roc_duration_and_delay(vif, duration, &req_dur, &delay); |
| 4549 |
tail->duration = cpu_to_le32(req_dur); |
| 4550 |
tail->apply_time_max_delay = cpu_to_le32(delay); |
| 4551 |
|
| 4552 |
IWL_DEBUG_TE(mvm, |
| 4553 |
"ROC: Requesting to remain on channel %u for %ums\n", |
| 4554 |
channel->hw_value, req_dur); |
| 4555 |
IWL_DEBUG_TE(mvm, |
| 4556 |
"\t(requested = %ums, max_delay = %ums)\n", |
| 4557 |
duration, delay); |
| 4558 |
|
| 4559 |
/* Set the node address */ |
| 4560 |
memcpy(tail->node_addr, vif->addr, ETH_ALEN); |
| 4561 |
|
| 4562 |
lockdep_assert_held(&mvm->mutex); |
| 4563 |
|
| 4564 |
spin_lock_bh(&mvm->time_event_lock); |
| 4565 |
|
| 4566 |
if (WARN_ON(te_data->id == HOT_SPOT_CMD)) { |
| 4567 |
spin_unlock_bh(&mvm->time_event_lock); |
| 4568 |
return -EIO; |
| 4569 |
} |
| 4570 |
|
| 4571 |
te_data->vif = vif; |
| 4572 |
te_data->duration = duration; |
| 4573 |
te_data->id = HOT_SPOT_CMD; |
| 4574 |
|
| 4575 |
spin_unlock_bh(&mvm->time_event_lock); |
| 4576 |
|
| 4577 |
/* |
| 4578 |
* Use a notification wait, which really just processes the |
| 4579 |
* command response and doesn't wait for anything, in order |
| 4580 |
* to be able to process the response and get the UID inside |
| 4581 |
* the RX path. Using CMD_WANT_SKB doesn't work because it |
| 4582 |
* stores the buffer and then wakes up this thread, by which |
| 4583 |
* time another notification (that the time event started) |
| 4584 |
* might already be processed unsuccessfully. |
| 4585 |
*/ |
| 4586 |
iwl_init_notification_wait(&mvm->notif_wait, &wait_time_event, |
| 4587 |
time_event_response, |
| 4588 |
ARRAY_SIZE(time_event_response), |
| 4589 |
iwl_mvm_rx_aux_roc, te_data); |
| 4590 |
|
| 4591 |
res = iwl_mvm_send_cmd_pdu(mvm, HOT_SPOT_CMD, 0, len, |
| 4592 |
&aux_roc_req); |
| 4593 |
|
| 4594 |
if (res) { |
| 4595 |
IWL_ERR(mvm, "Couldn't send HOT_SPOT_CMD: %d\n", res); |
| 4596 |
iwl_remove_notification(&mvm->notif_wait, &wait_time_event); |
| 4597 |
goto out_clear_te; |
| 4598 |
} |
| 4599 |
|
| 4600 |
/* No need to wait for anything, so just pass 1 (0 isn't valid) */ |
| 4601 |
res = iwl_wait_notification(&mvm->notif_wait, &wait_time_event, 1); |
| 4602 |
/* should never fail */ |
| 4603 |
WARN_ON_ONCE(res); |
| 4604 |
|
| 4605 |
if (res) { |
| 4606 |
out_clear_te: |
| 4607 |
spin_lock_bh(&mvm->time_event_lock); |
| 4608 |
iwl_mvm_te_clear_data(mvm, te_data); |
| 4609 |
spin_unlock_bh(&mvm->time_event_lock); |
| 4610 |
} |
| 4611 |
|
| 4612 |
return res; |
| 4613 |
} |
| 4614 |
|
| 4615 |
static int iwl_mvm_add_aux_sta_for_hs20(struct iwl_mvm *mvm, u32 lmac_id) |
| 4616 |
{ |
| 4617 |
int ret = 0; |
| 4618 |
|
| 4619 |
lockdep_assert_held(&mvm->mutex); |
| 4620 |
|
| 4621 |
if (!fw_has_capa(&mvm->fw->ucode_capa, |
| 4622 |
IWL_UCODE_TLV_CAPA_HOTSPOT_SUPPORT)) { |
| 4623 |
IWL_ERR(mvm, "hotspot not supported\n"); |
| 4624 |
return -EINVAL; |
| 4625 |
} |
| 4626 |
|
| 4627 |
if (iwl_mvm_has_new_station_api(mvm->fw)) { |
| 4628 |
ret = iwl_mvm_add_aux_sta(mvm, lmac_id); |
| 4629 |
WARN(ret, "Failed to allocate aux station"); |
| 4630 |
} |
| 4631 |
|
| 4632 |
return ret; |
| 4633 |
} |
| 4634 |
|
| 4635 |
static int iwl_mvm_roc_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif) |
| 4636 |
{ |
| 4637 |
int ret; |
| 4638 |
|
| 4639 |
lockdep_assert_held(&mvm->mutex); |
| 4640 |
|
| 4641 |
ret = iwl_mvm_binding_add_vif(mvm, vif); |
| 4642 |
if (WARN(ret, "Failed binding P2P_DEVICE\n")) |
| 4643 |
return ret; |
| 4644 |
|
| 4645 |
/* The station and queue allocation must be done only after the binding |
| 4646 |
* is done, as otherwise the FW might incorrectly configure its state. |
| 4647 |
*/ |
| 4648 |
return iwl_mvm_add_p2p_bcast_sta(mvm, vif); |
| 4649 |
} |
| 4650 |
|
| 4651 |
static int iwl_mvm_roc(struct ieee80211_hw *hw, |
| 4652 |
struct ieee80211_vif *vif, |
| 4653 |
struct ieee80211_channel *channel, |
| 4654 |
int duration, |
| 4655 |
enum ieee80211_roc_type type) |
| 4656 |
{ |
| 4657 |
static const struct iwl_mvm_roc_ops ops = { |
| 4658 |
.add_aux_sta_for_hs20 = iwl_mvm_add_aux_sta_for_hs20, |
| 4659 |
.link = iwl_mvm_roc_link, |
| 4660 |
}; |
| 4661 |
|
| 4662 |
return iwl_mvm_roc_common(hw, vif, channel, duration, type, &ops); |
| 4663 |
} |
| 4664 |
|
| 4665 |
static int iwl_mvm_roc_station(struct iwl_mvm *mvm, |
| 4666 |
struct ieee80211_channel *channel, |
| 4667 |
struct ieee80211_vif *vif, |
| 4668 |
int duration) |
| 4669 |
{ |
| 4670 |
int ret; |
| 4671 |
u32 cmd_id = WIDE_ID(MAC_CONF_GROUP, ROC_CMD); |
| 4672 |
u8 fw_ver = iwl_fw_lookup_cmd_ver(mvm->fw, cmd_id, |
| 4673 |
IWL_FW_CMD_VER_UNKNOWN); |
| 4674 |
|
| 4675 |
if (fw_ver == IWL_FW_CMD_VER_UNKNOWN) { |
| 4676 |
ret = iwl_mvm_send_aux_roc_cmd(mvm, channel, vif, duration); |
| 4677 |
} else if (fw_ver >= 3) { |
| 4678 |
ret = iwl_mvm_roc_add_cmd(mvm, channel, vif, duration, |
| 4679 |
ROC_ACTIVITY_HOTSPOT); |
| 4680 |
} else { |
| 4681 |
ret = -EOPNOTSUPP; |
| 4682 |
IWL_ERR(mvm, "ROC command version %d mismatch!\n", fw_ver); |
| 4683 |
} |
| 4684 |
|
| 4685 |
return ret; |
| 4686 |
} |
| 4687 |
|
| 4688 |
static int iwl_mvm_roc_p2p(struct iwl_mvm *mvm, |
| 4689 |
struct ieee80211_channel *channel, |
| 4690 |
struct ieee80211_vif *vif, |
| 4691 |
int duration, |
| 4692 |
enum ieee80211_roc_type type) |
| 4693 |
{ |
| 4694 |
enum iwl_roc_activity activity; |
| 4695 |
int ret; |
| 4696 |
|
| 4697 |
lockdep_assert_held(&mvm->mutex); |
| 4698 |
|
| 4699 |
switch (type) { |
| 4700 |
case IEEE80211_ROC_TYPE_NORMAL: |
| 4701 |
activity = ROC_ACTIVITY_P2P_DISC; |
| 4702 |
break; |
| 4703 |
case IEEE80211_ROC_TYPE_MGMT_TX: |
| 4704 |
activity = ROC_ACTIVITY_P2P_NEG; |
| 4705 |
break; |
| 4706 |
default: |
| 4707 |
WARN_ONCE(1, "Got an invalid P2P ROC type\n"); |
| 4708 |
return -EINVAL; |
| 4709 |
} |
| 4710 |
|
| 4711 |
ret = iwl_mvm_mld_add_aux_sta(mvm, |
| 4712 |
iwl_mvm_get_lmac_id(mvm, channel->band)); |
| 4713 |
if (ret) |
| 4714 |
return ret; |
| 4715 |
|
| 4716 |
return iwl_mvm_roc_add_cmd(mvm, channel, vif, duration, activity); |
| 4717 |
} |
| 4718 |
|
| 4719 |
static int iwl_mvm_p2p_find_phy_ctxt(struct iwl_mvm *mvm, |
| 4720 |
struct ieee80211_vif *vif, |
| 4721 |
struct ieee80211_channel *channel) |
| 4722 |
{ |
| 4723 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 4724 |
struct cfg80211_chan_def chandef; |
| 4725 |
int i; |
| 4726 |
|
| 4727 |
lockdep_assert_held(&mvm->mutex); |
| 4728 |
|
| 4729 |
if (mvmvif->deflink.phy_ctxt && |
| 4730 |
channel == mvmvif->deflink.phy_ctxt->channel) |
| 4731 |
return 0; |
| 4732 |
|
| 4733 |
/* Try using a PHY context that is already in use */ |
| 4734 |
for (i = 0; i < NUM_PHY_CTX; i++) { |
| 4735 |
struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[i]; |
| 4736 |
|
| 4737 |
if (!phy_ctxt->ref || mvmvif->deflink.phy_ctxt == phy_ctxt) |
| 4738 |
continue; |
| 4739 |
|
| 4740 |
if (channel == phy_ctxt->channel) { |
| 4741 |
if (mvmvif->deflink.phy_ctxt) |
| 4742 |
iwl_mvm_phy_ctxt_unref(mvm, |
| 4743 |
mvmvif->deflink.phy_ctxt); |
| 4744 |
|
| 4745 |
mvmvif->deflink.phy_ctxt = phy_ctxt; |
| 4746 |
iwl_mvm_phy_ctxt_ref(mvm, mvmvif->deflink.phy_ctxt); |
| 4747 |
return 0; |
| 4748 |
} |
| 4749 |
} |
| 4750 |
|
| 4751 |
/* We already have a phy_ctxt, but it's not on the right channel */ |
| 4752 |
if (mvmvif->deflink.phy_ctxt) |
| 4753 |
iwl_mvm_phy_ctxt_unref(mvm, mvmvif->deflink.phy_ctxt); |
| 4754 |
|
| 4755 |
mvmvif->deflink.phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); |
| 4756 |
if (!mvmvif->deflink.phy_ctxt) |
| 4757 |
return -ENOSPC; |
| 4758 |
|
| 4759 |
cfg80211_chandef_create(&chandef, channel, NL80211_CHAN_NO_HT); |
| 4760 |
|
| 4761 |
return iwl_mvm_phy_ctxt_add(mvm, mvmvif->deflink.phy_ctxt, |
| 4762 |
&chandef, NULL, 1, 1); |
| 4763 |
} |
| 4764 |
|
| 4765 |
/* Execute the common part for MLD and non-MLD modes */ |
| 4766 |
int iwl_mvm_roc_common(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 4767 |
struct ieee80211_channel *channel, int duration, |
| 4768 |
enum ieee80211_roc_type type, |
| 4769 |
const struct iwl_mvm_roc_ops *ops) |
| 4770 |
{ |
| 4771 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 4772 |
u32 lmac_id; |
| 4773 |
int ret; |
| 4774 |
|
| 4775 |
IWL_DEBUG_MAC80211(mvm, "enter (%d, %d, %d)\n", channel->hw_value, |
| 4776 |
duration, type); |
| 4777 |
|
| 4778 |
/* |
| 4779 |
* Flush the done work, just in case it's still pending, so that |
| 4780 |
* the work it does can complete and we can accept new frames. |
| 4781 |
*/ |
| 4782 |
flush_work(&mvm->roc_done_wk); |
| 4783 |
|
| 4784 |
guard(mvm)(mvm); |
| 4785 |
|
| 4786 |
switch (vif->type) { |
| 4787 |
case NL80211_IFTYPE_STATION: |
| 4788 |
lmac_id = iwl_mvm_get_lmac_id(mvm, channel->band); |
| 4789 |
|
| 4790 |
/* Use aux roc framework (HS20) */ |
| 4791 |
ret = ops->add_aux_sta_for_hs20(mvm, lmac_id); |
| 4792 |
if (!ret) |
| 4793 |
ret = iwl_mvm_roc_station(mvm, channel, vif, duration); |
| 4794 |
return ret; |
| 4795 |
case NL80211_IFTYPE_P2P_DEVICE: |
| 4796 |
/* handle below */ |
| 4797 |
break; |
| 4798 |
default: |
| 4799 |
IWL_ERR(mvm, "ROC: Invalid vif type=%u\n", vif->type); |
| 4800 |
return -EINVAL; |
| 4801 |
} |
| 4802 |
|
| 4803 |
if (iwl_mvm_has_p2p_over_aux(mvm)) { |
| 4804 |
ret = iwl_mvm_roc_p2p(mvm, channel, vif, duration, type); |
| 4805 |
return ret; |
| 4806 |
} |
| 4807 |
|
| 4808 |
ret = iwl_mvm_p2p_find_phy_ctxt(mvm, vif, channel); |
| 4809 |
if (ret) |
| 4810 |
return ret; |
| 4811 |
|
| 4812 |
ret = ops->link(mvm, vif); |
| 4813 |
if (ret) |
| 4814 |
return ret; |
| 4815 |
|
| 4816 |
return iwl_mvm_start_p2p_roc(mvm, vif, duration, type); |
| 4817 |
} |
| 4818 |
|
| 4819 |
int iwl_mvm_cancel_roc(struct ieee80211_hw *hw, |
| 4820 |
struct ieee80211_vif *vif) |
| 4821 |
{ |
| 4822 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 4823 |
|
| 4824 |
IWL_DEBUG_MAC80211(mvm, "enter\n"); |
| 4825 |
|
| 4826 |
iwl_mvm_stop_roc(mvm, vif); |
| 4827 |
|
| 4828 |
IWL_DEBUG_MAC80211(mvm, "leave\n"); |
| 4829 |
return 0; |
| 4830 |
} |
| 4831 |
|
| 4832 |
struct iwl_mvm_chanctx_usage_data { |
| 4833 |
struct iwl_mvm *mvm; |
| 4834 |
struct ieee80211_chanctx_conf *ctx; |
| 4835 |
bool use_def; |
| 4836 |
}; |
| 4837 |
|
| 4838 |
static void iwl_mvm_chanctx_usage_iter(void *_data, u8 *mac, |
| 4839 |
struct ieee80211_vif *vif) |
| 4840 |
{ |
| 4841 |
struct iwl_mvm_chanctx_usage_data *data = _data; |
| 4842 |
struct ieee80211_bss_conf *link_conf; |
| 4843 |
int link_id; |
| 4844 |
|
| 4845 |
for_each_vif_active_link(vif, link_conf, link_id) { |
| 4846 |
if (rcu_access_pointer(link_conf->chanctx_conf) != data->ctx) |
| 4847 |
continue; |
| 4848 |
|
| 4849 |
if (iwl_mvm_enable_fils(data->mvm, vif, data->ctx)) |
| 4850 |
data->use_def = true; |
| 4851 |
|
| 4852 |
if (vif->type == NL80211_IFTYPE_AP && link_conf->ftmr_params) |
| 4853 |
data->use_def = true; |
| 4854 |
} |
| 4855 |
} |
| 4856 |
|
| 4857 |
struct cfg80211_chan_def * |
| 4858 |
iwl_mvm_chanctx_def(struct iwl_mvm *mvm, struct ieee80211_chanctx_conf *ctx) |
| 4859 |
{ |
| 4860 |
struct iwl_mvm_chanctx_usage_data data = { |
| 4861 |
.mvm = mvm, |
| 4862 |
.ctx = ctx, |
| 4863 |
.use_def = false, |
| 4864 |
}; |
| 4865 |
|
| 4866 |
ieee80211_iterate_active_interfaces_atomic(mvm->hw, |
| 4867 |
IEEE80211_IFACE_ITER_NORMAL, |
| 4868 |
iwl_mvm_chanctx_usage_iter, |
| 4869 |
&data); |
| 4870 |
|
| 4871 |
return data.use_def ? &ctx->def : &ctx->min_def; |
| 4872 |
} |
| 4873 |
|
| 4874 |
static int __iwl_mvm_add_chanctx(struct iwl_mvm *mvm, |
| 4875 |
struct ieee80211_chanctx_conf *ctx) |
| 4876 |
{ |
| 4877 |
u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
| 4878 |
struct iwl_mvm_phy_ctxt *phy_ctxt; |
| 4879 |
struct cfg80211_chan_def *def = iwl_mvm_chanctx_def(mvm, ctx); |
| 4880 |
int ret; |
| 4881 |
|
| 4882 |
lockdep_assert_held(&mvm->mutex); |
| 4883 |
|
| 4884 |
IWL_DEBUG_MAC80211(mvm, "Add channel context\n"); |
| 4885 |
|
| 4886 |
phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); |
| 4887 |
if (!phy_ctxt) { |
| 4888 |
ret = -ENOSPC; |
| 4889 |
goto out; |
| 4890 |
} |
| 4891 |
|
| 4892 |
ret = iwl_mvm_phy_ctxt_add(mvm, phy_ctxt, def, &ctx->ap, |
| 4893 |
ctx->rx_chains_static, |
| 4894 |
ctx->rx_chains_dynamic); |
| 4895 |
if (ret) { |
| 4896 |
IWL_ERR(mvm, "Failed to add PHY context\n"); |
| 4897 |
goto out; |
| 4898 |
} |
| 4899 |
|
| 4900 |
*phy_ctxt_id = phy_ctxt->id; |
| 4901 |
out: |
| 4902 |
return ret; |
| 4903 |
} |
| 4904 |
|
| 4905 |
int iwl_mvm_add_chanctx(struct ieee80211_hw *hw, |
| 4906 |
struct ieee80211_chanctx_conf *ctx) |
| 4907 |
{ |
| 4908 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 4909 |
|
| 4910 |
guard(mvm)(mvm); |
| 4911 |
return __iwl_mvm_add_chanctx(mvm, ctx); |
| 4912 |
} |
| 4913 |
|
| 4914 |
static void __iwl_mvm_remove_chanctx(struct iwl_mvm *mvm, |
| 4915 |
struct ieee80211_chanctx_conf *ctx) |
| 4916 |
{ |
| 4917 |
u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
| 4918 |
struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id]; |
| 4919 |
|
| 4920 |
lockdep_assert_held(&mvm->mutex); |
| 4921 |
|
| 4922 |
iwl_mvm_phy_ctxt_unref(mvm, phy_ctxt); |
| 4923 |
} |
| 4924 |
|
| 4925 |
void iwl_mvm_remove_chanctx(struct ieee80211_hw *hw, |
| 4926 |
struct ieee80211_chanctx_conf *ctx) |
| 4927 |
{ |
| 4928 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 4929 |
|
| 4930 |
guard(mvm)(mvm); |
| 4931 |
__iwl_mvm_remove_chanctx(mvm, ctx); |
| 4932 |
} |
| 4933 |
|
| 4934 |
void iwl_mvm_change_chanctx(struct ieee80211_hw *hw, |
| 4935 |
struct ieee80211_chanctx_conf *ctx, u32 changed) |
| 4936 |
{ |
| 4937 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 4938 |
u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
| 4939 |
struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id]; |
| 4940 |
struct cfg80211_chan_def *def = iwl_mvm_chanctx_def(mvm, ctx); |
| 4941 |
|
| 4942 |
if (WARN_ONCE((phy_ctxt->ref > 1) && |
| 4943 |
(changed & ~(IEEE80211_CHANCTX_CHANGE_WIDTH | |
| 4944 |
IEEE80211_CHANCTX_CHANGE_RX_CHAINS | |
| 4945 |
IEEE80211_CHANCTX_CHANGE_RADAR | |
| 4946 |
IEEE80211_CHANCTX_CHANGE_MIN_DEF)), |
| 4947 |
"Cannot change PHY. Ref=%d, changed=0x%X\n", |
| 4948 |
phy_ctxt->ref, changed)) |
| 4949 |
return; |
| 4950 |
|
| 4951 |
guard(mvm)(mvm); |
| 4952 |
|
| 4953 |
/* we are only changing the min_width, may be a noop */ |
| 4954 |
if (changed == IEEE80211_CHANCTX_CHANGE_MIN_DEF) { |
| 4955 |
if (phy_ctxt->width == def->width) |
| 4956 |
return; |
| 4957 |
|
| 4958 |
/* we are just toggling between 20_NOHT and 20 */ |
| 4959 |
if (phy_ctxt->width <= NL80211_CHAN_WIDTH_20 && |
| 4960 |
def->width <= NL80211_CHAN_WIDTH_20) |
| 4961 |
return; |
| 4962 |
} |
| 4963 |
|
| 4964 |
iwl_mvm_bt_coex_vif_change(mvm); |
| 4965 |
iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, def, &ctx->ap, |
| 4966 |
ctx->rx_chains_static, |
| 4967 |
ctx->rx_chains_dynamic); |
| 4968 |
} |
| 4969 |
|
| 4970 |
/* |
| 4971 |
* This function executes the common part for MLD and non-MLD modes. |
| 4972 |
* |
| 4973 |
* Returns true if we're done assigning the chanctx |
| 4974 |
* (either on failure or success) |
| 4975 |
*/ |
| 4976 |
static bool |
| 4977 |
__iwl_mvm_assign_vif_chanctx_common(struct iwl_mvm *mvm, |
| 4978 |
struct ieee80211_vif *vif, |
| 4979 |
struct ieee80211_chanctx_conf *ctx, |
| 4980 |
bool switching_chanctx, int *ret) |
| 4981 |
{ |
| 4982 |
u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
| 4983 |
struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id]; |
| 4984 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 4985 |
|
| 4986 |
lockdep_assert_held(&mvm->mutex); |
| 4987 |
|
| 4988 |
mvmvif->deflink.phy_ctxt = phy_ctxt; |
| 4989 |
|
| 4990 |
switch (vif->type) { |
| 4991 |
case NL80211_IFTYPE_AP: |
| 4992 |
/* only needed if we're switching chanctx (i.e. during CSA) */ |
| 4993 |
if (switching_chanctx) { |
| 4994 |
mvmvif->ap_ibss_active = true; |
| 4995 |
break; |
| 4996 |
} |
| 4997 |
fallthrough; |
| 4998 |
case NL80211_IFTYPE_ADHOC: |
| 4999 |
/* |
| 5000 |
* The AP binding flow is handled as part of the start_ap flow |
| 5001 |
* (in bss_info_changed), similarly for IBSS. |
| 5002 |
*/ |
| 5003 |
*ret = 0; |
| 5004 |
return true; |
| 5005 |
case NL80211_IFTYPE_STATION: |
| 5006 |
break; |
| 5007 |
case NL80211_IFTYPE_MONITOR: |
| 5008 |
/* always disable PS when a monitor interface is active */ |
| 5009 |
mvmvif->ps_disabled = true; |
| 5010 |
break; |
| 5011 |
default: |
| 5012 |
*ret = -EINVAL; |
| 5013 |
return true; |
| 5014 |
} |
| 5015 |
return false; |
| 5016 |
} |
| 5017 |
|
| 5018 |
static int __iwl_mvm_assign_vif_chanctx(struct iwl_mvm *mvm, |
| 5019 |
struct ieee80211_vif *vif, |
| 5020 |
struct ieee80211_bss_conf *link_conf, |
| 5021 |
struct ieee80211_chanctx_conf *ctx, |
| 5022 |
bool switching_chanctx) |
| 5023 |
{ |
| 5024 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 5025 |
int ret; |
| 5026 |
|
| 5027 |
if (WARN_ON(!link_conf)) |
| 5028 |
return -EINVAL; |
| 5029 |
|
| 5030 |
if (__iwl_mvm_assign_vif_chanctx_common(mvm, vif, ctx, |
| 5031 |
switching_chanctx, &ret)) |
| 5032 |
goto out; |
| 5033 |
|
| 5034 |
ret = iwl_mvm_binding_add_vif(mvm, vif); |
| 5035 |
if (ret) |
| 5036 |
goto out; |
| 5037 |
|
| 5038 |
/* |
| 5039 |
* Power state must be updated before quotas, |
| 5040 |
* otherwise fw will complain. |
| 5041 |
*/ |
| 5042 |
iwl_mvm_power_update_mac(mvm); |
| 5043 |
|
| 5044 |
/* Setting the quota at this stage is only required for monitor |
| 5045 |
* interfaces. For the other types, the bss_info changed flow |
| 5046 |
* will handle quota settings. |
| 5047 |
*/ |
| 5048 |
if (vif->type == NL80211_IFTYPE_MONITOR) { |
| 5049 |
mvmvif->monitor_active = true; |
| 5050 |
ret = iwl_mvm_update_quotas(mvm, false, NULL); |
| 5051 |
if (ret) |
| 5052 |
goto out_remove_binding; |
| 5053 |
|
| 5054 |
ret = iwl_mvm_add_snif_sta(mvm, vif); |
| 5055 |
if (ret) |
| 5056 |
goto out_remove_binding; |
| 5057 |
|
| 5058 |
} |
| 5059 |
|
| 5060 |
/* Handle binding during CSA */ |
| 5061 |
if (vif->type == NL80211_IFTYPE_AP) { |
| 5062 |
iwl_mvm_update_quotas(mvm, false, NULL); |
| 5063 |
iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL); |
| 5064 |
} |
| 5065 |
|
| 5066 |
if (vif->type == NL80211_IFTYPE_STATION) { |
| 5067 |
if (!switching_chanctx) { |
| 5068 |
mvmvif->csa_bcn_pending = false; |
| 5069 |
goto out; |
| 5070 |
} |
| 5071 |
|
| 5072 |
mvmvif->csa_bcn_pending = true; |
| 5073 |
|
| 5074 |
if (!fw_has_capa(&mvm->fw->ucode_capa, |
| 5075 |
IWL_UCODE_TLV_CAPA_CHANNEL_SWITCH_CMD)) { |
| 5076 |
u32 duration = 5 * vif->bss_conf.beacon_int; |
| 5077 |
|
| 5078 |
/* Protect the session to make sure we hear the first |
| 5079 |
* beacon on the new channel. |
| 5080 |
*/ |
| 5081 |
iwl_mvm_protect_session(mvm, vif, duration, duration, |
| 5082 |
vif->bss_conf.beacon_int / 2, |
| 5083 |
true); |
| 5084 |
} |
| 5085 |
|
| 5086 |
iwl_mvm_update_quotas(mvm, false, NULL); |
| 5087 |
|
| 5088 |
iwl_mvm_send_ap_tx_power_constraint_cmd(mvm, vif, |
| 5089 |
link_conf, |
| 5090 |
false); |
| 5091 |
} |
| 5092 |
|
| 5093 |
goto out; |
| 5094 |
|
| 5095 |
out_remove_binding: |
| 5096 |
iwl_mvm_binding_remove_vif(mvm, vif); |
| 5097 |
iwl_mvm_power_update_mac(mvm); |
| 5098 |
out: |
| 5099 |
if (ret) |
| 5100 |
mvmvif->deflink.phy_ctxt = NULL; |
| 5101 |
return ret; |
| 5102 |
} |
| 5103 |
|
| 5104 |
static int iwl_mvm_assign_vif_chanctx(struct ieee80211_hw *hw, |
| 5105 |
struct ieee80211_vif *vif, |
| 5106 |
struct ieee80211_bss_conf *link_conf, |
| 5107 |
struct ieee80211_chanctx_conf *ctx) |
| 5108 |
{ |
| 5109 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 5110 |
|
| 5111 |
guard(mvm)(mvm); |
| 5112 |
return __iwl_mvm_assign_vif_chanctx(mvm, vif, link_conf, ctx, false); |
| 5113 |
} |
| 5114 |
|
| 5115 |
/* |
| 5116 |
* This function executes the common part for MLD and non-MLD modes. |
| 5117 |
* |
| 5118 |
* Returns if chanctx unassign chanctx is done |
| 5119 |
* (either on failure or success) |
| 5120 |
*/ |
| 5121 |
static bool __iwl_mvm_unassign_vif_chanctx_common(struct iwl_mvm *mvm, |
| 5122 |
struct ieee80211_vif *vif, |
| 5123 |
bool switching_chanctx) |
| 5124 |
{ |
| 5125 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 5126 |
|
| 5127 |
lockdep_assert_held(&mvm->mutex); |
| 5128 |
iwl_mvm_remove_time_event(mvm, mvmvif, |
| 5129 |
&mvmvif->time_event_data); |
| 5130 |
|
| 5131 |
switch (vif->type) { |
| 5132 |
case NL80211_IFTYPE_ADHOC: |
| 5133 |
return true; |
| 5134 |
case NL80211_IFTYPE_MONITOR: |
| 5135 |
mvmvif->monitor_active = false; |
| 5136 |
mvmvif->ps_disabled = false; |
| 5137 |
break; |
| 5138 |
case NL80211_IFTYPE_AP: |
| 5139 |
/* This part is triggered only during CSA */ |
| 5140 |
if (!switching_chanctx || !mvmvif->ap_ibss_active) |
| 5141 |
return true; |
| 5142 |
|
| 5143 |
mvmvif->csa_countdown = false; |
| 5144 |
|
| 5145 |
/* Set CS bit on all the stations */ |
| 5146 |
iwl_mvm_modify_all_sta_disable_tx(mvm, mvmvif, true); |
| 5147 |
|
| 5148 |
/* Save blocked iface, the timeout is set on the next beacon */ |
| 5149 |
rcu_assign_pointer(mvm->csa_tx_blocked_vif, vif); |
| 5150 |
|
| 5151 |
mvmvif->ap_ibss_active = false; |
| 5152 |
break; |
| 5153 |
default: |
| 5154 |
break; |
| 5155 |
} |
| 5156 |
return false; |
| 5157 |
} |
| 5158 |
|
| 5159 |
static void __iwl_mvm_unassign_vif_chanctx(struct iwl_mvm *mvm, |
| 5160 |
struct ieee80211_vif *vif, |
| 5161 |
struct ieee80211_bss_conf *link_conf, |
| 5162 |
struct ieee80211_chanctx_conf *ctx, |
| 5163 |
bool switching_chanctx) |
| 5164 |
{ |
| 5165 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 5166 |
struct ieee80211_vif *disabled_vif = NULL; |
| 5167 |
|
| 5168 |
if (__iwl_mvm_unassign_vif_chanctx_common(mvm, vif, switching_chanctx)) |
| 5169 |
goto out; |
| 5170 |
|
| 5171 |
if (vif->type == NL80211_IFTYPE_MONITOR) |
| 5172 |
iwl_mvm_rm_snif_sta(mvm, vif); |
| 5173 |
|
| 5174 |
|
| 5175 |
if (vif->type == NL80211_IFTYPE_STATION && switching_chanctx) { |
| 5176 |
disabled_vif = vif; |
| 5177 |
if (!fw_has_capa(&mvm->fw->ucode_capa, |
| 5178 |
IWL_UCODE_TLV_CAPA_CHANNEL_SWITCH_CMD)) |
| 5179 |
iwl_mvm_mac_ctxt_changed(mvm, vif, true, NULL); |
| 5180 |
} |
| 5181 |
|
| 5182 |
iwl_mvm_update_quotas(mvm, false, disabled_vif); |
| 5183 |
iwl_mvm_binding_remove_vif(mvm, vif); |
| 5184 |
|
| 5185 |
out: |
| 5186 |
if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_CHANNEL_SWITCH_CMD) && |
| 5187 |
switching_chanctx) |
| 5188 |
return; |
| 5189 |
mvmvif->deflink.phy_ctxt = NULL; |
| 5190 |
iwl_mvm_power_update_mac(mvm); |
| 5191 |
} |
| 5192 |
|
| 5193 |
static void iwl_mvm_unassign_vif_chanctx(struct ieee80211_hw *hw, |
| 5194 |
struct ieee80211_vif *vif, |
| 5195 |
struct ieee80211_bss_conf *link_conf, |
| 5196 |
struct ieee80211_chanctx_conf *ctx) |
| 5197 |
{ |
| 5198 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 5199 |
|
| 5200 |
guard(mvm)(mvm); |
| 5201 |
__iwl_mvm_unassign_vif_chanctx(mvm, vif, link_conf, ctx, false); |
| 5202 |
} |
| 5203 |
|
| 5204 |
static int |
| 5205 |
iwl_mvm_switch_vif_chanctx_swap(struct iwl_mvm *mvm, |
| 5206 |
struct ieee80211_vif_chanctx_switch *vifs, |
| 5207 |
const struct iwl_mvm_switch_vif_chanctx_ops *ops) |
| 5208 |
{ |
| 5209 |
int ret; |
| 5210 |
|
| 5211 |
guard(mvm)(mvm); |
| 5212 |
ops->__unassign_vif_chanctx(mvm, vifs[0].vif, vifs[0].link_conf, |
| 5213 |
vifs[0].old_ctx, true); |
| 5214 |
__iwl_mvm_remove_chanctx(mvm, vifs[0].old_ctx); |
| 5215 |
|
| 5216 |
ret = __iwl_mvm_add_chanctx(mvm, vifs[0].new_ctx); |
| 5217 |
if (ret) { |
| 5218 |
IWL_ERR(mvm, "failed to add new_ctx during channel switch\n"); |
| 5219 |
goto out_reassign; |
| 5220 |
} |
| 5221 |
|
| 5222 |
ret = ops->__assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].link_conf, |
| 5223 |
vifs[0].new_ctx, true); |
| 5224 |
if (ret) { |
| 5225 |
IWL_ERR(mvm, |
| 5226 |
"failed to assign new_ctx during channel switch\n"); |
| 5227 |
goto out_remove; |
| 5228 |
} |
| 5229 |
|
| 5230 |
/* we don't support TDLS during DCM - can be caused by channel switch */ |
| 5231 |
if (iwl_mvm_phy_ctx_count(mvm) > 1) |
| 5232 |
iwl_mvm_teardown_tdls_peers(mvm); |
| 5233 |
|
| 5234 |
return 0; |
| 5235 |
|
| 5236 |
out_remove: |
| 5237 |
__iwl_mvm_remove_chanctx(mvm, vifs[0].new_ctx); |
| 5238 |
|
| 5239 |
out_reassign: |
| 5240 |
if (__iwl_mvm_add_chanctx(mvm, vifs[0].old_ctx)) { |
| 5241 |
IWL_ERR(mvm, "failed to add old_ctx back after failure.\n"); |
| 5242 |
goto out_restart; |
| 5243 |
} |
| 5244 |
|
| 5245 |
if (ops->__assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].link_conf, |
| 5246 |
vifs[0].old_ctx, true)) { |
| 5247 |
IWL_ERR(mvm, "failed to reassign old_ctx after failure.\n"); |
| 5248 |
goto out_restart; |
| 5249 |
} |
| 5250 |
|
| 5251 |
return ret; |
| 5252 |
|
| 5253 |
out_restart: |
| 5254 |
/* things keep failing, better restart the hw */ |
| 5255 |
iwl_force_nmi(mvm->trans); |
| 5256 |
return ret; |
| 5257 |
} |
| 5258 |
|
| 5259 |
static int |
| 5260 |
iwl_mvm_switch_vif_chanctx_reassign(struct iwl_mvm *mvm, |
| 5261 |
struct ieee80211_vif_chanctx_switch *vifs, |
| 5262 |
const struct iwl_mvm_switch_vif_chanctx_ops *ops) |
| 5263 |
{ |
| 5264 |
int ret; |
| 5265 |
|
| 5266 |
guard(mvm)(mvm); |
| 5267 |
ops->__unassign_vif_chanctx(mvm, vifs[0].vif, vifs[0].link_conf, |
| 5268 |
vifs[0].old_ctx, true); |
| 5269 |
|
| 5270 |
ret = ops->__assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].link_conf, |
| 5271 |
vifs[0].new_ctx, true); |
| 5272 |
if (ret) { |
| 5273 |
IWL_ERR(mvm, |
| 5274 |
"failed to assign new_ctx during channel switch\n"); |
| 5275 |
goto out_reassign; |
| 5276 |
} |
| 5277 |
|
| 5278 |
return 0; |
| 5279 |
|
| 5280 |
out_reassign: |
| 5281 |
if (ops->__assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].link_conf, |
| 5282 |
vifs[0].old_ctx, true)) { |
| 5283 |
IWL_ERR(mvm, "failed to reassign old_ctx after failure.\n"); |
| 5284 |
goto out_restart; |
| 5285 |
} |
| 5286 |
|
| 5287 |
return ret; |
| 5288 |
|
| 5289 |
out_restart: |
| 5290 |
/* things keep failing, better restart the hw */ |
| 5291 |
iwl_force_nmi(mvm->trans); |
| 5292 |
return ret; |
| 5293 |
} |
| 5294 |
|
| 5295 |
/* Execute the common part for both MLD and non-MLD modes */ |
| 5296 |
int |
| 5297 |
iwl_mvm_switch_vif_chanctx_common(struct ieee80211_hw *hw, |
| 5298 |
struct ieee80211_vif_chanctx_switch *vifs, |
| 5299 |
int n_vifs, |
| 5300 |
enum ieee80211_chanctx_switch_mode mode, |
| 5301 |
const struct iwl_mvm_switch_vif_chanctx_ops *ops) |
| 5302 |
{ |
| 5303 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 5304 |
int ret; |
| 5305 |
|
| 5306 |
/* we only support a single-vif right now */ |
| 5307 |
if (n_vifs > 1) |
| 5308 |
return -EOPNOTSUPP; |
| 5309 |
|
| 5310 |
switch (mode) { |
| 5311 |
case CHANCTX_SWMODE_SWAP_CONTEXTS: |
| 5312 |
ret = iwl_mvm_switch_vif_chanctx_swap(mvm, vifs, ops); |
| 5313 |
break; |
| 5314 |
case CHANCTX_SWMODE_REASSIGN_VIF: |
| 5315 |
ret = iwl_mvm_switch_vif_chanctx_reassign(mvm, vifs, ops); |
| 5316 |
break; |
| 5317 |
default: |
| 5318 |
ret = -EOPNOTSUPP; |
| 5319 |
break; |
| 5320 |
} |
| 5321 |
|
| 5322 |
return ret; |
| 5323 |
} |
| 5324 |
|
| 5325 |
static int iwl_mvm_switch_vif_chanctx(struct ieee80211_hw *hw, |
| 5326 |
struct ieee80211_vif_chanctx_switch *vifs, |
| 5327 |
int n_vifs, |
| 5328 |
enum ieee80211_chanctx_switch_mode mode) |
| 5329 |
{ |
| 5330 |
static const struct iwl_mvm_switch_vif_chanctx_ops ops = { |
| 5331 |
.__assign_vif_chanctx = __iwl_mvm_assign_vif_chanctx, |
| 5332 |
.__unassign_vif_chanctx = __iwl_mvm_unassign_vif_chanctx, |
| 5333 |
}; |
| 5334 |
|
| 5335 |
return iwl_mvm_switch_vif_chanctx_common(hw, vifs, n_vifs, mode, &ops); |
| 5336 |
} |
| 5337 |
|
| 5338 |
int iwl_mvm_tx_last_beacon(struct ieee80211_hw *hw) |
| 5339 |
{ |
| 5340 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 5341 |
|
| 5342 |
return mvm->ibss_manager; |
| 5343 |
} |
| 5344 |
|
| 5345 |
static int iwl_mvm_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta, |
| 5346 |
bool set) |
| 5347 |
{ |
| 5348 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 5349 |
struct iwl_mvm_sta *mvm_sta = iwl_mvm_sta_from_mac80211(sta); |
| 5350 |
|
| 5351 |
if (!mvm_sta || !mvm_sta->vif) { |
| 5352 |
IWL_ERR(mvm, "Station is not associated to a vif\n"); |
| 5353 |
return -EINVAL; |
| 5354 |
} |
| 5355 |
|
| 5356 |
return iwl_mvm_mac_ctxt_beacon_changed(mvm, mvm_sta->vif, |
| 5357 |
&mvm_sta->vif->bss_conf); |
| 5358 |
} |
| 5359 |
|
| 5360 |
void iwl_mvm_channel_switch(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 5361 |
struct ieee80211_channel_switch *chsw) |
| 5362 |
{ |
| 5363 |
/* By implementing this operation, we prevent mac80211 from |
| 5364 |
* starting its own channel switch timer, so that we can call |
| 5365 |
* ieee80211_chswitch_done() ourselves at the right time |
| 5366 |
* (which is when the absence time event starts). |
| 5367 |
*/ |
| 5368 |
|
| 5369 |
IWL_DEBUG_MAC80211(IWL_MAC80211_GET_MVM(hw), |
| 5370 |
"dummy channel switch op\n"); |
| 5371 |
} |
| 5372 |
|
| 5373 |
static int iwl_mvm_schedule_client_csa(struct iwl_mvm *mvm, |
| 5374 |
struct ieee80211_vif *vif, |
| 5375 |
struct ieee80211_channel_switch *chsw) |
| 5376 |
{ |
| 5377 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 5378 |
struct iwl_chan_switch_te_cmd cmd = { |
| 5379 |
.mac_id = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, |
| 5380 |
mvmvif->color)), |
| 5381 |
.action = cpu_to_le32(FW_CTXT_ACTION_ADD), |
| 5382 |
.tsf = cpu_to_le32(chsw->timestamp), |
| 5383 |
.cs_count = chsw->count, |
| 5384 |
.cs_mode = chsw->block_tx, |
| 5385 |
}; |
| 5386 |
|
| 5387 |
lockdep_assert_held(&mvm->mutex); |
| 5388 |
|
| 5389 |
if (chsw->delay) |
| 5390 |
cmd.cs_delayed_bcn_count = |
| 5391 |
DIV_ROUND_UP(chsw->delay, vif->bss_conf.beacon_int); |
| 5392 |
|
| 5393 |
return iwl_mvm_send_cmd_pdu(mvm, |
| 5394 |
WIDE_ID(MAC_CONF_GROUP, |
| 5395 |
CHANNEL_SWITCH_TIME_EVENT_CMD), |
| 5396 |
0, sizeof(cmd), &cmd); |
| 5397 |
} |
| 5398 |
|
| 5399 |
static int iwl_mvm_old_pre_chan_sw_sta(struct iwl_mvm *mvm, |
| 5400 |
struct ieee80211_vif *vif, |
| 5401 |
struct ieee80211_channel_switch *chsw) |
| 5402 |
{ |
| 5403 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 5404 |
u32 apply_time; |
| 5405 |
|
| 5406 |
/* Schedule the time event to a bit before beacon 1, |
| 5407 |
* to make sure we're in the new channel when the |
| 5408 |
* GO/AP arrives. In case count <= 1 immediately schedule the |
| 5409 |
* TE (this might result with some packet loss or connection |
| 5410 |
* loss). |
| 5411 |
*/ |
| 5412 |
if (chsw->count <= 1) |
| 5413 |
apply_time = 0; |
| 5414 |
else |
| 5415 |
apply_time = chsw->device_timestamp + |
| 5416 |
((vif->bss_conf.beacon_int * (chsw->count - 1) - |
| 5417 |
IWL_MVM_CHANNEL_SWITCH_TIME_CLIENT) * 1024); |
| 5418 |
|
| 5419 |
if (chsw->block_tx) |
| 5420 |
iwl_mvm_csa_client_absent(mvm, vif); |
| 5421 |
|
| 5422 |
if (mvmvif->bf_enabled) { |
| 5423 |
int ret = iwl_mvm_disable_beacon_filter(mvm, vif); |
| 5424 |
|
| 5425 |
if (ret) |
| 5426 |
return ret; |
| 5427 |
} |
| 5428 |
|
| 5429 |
iwl_mvm_schedule_csa_period(mvm, vif, vif->bss_conf.beacon_int, |
| 5430 |
apply_time); |
| 5431 |
|
| 5432 |
return 0; |
| 5433 |
} |
| 5434 |
|
| 5435 |
static void iwl_mvm_csa_block_txqs(void *data, struct ieee80211_sta *sta) |
| 5436 |
{ |
| 5437 |
int i; |
| 5438 |
|
| 5439 |
for (i = 0; i < ARRAY_SIZE(sta->txq); i++) { |
| 5440 |
struct iwl_mvm_txq *mvmtxq = |
| 5441 |
iwl_mvm_txq_from_mac80211(sta->txq[i]); |
| 5442 |
|
| 5443 |
set_bit(IWL_MVM_TXQ_STATE_STOP_AP_CSA, &mvmtxq->state); |
| 5444 |
} |
| 5445 |
} |
| 5446 |
|
| 5447 |
#define IWL_MAX_CSA_BLOCK_TX 1500 |
| 5448 |
static int iwl_mvm_pre_channel_switch(struct iwl_mvm *mvm, |
| 5449 |
struct ieee80211_vif *vif, |
| 5450 |
struct ieee80211_channel_switch *chsw) |
| 5451 |
{ |
| 5452 |
struct ieee80211_vif *csa_vif; |
| 5453 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 5454 |
struct iwl_mvm_txq *mvmtxq; |
| 5455 |
int ret; |
| 5456 |
|
| 5457 |
lockdep_assert_held(&mvm->mutex); |
| 5458 |
|
| 5459 |
mvmvif->csa_failed = false; |
| 5460 |
mvmvif->csa_blocks_tx = false; |
| 5461 |
|
| 5462 |
IWL_DEBUG_MAC80211(mvm, "pre CSA to freq %d\n", |
| 5463 |
chsw->chandef.center_freq1); |
| 5464 |
|
| 5465 |
iwl_fw_dbg_trigger_simple_stop(&mvm->fwrt, |
| 5466 |
ieee80211_vif_to_wdev(vif), |
| 5467 |
FW_DBG_TRIGGER_CHANNEL_SWITCH); |
| 5468 |
|
| 5469 |
switch (vif->type) { |
| 5470 |
case NL80211_IFTYPE_AP: |
| 5471 |
csa_vif = |
| 5472 |
rcu_dereference_protected(mvm->csa_vif, |
| 5473 |
lockdep_is_held(&mvm->mutex)); |
| 5474 |
if (WARN_ONCE(csa_vif && csa_vif->bss_conf.csa_active, |
| 5475 |
"Another CSA is already in progress")) |
| 5476 |
return -EBUSY; |
| 5477 |
|
| 5478 |
/* we still didn't unblock tx. prevent new CS meanwhile */ |
| 5479 |
if (rcu_dereference_protected(mvm->csa_tx_blocked_vif, |
| 5480 |
lockdep_is_held(&mvm->mutex))) |
| 5481 |
return -EBUSY; |
| 5482 |
|
| 5483 |
rcu_assign_pointer(mvm->csa_vif, vif); |
| 5484 |
|
| 5485 |
if (WARN_ONCE(mvmvif->csa_countdown, |
| 5486 |
"Previous CSA countdown didn't complete")) |
| 5487 |
return -EBUSY; |
| 5488 |
|
| 5489 |
mvmvif->csa_target_freq = chsw->chandef.chan->center_freq; |
| 5490 |
|
| 5491 |
if (!chsw->block_tx) |
| 5492 |
break; |
| 5493 |
/* don't need blocking in driver otherwise - mac80211 will do */ |
| 5494 |
if (!ieee80211_hw_check(mvm->hw, HANDLES_QUIET_CSA)) |
| 5495 |
break; |
| 5496 |
|
| 5497 |
mvmvif->csa_blocks_tx = true; |
| 5498 |
mvmtxq = iwl_mvm_txq_from_mac80211(vif->txq); |
| 5499 |
set_bit(IWL_MVM_TXQ_STATE_STOP_AP_CSA, &mvmtxq->state); |
| 5500 |
ieee80211_iterate_stations_atomic(mvm->hw, |
| 5501 |
iwl_mvm_csa_block_txqs, |
| 5502 |
NULL); |
| 5503 |
break; |
| 5504 |
case NL80211_IFTYPE_STATION: |
| 5505 |
mvmvif->csa_blocks_tx = chsw->block_tx; |
| 5506 |
|
| 5507 |
/* |
| 5508 |
* In the new flow FW is in charge of timing the switch so there |
| 5509 |
* is no need for all of this |
| 5510 |
*/ |
| 5511 |
if (iwl_fw_lookup_notif_ver(mvm->fw, MAC_CONF_GROUP, |
| 5512 |
CHANNEL_SWITCH_ERROR_NOTIF, |
| 5513 |
0)) |
| 5514 |
break; |
| 5515 |
|
| 5516 |
/* |
| 5517 |
* We haven't configured the firmware to be associated yet since |
| 5518 |
* we don't know the dtim period. In this case, the firmware can't |
| 5519 |
* track the beacons. |
| 5520 |
*/ |
| 5521 |
if (!vif->cfg.assoc || !vif->bss_conf.dtim_period) |
| 5522 |
return -EBUSY; |
| 5523 |
|
| 5524 |
if (chsw->delay > IWL_MAX_CSA_BLOCK_TX) |
| 5525 |
schedule_delayed_work(&mvmvif->csa_work, 0); |
| 5526 |
|
| 5527 |
if (chsw->block_tx) { |
| 5528 |
/* |
| 5529 |
* In case of undetermined / long time with immediate |
| 5530 |
* quiet monitor status to gracefully disconnect |
| 5531 |
*/ |
| 5532 |
if (!chsw->count || |
| 5533 |
chsw->count * vif->bss_conf.beacon_int > |
| 5534 |
IWL_MAX_CSA_BLOCK_TX) |
| 5535 |
schedule_delayed_work(&mvmvif->csa_work, |
| 5536 |
msecs_to_jiffies(IWL_MAX_CSA_BLOCK_TX)); |
| 5537 |
} |
| 5538 |
|
| 5539 |
if (!fw_has_capa(&mvm->fw->ucode_capa, |
| 5540 |
IWL_UCODE_TLV_CAPA_CHANNEL_SWITCH_CMD)) { |
| 5541 |
ret = iwl_mvm_old_pre_chan_sw_sta(mvm, vif, chsw); |
| 5542 |
if (ret) |
| 5543 |
return ret; |
| 5544 |
} else { |
| 5545 |
iwl_mvm_schedule_client_csa(mvm, vif, chsw); |
| 5546 |
} |
| 5547 |
|
| 5548 |
mvmvif->csa_count = chsw->count; |
| 5549 |
mvmvif->csa_misbehave = false; |
| 5550 |
break; |
| 5551 |
default: |
| 5552 |
break; |
| 5553 |
} |
| 5554 |
|
| 5555 |
mvmvif->ps_disabled = true; |
| 5556 |
|
| 5557 |
ret = iwl_mvm_power_update_ps(mvm); |
| 5558 |
if (ret) |
| 5559 |
return ret; |
| 5560 |
|
| 5561 |
/* we won't be on this channel any longer */ |
| 5562 |
iwl_mvm_teardown_tdls_peers(mvm); |
| 5563 |
|
| 5564 |
return ret; |
| 5565 |
} |
| 5566 |
|
| 5567 |
int iwl_mvm_mac_pre_channel_switch(struct ieee80211_hw *hw, |
| 5568 |
struct ieee80211_vif *vif, |
| 5569 |
struct ieee80211_channel_switch *chsw) |
| 5570 |
{ |
| 5571 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 5572 |
|
| 5573 |
guard(mvm)(mvm); |
| 5574 |
return iwl_mvm_pre_channel_switch(mvm, vif, chsw); |
| 5575 |
} |
| 5576 |
|
| 5577 |
void iwl_mvm_channel_switch_rx_beacon(struct ieee80211_hw *hw, |
| 5578 |
struct ieee80211_vif *vif, |
| 5579 |
struct ieee80211_channel_switch *chsw) |
| 5580 |
{ |
| 5581 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 5582 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 5583 |
struct iwl_chan_switch_te_cmd cmd = { |
| 5584 |
.mac_id = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, |
| 5585 |
mvmvif->color)), |
| 5586 |
.action = cpu_to_le32(FW_CTXT_ACTION_MODIFY), |
| 5587 |
.tsf = cpu_to_le32(chsw->timestamp), |
| 5588 |
.cs_count = chsw->count, |
| 5589 |
.cs_mode = chsw->block_tx, |
| 5590 |
}; |
| 5591 |
|
| 5592 |
/* |
| 5593 |
* In the new flow FW is in charge of timing the switch so there is no |
| 5594 |
* need for all of this |
| 5595 |
*/ |
| 5596 |
if (iwl_fw_lookup_notif_ver(mvm->fw, MAC_CONF_GROUP, |
| 5597 |
CHANNEL_SWITCH_ERROR_NOTIF, 0)) |
| 5598 |
return; |
| 5599 |
|
| 5600 |
if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_CS_MODIFY)) |
| 5601 |
return; |
| 5602 |
|
| 5603 |
IWL_DEBUG_MAC80211(mvm, "Modify CSA on mac %d count = %d (old %d) mode = %d\n", |
| 5604 |
mvmvif->id, chsw->count, mvmvif->csa_count, chsw->block_tx); |
| 5605 |
|
| 5606 |
if (chsw->count >= mvmvif->csa_count && chsw->block_tx) { |
| 5607 |
if (mvmvif->csa_misbehave) { |
| 5608 |
struct ieee80211_bss_conf *link_conf; |
| 5609 |
|
| 5610 |
/* Second time, give up on this AP*/ |
| 5611 |
|
| 5612 |
link_conf = wiphy_dereference(hw->wiphy, |
| 5613 |
vif->link_conf[chsw->link_id]); |
| 5614 |
if (WARN_ON(!link_conf)) |
| 5615 |
return; |
| 5616 |
|
| 5617 |
iwl_mvm_abort_channel_switch(hw, vif, link_conf); |
| 5618 |
ieee80211_chswitch_done(vif, false, 0); |
| 5619 |
mvmvif->csa_misbehave = false; |
| 5620 |
return; |
| 5621 |
} |
| 5622 |
mvmvif->csa_misbehave = true; |
| 5623 |
} |
| 5624 |
mvmvif->csa_count = chsw->count; |
| 5625 |
|
| 5626 |
guard(mvm)(mvm); |
| 5627 |
if (mvmvif->csa_failed) |
| 5628 |
return; |
| 5629 |
|
| 5630 |
WARN_ON(iwl_mvm_send_cmd_pdu(mvm, |
| 5631 |
WIDE_ID(MAC_CONF_GROUP, |
| 5632 |
CHANNEL_SWITCH_TIME_EVENT_CMD), |
| 5633 |
0, sizeof(cmd), &cmd)); |
| 5634 |
} |
| 5635 |
|
| 5636 |
static void iwl_mvm_flush_no_vif(struct iwl_mvm *mvm, u32 queues, bool drop) |
| 5637 |
{ |
| 5638 |
int i; |
| 5639 |
|
| 5640 |
if (!iwl_mvm_has_new_tx_api(mvm)) { |
| 5641 |
/* we can't ask the firmware anything if it is dead */ |
| 5642 |
if (test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, |
| 5643 |
&mvm->status)) |
| 5644 |
return; |
| 5645 |
if (drop) { |
| 5646 |
guard(mvm)(mvm); |
| 5647 |
iwl_mvm_flush_tx_path(mvm, |
| 5648 |
iwl_mvm_flushable_queues(mvm) & queues); |
| 5649 |
} else { |
| 5650 |
iwl_trans_wait_tx_queues_empty(mvm->trans, queues); |
| 5651 |
} |
| 5652 |
return; |
| 5653 |
} |
| 5654 |
|
| 5655 |
guard(mvm)(mvm); |
| 5656 |
for (i = 0; i < mvm->fw->ucode_capa.num_stations; i++) { |
| 5657 |
struct ieee80211_sta *sta; |
| 5658 |
|
| 5659 |
sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i], |
| 5660 |
lockdep_is_held(&mvm->mutex)); |
| 5661 |
if (IS_ERR_OR_NULL(sta)) |
| 5662 |
continue; |
| 5663 |
|
| 5664 |
if (drop) |
| 5665 |
iwl_mvm_flush_sta_tids(mvm, i, 0xFFFF); |
| 5666 |
else |
| 5667 |
iwl_mvm_wait_sta_queues_empty(mvm, |
| 5668 |
iwl_mvm_sta_from_mac80211(sta)); |
| 5669 |
} |
| 5670 |
} |
| 5671 |
|
| 5672 |
void iwl_mvm_mac_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 5673 |
u32 queues, bool drop) |
| 5674 |
{ |
| 5675 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 5676 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 5677 |
struct iwl_mvm_sta *mvmsta; |
| 5678 |
struct ieee80211_sta *sta; |
| 5679 |
bool ap_sta_done = false; |
| 5680 |
int i; |
| 5681 |
u32 msk = 0; |
| 5682 |
|
| 5683 |
if (!vif) { |
| 5684 |
iwl_mvm_flush_no_vif(mvm, queues, drop); |
| 5685 |
return; |
| 5686 |
} |
| 5687 |
|
| 5688 |
if (!drop) { |
| 5689 |
if (vif->bss_conf.csa_active && mvmvif->csa_blocks_tx) |
| 5690 |
drop = true; |
| 5691 |
} |
| 5692 |
|
| 5693 |
/* Make sure we're done with the deferred traffic before flushing */ |
| 5694 |
flush_work(&mvm->add_stream_wk); |
| 5695 |
|
| 5696 |
mutex_lock(&mvm->mutex); |
| 5697 |
|
| 5698 |
/* flush the AP-station and all TDLS peers */ |
| 5699 |
for (i = 0; i < mvm->fw->ucode_capa.num_stations; i++) { |
| 5700 |
sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i], |
| 5701 |
lockdep_is_held(&mvm->mutex)); |
| 5702 |
if (IS_ERR_OR_NULL(sta)) |
| 5703 |
continue; |
| 5704 |
|
| 5705 |
mvmsta = iwl_mvm_sta_from_mac80211(sta); |
| 5706 |
if (mvmsta->vif != vif) |
| 5707 |
continue; |
| 5708 |
|
| 5709 |
if (sta == mvmvif->ap_sta) { |
| 5710 |
if (ap_sta_done) |
| 5711 |
continue; |
| 5712 |
ap_sta_done = true; |
| 5713 |
} |
| 5714 |
|
| 5715 |
if (drop) { |
| 5716 |
if (iwl_mvm_flush_sta(mvm, mvmsta->deflink.sta_id, |
| 5717 |
mvmsta->tfd_queue_msk)) |
| 5718 |
IWL_ERR(mvm, "flush request fail\n"); |
| 5719 |
} else { |
| 5720 |
if (iwl_mvm_has_new_tx_api(mvm)) |
| 5721 |
iwl_mvm_wait_sta_queues_empty(mvm, mvmsta); |
| 5722 |
else /* only used for !iwl_mvm_has_new_tx_api() below */ |
| 5723 |
msk |= mvmsta->tfd_queue_msk; |
| 5724 |
} |
| 5725 |
} |
| 5726 |
|
| 5727 |
mutex_unlock(&mvm->mutex); |
| 5728 |
|
| 5729 |
/* this can take a while, and we may need/want other operations |
| 5730 |
* to succeed while doing this, so do it without the mutex held |
| 5731 |
* If the firmware is dead, this can't work... |
| 5732 |
*/ |
| 5733 |
if (!drop && !iwl_mvm_has_new_tx_api(mvm) && |
| 5734 |
!test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, |
| 5735 |
&mvm->status)) |
| 5736 |
iwl_trans_wait_tx_queues_empty(mvm->trans, msk); |
| 5737 |
} |
| 5738 |
|
| 5739 |
void iwl_mvm_mac_flush_sta(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 5740 |
struct ieee80211_sta *sta) |
| 5741 |
{ |
| 5742 |
struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); |
| 5743 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 5744 |
struct iwl_mvm_link_sta *mvm_link_sta; |
| 5745 |
struct ieee80211_link_sta *link_sta; |
| 5746 |
int link_id; |
| 5747 |
|
| 5748 |
guard(mvm)(mvm); |
| 5749 |
for_each_sta_active_link(vif, sta, link_sta, link_id) { |
| 5750 |
mvm_link_sta = rcu_dereference_protected(mvmsta->link[link_id], |
| 5751 |
lockdep_is_held(&mvm->mutex)); |
| 5752 |
if (!mvm_link_sta) |
| 5753 |
continue; |
| 5754 |
|
| 5755 |
if (iwl_mvm_flush_sta(mvm, mvm_link_sta->sta_id, |
| 5756 |
mvmsta->tfd_queue_msk)) |
| 5757 |
IWL_ERR(mvm, "flush request fail\n"); |
| 5758 |
} |
| 5759 |
} |
| 5760 |
|
| 5761 |
static int iwl_mvm_mac_get_acs_survey(struct iwl_mvm *mvm, int idx, |
| 5762 |
struct survey_info *survey) |
| 5763 |
{ |
| 5764 |
int chan_idx; |
| 5765 |
enum nl80211_band band; |
| 5766 |
int ret; |
| 5767 |
|
| 5768 |
mutex_lock(&mvm->mutex); |
| 5769 |
|
| 5770 |
if (!mvm->acs_survey) { |
| 5771 |
ret = -ENOENT; |
| 5772 |
goto out; |
| 5773 |
} |
| 5774 |
|
| 5775 |
/* Find and return the next entry that has a non-zero active time */ |
| 5776 |
for (band = 0; band < NUM_NL80211_BANDS; band++) { |
| 5777 |
struct ieee80211_supported_band *sband = |
| 5778 |
mvm->hw->wiphy->bands[band]; |
| 5779 |
|
| 5780 |
if (!sband) |
| 5781 |
continue; |
| 5782 |
|
| 5783 |
for (chan_idx = 0; chan_idx < sband->n_channels; chan_idx++) { |
| 5784 |
struct iwl_mvm_acs_survey_channel *info = |
| 5785 |
&mvm->acs_survey->bands[band][chan_idx]; |
| 5786 |
|
| 5787 |
if (!info->time) |
| 5788 |
continue; |
| 5789 |
|
| 5790 |
/* Found (the next) channel to report */ |
| 5791 |
survey->channel = &sband->channels[chan_idx]; |
| 5792 |
survey->filled = SURVEY_INFO_TIME | |
| 5793 |
SURVEY_INFO_TIME_BUSY | |
| 5794 |
SURVEY_INFO_TIME_RX | |
| 5795 |
SURVEY_INFO_TIME_TX; |
| 5796 |
survey->time = info->time; |
| 5797 |
survey->time_busy = info->time_busy; |
| 5798 |
survey->time_rx = info->time_rx; |
| 5799 |
survey->time_tx = info->time_tx; |
| 5800 |
survey->noise = info->noise; |
| 5801 |
if (survey->noise < 0) |
| 5802 |
survey->filled |= SURVEY_INFO_NOISE_DBM; |
| 5803 |
|
| 5804 |
/* Clear time so that channel is only reported once */ |
| 5805 |
info->time = 0; |
| 5806 |
|
| 5807 |
ret = 0; |
| 5808 |
goto out; |
| 5809 |
} |
| 5810 |
} |
| 5811 |
|
| 5812 |
ret = -ENOENT; |
| 5813 |
|
| 5814 |
out: |
| 5815 |
mutex_unlock(&mvm->mutex); |
| 5816 |
|
| 5817 |
return ret; |
| 5818 |
} |
| 5819 |
|
| 5820 |
int iwl_mvm_mac_get_survey(struct ieee80211_hw *hw, int idx, |
| 5821 |
struct survey_info *survey) |
| 5822 |
{ |
| 5823 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 5824 |
u8 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, |
| 5825 |
WIDE_ID(SYSTEM_GROUP, |
| 5826 |
SYSTEM_STATISTICS_CMD), |
| 5827 |
IWL_FW_CMD_VER_UNKNOWN); |
| 5828 |
|
| 5829 |
memset(survey, 0, sizeof(*survey)); |
| 5830 |
|
| 5831 |
if (!fw_has_capa(&mvm->fw->ucode_capa, |
| 5832 |
IWL_UCODE_TLV_CAPA_RADIO_BEACON_STATS)) |
| 5833 |
return -ENOENT; |
| 5834 |
|
| 5835 |
/* |
| 5836 |
* Return the beacon stats at index zero and pass on following indices |
| 5837 |
* to the function returning the full survey, most likely for ACS |
| 5838 |
* (Automatic Channel Selection). |
| 5839 |
*/ |
| 5840 |
if (idx > 0) |
| 5841 |
return iwl_mvm_mac_get_acs_survey(mvm, idx - 1, survey); |
| 5842 |
|
| 5843 |
guard(mvm)(mvm); |
| 5844 |
|
| 5845 |
if (iwl_mvm_firmware_running(mvm)) { |
| 5846 |
int ret = iwl_mvm_request_statistics(mvm, false); |
| 5847 |
|
| 5848 |
if (ret) |
| 5849 |
return ret; |
| 5850 |
} |
| 5851 |
|
| 5852 |
survey->filled = SURVEY_INFO_TIME_RX | |
| 5853 |
SURVEY_INFO_TIME_TX; |
| 5854 |
|
| 5855 |
survey->time_rx = mvm->accu_radio_stats.rx_time + |
| 5856 |
mvm->radio_stats.rx_time; |
| 5857 |
do_div(survey->time_rx, USEC_PER_MSEC); |
| 5858 |
|
| 5859 |
survey->time_tx = mvm->accu_radio_stats.tx_time + |
| 5860 |
mvm->radio_stats.tx_time; |
| 5861 |
do_div(survey->time_tx, USEC_PER_MSEC); |
| 5862 |
|
| 5863 |
/* the new fw api doesn't support the following fields */ |
| 5864 |
if (cmd_ver != IWL_FW_CMD_VER_UNKNOWN) |
| 5865 |
return 0; |
| 5866 |
|
| 5867 |
survey->filled |= SURVEY_INFO_TIME | |
| 5868 |
SURVEY_INFO_TIME_SCAN; |
| 5869 |
survey->time = mvm->accu_radio_stats.on_time_rf + |
| 5870 |
mvm->radio_stats.on_time_rf; |
| 5871 |
do_div(survey->time, USEC_PER_MSEC); |
| 5872 |
|
| 5873 |
survey->time_scan = mvm->accu_radio_stats.on_time_scan + |
| 5874 |
mvm->radio_stats.on_time_scan; |
| 5875 |
do_div(survey->time_scan, USEC_PER_MSEC); |
| 5876 |
|
| 5877 |
return 0; |
| 5878 |
} |
| 5879 |
|
| 5880 |
static void iwl_mvm_set_sta_rate(u32 rate_n_flags, struct rate_info *rinfo) |
| 5881 |
{ |
| 5882 |
u32 format = rate_n_flags & RATE_MCS_MOD_TYPE_MSK; |
| 5883 |
u32 gi_ltf; |
| 5884 |
|
| 5885 |
switch (rate_n_flags & RATE_MCS_CHAN_WIDTH_MSK) { |
| 5886 |
case RATE_MCS_CHAN_WIDTH_20: |
| 5887 |
rinfo->bw = RATE_INFO_BW_20; |
| 5888 |
break; |
| 5889 |
case RATE_MCS_CHAN_WIDTH_40: |
| 5890 |
rinfo->bw = RATE_INFO_BW_40; |
| 5891 |
break; |
| 5892 |
case RATE_MCS_CHAN_WIDTH_80: |
| 5893 |
rinfo->bw = RATE_INFO_BW_80; |
| 5894 |
break; |
| 5895 |
case RATE_MCS_CHAN_WIDTH_160: |
| 5896 |
rinfo->bw = RATE_INFO_BW_160; |
| 5897 |
break; |
| 5898 |
case RATE_MCS_CHAN_WIDTH_320: |
| 5899 |
rinfo->bw = RATE_INFO_BW_320; |
| 5900 |
break; |
| 5901 |
} |
| 5902 |
|
| 5903 |
if (format == RATE_MCS_MOD_TYPE_CCK || |
| 5904 |
format == RATE_MCS_MOD_TYPE_LEGACY_OFDM) { |
| 5905 |
int rate = u32_get_bits(rate_n_flags, RATE_LEGACY_RATE_MSK); |
| 5906 |
|
| 5907 |
/* add the offset needed to get to the legacy ofdm indices */ |
| 5908 |
if (format == RATE_MCS_MOD_TYPE_LEGACY_OFDM) |
| 5909 |
rate += IWL_FIRST_OFDM_RATE; |
| 5910 |
|
| 5911 |
switch (rate) { |
| 5912 |
case IWL_RATE_1M_INDEX: |
| 5913 |
rinfo->legacy = 10; |
| 5914 |
break; |
| 5915 |
case IWL_RATE_2M_INDEX: |
| 5916 |
rinfo->legacy = 20; |
| 5917 |
break; |
| 5918 |
case IWL_RATE_5M_INDEX: |
| 5919 |
rinfo->legacy = 55; |
| 5920 |
break; |
| 5921 |
case IWL_RATE_11M_INDEX: |
| 5922 |
rinfo->legacy = 110; |
| 5923 |
break; |
| 5924 |
case IWL_RATE_6M_INDEX: |
| 5925 |
rinfo->legacy = 60; |
| 5926 |
break; |
| 5927 |
case IWL_RATE_9M_INDEX: |
| 5928 |
rinfo->legacy = 90; |
| 5929 |
break; |
| 5930 |
case IWL_RATE_12M_INDEX: |
| 5931 |
rinfo->legacy = 120; |
| 5932 |
break; |
| 5933 |
case IWL_RATE_18M_INDEX: |
| 5934 |
rinfo->legacy = 180; |
| 5935 |
break; |
| 5936 |
case IWL_RATE_24M_INDEX: |
| 5937 |
rinfo->legacy = 240; |
| 5938 |
break; |
| 5939 |
case IWL_RATE_36M_INDEX: |
| 5940 |
rinfo->legacy = 360; |
| 5941 |
break; |
| 5942 |
case IWL_RATE_48M_INDEX: |
| 5943 |
rinfo->legacy = 480; |
| 5944 |
break; |
| 5945 |
case IWL_RATE_54M_INDEX: |
| 5946 |
rinfo->legacy = 540; |
| 5947 |
} |
| 5948 |
return; |
| 5949 |
} |
| 5950 |
|
| 5951 |
rinfo->nss = u32_get_bits(rate_n_flags, |
| 5952 |
RATE_MCS_NSS_MSK) + 1; |
| 5953 |
rinfo->mcs = format == RATE_MCS_MOD_TYPE_HT ? |
| 5954 |
RATE_HT_MCS_INDEX(rate_n_flags) : |
| 5955 |
u32_get_bits(rate_n_flags, RATE_MCS_CODE_MSK); |
| 5956 |
|
| 5957 |
if (rate_n_flags & RATE_MCS_SGI_MSK) |
| 5958 |
rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 5959 |
|
| 5960 |
switch (format) { |
| 5961 |
case RATE_MCS_MOD_TYPE_EHT: |
| 5962 |
/* TODO: GI/LTF/RU. How does the firmware encode them? */ |
| 5963 |
rinfo->flags |= RATE_INFO_FLAGS_EHT_MCS; |
| 5964 |
break; |
| 5965 |
case RATE_MCS_MOD_TYPE_HE: |
| 5966 |
gi_ltf = u32_get_bits(rate_n_flags, RATE_MCS_HE_GI_LTF_MSK); |
| 5967 |
|
| 5968 |
rinfo->flags |= RATE_INFO_FLAGS_HE_MCS; |
| 5969 |
|
| 5970 |
if (rate_n_flags & RATE_MCS_HE_106T_MSK) { |
| 5971 |
rinfo->bw = RATE_INFO_BW_HE_RU; |
| 5972 |
rinfo->he_ru_alloc = NL80211_RATE_INFO_HE_RU_ALLOC_106; |
| 5973 |
} |
| 5974 |
|
| 5975 |
switch (rate_n_flags & RATE_MCS_HE_TYPE_MSK) { |
| 5976 |
case RATE_MCS_HE_TYPE_SU: |
| 5977 |
case RATE_MCS_HE_TYPE_EXT_SU: |
| 5978 |
if (gi_ltf == 0 || gi_ltf == 1) |
| 5979 |
rinfo->he_gi = NL80211_RATE_INFO_HE_GI_0_8; |
| 5980 |
else if (gi_ltf == 2) |
| 5981 |
rinfo->he_gi = NL80211_RATE_INFO_HE_GI_1_6; |
| 5982 |
else if (gi_ltf == 3) |
| 5983 |
rinfo->he_gi = NL80211_RATE_INFO_HE_GI_3_2; |
| 5984 |
else |
| 5985 |
rinfo->he_gi = NL80211_RATE_INFO_HE_GI_0_8; |
| 5986 |
break; |
| 5987 |
case RATE_MCS_HE_TYPE_MU: |
| 5988 |
if (gi_ltf == 0 || gi_ltf == 1) |
| 5989 |
rinfo->he_gi = NL80211_RATE_INFO_HE_GI_0_8; |
| 5990 |
else if (gi_ltf == 2) |
| 5991 |
rinfo->he_gi = NL80211_RATE_INFO_HE_GI_1_6; |
| 5992 |
else |
| 5993 |
rinfo->he_gi = NL80211_RATE_INFO_HE_GI_3_2; |
| 5994 |
break; |
| 5995 |
case RATE_MCS_HE_TYPE_TRIG: |
| 5996 |
if (gi_ltf == 0 || gi_ltf == 1) |
| 5997 |
rinfo->he_gi = NL80211_RATE_INFO_HE_GI_1_6; |
| 5998 |
else |
| 5999 |
rinfo->he_gi = NL80211_RATE_INFO_HE_GI_3_2; |
| 6000 |
break; |
| 6001 |
} |
| 6002 |
|
| 6003 |
if (rate_n_flags & RATE_HE_DUAL_CARRIER_MODE_MSK) |
| 6004 |
rinfo->he_dcm = 1; |
| 6005 |
break; |
| 6006 |
case RATE_MCS_MOD_TYPE_HT: |
| 6007 |
rinfo->flags |= RATE_INFO_FLAGS_MCS; |
| 6008 |
break; |
| 6009 |
case RATE_MCS_MOD_TYPE_VHT: |
| 6010 |
rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 6011 |
break; |
| 6012 |
} |
| 6013 |
} |
| 6014 |
|
| 6015 |
void iwl_mvm_mac_sta_statistics(struct ieee80211_hw *hw, |
| 6016 |
struct ieee80211_vif *vif, |
| 6017 |
struct ieee80211_sta *sta, |
| 6018 |
struct station_info *sinfo) |
| 6019 |
{ |
| 6020 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 6021 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 6022 |
struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); |
| 6023 |
int i; |
| 6024 |
|
| 6025 |
if (mvmsta->deflink.avg_energy) { |
| 6026 |
sinfo->signal_avg = -(s8)mvmsta->deflink.avg_energy; |
| 6027 |
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG); |
| 6028 |
} |
| 6029 |
|
| 6030 |
if (iwl_mvm_has_tlc_offload(mvm)) { |
| 6031 |
struct iwl_lq_sta_rs_fw *lq_sta = &mvmsta->deflink.lq_sta.rs_fw; |
| 6032 |
|
| 6033 |
iwl_mvm_set_sta_rate(lq_sta->last_rate_n_flags, &sinfo->txrate); |
| 6034 |
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE); |
| 6035 |
} |
| 6036 |
|
| 6037 |
/* if beacon filtering isn't on mac80211 does it anyway */ |
| 6038 |
if (!(vif->driver_flags & IEEE80211_VIF_BEACON_FILTER)) |
| 6039 |
return; |
| 6040 |
|
| 6041 |
if (!vif->cfg.assoc) |
| 6042 |
return; |
| 6043 |
|
| 6044 |
guard(mvm)(mvm); |
| 6045 |
|
| 6046 |
if (sta != mvmvif->ap_sta) |
| 6047 |
return; |
| 6048 |
|
| 6049 |
if (iwl_mvm_request_statistics(mvm, false)) |
| 6050 |
return; |
| 6051 |
|
| 6052 |
sinfo->rx_beacon = 0; |
| 6053 |
for_each_mvm_vif_valid_link(mvmvif, i) |
| 6054 |
sinfo->rx_beacon += mvmvif->link[i]->beacon_stats.num_beacons + |
| 6055 |
mvmvif->link[i]->beacon_stats.accu_num_beacons; |
| 6056 |
|
| 6057 |
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_BEACON_RX); |
| 6058 |
if (mvmvif->deflink.beacon_stats.avg_signal) { |
| 6059 |
/* firmware only reports a value after RXing a few beacons */ |
| 6060 |
sinfo->rx_beacon_signal_avg = |
| 6061 |
mvmvif->deflink.beacon_stats.avg_signal; |
| 6062 |
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_BEACON_SIGNAL_AVG); |
| 6063 |
} |
| 6064 |
} |
| 6065 |
|
| 6066 |
static void iwl_mvm_event_mlme_callback_ini(struct iwl_mvm *mvm, |
| 6067 |
struct ieee80211_vif *vif, |
| 6068 |
const struct ieee80211_mlme_event *mlme) |
| 6069 |
{ |
| 6070 |
if ((mlme->data == ASSOC_EVENT || mlme->data == AUTH_EVENT) && |
| 6071 |
(mlme->status == MLME_DENIED || mlme->status == MLME_TIMEOUT)) { |
| 6072 |
iwl_dbg_tlv_time_point(&mvm->fwrt, |
| 6073 |
IWL_FW_INI_TIME_POINT_ASSOC_FAILED, |
| 6074 |
NULL); |
| 6075 |
return; |
| 6076 |
} |
| 6077 |
|
| 6078 |
if (mlme->data == DEAUTH_RX_EVENT || mlme->data == DEAUTH_TX_EVENT) { |
| 6079 |
iwl_dbg_tlv_time_point(&mvm->fwrt, |
| 6080 |
IWL_FW_INI_TIME_POINT_DEASSOC, |
| 6081 |
NULL); |
| 6082 |
return; |
| 6083 |
} |
| 6084 |
} |
| 6085 |
|
| 6086 |
static void iwl_mvm_event_mlme_callback(struct iwl_mvm *mvm, |
| 6087 |
struct ieee80211_vif *vif, |
| 6088 |
const struct ieee80211_event *event) |
| 6089 |
{ |
| 6090 |
#define CHECK_MLME_TRIGGER(_cnt, _fmt...) \ |
| 6091 |
do { \ |
| 6092 |
if ((trig_mlme->_cnt) && --(trig_mlme->_cnt)) \ |
| 6093 |
break; \ |
| 6094 |
iwl_fw_dbg_collect_trig(&(mvm)->fwrt, trig, _fmt); \ |
| 6095 |
} while (0) |
| 6096 |
|
| 6097 |
struct iwl_fw_dbg_trigger_tlv *trig; |
| 6098 |
struct iwl_fw_dbg_trigger_mlme *trig_mlme; |
| 6099 |
|
| 6100 |
if (iwl_trans_dbg_ini_valid(mvm->trans)) { |
| 6101 |
iwl_mvm_event_mlme_callback_ini(mvm, vif, &event->u.mlme); |
| 6102 |
return; |
| 6103 |
} |
| 6104 |
|
| 6105 |
trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif), |
| 6106 |
FW_DBG_TRIGGER_MLME); |
| 6107 |
if (!trig) |
| 6108 |
return; |
| 6109 |
|
| 6110 |
trig_mlme = (void *)trig->data; |
| 6111 |
|
| 6112 |
if (event->u.mlme.data == ASSOC_EVENT) { |
| 6113 |
if (event->u.mlme.status == MLME_DENIED) |
| 6114 |
CHECK_MLME_TRIGGER(stop_assoc_denied, |
| 6115 |
"DENIED ASSOC: reason %d", |
| 6116 |
event->u.mlme.reason); |
| 6117 |
else if (event->u.mlme.status == MLME_TIMEOUT) |
| 6118 |
CHECK_MLME_TRIGGER(stop_assoc_timeout, |
| 6119 |
"ASSOC TIMEOUT"); |
| 6120 |
} else if (event->u.mlme.data == AUTH_EVENT) { |
| 6121 |
if (event->u.mlme.status == MLME_DENIED) |
| 6122 |
CHECK_MLME_TRIGGER(stop_auth_denied, |
| 6123 |
"DENIED AUTH: reason %d", |
| 6124 |
event->u.mlme.reason); |
| 6125 |
else if (event->u.mlme.status == MLME_TIMEOUT) |
| 6126 |
CHECK_MLME_TRIGGER(stop_auth_timeout, |
| 6127 |
"AUTH TIMEOUT"); |
| 6128 |
} else if (event->u.mlme.data == DEAUTH_RX_EVENT) { |
| 6129 |
CHECK_MLME_TRIGGER(stop_rx_deauth, |
| 6130 |
"DEAUTH RX %d", event->u.mlme.reason); |
| 6131 |
} else if (event->u.mlme.data == DEAUTH_TX_EVENT) { |
| 6132 |
CHECK_MLME_TRIGGER(stop_tx_deauth, |
| 6133 |
"DEAUTH TX %d", event->u.mlme.reason); |
| 6134 |
} |
| 6135 |
#undef CHECK_MLME_TRIGGER |
| 6136 |
} |
| 6137 |
|
| 6138 |
static void iwl_mvm_event_bar_rx_callback(struct iwl_mvm *mvm, |
| 6139 |
struct ieee80211_vif *vif, |
| 6140 |
const struct ieee80211_event *event) |
| 6141 |
{ |
| 6142 |
struct iwl_fw_dbg_trigger_tlv *trig; |
| 6143 |
struct iwl_fw_dbg_trigger_ba *ba_trig; |
| 6144 |
|
| 6145 |
trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif), |
| 6146 |
FW_DBG_TRIGGER_BA); |
| 6147 |
if (!trig) |
| 6148 |
return; |
| 6149 |
|
| 6150 |
ba_trig = (void *)trig->data; |
| 6151 |
|
| 6152 |
if (!(le16_to_cpu(ba_trig->rx_bar) & BIT(event->u.ba.tid))) |
| 6153 |
return; |
| 6154 |
|
| 6155 |
iwl_fw_dbg_collect_trig(&mvm->fwrt, trig, |
| 6156 |
"BAR received from %pM, tid %d, ssn %d", |
| 6157 |
event->u.ba.sta->addr, event->u.ba.tid, |
| 6158 |
event->u.ba.ssn); |
| 6159 |
} |
| 6160 |
|
| 6161 |
void iwl_mvm_mac_event_callback(struct ieee80211_hw *hw, |
| 6162 |
struct ieee80211_vif *vif, |
| 6163 |
const struct ieee80211_event *event) |
| 6164 |
{ |
| 6165 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 6166 |
|
| 6167 |
switch (event->type) { |
| 6168 |
case MLME_EVENT: |
| 6169 |
iwl_mvm_event_mlme_callback(mvm, vif, event); |
| 6170 |
break; |
| 6171 |
case BAR_RX_EVENT: |
| 6172 |
iwl_mvm_event_bar_rx_callback(mvm, vif, event); |
| 6173 |
break; |
| 6174 |
case BA_FRAME_TIMEOUT: |
| 6175 |
iwl_mvm_event_frame_timeout_callback(mvm, vif, event->u.ba.sta, |
| 6176 |
event->u.ba.tid); |
| 6177 |
break; |
| 6178 |
default: |
| 6179 |
break; |
| 6180 |
} |
| 6181 |
} |
| 6182 |
|
| 6183 |
#define SYNC_RX_QUEUE_TIMEOUT (HZ) |
| 6184 |
void iwl_mvm_sync_rx_queues_internal(struct iwl_mvm *mvm, |
| 6185 |
enum iwl_mvm_rxq_notif_type type, |
| 6186 |
bool sync, |
| 6187 |
const void *data, u32 size) |
| 6188 |
{ |
| 6189 |
DEFINE_RAW_FLEX(struct iwl_rxq_sync_cmd, cmd, payload, |
| 6190 |
sizeof(struct iwl_mvm_internal_rxq_notif)); |
| 6191 |
struct iwl_mvm_internal_rxq_notif *notif = |
| 6192 |
(struct iwl_mvm_internal_rxq_notif *)cmd->payload; |
| 6193 |
struct iwl_host_cmd hcmd = { |
| 6194 |
.id = WIDE_ID(DATA_PATH_GROUP, TRIGGER_RX_QUEUES_NOTIF_CMD), |
| 6195 |
.data[0] = cmd, |
| 6196 |
.len[0] = __struct_size(cmd), |
| 6197 |
.data[1] = data, |
| 6198 |
.len[1] = size, |
| 6199 |
.flags = CMD_SEND_IN_RFKILL | (sync ? 0 : CMD_ASYNC), |
| 6200 |
}; |
| 6201 |
int ret; |
| 6202 |
|
| 6203 |
cmd->rxq_mask = cpu_to_le32(BIT(mvm->trans->info.num_rxqs) - 1); |
| 6204 |
cmd->count = cpu_to_le32(sizeof(struct iwl_mvm_internal_rxq_notif) + |
| 6205 |
size); |
| 6206 |
notif->type = type; |
| 6207 |
notif->sync = sync; |
| 6208 |
|
| 6209 |
/* size must be a multiple of DWORD */ |
| 6210 |
if (WARN_ON(cmd->count & cpu_to_le32(3))) |
| 6211 |
return; |
| 6212 |
|
| 6213 |
if (!iwl_mvm_has_new_rx_api(mvm)) |
| 6214 |
return; |
| 6215 |
|
| 6216 |
if (sync) { |
| 6217 |
notif->cookie = mvm->queue_sync_cookie; |
| 6218 |
mvm->queue_sync_state = (1 << mvm->trans->info.num_rxqs) - 1; |
| 6219 |
} |
| 6220 |
|
| 6221 |
ret = iwl_mvm_send_cmd(mvm, &hcmd); |
| 6222 |
if (ret) { |
| 6223 |
IWL_ERR(mvm, "Failed to trigger RX queues sync (%d)\n", ret); |
| 6224 |
goto out; |
| 6225 |
} |
| 6226 |
|
| 6227 |
if (sync) { |
| 6228 |
lockdep_assert_held(&mvm->mutex); |
| 6229 |
ret = wait_event_timeout(mvm->rx_sync_waitq, |
| 6230 |
READ_ONCE(mvm->queue_sync_state) == 0, |
| 6231 |
SYNC_RX_QUEUE_TIMEOUT); |
| 6232 |
WARN_ONCE(!ret, "queue sync: failed to sync, state is 0x%lx, cookie %d\n", |
| 6233 |
mvm->queue_sync_state, |
| 6234 |
mvm->queue_sync_cookie); |
| 6235 |
} |
| 6236 |
|
| 6237 |
out: |
| 6238 |
if (sync) { |
| 6239 |
mvm->queue_sync_state = 0; |
| 6240 |
mvm->queue_sync_cookie++; |
| 6241 |
} |
| 6242 |
} |
| 6243 |
|
| 6244 |
void iwl_mvm_sync_rx_queues(struct ieee80211_hw *hw) |
| 6245 |
{ |
| 6246 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 6247 |
|
| 6248 |
guard(mvm)(mvm); |
| 6249 |
iwl_mvm_sync_rx_queues_internal(mvm, IWL_MVM_RXQ_EMPTY, true, NULL, 0); |
| 6250 |
} |
| 6251 |
|
| 6252 |
int |
| 6253 |
iwl_mvm_mac_get_ftm_responder_stats(struct ieee80211_hw *hw, |
| 6254 |
struct ieee80211_vif *vif, |
| 6255 |
struct cfg80211_ftm_responder_stats *stats) |
| 6256 |
{ |
| 6257 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 6258 |
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 6259 |
|
| 6260 |
if (vif->p2p || vif->type != NL80211_IFTYPE_AP || |
| 6261 |
!mvmvif->ap_ibss_active || !vif->bss_conf.ftm_responder) |
| 6262 |
return -EINVAL; |
| 6263 |
|
| 6264 |
mutex_lock(&mvm->mutex); |
| 6265 |
*stats = mvm->ftm_resp_stats; |
| 6266 |
mutex_unlock(&mvm->mutex); |
| 6267 |
|
| 6268 |
stats->filled = BIT(NL80211_FTM_STATS_SUCCESS_NUM) | |
| 6269 |
BIT(NL80211_FTM_STATS_PARTIAL_NUM) | |
| 6270 |
BIT(NL80211_FTM_STATS_FAILED_NUM) | |
| 6271 |
BIT(NL80211_FTM_STATS_ASAP_NUM) | |
| 6272 |
BIT(NL80211_FTM_STATS_NON_ASAP_NUM) | |
| 6273 |
BIT(NL80211_FTM_STATS_TOTAL_DURATION_MSEC) | |
| 6274 |
BIT(NL80211_FTM_STATS_UNKNOWN_TRIGGERS_NUM) | |
| 6275 |
BIT(NL80211_FTM_STATS_RESCHEDULE_REQUESTS_NUM) | |
| 6276 |
BIT(NL80211_FTM_STATS_OUT_OF_WINDOW_TRIGGERS_NUM); |
| 6277 |
|
| 6278 |
return 0; |
| 6279 |
} |
| 6280 |
|
| 6281 |
int iwl_mvm_start_pmsr(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 6282 |
struct cfg80211_pmsr_request *request) |
| 6283 |
{ |
| 6284 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 6285 |
|
| 6286 |
guard(mvm)(mvm); |
| 6287 |
return iwl_mvm_ftm_start(mvm, vif, request); |
| 6288 |
} |
| 6289 |
|
| 6290 |
void iwl_mvm_abort_pmsr(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 6291 |
struct cfg80211_pmsr_request *request) |
| 6292 |
{ |
| 6293 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 6294 |
|
| 6295 |
guard(mvm)(mvm); |
| 6296 |
iwl_mvm_ftm_abort(mvm, request); |
| 6297 |
} |
| 6298 |
|
| 6299 |
static bool iwl_mvm_can_hw_csum(struct sk_buff *skb) |
| 6300 |
{ |
| 6301 |
u8 protocol = ip_hdr(skb)->protocol; |
| 6302 |
|
| 6303 |
if (!IS_ENABLED(CONFIG_INET)) |
| 6304 |
return false; |
| 6305 |
|
| 6306 |
return protocol == IPPROTO_TCP || protocol == IPPROTO_UDP; |
| 6307 |
} |
| 6308 |
|
| 6309 |
static bool iwl_mvm_mac_can_aggregate(struct ieee80211_hw *hw, |
| 6310 |
struct sk_buff *head, |
| 6311 |
struct sk_buff *skb) |
| 6312 |
{ |
| 6313 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 6314 |
|
| 6315 |
/* For now don't aggregate IPv6 in AMSDU */ |
| 6316 |
if (skb->protocol != htons(ETH_P_IP)) |
| 6317 |
return false; |
| 6318 |
|
| 6319 |
if (!iwl_mvm_is_csum_supported(mvm)) |
| 6320 |
return true; |
| 6321 |
|
| 6322 |
return iwl_mvm_can_hw_csum(skb) == iwl_mvm_can_hw_csum(head); |
| 6323 |
} |
| 6324 |
|
| 6325 |
int iwl_mvm_set_hw_timestamp(struct ieee80211_hw *hw, |
| 6326 |
struct ieee80211_vif *vif, |
| 6327 |
struct cfg80211_set_hw_timestamp *hwts) |
| 6328 |
{ |
| 6329 |
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 6330 |
u32 protocols = 0; |
| 6331 |
|
| 6332 |
/* HW timestamping is only supported for a specific station */ |
| 6333 |
if (!hwts->macaddr) |
| 6334 |
return -EOPNOTSUPP; |
| 6335 |
|
| 6336 |
if (hwts->enable) |
| 6337 |
protocols = |
| 6338 |
IWL_TIME_SYNC_PROTOCOL_TM | IWL_TIME_SYNC_PROTOCOL_FTM; |
| 6339 |
|
| 6340 |
guard(mvm)(mvm); |
| 6341 |
return iwl_mvm_time_sync_config(mvm, hwts->macaddr, protocols); |
| 6342 |
} |
| 6343 |
|
| 6344 |
const struct ieee80211_ops iwl_mvm_hw_ops = { |
| 6345 |
.tx = iwl_mvm_mac_tx, |
| 6346 |
.wake_tx_queue = iwl_mvm_mac_wake_tx_queue, |
| 6347 |
.ampdu_action = iwl_mvm_mac_ampdu_action, |
| 6348 |
.get_antenna = iwl_mvm_op_get_antenna, |
| 6349 |
.set_antenna = iwl_mvm_op_set_antenna, |
| 6350 |
.start = iwl_mvm_mac_start, |
| 6351 |
.reconfig_complete = iwl_mvm_mac_reconfig_complete, |
| 6352 |
.stop = iwl_mvm_mac_stop, |
| 6353 |
.add_interface = iwl_mvm_mac_add_interface, |
| 6354 |
.remove_interface = iwl_mvm_mac_remove_interface, |
| 6355 |
.config = iwl_mvm_mac_config, |
| 6356 |
.prepare_multicast = iwl_mvm_prepare_multicast, |
| 6357 |
.configure_filter = iwl_mvm_configure_filter, |
| 6358 |
.config_iface_filter = iwl_mvm_config_iface_filter, |
| 6359 |
.bss_info_changed = iwl_mvm_bss_info_changed, |
| 6360 |
.hw_scan = iwl_mvm_mac_hw_scan, |
| 6361 |
.cancel_hw_scan = iwl_mvm_mac_cancel_hw_scan, |
| 6362 |
.sta_pre_rcu_remove = iwl_mvm_sta_pre_rcu_remove, |
| 6363 |
.sta_state = iwl_mvm_mac_sta_state, |
| 6364 |
.sta_notify = iwl_mvm_mac_sta_notify, |
| 6365 |
.allow_buffered_frames = iwl_mvm_mac_allow_buffered_frames, |
| 6366 |
.release_buffered_frames = iwl_mvm_mac_release_buffered_frames, |
| 6367 |
.set_rts_threshold = iwl_mvm_mac_set_rts_threshold, |
| 6368 |
.link_sta_rc_update = iwl_mvm_sta_rc_update, |
| 6369 |
.conf_tx = iwl_mvm_mac_conf_tx, |
| 6370 |
.mgd_prepare_tx = iwl_mvm_mac_mgd_prepare_tx, |
| 6371 |
.mgd_complete_tx = iwl_mvm_mac_mgd_complete_tx, |
| 6372 |
.mgd_protect_tdls_discover = iwl_mvm_mac_mgd_protect_tdls_discover, |
| 6373 |
.flush = iwl_mvm_mac_flush, |
| 6374 |
.flush_sta = iwl_mvm_mac_flush_sta, |
| 6375 |
.sched_scan_start = iwl_mvm_mac_sched_scan_start, |
| 6376 |
.sched_scan_stop = iwl_mvm_mac_sched_scan_stop, |
| 6377 |
.set_key = iwl_mvm_mac_set_key, |
| 6378 |
.update_tkip_key = iwl_mvm_mac_update_tkip_key, |
| 6379 |
.remain_on_channel = iwl_mvm_roc, |
| 6380 |
.cancel_remain_on_channel = iwl_mvm_cancel_roc, |
| 6381 |
.add_chanctx = iwl_mvm_add_chanctx, |
| 6382 |
.remove_chanctx = iwl_mvm_remove_chanctx, |
| 6383 |
.change_chanctx = iwl_mvm_change_chanctx, |
| 6384 |
.assign_vif_chanctx = iwl_mvm_assign_vif_chanctx, |
| 6385 |
.unassign_vif_chanctx = iwl_mvm_unassign_vif_chanctx, |
| 6386 |
.switch_vif_chanctx = iwl_mvm_switch_vif_chanctx, |
| 6387 |
|
| 6388 |
.start_ap = iwl_mvm_start_ap, |
| 6389 |
.stop_ap = iwl_mvm_stop_ap, |
| 6390 |
.join_ibss = iwl_mvm_start_ibss, |
| 6391 |
.leave_ibss = iwl_mvm_stop_ibss, |
| 6392 |
|
| 6393 |
.tx_last_beacon = iwl_mvm_tx_last_beacon, |
| 6394 |
|
| 6395 |
.set_tim = iwl_mvm_set_tim, |
| 6396 |
|
| 6397 |
.channel_switch = iwl_mvm_channel_switch, |
| 6398 |
.pre_channel_switch = iwl_mvm_mac_pre_channel_switch, |
| 6399 |
.post_channel_switch = iwl_mvm_post_channel_switch, |
| 6400 |
.abort_channel_switch = iwl_mvm_abort_channel_switch, |
| 6401 |
.channel_switch_rx_beacon = iwl_mvm_channel_switch_rx_beacon, |
| 6402 |
|
| 6403 |
.tdls_channel_switch = iwl_mvm_tdls_channel_switch, |
| 6404 |
.tdls_cancel_channel_switch = iwl_mvm_tdls_cancel_channel_switch, |
| 6405 |
.tdls_recv_channel_switch = iwl_mvm_tdls_recv_channel_switch, |
| 6406 |
|
| 6407 |
.event_callback = iwl_mvm_mac_event_callback, |
| 6408 |
|
| 6409 |
.sync_rx_queues = iwl_mvm_sync_rx_queues, |
| 6410 |
|
| 6411 |
#ifdef CONFIG_PM_SLEEP |
| 6412 |
/* look at d3.c */ |
| 6413 |
.suspend = iwl_mvm_suspend, |
| 6414 |
.resume = iwl_mvm_resume, |
| 6415 |
.set_wakeup = iwl_mvm_set_wakeup, |
| 6416 |
.set_rekey_data = iwl_mvm_set_rekey_data, |
| 6417 |
#if IS_ENABLED(CONFIG_IPV6) |
| 6418 |
.ipv6_addr_change = iwl_mvm_ipv6_addr_change, |
| 6419 |
#endif |
| 6420 |
.set_default_unicast_key = iwl_mvm_set_default_unicast_key, |
| 6421 |
#endif |
| 6422 |
.get_survey = iwl_mvm_mac_get_survey, |
| 6423 |
.sta_statistics = iwl_mvm_mac_sta_statistics, |
| 6424 |
.get_ftm_responder_stats = iwl_mvm_mac_get_ftm_responder_stats, |
| 6425 |
.start_pmsr = iwl_mvm_start_pmsr, |
| 6426 |
.abort_pmsr = iwl_mvm_abort_pmsr, |
| 6427 |
|
| 6428 |
.can_aggregate_in_amsdu = iwl_mvm_mac_can_aggregate, |
| 6429 |
#ifdef CONFIG_IWLWIFI_DEBUGFS |
| 6430 |
.vif_add_debugfs = iwl_mvm_vif_add_debugfs, |
| 6431 |
.link_sta_add_debugfs = iwl_mvm_link_sta_add_debugfs, |
| 6432 |
#endif |
| 6433 |
.set_hw_timestamp = iwl_mvm_set_hw_timestamp, |
| 6434 |
}; |